60 template < index_t DIMENSION >
78 void remove_mesh_entities(
const std::set< gmme_id >& entities );
89 void remove_geological_entities(
const std::set< gmge_id >& entities );
94 void remove_entities_and_dependencies(
95 const std::set< gmme_id >& entities_to_remove );
103 update_mesh_entity_index( ME );
104 update_mesh_entity_boundaries( ME );
105 delete_invalid_boundaries( ME );
107 update_mesh_entity_incident_entity( ME );
108 delete_invalid_incident_entity( ME );
113 const std::set< gmme_id >& mesh_entities_to_remove )
115 nb_mesh_entity_types_ =
116 geomodel_.entity_type_manager()
117 .mesh_entity_manager.nb_mesh_entity_types();
118 nb_geological_entity_types_ =
119 geomodel_.nb_geological_entity_types();
121 nb_geological_entity_types_ + nb_mesh_entity_types_;
122 nb_removed_mesh_entities_.resize( nb_mesh_entity_types_, 0 );
123 nb_removed_geological_entities_.resize(
124 nb_geological_entity_types_, 0 );
125 fill_entity_type_to_index_map();
126 fill_nb_initial_entities();
127 initialize_costly_storage();
128 fill_nb_children_vector();
130 check_if_entities_are_meshed( mesh_entities_to_remove );
131 fill_to_erase_vectors( mesh_entities_to_remove );
132 fill_removed_entities_and_mapping();
136 for(
auto i :
range( nb_mesh_entity_types_ ) )
138 for(
auto j :
range( nb_initial_mesh_entities_[i] ) )
140 if( mesh_entity_to_erase_[i][j] )
143 index_to_mesh_entity_type( i );
145 range( geomodel_.mesh_entity( type_name, j )
149 geomodel_.mesh_entity( type_name, j )
151 nb_childs_[geological_entity_type_to_index(
155 delete_mesh_entity( i, j );
158 clear_null_mesh_entities( i );
161 void do_delete_flagged_geological_entities();
164 const std::set< gmme_id >& mesh_entities_to_remove )
166 for(
const gmme_id& it : mesh_entities_to_remove )
168 if( !geomodel_.entity_type_manager()
169 .mesh_entity_manager.is_valid_type( it.type() ) )
173 "using mesh removal." );
180 mesh_entity_to_erase_.resize( nb_mesh_entity_types_ );
182 old_2_new_mesh_entity_.resize( nb_mesh_entity_types_ );
183 old_2_new_geological_entity_.resize( nb_geological_entity_types_ );
184 nb_childs_.resize( nb_geological_entity_types_ );
185 for(
auto i :
range( nb_mesh_entity_types_ ) )
187 index_t size = geomodel_.nb_mesh_entities(
188 index_to_mesh_entity_type( i ) );
189 mesh_entity_to_erase_[i].resize( size,
false );
190 old_2_new_mesh_entity_[i].resize( size, 0 );
193 for(
auto i :
range( nb_geological_entity_types_ ) )
195 index_t size = geomodel_.nb_geological_entities(
196 index_to_geological_entity_type( i ) );
197 old_2_new_geological_entity_[i].resize( size, 0 );
198 nb_childs_[i].resize( size, 0 );
201 void delete_mesh_entity( index_t type, index_t index );
205 const MeshEntityType& type_name = index_to_mesh_entity_type( type );
206 std::vector< std::unique_ptr< GeoModelMeshEntity< DIMENSION > > >&
207 store = geomodel_access_.modifiable_mesh_entities( type_name );
209 std::remove( store.begin(), store.end(),
211 unique_ptr< GeoModelMeshEntity< DIMENSION >
> >(
217 == nb_initial_mesh_entities_[type]
218 - nb_removed_mesh_entities_[type] );
224 index_to_geological_entity_type( type );
226 unique_ptr< GeoModelGeologicalEntity< DIMENSION > > >&
227 store = geomodel_access_.modifiable_geological_entities(
230 std::remove( store.begin(), store.end(),
232 unique_ptr< GeoModelGeologicalEntity< DIMENSION >
> >(
238 == nb_initial_geological_entities_[type]
239 - nb_removed_geological_entities_[type] );
243 for(
auto i :
range( nb_mesh_entity_types_ ) )
246 index_to_mesh_entity_type( i );
248 range( geomodel_.nb_mesh_entities( entity_type ) ) )
250 gmme_id new_id( entity_type, j );
252 geomodel_access_.modifiable_mesh_entity( new_id );
253 update_mesh_entity( ME );
260 for(
auto i :
range( nb_geological_entity_types_ ) )
263 index_to_geological_entity_type( i );
265 range( geomodel_.nb_geological_entities( entity_type ) ) )
267 gmge_id new_id( entity_type, j );
269 geomodel_access_.modifiable_geological_entity( new_id );
270 update_geological_entity_index( GE );
271 update_geological_entity_children( GE );
272 delete_invalid_children( GE );
276 for(
auto i :
range( nb_mesh_entity_types_ ) )
279 index_to_mesh_entity_type( i );
281 range( geomodel_.nb_mesh_entities( entity_type ) ) )
283 gmme_id new_id( entity_type, j );
285 geomodel_access_.modifiable_mesh_entity( new_id );
286 update_mesh_entity_parents( ME );
287 delete_invalid_parents( ME );
318 for(
auto i :
range( nb_mesh_entity_types_ ) )
320 for(
auto j :
range( nb_initial_mesh_entities_[i] ) )
322 if( mesh_entity_to_erase_[i][j] )
324 nb_removed_mesh_entities_[i]++;
325 old_2_new_mesh_entity_[i][j] = NO_ID;
329 old_2_new_mesh_entity_[i][j] =
330 j - nb_removed_mesh_entities_[i];
336 const std::set< gmme_id >& mesh_entities_to_remove )
338 for(
const gmme_id& cur : mesh_entities_to_remove )
340 index_t type_index = mesh_entity_type_to_index( cur.type() );
341 mesh_entity_to_erase_[type_index][cur.index()] =
true;
345 void fill_nb_children_vector();
349 nb_initial_mesh_entities_.resize( nb_mesh_entity_types_, 0 );
350 for(
auto i :
range( nb_mesh_entity_types_ ) )
353 nb_initial_mesh_entities_[i] =
354 geomodel_.nb_mesh_entities( type );
357 nb_initial_geological_entities_.resize(
358 nb_geological_entity_types_, 0 );
359 for(
auto i :
range( nb_geological_entity_types_ ) )
362 index_to_geological_entity_type( i );
363 nb_initial_geological_entities_[i] =
364 geomodel_.nb_geological_entities( type );
370 geomodel_.entity_type_manager();
371 mesh_entity_types_.insert( mesh_entity_types_.end(),
375 if( nb_geological_entity_types_ != 0 )
377 geological_entity_types_.insert( geological_entity_types_.end(),
390 return mesh_entity_type_to_index( type );
393 index_t geological_entity_type_index(
399 return mesh_entity_type_to_index( child_type );
406 geomodel_.entity_type_manager().relationship_manager;
413 if( !geomodel_.entity_type_manager()
414 .mesh_entity_manager.is_valid_type( b_type ) )
418 return mesh_entity_type_to_index( b_type );
425 geomodel_.entity_type_manager().mesh_entity_manager;
434 if( !geomodel_.entity_type_manager()
435 .mesh_entity_manager.is_valid_type( in_ent_type ) )
439 return mesh_entity_type_to_index( in_ent_type );
446 geomodel_.entity_type_manager().mesh_entity_manager;
452 return i < nb_mesh_entity_types_;
457 return !is_mesh_entity( i );
464 for(
auto i :
range( nb_childs_.size() ) )
466 for(
auto j :
range( nb_childs_[i].size() ) )
468 if( nb_childs_[i][j] == 0 )
470 nb_removed_geological_entities_[i]++;
471 old_2_new_geological_entity_[i][j] = NO_ID;
475 old_2_new_geological_entity_[i][j] =
476 j - nb_removed_geological_entities_[i];
482 void set_mesh_entity_index(
484 index_t new_index_in_geomodel );
485 void set_geological_entity_index(
487 index_t new_index_in_geomodel );
489 void update_mesh_entity_index(
491 void update_geological_entity_index(
493 void update_mesh_entity_boundaries(
497 Region3D& region, index_t boundary_index,
bool new_side )
501 geomodel_access_.modifiable_mesh_entity( region.gmme() ) );
502 region_access.modifiable_sides()[boundary_index] = new_side;
505 void update_mesh_entity_incident_entity(
507 void update_mesh_entity_parents(
509 void update_geological_entity_children(
513 template <
typename TEST,
typename THINGS_TO_DELETE >
515 std::vector< THINGS_TO_DELETE >& vector,
const TEST& test )
517 auto new_end = std::remove_if( vector.begin(), vector.end(), test );
518 if( new_end == vector.begin() )
524 else if( new_end < vector.end() )
526 vector.erase( new_end, vector.end() );
538 E.
geomodel().entity_type_manager().relationship_manager;
540 gmme_id invalid_child( child_type, NO_ID );
542 [&invalid_child, &manager]( index_t i ) {
551 gmme_id invalid( b_type, NO_ID );
552 if( !geomodel_.entity_type_manager()
553 .mesh_entity_manager.is_valid_type( b_type ) )
559 E.
geomodel().entity_type_manager().relationship_manager;
561 [&invalid, &manager]( index_t i ) {
571 gmme_id invalid( in_ent_type, NO_ID );
572 if( !geomodel_.entity_type_manager()
573 .mesh_entity_manager.is_valid_type( in_ent_type ) )
579 E.
geomodel().entity_type_manager().relationship_manager;
581 [&invalid, &manager]( index_t i ) {
590 E.
geomodel().entity_type_manager().relationship_manager;
591 remove_invalid_values(
599 return find( mesh_entity_types_, type );
605 return find( geological_entity_types_, type );
609 return mesh_entity_types_[index];
613 index_t index )
const 615 return geological_entity_types_[index];
653 template < index_t DIMENSION >
677 void update_mesh_entity( GeoModelMeshEntity3D& ME )
override;
680 Region3D& R, index_t boundary_index,
bool new_side )
683 GeoModelMeshEntityAccess3D region_access(
684 geomodel_access_.modifiable_mesh_entity( R.gmme() ) );
685 region_access.modifiable_sides()[boundary_index] = new_side;
691 boundary_entity_type( R.mesh_entity_type() );
692 gmme_id invalid_value( surface_type, NO_ID );
695 for( index_t i = 0; i + offset < R.nb_boundaries(); ++i )
697 if( R.boundary_gmme( i ) == invalid_value )
703 bool new_side = R.side( i + offset );
704 set_boundary_side( R, i, new_side );
711 GeoModelMeshEntityAccess3D region_access(
712 geomodel_access_.modifiable_mesh_entity( R.gmme() ) );
713 region_access.modifiable_sides().resize( R.nb_boundaries() );
std::vector< index_t > & modifiable_boundaries()
#define ringmesh_disable_copy_and_move(Class)
std::vector< index_t > nb_initial_geological_entities_
void delete_invalid_incident_entity(GeoModelMeshEntity< DIMENSION > &E)
const GeoModel< DIMENSION > & geomodel() const
virtual MeshEntityType type_name() const =0
void delete_invalid_signs(Region3D &R)
Abstract base class for GeoModelMeshEntity.
GeologicalEntityType entity_type() const
void fill_to_erase_vectors(const std::set< gmme_id > &mesh_entities_to_remove)
GeologicalTypeManager geological_entity_manager
const MeshEntityType & boundary_entity_type(const MeshEntityType &type) const
const MeshEntityType & incident_entity_type(const MeshEntityType &type) const
The GeologicalEntityType described the type of the Geological entities User can defined there own Geo...
bool is_geological_entity(index_t i) const
index_t mesh_entity_type_to_index(const MeshEntityType &type) const
void clear_null_geological_entities(index_t type)
Base class to build or edit a GeoModel.
GeoModel< DIMENSION > & geomodel_
void do_delete_flagged_mesh_entities()
std::vector< index_t > nb_initial_mesh_entities_
void set_boundary_side(Region3D ®ion, index_t boundary_index, bool new_side)
const GeologicalEntityType & index_to_geological_entity_type(index_t index) const
#define ringmesh_template_assert_2d_or_3d(type)
void fill_removed_entities_and_mapping()
std::vector< std::vector< index_t > > old_2_new_mesh_entity_
const gmme_id & boundary_gmme(index_t relation_id) const
void flag_geological_entities_without_children()
void set_boundary_side(Region3D &R, index_t boundary_index, bool new_side)
std::vector< index_t > & modifiable_children()
index_t nb_geological_entity_types_
Entity_type_template type() const
index_t mesh_entity_type_index(const GeoModelMeshEntity< DIMENSION > &E) const
std::vector< MeshEntityType > mesh_entity_types_
void clear_null_mesh_entities(index_t type)
std::vector< std::vector< bool > > mesh_entity_to_erase_
MeshEntityTypeManager< DIMENSION > mesh_entity_manager
index_t incident_entity_type_to_index(const MeshEntityType &type) const
TODO unused function. To handle during removal refactoring BC.
const MeshEntityType child_type(const GeologicalEntityType &parent_type) const
void delete_invalid_boundaries(GeoModelMeshEntity< DIMENSION > &E)
virtual void update_mesh_entity(GeoModelMeshEntity< DIMENSION > &ME)
const gmge_id & parent_of_gmme(index_t relation_id) const
index_t boundary_type_index(const MeshEntityType &type) const
GeoModelAccess< DIMENSION > geomodel_access_
void remove_invalid_values(std::vector< THINGS_TO_DELETE > &vector, const TEST &test)
std::vector< std::vector< index_t > > old_2_new_geological_entity_
index_t find(const container &in, const T &value)
Returns the position of the first entity matching.
index_t nb_mesh_entity_types_
const MeshEntityType & index_to_mesh_entity_type(index_t index) const
std::vector< index_t > nb_removed_geological_entities_
const gmme_id & child_of_gmge(index_t relation_id) const
GeoModelBuilder< DIMENSION > & builder_
Global entity manager which could be associated to a geomodel to give access to different manager to ...
std::vector< index_t > & modifiable_parents()
Builder tools to remove entities from a GeoModel.
void fill_nb_initial_entities()
bool is_mesh_entity(index_t i) const
void delete_invalid_parents(GeoModelMeshEntity< DIMENSION > &E)
#define ringmesh_assert(x)
void initialize_costly_storage()
void update_region_boundary_signs(Region3D &R)
std::vector< std::vector< index_t > > nb_childs_
index_t nb_children() const
void fill_entity_type_to_index_map()
const MeshEntityType & incident_entity_type(const MeshEntityType &mesh_entity_type) const
const MeshEntityType children_type(const GeologicalEntityType &type) const
const MeshEntityType & boundary_entity_type(const MeshEntityType &mesh_entity_type) const
The MeshEntityType described the type of the meshed entities There are 4 MeshEntityTypes correspondin...
index_t children_type_index(const GeologicalEntityType &type) const
index_t geological_entity_type_to_index(const GeologicalEntityType &type) const
This template is a specialization of a gme_id to the GeoModelGeologicalEntity.
this class contains methods to manage relations between Geological and Mesh entities. For instance: A "Contact" can be the parent of one or more "Line" An "Interface" can the parent of one or more "Surface" A "Layer" can be the parent of one or more "Region"
std::vector< GeologicalEntityType > geological_entity_types_
Classes to build GeoModel from various inputs.
std::vector< index_t > nb_removed_mesh_entities_
void delete_invalid_children(GeoModelGeologicalEntity< DIMENSION > &E)
void update_mesh_entity_connectivity()
void initialize_for_removal(const std::set< gmme_id > &mesh_entities_to_remove)
void check_if_entities_are_meshed(const std::set< gmme_id > &mesh_entities_to_remove)
std::vector< index_t > & modifiable_incident_entities()
This template is a specialization of a gme_id to the GeoModelMeshEntity.
FORWARD_DECLARATION_DIMENSION_CLASS(GeoModelMeshEntityAccess)
void update_geological_entity_connectivity()
MeshEntityType mesh_entity_type() const
const gmme_id & incident_entity_gmme(index_t relation_id) const