The Parametric Pseudo-Manifold (PPS) Library 1.0
|
This class represents a file writer for writing out a triangle surface mesh information to an OFF file. More...
#include <writer.h>
Public Member Functions | |
Writer (const std::string &fn) | |
Creates an instance of this class. | |
Writer (const Writer &w) | |
Creates an instance of this class from another instance. | |
~Writer () | |
Destroys an instance of this class. | |
void | write (unsigned nv, double *vset, unsigned nf, unsigned *fset) |
Writes the vertex and face information of a surface mesh to an OFF file. | |
Private Member Functions | |
void | write_header (unsigned nv, unsigned nf) |
Writes the file header information. | |
void | write_vertices (unsigned nv, double *vset) |
Writes the file header information. | |
void | write_faces (unsigned nf, unsigned *fset) |
Writes the mesh face information. | |
Private Attributes | |
std::string | _fname |
The name of the output file. | |
std::fstream | _fs |
The output file stream. |
This class represents a file writer for writing out a triangle surface mesh information to an OFF file.
offlib::Writer::Writer | ( | const std::string & | fn | ) |
Creates an instance of this class.
fn | The name of an OFF input file. |
Definition at line 56 of file writer.cpp.
References _fname.
{ assert( !fn.empty() ) ; _fname = fn + std::string( ".off" ) ; return ; }
offlib::Writer::Writer | ( | const Writer & | w | ) |
Creates an instance of this class from another instance.
w | Another instance of this class. |
Definition at line 73 of file writer.cpp.
: _fname( w._fname ) {}
void offlib::Writer::write | ( | unsigned | nv, |
double * | vset, | ||
unsigned | nf, | ||
unsigned * | fset | ||
) |
Writes the vertex and face information of a surface mesh to an OFF file.
nv | The number of vertices of the mesh. |
vset | The Cartesian coordinates of the mesh vertices. |
nf | The number of faces of the mesh. |
fset | The set of vertex identifiers of the mesh faces. |
Definition at line 89 of file writer.cpp.
References _fname, _fs, write_faces(), write_header(), and write_vertices().
Referenced by main().
{ _fs.open( _fname.c_str() , std::ios::out | std::ios::binary ) ; assert( _fs != 0 ) ; write_header( nv , nf ) ; write_vertices( nv , vset ) ; write_faces( nf , fset ) ; _fs.close() ; return ; }
void offlib::Writer::write_faces | ( | unsigned | nf, |
unsigned * | fset | ||
) | [private] |
Writes the mesh face information.
nf | The number of faces of the mesh. |
fset | The set of vertex identifiers of the mesh faces. |
Definition at line 183 of file writer.cpp.
References _fs.
Referenced by write().
{ for ( unsigned i = 0 ; i < nf ; i++ ) { const unsigned j = 3 * i; _fs << "3 " << fset[ j ] << " " << fset[ j + 1 ] << " " << fset[ j + 2 ] << std::endl ; } return ; }
void offlib::Writer::write_header | ( | unsigned | nv, |
unsigned | nf | ||
) | [private] |
Writes the file header information.
nv | The number of vertices of the mesh. |
nf | The number of faces of the mesh. |
Definition at line 121 of file writer.cpp.
References _fs.
Referenced by write().
void offlib::Writer::write_vertices | ( | unsigned | nv, |
double * | vset | ||
) | [private] |
Writes the file header information.
Writes the mesh vertex information.
nv | The number of vertices of the mesh. |
vset | The Cartesian coordinates of the mesh vertices. |
Definition at line 151 of file writer.cpp.
References _fs.
Referenced by write().