46 Corner3D::type_name_static(), Line3D::type_name_static(),
47 Surface3D::type_name_static()
50 struct GeologicalEntityTypeMapFrom2DTo3DInitializer
52 static std::map< GeologicalEntityType, GeologicalEntityType >
55 std::map< GeologicalEntityType, GeologicalEntityType > map;
56 map[Contact3D::type_name_static()] =
57 Interface2D::type_name_static();
58 map[Interface3D::type_name_static()] = Layer2D::type_name_static();
63 template <
typename U,
typename T >
64 const T& mapped_value(
const std::map< U, T >& map,
const U& key )
66 return map.find( key )->second;
69 const std::map< GeologicalEntityType, GeologicalEntityType >
70 geol_entity_type_2d_to_3d_map =
71 GeologicalEntityTypeMapFrom2DTo3DInitializer::initialize_map();
78 copy_geomodel_3d_topology();
79 copy_geomodel_3d_geological_informations();
80 project_geomodel_3d_mesh_entities();
86 for(
const auto& entity_type : projectable_entity_types )
88 topology.create_mesh_entities(
89 entity_type, geomodel3d_from_.nb_mesh_entities( entity_type ) );
91 for(
const auto& entity_type : projectable_entity_types )
93 for(
const auto entity_id :
94 range( geomodel3d_from_.nb_mesh_entities( entity_type ) ) )
97 geomodel3d_from_.mesh_entity( entity_type, entity_id );
98 for(
const auto& boundary_id :
range( entity.nb_boundaries() ) )
100 topology.add_mesh_entity_boundary_relation(
101 entity.gmme(), entity.boundary( boundary_id ).gmme() );
109 for(
const auto& geol_entity_id :
110 range( geomodel3d_from_.nb_geological_entity_types() ) )
112 const auto& cur_type =
113 geomodel3d_from_.geological_entity_type( geol_entity_id );
114 geology.create_geological_entities(
115 mapped_value( geol_entity_type_2d_to_3d_map, cur_type ),
116 geomodel3d_from_.nb_geological_entities( cur_type ) );
118 for(
const auto& geol_entity_id :
119 range( geomodel3d_from_.nb_geological_entity_types() ) )
121 const auto& cur_type =
122 geomodel3d_from_.geological_entity_type( geol_entity_id );
123 for(
const auto& cur_geol_entity :
124 geomodel3d_from_.geol_entities( cur_type ) )
126 for(
const auto& child_id :
127 range( cur_geol_entity.nb_children() ) )
129 geology.add_parent_children_relation(
131 geol_entity_type_2d_to_3d_map, cur_type ),
132 cur_geol_entity.index() },
133 cur_geol_entity.child_gmme( child_id ) );
141 for(
const auto& corner : geomodel3d_from_.corners() )
143 auto projected_vertices = compute_projected_vertices( corner );
145 geometry.set_corner( corner.index(), projected_vertices.front() );
148 for(
const auto& line : geomodel3d_from_.lines() )
150 auto projected_vertices = compute_projected_vertices( line );
151 geometry.set_line( line.index(), projected_vertices );
154 for(
const auto& surface : geomodel3d_from_.surfaces() )
156 auto projected_vertices = compute_projected_vertices( surface );
157 std::vector< index_t > surface_polygons;
158 surface_polygons.reserve( 4 * surface.nb_mesh_elements() );
159 std::vector< index_t > surface_polygon_ptr( 1, 0 );
160 surface_polygon_ptr.reserve( surface.nb_mesh_elements() + 1 );
161 for(
const auto& polygon_id :
range( surface.nb_mesh_elements() ) )
163 for(
const auto& v_id :
164 range( surface.nb_mesh_element_vertices( polygon_id ) ) )
166 surface_polygons.push_back(
167 surface.mesh_element_vertex_index(
168 { polygon_id, v_id } ) );
170 surface_polygon_ptr.push_back(
171 surface_polygon_ptr.back()
172 + surface.nb_mesh_element_vertices( polygon_id ) );
174 geometry.set_surface_geometry( surface.index(), projected_vertices,
175 surface_polygons, surface_polygon_ptr );
180 const GeoModelMeshEntity3D& entity )
182 std::vector< vec2 > projected_vertices;
183 projected_vertices.reserve( entity.nb_vertices() );
184 for(
const auto v :
range( entity.nb_vertices() ) )
186 projected_vertices.push_back( get_2d_coord( entity.vertex( v ) ) );
188 return projected_vertices;
void copy_geomodel_3d_geological_informations()
void project_geomodel_3d_mesh_entities()
std::vector< vec2 > compute_projected_vertices(const GeoModelMeshEntity3D &entity)
void print_geomodel(const GeoModel< DIMENSION > &geomodel)
Print in the console the geomodel statistics.
void copy_geomodel_3d_topology()
#define ringmesh_assert(x)
The MeshEntityType described the type of the meshed entities There are 4 MeshEntityTypes correspondin...
Classes to build GeoModel from various inputs.