本文整理汇总了C++中Symbol::comp方法的典型用法代码示例。如果您正苦于以下问题:C++ Symbol::comp方法的具体用法?C++ Symbol::comp怎么用?C++ Symbol::comp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symbol
的用法示例。
在下文中一共展示了Symbol::comp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply_rule
//.........这里部分代码省略.........
}
node_child.push_back ( node_parent.extrude ( p, rule -> symbolNames[0]));
}
// "Rotate" => not valid at the moment
// "Rename" => rename ( string symbolName ); // if name = "epsilon", then active = 0; else change the name
else if ( rule -> function == "rename" )
{
node_child = node_parent.rename ( rule -> symbolNames[0] );
}
// "Subdiv" => vector<Symbol>Symbol::subDiv( int d, vector<double>&splits, vector<string> &symbols); // 0-x, 1-y, 2-z; splits are absolute value
else if ( rule -> function == "subDiv" )
{
vector< pair< float, float > > :: iterator it = rule -> parameters.begin();
int d; // parameter shows the cordinate we Subdiv along
d = ( it -> first ) * ( -1 ) - 1; // convert the dimention keyword from {-1,-2,-3} to {0,1,2}
vector<double> splits; // absolute value of the splits part.
int r_count =0; // count of the relative value
int i = 0; // index of the relative value
vector<int> idx; // list of index for the relative values
double sum_absolute = 0;
it ++;
while ( it != rule -> parameters.end() )
{
if ( it -> first == -1 )
{
splits.push_back ( node_parent.scale[0] * ( it -> second ) );
sum_absolute += * (splits.end() - 1);
}
else if ( it -> first == -2 )
{
splits.push_back ( node_parent.scale[1] * ( it -> second ) );
sum_absolute += * (splits.end() - 1);
}
else if ( it -> first == -3 )
{
splits.push_back ( node_parent.scale[2] * ( it -> second ) );
sum_absolute += * (splits.end() - 1);
}
else if ( it -> first == -4 )
{
splits.push_back ( it -> second );
r_count += it -> second;
idx.push_back ( i );
}
else
{
splits.push_back ( ( it -> first ) * ( it -> second ) );
sum_absolute += * ( splits.end() -1);
}
i ++; // index of the relative value
it ++;
}
double r = ( node_parent.scale[d] - sum_absolute ) / r_count;
for ( int it_of_idx = 0; it_of_idx < idx.size(); it_of_idx ++)
splits [ idx[ it_of_idx ] ] *= r;
node_child = node_parent.subDiv ( d, splits, rule -> symbolNames );
}
// "Component_split" => vector<Symbol>Symbol::comp( vector<string> symbols); // s gives us the name of the new Symbol
else if ( rule -> function == "comp" )
{
node_child = node_parent.comp ( rule -> symbolNames );
}
// "Repeat" => vector<Symbol>Symbol::repeat( int dim, double size, string symbol); // 0-x, 1-y, 2-z;
else if ( rule -> function == "repeat" )
{
// take the parameters and symbol_IDs of the result
vector< pair< float, float > > :: iterator it = rule -> parameters.begin();
int d = ( it -> first ) * ( -1 ) - 1; // convert the dimention keyword from {-1,-2,-3} to {0,1,2}
it ++;
double size;
if ( it -> first == -1 ) // convert the dimention keyword from {-1,-2,-3} to {0,1,2}
size = node_parent.scale[0] * ( it -> second );
else if ( it -> first == -2 )
size = node_parent.scale[1] * ( it -> second );
else if ( it -> first == -3 )
size = ( node_parent.scale[2] * ( it -> second ));
else
size = ( it -> first ) * ( it -> second );
string name = rule -> symbolNames [0]; // convert symbol name
// pass parameter to the Symbol functions
node_child = node_parent.repeat ( d, size, name );
}
// "Occlusion" =>
return node_child;
}