36 #include <ringmesh/ringmesh_tests_config.h> 40 #include <geogram/basic/command_line.h> 42 #include <geogram/mesh/mesh_io.h> 64 Logger::out(
"TEST",
"Test GeoModel building from Surface" );
66 std::vector< std::future< void > > futures;
69 GEO::mesh_load( ringmesh_test_data_path +
"modelA6.mesh", in );
81 GEO::CmdLine::set_arg(
"in:intersection_check",
true );
83 GEO::CmdLine::set_arg(
"in:intersection_check",
false );
86 futures.emplace_back( std::async( std::launch::async, [&geomodel] {
90 "Failed when loading model ", geomodel.name(),
91 ": the loaded model is not valid." );
95 futures.emplace_back( std::async( std::launch::async, [&geomodel] {
97 std::string output_file( ringmesh_test_output_path );
98 output_file +=
"saved_modelA6.gm";
102 GEO::Mesh surface_meshes;
105 for(
const auto& surface : geomodel.surfaces() )
107 index_t vertex_it{ surface_meshes.vertices.create_vertices(
108 surface.nb_vertices() ) };
109 for( index_t v :
range( surface.nb_vertices() ) )
111 surface_meshes.vertices.point( vertex_it + v ) =
114 index_t facet_it{ surface_meshes.facets.create_triangles(
115 surface.nb_mesh_elements() ) };
116 for( index_t f :
range( surface.nb_mesh_elements() ) )
119 range( surface.nb_mesh_element_vertices( f ) ) )
121 surface_meshes.facets.set_vertex( facet_it + f, v,
123 + surface.mesh_element_vertex_index( { f, v } ) );
127 surface_meshes.facets.connect();
129 futures.emplace_back(
130 std::async( std::launch::async, [&surface_meshes] {
132 std::string output_file2( ringmesh_test_output_path );
133 output_file2 +=
"saved_modelA6_dupl_points.mesh";
134 GEO::mesh_save( surface_meshes, output_file2 );
137 GeoModel3D reloaded_model;
145 futures.emplace_back(
146 std::async( std::launch::async, [&reloaded_model] {
151 "Failed when reloading model ", reloaded_model.name(),
152 ": the reloaded model is not valid." );
157 if( surface_meshes.vertices.nb() != in.vertices.nb() )
160 "Error when building model: not same number of vertices ",
161 "than input mesh." );
163 if( surface_meshes.facets.nb() != in.facets.nb() )
166 "Error when building model: not same number of facets ",
167 "than input mesh." );
169 if( surface_meshes.cells.nb() != in.cells.nb() )
172 "Error when building model: not same number of cells ",
173 "than input mesh." );
177 if( reloaded_model.nb_corners() != geomodel.nb_corners() )
180 "Error when reload model: not same number of corners ",
181 "between saved model and reload model." );
183 if( reloaded_model.nb_lines() != geomodel.nb_lines() )
186 "Error when reload model: not same number of lines ",
187 "between saved model and reload model." );
189 if( reloaded_model.nb_surfaces() != geomodel.nb_surfaces() )
192 "Error when reload model: not same number of surfaces ",
193 "between saved model and reload model." );
195 if( reloaded_model.nb_regions() != geomodel.nb_regions() )
198 "Error when reload model: not same number of regions ",
199 "between saved model and reload model." );
202 for(
auto& future : futures )
212 catch(
const std::exception& e )
bool is_geomodel_valid(const GeoModel< DIMENSION > &geomodel, ValidityCheckMode validity_check_mode=ValidityCheckMode::ALL)
Check global geomodel validity.
void end_geomodel()
Finish up geomodel building and complete missing information.
void print_geomodel(const GeoModel< DIMENSION > &geomodel)
Print in the console the geomodel statistics.
static void err(const std::string &feature, const Args &... args)
void build_regions_from_lines_and_surfaces()
static void out(const std::string &feature, const Args &... args)
void geomodel_save(const GeoModel< DIMENSION > &geomodel, const std::string &filename)
const std::string & category() const
Classes to build GeoModel from various inputs.
void build_polygonal_surfaces_from_connected_components()
void build_lines_and_corners_from_surfaces()
To build a GeoModel from a set of disconnected polygonal surfaces.
void RINGMESH_API default_configure()