talpa/iomesh.cpp
// ---------------------------------------------------------
///
/// Read mesh in binary format, with per-vertex velocities
///
// ---------------------------------------------------------
Read mesh in binary format, with per-vertex velocities
Read mesh in binary format with per - vertex velocities
bool read_binary_file_with_velocities( NonDestructiveTriMesh &mesh, 
                                      std::vector<Vec3d> &x, 
                                      std::vector<double> &masses,
                                      std::vector<Vec3d> &v, 
                                      double& curr_t, 
                                      const char *filename_format, ...)
{
    va_list ap;
    va_start(ap, filename_format);   
    bifstream infile( filename_format, ap );
    va_end(ap);
    infile.read_endianity();
    infile >> curr_t;
    unsigned int nverts;
    infile >> nverts;
    mesh.set_num_vertices(nverts);
    x.resize( nverts );
    for ( unsigned int i = 0; i < nverts; ++i )
    {
        infile >> x[i][0];
        infile >> x[i][1];
        infile >> x[i][2];      
    }
    masses.resize( nverts );
    for ( unsigned int i = 0; i < masses.size(); ++i )
    {
        infile >> masses[i];
    }
    v.resize( nverts );
    for ( unsigned int i = 0; i < nverts; ++i )
    {
        infile >> v[i][0];
        infile >> v[i][1];
        infile >> v[i][2];      
    }
    unsigned int ntris;
    infile >> ntris;
    for ( unsigned int t = 0; t < ntris; ++t )
    {
        Vec3st tri;
        infile >> tri[0];
        infile >> tri[1];
        infile >> tri[2];
        mesh.add_triangle(tri);
    }
    infile.close();
    return infile.good();
}
bool read_binary_file_with_velocities ( NonDestructiveTriMesh & mesh , std :: vector < Vec3d > & x , std :: vector < double > & masses , std :: vector < Vec3d > & v , double & curr_t , const char * filename_format , ... ) { va_list ap ; va_start ( ap , filename_format ) ; bifstream infile ( filename_format , ap ) ; va_end ( ap ) ; infile . read_endianity ( ) ; infile >> curr_t ; unsigned int nverts ; infile >> nverts ; mesh . set_num_vertices ( nverts ) ; x . resize ( nverts ) ; for ( unsigned int i = 0 ; i < nverts ; ++ i ) { infile >> x [ i ] [ 0 ] ; infile >> x [ i ] [ 1 ] ; infile >> x [ i ] [ 2 ] ; } masses . resize ( nverts ) ; for ( unsigned int i = 0 ; i < masses . size ( ) ; ++ i ) { infile >> masses [ i ] ; } v . resize ( nverts ) ; for ( unsigned int i = 0 ; i < nverts ; ++ i ) { infile >> v [ i ] [ 0 ] ; infile >> v [ i ] [ 1 ] ; infile >> v [ i ] [ 2 ] ; } unsigned int ntris ; infile >> ntris ; for ( unsigned int t = 0 ; t < ntris ; ++ t ) { Vec3st tri ; infile >> tri [ 0 ] ; infile >> tri [ 1 ] ; infile >> tri [ 2 ] ; mesh . add_triangle ( tri ) ; } infile . close ( ) ; return infile . good ( ) ; }
Read mesh in binary format, with per-vertex velocities
Read mesh in binary format with per - vertex velocities