talpa/main.cpp
// ---------------------------------------------------------
///
/// Initialize the simulation.  Set the simulation parameters, initial geometry, etc.
///
// ---------------------------------------------------------
Initialize the simulation.  Set the simulation parameters, initial geometry, etc.
Initialize the simulation . Set the simulation parameters initial geometry etc .
void init_simulation( char *script_filename )
    {
        SurfTrackInitializationParameters init_params;
        std::vector<Vec3ui> tris;
        std::vector<Vec3d> verts;
        std::vector<Vec3d> velocities;
        std::vector<double> masses;
        ScriptInit script_init;
        script_init.parse_script( script_filename );
        if ( script_init.output_path_is_relative )
        {
            snprintf( g_output_path, 256, "%s/%s", g_base_output_path, script_init.output_path.c_str() );
        }
        else
        {
            snprintf( g_output_path, 256, "%s", script_init.output_path.c_str() );
        }
        frame_stepper = new FrameStepper( script_init.frame_dt );
        if ( script_init.end_sim_t != UNINITIALIZED_DOUBLE )
        {
            sim = new Simulation( script_init.sim_dt, script_init.end_sim_t );
        }
        else
        {
            sim = new Simulation( script_init.sim_dt );
        }
        if ( script_init.curr_t_specified )
        {
            sim->m_curr_t = script_init.curr_t;
            unsigned int curr_frame = static_cast<unsigned int>(script_init.curr_t / script_init.frame_dt); 
            std::cout << "curr_t: " << sim->m_curr_t << std::endl;
            std::cout << "curr_frame: " << curr_frame << std::endl; 
            frame_stepper->frame_count = curr_frame;
        }
        g_surf = new SurfTrack( script_init.vertices, script_init.triangles, script_init.masses, script_init.surf_track_params );   
        g_surf->defrag_mesh();
        driver = script_init.driver;   
        driver->initialize( *g_surf );
        if ( g_surf->m_collision_safety )
        {
            g_surf->m_collision_pipeline.assert_mesh_is_intersection_free( false );      
        }
        g_stats.set_double( "max_edge_length", g_surf->m_splitter.m_max_edge_length );
        g_stats.set_double( "min_edge_length", g_surf->m_collapser.m_min_edge_length );
        g_stats.set_double( "max_volume_change", g_surf->m_max_volume_change );
        set_time_base();
#ifdef USE_GUI
        init_gui( script_init );
#endif
    }
void init_simulation ( char * script_filename ) { SurfTrackInitializationParameters init_params ; std :: vector < Vec3ui > tris ; std :: vector < Vec3d > verts ; std :: vector < Vec3d > velocities ; std :: vector < double > masses ; ScriptInit script_init ; script_init . parse_script ( script_filename ) ; if ( script_init . output_path_is_relative ) { snprintf ( g_output_path , 256 , " " , g_base_output_path , script_init . output_path . c_str ( ) ) ; } else { snprintf ( g_output_path , 256 , " " , script_init . output_path . c_str ( ) ) ; } frame_stepper = new FrameStepper ( script_init . frame_dt ) ; if ( script_init . end_sim_t != UNINITIALIZED_DOUBLE ) { sim = new Simulation ( script_init . sim_dt , script_init . end_sim_t ) ; } else { sim = new Simulation ( script_init . sim_dt ) ; } if ( script_init . curr_t_specified ) { sim -> m_curr_t = script_init . curr_t ; unsigned int curr_frame = static_cast < unsigned int > ( script_init . curr_t / script_init . frame_dt ) ; std :: cout << " " << sim -> m_curr_t << std :: endl ; std :: cout << " " << curr_frame << std :: endl ; frame_stepper -> frame_count = curr_frame ; } g_surf = new SurfTrack ( script_init . vertices , script_init . triangles , script_init . masses , script_init . surf_track_params ) ; g_surf -> defrag_mesh ( ) ; driver = script_init . driver ; driver -> initialize ( * g_surf ) ; if ( g_surf -> m_collision_safety ) { g_surf -> m_collision_pipeline . assert_mesh_is_intersection_free ( false ) ; } g_stats . set_double ( " " , g_surf -> m_splitter . m_max_edge_length ) ; g_stats . set_double ( " " , g_surf -> m_collapser . m_min_edge_length ) ; g_stats . set_double ( " " , g_surf -> m_max_volume_change ) ; set_time_base ( ) ; #ifdef USE_GUI init_gui ( script_init ) ; #endif }
Initialize the simulation.
Initialize the simulation .
// Init frame stepper // init simulation // init SurfTrack // init driver