Browse Source

修改了类文件“StringHelper.php”中的用于处理多维数组的递归函数,删除其中多余函数

master
yuanjiajia 3 years ago
parent
commit
d2ae69ad73
  1. 4
      examples/print.php
  2. 5
      src/scene/Path.php
  3. 7
      src/scene/Random.php
  4. 2
      src/scene/RenderEngine.php
  5. 7
      src/scene/Sobol.php
  6. 71
      src/utils/StringHelper.php

4
examples/print.php

@ -5,8 +5,8 @@
namespace Blobt\Luxcore\scene; namespace Blobt\Luxcore\scene;
include dirname(dirname(__FILE__)) . "/vendor/autoload.php"; include dirname(dirname(__FILE__)) . "/vendor/autoload.php";
/*
/*
//设置打印渲染引擎的配置参数 //设置打印渲染引擎的配置参数
$renderEngine = new RenderEngine(); $renderEngine = new RenderEngine();
echo $renderEngine; echo $renderEngine;
@ -27,9 +27,9 @@ echo $path;
$sampler = new Sampler(['imagemutationrate' => 0.888]); $sampler = new Sampler(['imagemutationrate' => 0.888]);
$sampler->random->overlapping = 32; $sampler->random->overlapping = 32;
echo $sampler; echo $sampler;
*/ */
$film = new Film(); $film = new Film();
echo "$film\n"; echo "$film\n";

5
src/scene/Path.php

@ -26,11 +26,6 @@ class Path extends BaseCfg
*/ */
public $clampingVarianceMaxvalue = 1000; public $clampingVarianceMaxvalue = 1000;
/**
* @var integer $maxdepth 当渲染引擎为 BIDIR 时,光线跟踪的最大深度(取值:大于0的整数)
*/
public $maxdepth = 10;
/** /**
* 实例 PathDepth类、HybridBackforWard类的两个对象 * 实例 PathDepth类、HybridBackforWard类的两个对象
*/ */

7
src/scene/Random.php

@ -29,17 +29,18 @@ class Random extends BaseCfg
public $overlapping = self::PROGRESSIVE; public $overlapping = self::PROGRESSIVE;
/** /**
* @var integer 这是 $overlapping”参数的倍数
* @var integer 这是 $overlapping”参数的倍数(此参数只在GPU渲染模式可设置)
*/ */
public $superSampling = self::POW_TWO_ZERO; public $superSampling = self::POW_TWO_ZERO;
/** /**
* @var integer TODO:具体作用尚不明确
* @var integer TODO:具体作用尚不明确(默认16)
*/ */
public $tileSize = 16; public $tileSize = 16;
/** /**
* @var integer TODO:具体作用尚不明确,
* @var integer TODO:具体作用尚不明确,(当“$overlapping”优化类型为“PROGRESSIVE”,此值被设为16;
* 当“$overlapping”优化类型为“CACHE_FRIENDLY”,此值被设为1)
*/ */
public $bucketSize = 1; public $bucketSize = 1;

2
src/scene/RenderEngine.php

@ -7,8 +7,6 @@ class RenderEngine extends BaseCfg
const TYPE_PATHCPU = 'PATHCPU'; const TYPE_PATHCPU = 'PATHCPU';
const TYPE_PATHGPU = 'PATHGPU'; const TYPE_PATHGPU = 'PATHGPU';
const TYPE_BIDIRCPU = 'BIDIRCPU';
/** /**
* @var string 使用何种渲染引擎(可取值是 PATHCPU、PATHGPU、BIDIRCPU 三个字符串之一) * @var string 使用何种渲染引擎(可取值是 PATHCPU、PATHGPU、BIDIRCPU 三个字符串之一)

7
src/scene/Sobol.php

@ -28,17 +28,18 @@ class Sobol extends BaseCfg
public $overlapping = self::PROGRESSIVE; public $overlapping = self::PROGRESSIVE;
/** /**
* @var integer 这是 $overlapping”参数的倍数
* @var integer 这是 $overlapping”参数的倍数(此参数只在GPU渲染模式可设置)
*/ */
public $superSampling = self::POW_TWO_ZERO; public $superSampling = self::POW_TWO_ZERO;
/** /**
* @var integer TODO:具体作用尚不明确
* @var integer TODO:具体作用尚不明确(默认16)
*/ */
public $tileSize = 16; public $tileSize = 16;
/** /**
* @var integer TODO:具体作用尚不明确
* @var integer TODO:具体作用尚不明确,(当“$overlapping”优化类型为“PROGRESSIVE”,此值被设为16;
* 当“$overlapping”优化类型为“CACHE_FRIENDLY”,此值被设为1)
*/ */
public $bucketSize = 1; public $bucketSize = 1;

