51 template < index_t DIMENSION >
55 for(
const auto& corner : geomodel.
corners() )
57 if( corner.vertex( 0 ) == point )
65 template < index_t DIMENSION >
69 const auto& geomodel_vertices = geomodel.
mesh.vertices;
70 const auto& vertices =
71 geomodel_vertices.gme_vertices( geomodel_point_id );
72 for(
const auto& vertex : vertices )
88 template < index_t DIMENSION >
99 if( rhs_vertices[v] != line.
vertex( v ) )
122 template < index_t DIMENSION >
123 std::vector< index_t > get_sorted_incident_surfaces(
126 std::vector< index_t > incident_surfaces;
128 incident_surfaces.resize( nb );
129 for(
auto i :
range( nb ) )
133 std::sort( incident_surfaces.begin(), incident_surfaces.end() );
134 return incident_surfaces;
137 template < index_t DIMENSION >
138 index_t add_to_set_children_of_geological_entities(
140 const std::set< gmge_id >& geological_entities,
141 std::set< gmme_id >& mesh_entities )
143 const auto old_number_of_entities =
static_cast< index_t
>(
144 mesh_entities.size() + geological_entities.size() );
145 for(
const auto& cur_gmge_id : geological_entities )
147 const auto& cur_geol_entity =
149 for(
auto child_i :
range( cur_geol_entity.nb_children() ) )
151 mesh_entities.insert( cur_geol_entity.child_gmme( child_i ) );
154 const auto new_number_of_entities =
static_cast< index_t
>(
155 mesh_entities.size() + geological_entities.size() );
157 return new_number_of_entities - old_number_of_entities;
160 template < index_t DIMENSION >
161 index_t add_to_set_geological_entities_which_have_no_child(
163 const std::set< gmme_id >& mesh_entities,
164 std::set< gmge_id >& geological_entities )
166 const auto old_number_of_entities =
static_cast< index_t
>(
167 mesh_entities.size() + geological_entities.size() );
168 const auto nb_geological_entity_types =
170 .geological_entity_manager.nb_geological_entity_types();
171 for(
auto geol_entity_type_i :
range( nb_geological_entity_types ) )
173 const auto& geol_type =
175 .geological_entity_manager.geological_entity_type(
176 geol_entity_type_i );
178 for(
auto geol_entity_i :
181 bool no_child{
true };
182 const auto& cur_geol_entity =
184 for(
auto child_i :
range( cur_geol_entity.nb_children() ) )
186 if( mesh_entities.count(
187 cur_geol_entity.child_gmme( child_i ) )
196 geological_entities.insert( cur_geol_entity.gmge() );
200 const auto new_number_of_entities =
static_cast< index_t
>(
201 mesh_entities.size() + geological_entities.size() );
203 return new_number_of_entities - old_number_of_entities;
206 template < index_t DIMENSION >
207 index_t add_to_set_mesh_entities_being_boundaries_of_no_mesh_entity(
209 std::set< gmme_id >& mesh_entities )
211 const auto old_number_of_entities =
212 static_cast< index_t
>( mesh_entities.size() );
213 for(
const auto& mesh_type :
215 .mesh_entity_manager.mesh_entity_types() )
217 if( mesh_type == Region3D::type_name_static() )
222 for(
auto mesh_entity_i :
225 bool no_incident{
true };
226 const auto& cur_mesh_entity =
228 for(
auto incident_entity_i :
229 range( cur_mesh_entity.nb_incident_entities() ) )
231 if( mesh_entities.count(
232 cur_mesh_entity.incident_entity_gmme(
233 incident_entity_i ) )
242 mesh_entities.insert( cur_mesh_entity.gmme() );
246 const auto new_number_of_entities =
247 static_cast< index_t
>( mesh_entities.size() );
249 return new_number_of_entities - old_number_of_entities;
256 template < index_t DIMENSION >
259 : builder_( builder ),
260 geomodel_( geomodel ),
261 geomodel_access_( geomodel )
265 template < index_t DIMENSION >
270 copy_mesh_entity_topology< Corner >( from );
271 copy_mesh_entity_topology< Line >( from );
272 copy_mesh_entity_topology< Surface >( from );
275 template < index_t DIMENSION >
279 copy_all_mesh_entity_topology( from );
281 geomodel_access_.modifiable_epsilon() = from.
epsilon();
282 geomodel_access_.modifiable_entity_type_manager().relationship_manager =
286 template < index_t DIMENSION >
288 std::set< gmme_id >& mesh_entities,
289 std::set< gmge_id >& geological_entities )
const 291 auto nb_added = add_to_set_children_of_geological_entities(
292 geomodel_, geological_entities, mesh_entities );
293 nb_added += add_to_set_geological_entities_which_have_no_child(
294 geomodel_, mesh_entities, geological_entities );
295 nb_added += add_to_set_mesh_entities_being_boundaries_of_no_mesh_entity(
296 geomodel_, mesh_entities );
301 return get_dependent_entities( mesh_entities, geological_entities );
306 template < index_t DIMENSION >
310 gmme_id result{ find_corner( geomodel_, point ) };
311 if( !result.is_defined() )
313 result = create_mesh_entity< Corner >();
314 builder_.geometry.set_corner( result.index(), point );
319 template < index_t DIMENSION >
321 index_t geomodel_point_id )
323 gmme_id result{ find_corner( geomodel_, geomodel_point_id ) };
324 if( !result.is_defined() )
326 result = create_mesh_entity< Corner >();
327 builder_.geometry.set_corner( result.index(), geomodel_point_id );
332 template < index_t DIMENSION >
337 for(
const auto& line : geomodel_.lines() )
339 if( line_equal( line, vertices ) )
341 result = line.
gmme();
346 result = create_mesh_entity< Line >();
347 builder_.geometry.set_line( result.
index(), vertices );
351 add_mesh_entity_boundary_relation(
352 result, find_or_create_corner( vertices.front() ) );
353 add_mesh_entity_boundary_relation(
354 result, find_or_create_corner( vertices.back() ) );
359 template < index_t DIMENSION >
361 const std::vector< index_t >& sorted_adjacent_surfaces,
365 for(
const auto& line : geomodel_.lines() )
370 if( ( c0 == first_corner && c1 == second_corner )
371 || ( c0 == second_corner && c1 == first_corner ) )
373 std::vector< index_t > cur_adjacent_surfaces{
374 get_sorted_incident_surfaces( line )
376 if( cur_adjacent_surfaces.size()
377 == sorted_adjacent_surfaces.size()
378 && std::equal( cur_adjacent_surfaces.begin(),
379 cur_adjacent_surfaces.end(),
380 sorted_adjacent_surfaces.begin() ) )
386 return create_mesh_entity< Line >();
389 template < index_t DIMENSION >
394 auto& manager = geomodel_access_.modifiable_entity_type_manager()
395 .relationship_manager;
396 index_t relation_id{ manager.find_boundary_relationship(
397 incident_entity, boundary ) };
398 if( relation_id == NO_ID )
401 "No boundary relation found between ", boundary,
" and ",
405 geomodel_access_.modifiable_mesh_entity( boundary ) );
406 auto& incident_entities =
408 std::remove_if( incident_entities.begin(), incident_entities.end(),
410 index_t relation ) {
return relation == relation_id; } );
412 geomodel_access_.modifiable_mesh_entity( incident_entity ) );
414 std::remove_if( boundaries.begin(), boundaries.end(),
416 index_t relation ) {
return relation == relation_id; } );
419 template < index_t DIMENSION >
420 template <
template < index_t >
class ENTITY >
424 const auto& entity_type = ENTITY< DIMENSION >::type_name_static();
425 index_t nb_entities{ geomodel_.nb_mesh_entities( entity_type ) };
426 index_t new_id{ nb_entities };
427 geomodel_access_.modifiable_mesh_entities( entity_type )
429 template create_entity< ENTITY >(
430 geomodel_, new_id, mesh_type ) );
431 return geomodel_access_.modifiable_mesh_entities( entity_type )
436 template < index_t DIMENSION >
437 template <
template < index_t >
class ENTITY >
439 index_t nb_additionnal_entities,
const MeshType& type )
441 const auto& entity_type = ENTITY< DIMENSION >::type_name_static();
442 auto& store = geomodel_access_.modifiable_mesh_entities( entity_type );
443 index_t old_size{
static_cast< index_t
>( store.size() ) };
444 index_t new_size{ old_size + nb_additionnal_entities };
445 store.reserve( new_size );
446 for(
auto i :
range( old_size, new_size ) )
449 template create_entity< ENTITY >( geomodel_, i, type ) );
454 template < index_t DIMENSION >
459 const auto& incident_entity_mesh_entity =
460 geomodel_.mesh_entity( incident_entity );
462 range( incident_entity_mesh_entity.nb_incident_entities() ) )
464 if( incident_entity_mesh_entity.incident_entity_gmme( in_ent )
468 incident_entity_mesh_entity );
474 template < index_t DIMENSION >
481 const auto& incident_entity_type =
482 geomodel_.entity_type_manager()
483 .mesh_entity_manager.incident_entity_type( boundary_id.
type() );
484 if( incident_entity_id.
type() != incident_entity_type )
487 "Wrong incident entity type in the boundary relation between ",
488 boundary_id,
" and ", incident_entity_id );
490 const auto& boundary_type =
491 geomodel_.entity_type_manager()
492 .mesh_entity_manager.boundary_entity_type(
493 incident_entity_id.
type() );
494 if( boundary_id.
type() != boundary_type )
497 "Wrong boundary type in the boundary relation between ",
498 boundary_id,
" and ", incident_entity_id );
501 check_if_boundary_incident_entity_relation_already_exists(
502 incident_entity_id, boundary_id )
504 auto& manager = geomodel_access_.modifiable_entity_type_manager()
505 .relationship_manager;
506 if( relation_id == NO_ID )
508 relation_id = manager.add_boundary_relationship(
509 incident_entity_id, boundary_id );
511 auto& boundary_entity =
512 geomodel_access_.modifiable_mesh_entity( boundary_id );
516 auto& incident_entity =
517 geomodel_access_.modifiable_mesh_entity( incident_entity_id );
523 template < index_t DIMENSION >
525 const gmme_id& gmme, index_t
id, index_t boundary_id,
bool side )
529 auto& mesh_entity = geomodel_access_.modifiable_mesh_entity( gmme );
531 geomodel_.entity_type_manager()
532 .mesh_entity_manager.boundary_entity_type( gmme.
type() );
533 gmme_id boundary( b_type, boundary_id );
536 auto& manager = geomodel_access_.modifiable_entity_type_manager()
537 .relationship_manager;
538 manager.set_boundary_to_boundary_relationship( relation_id, boundary );
541 template < index_t DIMENSION >
544 const gmme_id& gmme, index_t
id, index_t incident_entity_id )
548 auto& mesh_entity = geomodel_access_.modifiable_mesh_entity( gmme );
550 const auto& in_ent_type =
551 geomodel_.entity_type_manager()
552 .mesh_entity_manager.incident_entity_type( gmme.
type() );
553 gmme_id incident_entity( in_ent_type, incident_entity_id );
556 auto& manager = geomodel_access_.modifiable_entity_type_manager()
557 .relationship_manager;
558 manager.set_incident_entity_to_boundary_relationship(
559 relation_id, incident_entity );
562 template < index_t DIMENSION >
566 geomodel_access_.modifiable_mesh_entities( type )[index].reset();
569 template < index_t DIMENSION >
573 const auto& manager =
574 geomodel_.entity_type_manager().mesh_entity_manager;
575 if( manager.is_corner( type ) )
577 return this->create_mesh_entity< Corner >();
579 if( manager.is_line( type ) )
581 return create_mesh_entity< Line >();
583 if( manager.is_surface( type ) )
585 return create_mesh_entity< Surface >();
591 template < index_t DIMENSION >
595 const auto& manager =
596 geomodel_.entity_type_manager().mesh_entity_manager;
597 if( manager.is_corner( type ) )
599 return this->create_mesh_entities< Corner >(
600 nb_additional_entities );
602 if( manager.is_line( type ) )
604 return create_mesh_entities< Line >( nb_additional_entities );
606 if( manager.is_surface( type ) )
608 return create_mesh_entities< Surface >( nb_additional_entities );
617 const auto& manager =
618 geomodel_.entity_type_manager().mesh_entity_manager;
619 if( manager.is_region( type ) )
621 return GeoModelBuilderTopologyBase3D::
622 create_mesh_entity< Region >();
624 return GeoModelBuilderTopologyBase3D::create_mesh_entity( type );
629 const auto& manager =
630 geomodel_.entity_type_manager().mesh_entity_manager;
631 if( manager.is_region( type ) )
633 return GeoModelBuilderTopologyBase3D::
634 create_mesh_entities< Region >( nb_additional_entities );
636 return GeoModelBuilderTopologyBase3D::create_mesh_entities(
637 type, nb_additional_entities );
640 const GeoModel3D& from )
642 GeoModelBuilderTopologyBase3D::copy_all_mesh_entity_topology( from );
643 copy_mesh_entity_topology< Region >( from );
647 const gmme_id& gmme, index_t
id, index_t boundary_id,
bool side )
649 GeoModelBuilderTopologyBase2D::set_mesh_entity_boundary(
650 gmme,
id, boundary_id );
652 auto& mesh_entity = geomodel_access_.modifiable_mesh_entity( gmme );
653 GeoModelMeshEntityAccess2D gme_access( mesh_entity );
654 if( gmme.
type() == Surface2D::type_name_static() )
656 gme_access.modifiable_sides()[id] = side;
661 const gmme_id& incident_entity_id,
665 GeoModelBuilderTopologyBase2D::add_mesh_entity_boundary_relation(
666 incident_entity_id, boundary_id );
668 auto& incident_entity =
669 geomodel_access_.modifiable_mesh_entity( incident_entity_id );
670 GeoModelMeshEntityAccess2D incident_entity_access( incident_entity );
671 if( incident_entity_id.
type() == Surface2D::type_name_static() )
673 incident_entity_access.modifiable_sides().push_back( side );
678 const gmme_id& gmme, index_t
id, index_t boundary_id,
bool side )
680 GeoModelBuilderTopologyBase3D::set_mesh_entity_boundary(
681 gmme,
id, boundary_id );
683 auto& mesh_entity = geomodel_access_.modifiable_mesh_entity( gmme );
684 GeoModelMeshEntityAccess3D gme_access( mesh_entity );
685 if( gmme.
type() == Region3D::type_name_static() )
687 gme_access.modifiable_sides()[id] = side;
692 const gmme_id& incident_entity_id,
696 GeoModelBuilderTopologyBase3D::add_mesh_entity_boundary_relation(
697 incident_entity_id, boundary_id );
699 auto& incident_entity =
700 geomodel_access_.modifiable_mesh_entity( incident_entity_id );
701 GeoModelMeshEntityAccess3D incident_entity_access( incident_entity );
702 if( incident_entity_id.
type() == Region3D::type_name_static() )
704 incident_entity_access.modifiable_sides().push_back( side );
std::vector< index_t > & modifiable_boundaries()
index_t nb_incident_entities() const
GeoModelMesh< DIMENSION > mesh
Abstract base class for GeoModelMeshEntity.
GEO::vecng< DIMENSION, double > vecn
const EntityTypeManager< DIMENSION > & entity_type_manager() const
Gets the EntityTypeManager associated to the GeoModel.
const vecn< DIMENSION > & vertex(index_t vertex_index) const
Coordinates of the vertex_index.
virtual const GeoModelMeshEntity< DIMENSION > & mesh_entity(const gmme_id &id) const
Generic access to a meshed entity.
void ringmesh_unused(const T &)
GeoModelBuilderTopologyBase(GeoModelBuilder< DIMENSION > &builder, GeoModel< DIMENSION > &geomodel)
A GeoModelEntity of type CORNER.
const gmme_id & boundary_gmme(index_t x) const
Entity_type_template type() const
static MeshEntityType type_name_static()
const gmme_id & incident_entity_gmme(index_t x) const
#define ringmesh_assert(x)
A GeoModelEntity of type REGION.
The MeshEntityType described the type of the meshed entities There are 4 MeshEntityTypes correspondin...
corner_range< DIMENSION > corners() const
Classes to build GeoModel from various inputs.
const GeoModelGeologicalEntity< DIMENSION > & geological_entity(gmge_id id) const
Returns a const reference the identified GeoModelGeologicalEntity.
A GeoModelEntity of type LINE.
const std::vector< index_t > & incident_entity_relation_ids() const
virtual index_t nb_mesh_entities(const MeshEntityType &type) const
Returns the number of mesh entities of the given type.
std::vector< index_t > & modifiable_incident_entities()
This template is a specialization of a gme_id to the GeoModelMeshEntity.
index_t nb_geological_entities(const GeologicalEntityType &type) const
Returns the number of geological entities of the given type.
index_t nb_vertices() const
#define ringmesh_assert_not_reached