37 class TetGenIOHandler final:
public GeoModelIOHandler< 3 > {
39 void load(
const std::string& filename, GeoModel3D& geomodel )
final 43 throw RINGMeshException(
"I/O",
44 "Loading of a GeoModel from TetGen not implemented yet" );
46 void save(
const GeoModel3D& geomodel,
const std::string& filename )
final 48 std::string directory = GEO::FileSystem::dir_name( filename );
49 std::string file = GEO::FileSystem::base_name( filename );
51 std::ostringstream oss_node;
52 oss_node << directory <<
"/" << file <<
".node";
53 std::ofstream node( oss_node.str().c_str() );
56 const GeoModelMesh3D& mesh = geomodel.mesh;
57 node << mesh.vertices.nb() <<
" 3 0 0" <<
EOL;
58 for(
auto v : range( mesh.vertices.nb() ) ) {
59 node << v <<
SPACE << mesh.vertices.vertex( v ) <<
EOL;
62 std::ostringstream oss_ele;
63 oss_ele << directory <<
"/" << file <<
".ele";
64 std::ofstream ele( oss_ele.str().c_str() );
65 std::ostringstream oss_neigh;
66 oss_neigh << directory <<
"/" << file <<
".neigh";
67 std::ofstream neigh( oss_neigh.str().c_str() );
69 ele << mesh.cells.nb() <<
" 4 1" <<
EOL;
70 neigh << mesh.cells.nb() <<
" 4" <<
EOL;
71 index_t nb_tet_exported = 0;
72 for(
auto m : range( geomodel.nb_regions() ) ) {
73 for(
auto tet : range( mesh.cells.nb_tet( m ) ) ) {
74 index_t cell = mesh.cells.tet( m, tet );
75 ele << nb_tet_exported <<
SPACE 76 << mesh.cells.vertex( ElementLocalVertex( cell, 0 ) )
78 << mesh.cells.vertex( ElementLocalVertex( cell, 1 ) )
80 << mesh.cells.vertex( ElementLocalVertex( cell, 2 ) )
82 << mesh.cells.vertex( ElementLocalVertex( cell, 3 ) )
84 neigh << nb_tet_exported;
85 for(
auto f : range( mesh.cells.nb_facets( tet ) ) ) {
87 index_t adj = mesh.cells.adjacent( cell, f );
88 if( adj == GEO::NO_CELL ) {
void ringmesh_unused(const T &)