本文整理汇总了C++中SWIFT_Array::Max_Length方法的典型用法代码示例。如果您正苦于以下问题:C++ SWIFT_Array::Max_Length方法的具体用法?C++ SWIFT_Array::Max_Length怎么用?C++ SWIFT_Array::Max_Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SWIFT_Array
的用法示例。
在下文中一共展示了SWIFT_Array::Max_Length方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Key_K_CB
int Key_K_CB( Togl *togl, int argc, const char *argv[] )
{
if( dh == DRAW_HIERARCHY ) {
if( which_pieces.Length() != 1 ) {
// Go up the hierarchy
int i;
SWIFT_Array<SWIFT_BV*> new_which_pieces( which_pieces.Length() );
SWIFT_BV* parent;
new_which_pieces.Set_Length( 0 );
parent = NULL;
for( i = 0; i < which_pieces.Length(); i++ ) {
if( uleaves && which_pieces[i]->Is_Leaf() &&
which_pieces[i]->Level() < level
) {
new_which_pieces.Add( which_pieces[i] );
} else if( parent != which_pieces[i]->Parent() ) {
parent = which_pieces[i]->Parent();
new_which_pieces.Add( parent );
}
}
level--;
// Include the new leaves at this level if uleaves is false
if( !uleaves ) {
for( i = 0; i < num_leaves; i++ ) {
if( leaves[i]->Level() == level ) {
new_which_pieces.Add_Grow( leaves[i], 10 );
}
}
}
which_pieces.Destroy();
which_pieces = new_which_pieces;
new_which_pieces.Nullify();
}
} else {
// Show next convex piece and set text field
char temp[80];
if( which_cps.Length() == 0 ) {
which_cps.Set_Length( 1 );
which_cps[0] = 0;
} else {
which_cps[0] = (which_cps[0] == which_cps.Max_Length()-1 ?
0 : which_cps[0]+1);
which_cps.Set_Length( 1 );
}
sprintf( temp, "set which_cps %d", which_cps[0] );
Tcl_Eval( Togl_Interp( togl ), temp );
}
Togl_PostRedisplay( togl );
return TCL_OK;
}
示例2: Key_J_CB
int Key_J_CB( Togl *togl, int argc, const char *argv[] )
{
if( dh == DRAW_HIERARCHY ) {
int i, j;
bool advanced = false;
SWIFT_Array<SWIFT_BV*> new_which_pieces( 100 );
new_which_pieces.Set_Length( 0 );
for( i = 0; i < which_pieces.Length(); i++ ) {
if( uleaves && which_pieces[i]->Is_Leaf() ) {
// Keep this leaf
new_which_pieces.Add_Grow( which_pieces[i], 10 );
} else {
for( j = 0; j < which_pieces[i]->Num_Children(); j++ ) {
new_which_pieces.Add_Grow(
which_pieces[i]->Children()[j], 10 );
advanced = true;
}
}
}
if( advanced ) {
level++;
which_pieces.Destroy();
which_pieces = new_which_pieces;
new_which_pieces.Nullify();
}
} else {
// Show previous convex piece and set text field
char temp[80];
if( which_cps.Length() == 0 ) {
which_cps.Set_Length( 1 );
which_cps[0] = 0;
} else {
which_cps[0] = (which_cps[0] == 0 ?
which_cps.Max_Length()-1 : which_cps[0]-1);
which_cps.Set_Length( 1 );
}
sprintf( temp, "set which_cps %d", which_cps[0] );
Tcl_Eval( Togl_Interp( togl ), temp );
}
Togl_PostRedisplay( togl );
return TCL_OK;
}
示例3: Convex_Pieces_CB
int Convex_Pieces_CB( Togl *togl, int argc, const char *argv[] )
{
if( argv[2][0] == 'A' || argv[2][0] == 'a' ) {
// Want to draw all pieces
int i;
which_cps.Set_Length( which_cps.Max_Length() );
for( i = 0; i < which_cps.Length(); i++ ) {
which_cps[i] = i;
}
} else {
// Parse the string to determine which ones to draw
long upper, lower;
const char* str = argv[2];
char* endp;
int i;
SWIFT_Array<int> which_cps_back = which_cps;
which_cps.Set_Length( 0 );
while( *str != '\0' && which_cps.Length() != which_cps.Max_Length() ) {
if( isdigit( *str ) ) {
// Read the next segment
lower = strtol( str, &endp, 10 );
str = endp;
if( lower < 0 ) {
lower = 0;
}
if( lower >= which_cps.Max_Length() ) {
lower = which_cps.Max_Length()-1;
}
upper = lower;
if( *str == '-' ) {
str++;
if( isdigit( *str ) ) {
upper = strtol( str, &endp, 10 );
str = endp;
if( upper < 0 ) {
upper = 0;
}
if( upper >= which_cps.Max_Length() ) {
upper = which_cps.Max_Length()-1;
}
if( upper < lower ) {
int j = lower;
lower = upper;
upper = j;
}
} else {
cerr << "Error: Expecting number after '-'" << endl;
which_cps = which_cps_back;
break;
}
}
// Save the segment
for( i = lower; i <= upper &&
which_cps.Length() != which_cps.Max_Length(); i++
) {
which_cps.Add( i );
}
// Done this segment
if( *str == ',' ) {
str++;
} else {
// Assume that we found the end of the list
break;
}
} else {
break;
}
}
}
Togl_PostRedisplay( t );
return TCL_OK;
}