예제 #1
0
파일: gui.cpp 프로젝트: ipa-nhg/kukadu
int Upper_Leaves_CB( Togl *togl, int argc, const char *argv[] )
{
    int i;

    if( uleaves ) {
        // Include all leaves above the current level
        for( i = 0; i < num_leaves; i++ ) {
            if( leaves[i]->Level() < level ) {
                which_pieces.Add_Grow( leaves[i], 10 );
            }
        }
    } else {
        // Remove all leaves above the current level
        SWIFT_Array<SWIFT_BV*> new_which_pieces;

        new_which_pieces.Create( which_pieces.Length() );
        new_which_pieces.Set_Length( 0 );
        for( i = 0; i < which_pieces.Length(); i++ ) {
            if( !which_pieces[i]->Is_Leaf() ||
                which_pieces[i]->Level() == level
            ) {
                // Keep this piece
                new_which_pieces.Add( which_pieces[i] );
            }
        }

        which_pieces.Destroy();
        which_pieces = new_which_pieces;
        new_which_pieces.Nullify();
    }

    Togl_PostRedisplay( t );
    return TCL_OK;
}
예제 #2
0
파일: gui.cpp 프로젝트: ipa-nhg/kukadu
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;
}
예제 #3
0
파일: gui.cpp 프로젝트: ipa-nhg/kukadu
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;
}
예제 #4
0
파일: gui.cpp 프로젝트: ipa-nhg/kukadu
void Compute_Leaves( SWIFT_BV* piece )
{
    int i;

    if( piece == mesh->Root() ) {
        leaves.Destroy();
        leaves.Create( num_leaves );
        leaves.Set_Length( 0 );
    }

    if( piece->Is_Leaf() ) {
        leaves.Add( piece );
    } else {
        for( i = 0; i < piece->Num_Children(); i++ ) {
            Compute_Leaves( piece->Children()[i] );
        }
    }
}