talpa/iomesh.cpp
// ---------------------------------------------------------
///
/// Write mesh in binary format, with per-vertex velocities
///
// ---------------------------------------------------------
Write mesh in binary format, with per-vertex velocities
Write mesh in binary format with per - vertex velocities
bool write_binary_file_with_velocities( const NonDestructiveTriMesh &mesh, 
                                       const std::vector<Vec3d> &x,
                                       const std::vector<double> &masses,                                       
                                       const std::vector<Vec3d> &v,
                                       double curr_t, 
                                       const char *filename_format, ...)
{
    va_list ap;
    va_start(ap, filename_format);   
    bofstream outfile( filename_format, ap );
    va_end(ap);
    outfile.write_endianity();
    outfile << curr_t;
    unsigned int nverts = static_cast<unsigned int>( x.size() );
    outfile << nverts;
    for ( unsigned int i = 0; i < x.size(); ++i )
    {
        outfile << x[i][0];
        outfile << x[i][1];
        outfile << x[i][2];
    }
    assert( x.size() == masses.size() );
    for ( unsigned int i = 0; i < masses.size(); ++i )
    {
        outfile << masses[i];
    }
    for ( unsigned int i = 0; i < v.size(); ++i )
    {
        outfile << v[i][0];
        outfile << v[i][1];
        outfile << v[i][2];
    }
    unsigned int ntris = static_cast<unsigned int>( mesh.num_triangles() );
    outfile << ntris;
    for ( unsigned int t = 0; t < mesh.num_triangles(); ++t )
    {
        const Vec3ui& tri = Vec3ui( mesh.get_triangle(t) );
        outfile << tri[0];
        outfile << tri[1];
        outfile << tri[2];      
    }
    outfile.close();
    return outfile.good();
}
bool write_binary_file_with_velocities ( const NonDestructiveTriMesh & mesh , const std :: vector < Vec3d > & x , const std :: vector < double > & masses , const std :: vector < Vec3d > & v , double curr_t , const char * filename_format , ... ) { va_list ap ; va_start ( ap , filename_format ) ; bofstream outfile ( filename_format , ap ) ; va_end ( ap ) ; outfile . write_endianity ( ) ; outfile << curr_t ; unsigned int nverts = static_cast < unsigned int > ( x . size ( ) ) ; outfile << nverts ; for ( unsigned int i = 0 ; i < x . size ( ) ; ++ i ) { outfile << x [ i ] [ 0 ] ; outfile << x [ i ] [ 1 ] ; outfile << x [ i ] [ 2 ] ; } assert ( x . size ( ) == masses . size ( ) ) ; for ( unsigned int i = 0 ; i < masses . size ( ) ; ++ i ) { outfile << masses [ i ] ; } for ( unsigned int i = 0 ; i < v . size ( ) ; ++ i ) { outfile << v [ i ] [ 0 ] ; outfile << v [ i ] [ 1 ] ; outfile << v [ i ] [ 2 ] ; } unsigned int ntris = static_cast < unsigned int > ( mesh . num_triangles ( ) ) ; outfile << ntris ; for ( unsigned int t = 0 ; t < mesh . num_triangles ( ) ; ++ t ) { const Vec3ui & tri = Vec3ui ( mesh . get_triangle ( t ) ) ; outfile << tri [ 0 ] ; outfile << tri [ 1 ] ; outfile << tri [ 2 ] ; } outfile . close ( ) ; return outfile . good ( ) ; }
Write mesh in binary format, with per-vertex velocities
Write mesh in binary format with per - vertex velocities