71
src/utils/StringHelper.php

@ -4,46 +4,6 @@ namespace Blobt\Luxcore\utils;
class StringHelper class StringHelper
{ {
static public function functionNameStrToArray($functionNameStr)
{
$functionNameArray = null;
$functionNameTemp = null;
if ($functionNameStr != null) {
$strLen = strlen($functionNameStr);
/*
检查字符串内不能包含 英文字母及“_” 以外的字符
*/
for ($i = 0; $i < $strLen; $i++) {
if (!((ord($functionNameStr[$i]) >= 65) && (ord($functionNameStr[$i]) <= 122)) && ($functionNameStr[$i] != "_")) {
echo '解析错误: 函数名称 存在非法字符 “' . $functionNameStr[$i] . '”' . "\n";
return null;
}
}
/*
将函数名字符串,以大写的首字母为分割,转换成数组
*/
for ($i = 0; $i < $strLen; $i++) {
$functionNameTemp[] = $functionNameStr[$i];
if (((ord(substr($functionNameStr, $i + 1, 1)) >= 65) && (ord(substr($functionNameStr, $i + 1, 1)) <= 90)) || ($i == $strLen - 1)) {
$functionNameTemp = implode($functionNameTemp);
$functionNameArray[] = $functionNameTemp;
$functionNameTemp = null;
}
}
return $functionNameArray;
} else {
echo '解析错误:函数名称字符串不能为空' . "\n";
return null;
}
}
/** /**
* 把驼峰命名字符串截成数组 * 把驼峰命名字符串截成数组
*/ */
@ -62,48 +22,35 @@ class StringHelper
*/ */
static public function arrayToString(&$tempArr) static public function arrayToString(&$tempArr)
{ {
static $retStr = [];
static $tempStr = [];
static $i = 0;
if( $i < 0 )//检查递归函数是 被外部调用还是 还是函数内部调用
{
$i = 0;
$retStr = [];
$tempStr = [];
}
$retStr = [];
foreach($tempArr as $key => $value) foreach($tempArr as $key => $value)
{ {
if(is_array($value)) if(is_array($value))
{ {
$tempStr[$i] = "{$key}.";
$i++;
self::arrayToString($value);
foreach( self::arrayToString($value) as $value )
{
$retStr[] = "{$key}.{$value}";
}
} }
else if( is_string($value) ) else if( is_string($value) )
{ {
if( mb_ereg('^[0-9]+$',str_replace('.','',str_replace(' ','',$value))) ) if( mb_ereg('^[0-9]+$',str_replace('.','',str_replace(' ','',$value))) )
{ {
$tempStr[$i] = "{$key} = {$value}";
$retStr[] = "{$key} = {$value}";
} }
else else
{ {
$tempStr[$i] = "{$key} = \"{$value}\"";
$retStr[] = "{$key} = \"{$value}\"";
} }
$retStr[] = implode($tempStr);
} }
else else
{ {
$tempStr[$i] = "{$key} = {$value}";
$retStr[] = implode($tempStr);
$retStr[] = "{$key} = {$value}";
} }
} }
$tempStr[$i] = null;
$i--;
return $retStr; return $retStr;
} }
} }
?> ?>
Loading…
Cancel
Save