41 #include <geogram/basic/algorithm.h> 43 #include <geogram/basic/permutation.h> 44 #include <geogram/mesh/mesh_geometry.h> 62 template < index_t DIMENSION >
63 class GeoModelMeshPolygonsBaseSort
67 const std::vector< index_t >& surface_id )
68 : mesh_( mesh ), surface_id_( surface_id )
72 bool operator()( index_t i, index_t j )
const 74 if( surface_id_[i] != surface_id_[j] )
76 return surface_id_[i] < surface_id_[j];
80 return mesh_.nb_polygon_vertices( i )
81 < mesh_.nb_polygon_vertices( j );
87 const std::vector< index_t >& surface_id_;
90 template < index_t DIMENSION >
91 class GeoModelMeshCellsSort
95 const std::vector< index_t >& region_id )
96 : mesh_( mesh ), region_id_( region_id )
100 bool operator()( index_t i, index_t j )
const 102 if( region_id_[i] != region_id_[j] )
104 return region_id_[i] < region_id_[j];
106 return mesh_.cell_type( i ) < mesh_.cell_type( j );
111 const std::vector< index_t >& region_id_;
114 std::string vertex_map_name()
116 return "model_vertex_map";
119 template < index_t DIMENSION >
120 std::vector< index_t > cell_facets_around_vertex(
123 std::vector< index_t > facets;
133 facets.push_back( f );
141 template < index_t DIMENSION >
156 template < index_t DIMENSION >
159 : gmm_( gmm ), geomodel_( gm ), mesh_base_( nullptr )
163 template < index_t DIMENSION >
167 : geomodel_vertices_( geomodel_vertices ),
geomodel_( geomodel )
177 template < index_t DIMENSION >
184 template < index_t DIMENSION >
187 index_t mesh_entity_vertex_index )
const 190 mesh_entity_vertex_index
191 <
geomodel_.mesh_entity( mesh_entity_id ).nb_vertices() );
193 return vertex_map( mesh_entity_id )[mesh_entity_vertex_index];
196 template < index_t DIMENSION >
204 template < index_t DIMENSION >
210 std::vector< GMEVertex > result;
211 result.reserve( all_gmes.size() );
212 for(
const auto&
vertex : all_gmes )
214 if(
vertex.gmme.type() == mesh_entity_type )
216 result.push_back(
vertex );
222 template < index_t DIMENSION >
225 index_t v,
const gmme_id& mesh_entity_id )
const 227 std::vector< index_t > result;
229 for(
const auto&
vertex : all_gmes )
231 if(
vertex.gmme == mesh_entity_id )
233 result.push_back(
vertex.v_index );
239 template < index_t DIMENSION >
240 const std::vector< index_t >&
242 const gmme_id& mesh_entity_id )
const 248 template < index_t DIMENSION >
249 std::vector< index_t >&
251 const gmme_id& mesh_entity_id )
256 template < index_t DIMENSION >
259 index_t mesh_entity_vertex_index,
260 index_t geomodel_entity_vertex_index )
263 vertex_map( mesh_entity_id )[mesh_entity_vertex_index] =
264 geomodel_entity_vertex_index;
267 template < index_t DIMENSION >
275 template < index_t DIMENSION >
279 const auto& all_mesh_entity_types =
281 .mesh_entity_manager.mesh_entity_types();
282 for(
const auto& cur_entity_type : all_mesh_entity_types )
284 auto nb_cur_type_entities =
285 geomodel_.nb_mesh_entities( cur_entity_type );
287 vertex_maps_.at( cur_entity_type )->resize( nb_cur_type_entities );
288 for(
auto e :
range( nb_cur_type_entities ) )
295 template < index_t DIMENSION >
303 const auto& mesh_entity =
geomodel_.mesh_entity( mesh_entity_id );
305 ->at( mesh_entity_id.
index() )
306 .resize( mesh_entity.nb_vertices(), NO_ID );
311 template < index_t DIMENSION >
314 const std::vector< index_t >& old2new )
316 const auto& all_mesh_entity_types =
318 .mesh_entity_manager.mesh_entity_types();
319 for(
const auto& cur_entity_type : all_mesh_entity_types )
324 const auto& E =
geomodel_.mesh_entity( cur_entity_type, e );
326 for(
auto v :
range( E.nb_vertices() ) )
329 auto new_m_id = old2new[old_m_id];
343 template < index_t DIMENSION >
349 ->at( mesh_entity_id.
index() )
353 ->at( mesh_entity_id.
index() )
358 template < index_t DIMENSION >
363 const auto& E =
geomodel_.mesh_entity( mesh_entity_id );
364 for(
auto v :
range( E.nb_vertices() ) )
366 mesh_entity_vertex_map[v] =
372 template < index_t DIMENSION >
375 const gmme_id& mesh_entity_id )
386 template < index_t DIMENSION >
389 const gmme_id& mesh_entity_id )
const 392 ->second->at( mesh_entity_id.
index() )
396 template < index_t DIMENSION >
410 template < index_t DIMENSION >
417 template < index_t DIMENSION >
420 const gmme_id& mesh_entity_id )
const 422 const auto& mesh_entity =
geomodel_.mesh_entity( mesh_entity_id );
423 return mesh_entity.vertex_attribute_manager();
426 template < index_t DIMENSION >
435 this->set_mesh( mesh_.get() );
438 template < index_t DIMENSION >
441 return mesh_->nb_vertices() > 0;
444 template < index_t DIMENSION >
447 if( !is_initialized() )
453 template < index_t DIMENSION >
460 count += geomodel.
mesh_entity( entity_type, i ).nb_vertices();
465 template < index_t DIMENSION >
475 const auto& E = geomodel.
mesh_entity( entity_type, i );
476 if( E.nb_vertices() == 0 )
483 for(
auto v :
range( E.nb_vertices() ) )
485 auto local_count = count + v;
486 mesh_builder->set_vertex( local_count, E.vertex( v ) );
488 vertex_mapper_.set_vertex_map_value(
id, v, local_count );
489 vertex_mapper_.add_to_gme_vertices(
493 count += E.nb_vertices();
497 template < index_t DIMENSION >
510 template < index_t DIMENSION >
515 auto nb = nb_total_vertices();
527 vertex_mapper_.clear_and_resize_geomodel_vertex_gmes( nb );
528 vertex_mapper_.bind_all_mesh_entity_vertex_maps();
536 template < index_t DIMENSION >
540 fill_vertices_for_entity_type(
542 fill_vertices_for_entity_type(
544 fill_vertices_for_entity_type(
549 template < index_t DIMENSION >
552 this->gmm_.polygons.
clear();
553 this->gmm_.wells.clear();
554 vertex_mapper_.clear();
558 builder->
clear(
true,
false );
561 template < index_t DIMENSION >
563 const gmme_id& mesh_entity_id )
565 vertex_mapper_.clear_vertex_map( mesh_entity_id );
568 template < index_t DIMENSION >
570 const gmme_id& mesh_entity_id )
572 vertex_mapper_.resize_vertex_map( mesh_entity_id );
575 template < index_t DIMENSION >
578 test_and_initialize();
579 return mesh_->nb_vertices();
582 template < index_t DIMENSION >
586 test_and_initialize();
588 return mesh_->vertex( v );
591 template < index_t DIMENSION >
595 test_and_initialize();
596 const auto& colocator = mesh_->vertex_nn_search();
597 auto vertices = colocator.get_neighbors( p, this->geomodel_.epsilon() );
598 if( vertices.empty() )
606 template < index_t DIMENSION >
608 const gmme_id& mesh_entity, index_t entity_vertex_index )
const 610 test_and_initialize();
611 return vertex_mapper_.geomodel_vertex_index(
612 mesh_entity, entity_vertex_index );
615 template < index_t DIMENSION >
620 auto entity_vertex_index =
621 this->geomodel_.mesh_entity( mesh_entity )
622 .mesh_element_vertex_index( element_local_vertex );
623 return geomodel_vertex_id( mesh_entity, entity_vertex_index );
626 template < index_t DIMENSION >
627 std::vector< index_t >
629 const gmme_id& mesh_entity, index_t geomodel_vertex_index )
const 631 test_and_initialize();
633 return vertex_mapper_.mesh_entity_vertex_indices(
634 geomodel_vertex_index, mesh_entity );
637 template < index_t DIMENSION >
638 const std::vector< GMEVertex >&
641 test_and_initialize();
642 return vertex_mapper_.mesh_entity_vertex_indices( v );
645 template < index_t DIMENSION >
646 std::vector< GMEVertex >
650 test_and_initialize();
651 return vertex_mapper_.mesh_entity_vertex_indices( v, entity_type );
654 template < index_t DIMENSION >
661 vertex_mapper_.resize_geomodel_vertex_gmes( nb() );
665 template < index_t DIMENSION >
672 const auto start_index = builder->create_vertex( points[0] );
673 for(
auto i :
range( 1, points.size() ) )
675 builder->create_vertex( points[i] );
677 vertex_mapper_.resize_geomodel_vertex_gmes( nb() );
681 template < index_t DIMENSION >
685 test_and_initialize();
690 mesh_builder->set_vertex( v, point );
694 const auto& gme_v = gme_vertices( v );
695 for(
const auto& info : gme_v )
697 builder.
geometry.set_mesh_entity_vertex(
698 info.gmme, info.v_index, point,
false );
702 template < index_t DIMENSION >
705 index_t entity_vertex_index,
706 index_t geomodel_vertex_index )
708 vertex_mapper_.set_vertex_map_value(
709 entity_id, entity_vertex_index, geomodel_vertex_index );
710 vertex_mapper_.add_to_gme_vertices(
711 GMEVertex( entity_id, entity_vertex_index ),
712 geomodel_vertex_index );
715 template < index_t DIMENSION >
725 index_t nb_colocalised_vertices{ NO_ID };
726 std::vector< index_t > old2new;
727 std::tie( nb_colocalised_vertices, old2new ) =
728 mesh_->vertex_nn_search().get_colocated_index_mapping(
729 this->geomodel_.epsilon() );
730 if( nb_colocalised_vertices > 0 )
732 erase_vertices( old2new );
736 template < index_t DIMENSION >
738 std::vector< index_t >& to_delete )
743 std::vector< bool > to_delete_bool( nb(),
false );
749 index_t nb_todelete{ 0 };
751 for(
auto v :
range( nb() ) )
753 if( to_delete[v] != v )
755 to_delete_bool[v] =
true;
757 if( to_delete[v] != NO_ID )
760 to_delete[v] = to_delete[to_delete[v]];
769 if( nb_todelete == 0 )
773 if( nb_todelete == nb() )
781 for(
auto v :
range( nb() ) )
783 vertex_mapper_.clear_geomodel_vertex_gmes( v );
791 vertex_mapper_.update_mesh_entity_maps_and_gmes( to_delete );
794 template < index_t DIMENSION >
805 std::unique_ptr< PointSetMesh3D >& mesh )
812 this->
gmm_.cells.clear();
813 GeoModelMeshVerticesBase3D::clear();
818 auto nb = GeoModelMeshVerticesBase3D::nb_total_vertices();
826 auto count = GeoModelMeshVerticesBase3D::fill_vertices();
828 this->
geomodel_, Region3D::type_name_static(), count );
835 const GeoModel3D& geomodel )
836 : geomodel_vertices_( geomodel_vertices ),
geomodel_( geomodel )
845 template < index_t DIMENSION >
855 template < index_t DIMENSION >
858 return mesh_->nb_cells() > 0;
861 template < index_t DIMENSION >
870 template < index_t DIMENSION >
873 this->
gmm_.vertices.test_and_initialize();
876 if(
mesh_->nb_vertices() != this->
gmm_.vertices.nb() )
878 copy_vertices( mesh_builder.get(), *this->
gmm_.vertices.mesh_ );
888 std::vector< index_t > nb_cells_per_type(
910 switch( cur_cell_type )
960 std::vector< index_t > cells_offset_per_type(
965 cells_offset_per_type[t] += cells_offset_per_type[t - 1];
966 cells_offset_per_type[t] += nb_cells_per_type[t - 1];
977 mesh_builder->create_cells( nb_cells_per_type[i],
CellType( i ) );
982 std::vector< index_t > cur_cell_per_type(
984 const auto& geomodel_vertices = this->
gmm_.vertices;
993 for(
auto v :
range(
mesh_->nb_cell_vertices( cur_cell ) ) )
995 auto region_vertex_index =
996 region.mesh_element_vertex_index( { c, v } );
997 auto global_vertex_id =
998 geomodel_vertices.geomodel_vertex_id(
999 region.gmme(), region_vertex_index );
1000 mesh_builder->set_cell_vertex(
1011 mesh_builder->connect_cells();
1025 template < index_t DIMENSION >
1030 std::vector< index_t > sorted_indices(
mesh_->nb_cells() );
1031 std::iota( sorted_indices.begin(), sorted_indices.end(), 0 );
1033 std::sort( sorted_indices.begin(), sorted_indices.end(), action );
1034 mesh_builder->permute_cells( sorted_indices );
1036 auto sorted_indices_geo =
1038 GEO::Permutation::apply(
1039 region_id_.data(), sorted_indices_geo,
sizeof( index_t ) );
1040 GEO::Permutation::apply(
1041 cell_id_.data(), sorted_indices_geo,
sizeof( index_t ) );
1044 template < index_t DIMENSION >
1051 template < index_t DIMENSION >
1059 template < index_t DIMENSION >
1063 return mesh_->nb_cells();
1066 template < index_t DIMENSION >
1071 return mesh_->nb_cell_vertices( c );
1074 template < index_t DIMENSION >
1083 return mesh_->cell_vertex( cell_local_vertex );
1086 template < index_t DIMENSION >
1091 return mesh_->nb_cell_edges( c );
1094 template < index_t DIMENSION >
1099 return mesh_->nb_cell_facets( c );
1102 template < index_t DIMENSION >
1110 return mesh_->nb_cell_facet_vertices( cell_local_facet );
1113 template < index_t DIMENSION >
1121 return mesh_->cell_facet_vertex( cell_local_facet, lv );
1124 template < index_t DIMENSION >
1126 index_t c, index_t le, index_t lv )
const 1128 geo_debug_assert( le <
nb_edges( c ) );
1129 geo_debug_assert( lv < 2 );
1130 return mesh_->cell_edge_vertex( c, le, lv );
1133 template < index_t DIMENSION >
1135 index_t c, index_t f )
const 1143 template < index_t DIMENSION >
1151 template < index_t DIMENSION >
1159 template < index_t DIMENSION >
1164 return mesh_->cell_type( c );
1167 template < index_t DIMENSION >
1191 template < index_t DIMENSION >
1214 == this->
geomodel_.region( r ).nb_mesh_elements() );
1225 template < index_t DIMENSION >
1237 return prism( r, c );
1252 template < index_t DIMENSION >
1259 template < index_t DIMENSION >
1272 template < index_t DIMENSION >
1282 template < index_t DIMENSION >
1289 template < index_t DIMENSION >
1301 template < index_t DIMENSION >
1311 template < index_t DIMENSION >
1318 template < index_t DIMENSION >
1329 template < index_t DIMENSION >
1339 template < index_t DIMENSION >
1346 template < index_t DIMENSION >
1358 template < index_t DIMENSION >
1360 index_t r, index_t p )
const 1369 template < index_t DIMENSION >
1376 template < index_t DIMENSION >
1389 template < index_t DIMENSION >
1391 index_t r, index_t c )
const 1400 template < index_t DIMENSION >
1403 return mode_ == this->
gmm_.duplicate_mode();
1406 template < index_t DIMENSION >
1416 template < index_t DIMENSION >
1422 std::vector< vec3 > corner_vertices(
1426 index_t begin =
mesh_->cell_begin( c );
1427 for(
auto v :
range(
mesh_->nb_cell_vertices( c ) ) )
1429 corner_vertices[begin + v] =
mesh_->vertex(
1435 std::vector< ActionOnSurface > actions_on_surfaces(
1437 std::vector< bool > is_vertex_to_duplicate(
1438 corner_vertices.size(), false );
1441 for(
const auto& surface : this->
geomodel_.surfaces() )
1447 actions_on_surfaces[surface.index()] =
TO_PROCESS;
1448 for(
auto v :
range( surface.nb_vertices() ) )
1451 surface.vertex( v ), this->
geomodel_.epsilon() );
1452 for(
auto co : colocated_corners )
1454 is_vertex_to_duplicate[co] =
true;
1460 corner_vertices.clear();
1469 this->
gmm_.polygons.test_and_initialize();
1472 for(
auto v :
range(
mesh_->nb_cell_vertices( c ) ) )
1475 index_t co =
mesh_->cell_begin( c ) + v;
1477 if( !is_vertex_to_duplicate[co] )
1487 std::vector< index_t > corner_used;
1491 std::vector< index_t > cell_added;
1495 std::vector< action_on_surface > surfaces;
1498 std::stack< index_t > S;
1500 cell_added.push_back( c );
1503 auto cur_c = S.top();
1506 auto cur_co =
mesh_->find_cell_corner( cur_c, vertex_id );
1508 is_vertex_to_duplicate[cur_co] =
false;
1509 corner_used.push_back( cur_co );
1513 cell_facets_around_vertex( *
mesh_, cur_c, vertex_id );
1514 for(
auto cur_f : facets )
1518 index_t polygon{ NO_ID };
1521 cur_c, cur_f, polygon, side ) )
1524 this->
gmm_.polygons.surface( polygon );
1525 surfaces.emplace_back(
1535 mesh_->cell_adjacent( { cur_c, cur_f } );
1536 if( cur_adj != NO_ID
1537 && !
contains( cell_added, cur_adj ) )
1539 cell_added.push_back( cur_adj );
1544 }
while( !S.empty() );
1559 auto duplicated_vertex_id =
1560 this->
gmm_.vertices.nb()
1561 +
static_cast< index_t
>(
1570 for(
auto cur_co : corner_used )
1572 mesh_builder->set_cell_corner_vertex_index(
1573 cur_co, duplicated_vertex_id );
1581 template < index_t DIMENSION >
1583 index_t c, index_t f, index_t& polygon,
bool& side )
const 1587 if( polygon != NO_ID )
1589 auto facet_normal = this->
gmm_.polygons.normal( polygon );
1590 auto cell_facet_normal =
mesh_->cell_facet_normal( { c, f } );
1591 side = dot( facet_normal, cell_facet_normal ) > 0;
1593 return polygon != NO_ID;
1596 template < index_t DIMENSION >
1598 const std::vector< action_on_surface >& surfaces,
1599 std::vector< ActionOnSurface >& info )
1602 std::vector< action_on_surface > temp_surfaces;
1603 temp_surfaces.reserve( temp_surfaces.size() );
1607 for(
auto i :
range( 1, surfaces.size() ) )
1609 if( surfaces[i - 1].first == surfaces[i].first )
1617 temp_surfaces.push_back( surfaces[i - 1] );
1620 temp_surfaces.push_back( surfaces.back() );
1622 for(
const auto& action : temp_surfaces )
1624 auto s = action.first;
1639 if( info[s] == action.second )
1649 template < index_t DIMENSION >
1651 index_t surface_id )
const 1653 const auto& cur_surface = this->
geomodel_.surface( surface_id );
1654 if( cur_surface.is_on_voi() )
1658 switch( this->
gmm_.duplicate_mode() )
1664 auto parent_interface = cur_surface.parent_gmge(
1666 if( parent_interface.is_defined() )
1669 this->
geomodel_.geological_entity( parent_interface )
1670 .geological_feature();
1682 template < index_t DIMENSION >
1689 template < index_t DIMENSION >
1695 template < index_t DIMENSION >
1704 auto corner_value =
mesh_->cell_vertex( cell_local_vertex );
1709 return corner_value -
mesh_->nb_vertices();
1712 template < index_t DIMENSION >
1714 index_t duplicate_vertex_index )
const 1722 template < index_t DIMENSION >
1727 mesh_builder->clear(
true,
false );
1739 template < index_t DIMENSION >
1746 for(
auto v :
range(
mesh_->nb_cell_vertices( c ) ) )
1749 if( index != NO_ID )
1751 mesh_builder->set_cell_corner_vertex_index(
1761 template < index_t DIMENSION >
1770 template < index_t DIMENSION >
1773 this->
gmm_.polygons.test_and_initialize();
1776 const auto& nn_search = this->
gmm_.polygons.nn_search();
1779 for(
auto f :
range(
mesh_->nb_cell_facets( c ) ) )
1781 auto result = nn_search.get_neighbors(
1782 mesh_->cell_facet_barycenter( { c, f } ),
1784 if( !result.empty() )
1795 template < index_t DIMENSION >
1799 return mesh_->cell_barycenter( c );
1802 template < index_t DIMENSION >
1806 return mesh_->cell_volume( c );
1809 template < index_t DIMENSION >
1814 return mesh_->cell_aabb();
1818 template < index_t DIMENSION >
1820 template < index_t DIMENSION >
1824 template < index_t DIMENSION >
1834 template < index_t DIMENSION >
1840 template < index_t DIMENSION >
1847 template < index_t DIMENSION >
1854 template < index_t DIMENSION >
1857 return mesh_->nb_edges() > 0;
1860 template < index_t DIMENSION >
1864 return mesh_->nb_edges();
1867 template < index_t DIMENSION >
1874 return mesh_->edge_vertex( edge_local_vertex );
1877 template < index_t DIMENSION >
1885 template < index_t DIMENSION >
1893 template < index_t DIMENSION >
1901 template < index_t DIMENSION >
1909 template < index_t DIMENSION >
1916 mesh_builder->clear(
true,
false );
1919 template < index_t DIMENSION >
1928 template < index_t DIMENSION >
1931 this->
gmm_.vertices.test_and_initialize();
1935 if(
mesh_->nb_vertices() != this->
gmm_.vertices.nb() )
1937 copy_vertices( mesh_builder.get(), *this->
gmm_.vertices.mesh_ );
1949 mesh_builder->create_edges(
nb_edges_ );
1951 const auto& geomodel_vertices = this->
gmm_.vertices;
1952 index_t cur_edge{ 0 };
1956 auto line_id =
line.gmme();
1957 for(
auto e :
range(
line.nb_mesh_elements() ) )
1959 for(
auto v :
range( 2 ) )
1961 auto v_id = geomodel_vertices.geomodel_vertex_id(
1964 mesh_builder->set_edge_vertex(
1974 template < index_t DIMENSION >
1978 return mesh_->edge_barycenter( e );
1981 template < index_t DIMENSION >
1985 return mesh_->edge_length( e );
1988 template < index_t DIMENSION >
1993 return mesh_->edge_aabb();
1997 template < index_t DIMENSION >
2000 template < index_t DIMENSION >
2005 template < index_t DIMENSION >
2012 this->set_mesh( mesh_.get() );
2015 template < index_t DIMENSION >
2018 clear_polygones_data();
2021 template < index_t DIMENSION >
2024 surface_id_.resize( mesh_->nb_polygons(), NO_ID );
2025 polygon_id_.resize( mesh_->nb_polygons(), NO_ID );
2028 template < index_t DIMENSION >
2031 surface_id_.
clear();
2032 polygon_id_.clear();
2035 template < index_t DIMENSION >
2041 template < index_t DIMENSION >
2044 test_and_initialize();
2045 return mesh_->nb_polygons();
2048 template < index_t DIMENSION >
2052 test_and_initialize();
2054 return mesh_->nb_polygon_vertices( p );
2057 template < index_t DIMENSION >
2061 test_and_initialize();
2063 polygon_local_vertex.
element_id_ < mesh_->nb_polygons() );
2066 < mesh_->nb_polygon_vertices( polygon_local_vertex.
element_id_ ) );
2067 return mesh_->polygon_vertex( polygon_local_vertex );
2070 template < index_t DIMENSION >
2074 test_and_initialize();
2076 polygon_local_edge.
polygon_id_ < mesh_->nb_polygons() );
2079 < mesh_->nb_polygon_vertices( polygon_local_edge.
polygon_id_ ) );
2080 return mesh_->polygon_adjacent( polygon_local_edge );
2083 template < index_t DIMENSION >
2086 test_and_initialize();
2088 return surface_id_[p];
2091 template < index_t DIMENSION >
2095 test_and_initialize();
2097 return polygon_id_[p];
2100 template < index_t DIMENSION >
2101 std::tuple< PolygonType, index_t >
2104 test_and_initialize();
2106 auto polygon = index_in_surface( p );
2107 auto s = surface( p );
2112 if( polygon < nb_polygons( s, T ) )
2114 return std::make_tuple( T, polygon );
2116 polygon -= nb_polygons( s, T );
2119 return std::make_tuple( PolygonType::UNDEFINED, NO_ID );
2122 template < index_t DIMENSION >
2126 test_and_initialize();
2129 case PolygonType::TRIANGLE:
2130 return nb_triangle();
2131 case PolygonType::QUAD:
2133 case PolygonType::UNCLASSIFIED:
2134 return nb_unclassified_polygon();
2135 case PolygonType::UNDEFINED:
2143 template < index_t DIMENSION >
2147 test_and_initialize();
2151 case PolygonType::TRIANGLE:
2152 return nb_triangle( s );
2153 case PolygonType::QUAD:
2154 return nb_quad( s );
2155 case PolygonType::UNCLASSIFIED:
2156 return nb_unclassified_polygon( s );
2157 case PolygonType::UNDEFINED:
2159 PolygonType::UNDEFINED )
2162 PolygonType::UNDEFINED )
2170 template < index_t DIMENSION >
2174 test_and_initialize();
2178 case PolygonType::TRIANGLE:
2179 return triangle( s, p );
2180 case PolygonType::QUAD:
2181 return quad( s, p );
2182 case PolygonType::UNCLASSIFIED:
2183 return unclassified_polygon( s, p );
2184 case PolygonType::UNDEFINED:
2186 PolygonType::UNDEFINED )
2195 template < index_t DIMENSION >
2198 test_and_initialize();
2199 return nb_triangles_;
2202 template < index_t DIMENSION >
2206 test_and_initialize();
2208 return surface_polygon_ptr_
2211 - surface_polygon_ptr_
2216 template < index_t DIMENSION >
2218 index_t s, index_t t )
const 2220 test_and_initialize();
2225 PolygonType::TRIANGLE )]
2229 template < index_t DIMENSION >
2232 test_and_initialize();
2236 template < index_t DIMENSION >
2239 test_and_initialize();
2245 - surface_polygon_ptr_
2250 template < index_t DIMENSION >
2252 index_t s, index_t q )
const 2254 test_and_initialize();
2262 template < index_t DIMENSION >
2266 test_and_initialize();
2267 return nb_unclassified_polygons_;
2270 template < index_t DIMENSION >
2274 test_and_initialize();
2276 return surface_polygon_ptr_
2280 - surface_polygon_ptr_
2285 template < index_t DIMENSION >
2287 index_t s, index_t p )
const 2289 test_and_initialize();
2294 PolygonType::UNCLASSIFIED )]
2298 template < index_t DIMENSION >
2301 surface_polygon_ptr_.
clear();
2306 mesh_builder->clear(
true,
false );
2309 template < index_t DIMENSION >
2312 if( !is_initialized() )
2318 template < index_t DIMENSION >
2322 surface_polygon_ptr_.resize(
2323 this->geomodel_.nb_surfaces()
2329 if( mesh_->nb_vertices() != this->gmm_.vertices.nb() )
2331 copy_vertices( mesh_builder.get(), *this->gmm_.vertices.mesh_ );
2335 std::map< PolygonType, index_t > nb_polygon_per_type = {
2336 { PolygonType::TRIANGLE, 0 }, { PolygonType::QUAD, 0 },
2337 { PolygonType::UNCLASSIFIED, 0 }
2339 for(
auto s :
range( this->geomodel_.nb_surfaces() ) )
2341 const auto& surface = this->geomodel_.surface( s );
2342 if( surface.is_simplicial() )
2344 nb_polygon_per_type[PolygonType::TRIANGLE] +=
2345 surface.nb_mesh_elements();
2346 surface_polygon_ptr_
2349 surface.nb_mesh_elements();
2353 for(
auto p :
range( surface.nb_mesh_elements() ) )
2355 switch( surface.nb_mesh_element_vertices( p ) )
2358 nb_polygon_per_type[PolygonType::TRIANGLE]++;
2359 surface_polygon_ptr_
2365 nb_polygon_per_type[PolygonType::QUAD]++;
2366 surface_polygon_ptr_
2372 nb_polygon_per_type[PolygonType::UNCLASSIFIED]++;
2374 PolygonType::UNDEFINED )
2377 PolygonType::UNCLASSIFIED )
2386 auto nb_total_polygons =
2387 nb_polygon_per_type[PolygonType::TRIANGLE]
2389 + nb_polygon_per_type[PolygonType::QUAD]
2390 + nb_polygon_per_type[PolygonType::UNCLASSIFIED];
2392 if( nb_total_polygons == 0 )
2398 if( nb_polygon_per_type[PolygonType::TRIANGLE] )
2400 mesh_builder->create_triangles(
2401 nb_polygon_per_type[PolygonType::TRIANGLE] );
2403 if( nb_polygon_per_type[PolygonType::QUAD] )
2405 mesh_builder->create_quads(
2406 nb_polygon_per_type[PolygonType::QUAD] );
2410 std::map< PolygonType, index_t > polygon_offset_per_type = {
2411 { PolygonType::TRIANGLE, 0 }, { PolygonType::QUAD, 0 },
2412 { PolygonType::UNCLASSIFIED, 0 }
2414 polygon_offset_per_type[PolygonType::QUAD] =
2415 nb_polygon_per_type[PolygonType::TRIANGLE];
2416 polygon_offset_per_type[PolygonType::UNCLASSIFIED] =
2417 nb_polygon_per_type[PolygonType::TRIANGLE]
2418 + nb_polygon_per_type[PolygonType::QUAD];
2420 for(
auto i :
range( 1, surface_polygon_ptr_.size() - 1 ) )
2422 surface_polygon_ptr_[i + 1] += surface_polygon_ptr_[i];
2427 resize_polygones_data();
2428 const auto& geomodel_vertices = this->gmm_.vertices;
2429 std::vector< index_t > cur_polygon_per_type(
2431 for(
auto s :
range( this->geomodel_.nb_surfaces() ) )
2433 const auto& surface = this->geomodel_.surface( s );
2434 auto surface_id = surface.gmme();
2435 for(
auto p :
range( surface.nb_mesh_elements() ) )
2437 auto nb_vertices = surface.nb_mesh_element_vertices( p );
2438 index_t cur_polygon{ NO_ID };
2439 if( nb_vertices < 5 )
2441 auto T =
static_cast< PolygonType >( nb_vertices - 3 );
2443 polygon_offset_per_type[T]
2445 for(
auto v :
range( nb_vertices ) )
2447 auto v_id = geomodel_vertices.geomodel_vertex_id(
2450 mesh_builder->set_polygon_vertex(
2456 std::vector< index_t > vertices( nb_vertices );
2457 for(
auto v :
range( nb_vertices ) )
2459 vertices[v] = geomodel_vertices.geomodel_vertex_id(
2462 cur_polygon = mesh_builder->create_polygon( vertices );
2464 surface_id_[cur_polygon] = s;
2465 polygon_id_[cur_polygon] = p;
2472 mesh_builder->connect_polygons();
2473 disconnect_along_lines();
2476 nb_triangles_ = nb_polygon_per_type[PolygonType::TRIANGLE];
2477 nb_quads_ = nb_polygon_per_type[PolygonType::QUAD];
2478 nb_unclassified_polygons_ =
2479 nb_polygon_per_type[PolygonType::UNCLASSIFIED];
2482 template < index_t DIMENSION >
2487 std::vector< index_t > sorted_indices( mesh_->nb_polygons() );
2488 std::iota( sorted_indices.begin(), sorted_indices.end(), 0 );
2489 GeoModelMeshPolygonsBaseSort< DIMENSION > action( *mesh_, surface_id_ );
2490 std::sort( sorted_indices.begin(), sorted_indices.end(), action );
2491 mesh_builder->permute_polygons( sorted_indices );
2493 auto sorted_indices_geo =
2495 GEO::Permutation::apply(
2496 surface_id_.data(), sorted_indices_geo,
sizeof( index_t ) );
2497 GEO::Permutation::apply(
2498 polygon_id_.data(), sorted_indices_geo,
sizeof( index_t ) );
2501 template < index_t DIMENSION >
2506 for(
auto s :
range( this->geomodel_.nb_surfaces() ) )
2508 const auto& surface = this->geomodel_.surface( s );
2509 for(
auto p :
range( nb_polygons( s ) ) )
2511 auto polygon_id = polygon( s, p );
2512 auto surface_polygon_id = index_in_surface( polygon_id );
2513 for(
auto v :
range( nb_vertices( polygon_id ) ) )
2515 auto adj = surface.polygon_adjacent_index(
2519 mesh_builder->set_polygon_adjacent(
2527 template < index_t DIMENSION >
2531 test_and_initialize();
2532 return mesh_->polygon_barycenter( p );
2535 template < index_t DIMENSION >
2538 test_and_initialize();
2539 return mesh_->polygon_area( p );
2542 template < index_t DIMENSION >
2546 test_and_initialize();
2547 return mesh_->polygon_aabb();
2550 template < index_t DIMENSION >
2561 std::unique_ptr< SurfaceMesh3D >& mesh )
2569 return mesh_->polygon_normal( p );
2574 template < index_t DIMENSION >
2584 template < index_t DIMENSION >
2592 template < index_t DIMENSION >
2596 return mesh_->nb_edges();
2599 template < index_t DIMENSION >
2606 template < index_t DIMENSION >
2608 index_t w, index_t e, index_t v )
const 2614 template < index_t DIMENSION >
2619 mesh_builder->clear(
true,
false );
2623 template < index_t DIMENSION >
2626 return mesh_->nb_edges() > 0;
2629 template < index_t DIMENSION >
2638 template < index_t DIMENSION >
2645 this->
gmm_.vertices.test_and_initialize();
2648 if(
mesh_->nb_vertices() != this->
gmm_.vertices.nb() )
2650 copy_vertices( mesh_builder.get(), *this->
gmm_.vertices.mesh_ );
2654 const auto& wells = *this->
geomodel_.wells();
2655 well_ptr_.resize( wells.nb_wells() + 1, 0 );
2657 for(
auto w :
range( wells.nb_wells() ) )
2659 nb_edges += wells.well( w ).nb_edges();
2670 mesh_builder->create_edges(
well_ptr_.back() );
2673 index_t cur_edge{ 0 };
2674 for(
auto w :
range( 0, wells.nb_wells() ) )
2679 for(
auto e :
range( well.
part( p ).nb_edges() ) )
2681 const auto& e0 = well.
part( p ).edge_vertex( { e, 0 } );
2682 mesh_builder->set_edge_vertex(
2684 this->
gmm_.vertices.index( e0 ) );
2685 const auto& e1 = well.
part( p ).edge_vertex( { e, 1 } );
2686 mesh_builder->set_edge_vertex(
2688 this->
gmm_.vertices.index( e1 ) );
2695 template < index_t DIMENSION >
2700 return mesh_->edge_aabb();
2705 template < index_t DIMENSION >
2709 vertices( gmm, geomodel, mesh_set_.point_set_mesh ),
2710 edges( gmm, geomodel, mesh_set_.line_mesh ),
2711 wells( gmm, geomodel, mesh_set_.well_mesh ),
2712 polygons( gmm, geomodel, mesh_set_.surface_mesh )
2716 template < index_t DIMENSION >
2719 polygons.clear_polygones_data();
2722 template < index_t DIMENSION >
2725 vertices.remove_colocated();
2728 template < index_t DIMENSION >
2730 std::vector< index_t >& to_delete )
2735 template < index_t DIMENSION >
2739 if( mesh_set_.point_set_mesh->type_name() != type )
2742 mesh_set_.create_point_set_mesh( type );
2746 template < index_t DIMENSION >
2750 if( mesh_set_.line_mesh->type_name() != type )
2753 mesh_set_.create_line_mesh( type );
2757 template < index_t DIMENSION >
2761 if( mesh_set_.surface_mesh->type_name() != type )
2764 mesh_set_.create_surface_mesh( type );
2768 template < index_t DIMENSION >
2776 cells( *this, geomodel,
mesh_set_.volume_mesh )
2787 if(
mesh_set_.volume_mesh->type_name() != type )
2796 transfer_vertex_attributes_from_gmm_to_gm_regions();
2797 transfer_cell_attributes_from_gmm_to_gm_regions();
2802 transfer_vertex_attributes_from_gm_regions_to_gmm();
2803 transfer_cell_attributes_from_gm_regions_to_gmm();
2809 auto& gmm_v_attr_mgr =
vertices.attribute_manager();
2810 GEO::vector< std::string > att_v_names;
2811 gmm_v_attr_mgr.list_attribute_names( att_v_names );
2812 for(
const auto& cur_attr_name : att_v_names )
2816 if( cur_attr_name ==
"point" )
2821 auto* cur_v_att_store_in_gmm =
2822 gmm_v_attr_mgr.find_attribute_store( cur_attr_name );
2824 auto dim = cur_v_att_store_in_gmm->dimension();
2828 auto vertices_on_geomodel_region =
vertices.gme_type_vertices(
2829 Region3D::type_name_static(), v );
2830 for(
const auto& cur_vertex_on_geomodel :
2831 vertices_on_geomodel_region )
2833 const auto& cur_region =
2834 geomodel_.region( cur_vertex_on_geomodel.gmme.index() );
2835 auto& reg_v_attr_mgr =
2836 cur_region.vertex_attribute_manager();
2837 GEO::AttributeStore* cur_v_att_store_in_reg{
nullptr };
2839 if( !reg_v_attr_mgr.is_defined( cur_attr_name ) )
2841 const auto cur_type_name = GEO::AttributeStore::
2842 element_type_name_by_element_typeid_name(
2843 cur_v_att_store_in_gmm->element_typeid_name() );
2845 GEO::AttributeStore::element_type_name_is_known(
2847 cur_v_att_store_in_reg = GEO::AttributeStore::
2848 create_attribute_store_by_element_type_name(
2849 cur_type_name, dim );
2850 reg_v_attr_mgr.bind_attribute_store(
2851 cur_attr_name, cur_v_att_store_in_reg );
2855 cur_v_att_store_in_reg =
2856 reg_v_attr_mgr.find_attribute_store(
2861 cur_v_att_store_in_reg->element_size()
2862 == cur_v_att_store_in_gmm->element_size() );
2865 static_cast< GEO::Memory::pointer >(
2866 cur_v_att_store_in_reg->data() )
2867 + cur_vertex_on_geomodel.v_index * dim
2868 * cur_v_att_store_in_reg->element_size(),
2869 static_cast< GEO::Memory::pointer
>(
2870 cur_v_att_store_in_gmm->data() )
2871 + v * dim * cur_v_att_store_in_gmm->element_size(),
2872 dim * cur_v_att_store_in_reg->element_size() );
2881 for(
const auto& cur_reg :
geomodel().regions() )
2883 GEO::vector< std::string > att_v_names;
2884 GEO::AttributesManager& reg_vertex_attr_mgr =
2885 cur_reg.vertex_attribute_manager();
2886 reg_vertex_attr_mgr.list_attribute_names( att_v_names );
2887 for(
const auto& cur_attr_name : att_v_names )
2891 if( cur_attr_name ==
"point" )
2896 auto* cur_v_att_store_in_reg =
2897 reg_vertex_attr_mgr.find_attribute_store( cur_attr_name );
2899 index_t dim = cur_v_att_store_in_reg->dimension();
2900 GEO::AttributeStore* cur_v_att_store{
nullptr };
2901 if( !
vertices.attribute_manager().is_defined( cur_attr_name ) )
2903 const auto cur_type_name = GEO::AttributeStore::
2904 element_type_name_by_element_typeid_name(
2905 cur_v_att_store_in_reg->element_typeid_name() );
2907 GEO::AttributeStore::element_type_name_is_known(
2909 cur_v_att_store = GEO::AttributeStore::
2910 create_attribute_store_by_element_type_name(
2911 cur_type_name, dim );
2912 vertices.attribute_manager().bind_attribute_store(
2913 cur_attr_name, cur_v_att_store );
2918 vertices.attribute_manager().find_attribute_store(
2923 == cur_v_att_store_in_reg->element_size() );
2925 for(
auto v_in_reg_itr :
range( cur_reg.nb_vertices() ) )
2927 auto v_id_in_gmm =
vertices.geomodel_vertex_id(
2928 cur_reg.gmme(), v_in_reg_itr );
2930 static_cast< GEO::Memory::pointer >(
2931 cur_v_att_store->data() )
2933 * cur_v_att_store->element_size(),
2934 static_cast< GEO::Memory::pointer
>(
2935 cur_v_att_store_in_reg->data() )
2936 + v_in_reg_itr * dim
2937 * cur_v_att_store_in_reg->element_size(),
2938 dim * cur_v_att_store->element_size() );
2947 auto& gmm_c_attr_mgr = cells.attribute_manager();
2948 GEO::vector< std::string > att_c_names;
2949 gmm_c_attr_mgr.list_attribute_names( att_c_names );
2950 const auto& nn_search = cells.cell_nn_search();
2952 for(
const auto& cur_attr_name : att_c_names )
2954 auto* cur_c_att_store_in_gmm =
2955 gmm_c_attr_mgr.find_attribute_store( cur_attr_name );
2957 auto dim = cur_c_att_store_in_gmm->dimension();
2959 for(
const auto& cur_region :
geomodel_.regions() )
2961 auto& reg_c_attr_mgr = cur_region.cell_attribute_manager();
2962 GEO::AttributeStore* cur_c_att_store_in_reg{
nullptr };
2964 if( !reg_c_attr_mgr.is_defined( cur_attr_name ) )
2966 const auto cur_type_name = GEO::AttributeStore::
2967 element_type_name_by_element_typeid_name(
2968 cur_c_att_store_in_gmm->element_typeid_name() );
2970 GEO::AttributeStore::element_type_name_is_known(
2972 cur_c_att_store_in_reg = GEO::AttributeStore::
2973 create_attribute_store_by_element_type_name(
2974 cur_type_name, dim );
2975 reg_c_attr_mgr.bind_attribute_store(
2976 cur_attr_name, cur_c_att_store_in_reg );
2980 cur_c_att_store_in_reg =
2981 reg_c_attr_mgr.find_attribute_store( cur_attr_name );
2985 == cur_c_att_store_in_gmm->element_size() );
2987 for(
auto c :
range( cur_region.nb_mesh_elements() ) )
2989 auto center = cur_region.mesh_element_barycenter( c );
2990 auto c_in_geom_model_mesh =
2991 nn_search.get_neighbors( center,
geomodel_.epsilon() );
2994 static_cast< GEO::Memory::pointer >(
2995 cur_c_att_store_in_reg->data() )
2996 + c * dim * cur_c_att_store_in_reg->element_size(),
2997 static_cast< GEO::Memory::pointer
>(
2998 cur_c_att_store_in_gmm->data() )
2999 + c_in_geom_model_mesh[0] * dim
3000 * cur_c_att_store_in_gmm->element_size(),
3001 dim * cur_c_att_store_in_reg->element_size() );
3010 const auto& nn_search = cells.cell_nn_search();
3011 for(
const auto& cur_reg :
geomodel().regions() )
3013 GEO::vector< std::string > att_c_names;
3014 auto& reg_cell_attr_mgr = cur_reg.cell_attribute_manager();
3015 reg_cell_attr_mgr.list_attribute_names( att_c_names );
3016 for(
const auto& cur_attr_name : att_c_names )
3018 auto* cur_c_att_store_in_reg =
3019 reg_cell_attr_mgr.find_attribute_store( cur_attr_name );
3021 index_t dim = cur_c_att_store_in_reg->dimension();
3022 GEO::AttributeStore* cur_c_att_store{
nullptr };
3023 if( !cells.attribute_manager().is_defined( cur_attr_name ) )
3025 const std::string cur_type_name = GEO::AttributeStore::
3026 element_type_name_by_element_typeid_name(
3027 cur_c_att_store_in_reg->element_typeid_name() );
3029 GEO::AttributeStore::element_type_name_is_known(
3031 cur_c_att_store = GEO::AttributeStore::
3032 create_attribute_store_by_element_type_name(
3033 cur_type_name, dim );
3034 cells.attribute_manager().bind_attribute_store(
3035 cur_attr_name, cur_c_att_store );
3040 cells.attribute_manager().find_attribute_store(
3045 == cur_c_att_store_in_reg->element_size() );
3047 for(
auto c_in_reg_itr :
range( cur_reg.nb_mesh_elements() ) )
3050 cur_reg.mesh_element_barycenter( c_in_reg_itr );
3051 auto c_in_geom_model_mesh =
3052 nn_search.get_neighbors( center,
geomodel_.epsilon() );
3055 static_cast< GEO::Memory::pointer >(
3056 cur_c_att_store->data() )
3057 + c_in_geom_model_mesh[0] * dim
3058 * cur_c_att_store->element_size(),
3059 static_cast< GEO::Memory::pointer
>(
3060 cur_c_att_store_in_reg->data() )
3061 + c_in_reg_itr * dim
3062 * cur_c_att_store_in_reg->element_size(),
3063 dim * cur_c_att_store->element_size() );
const LineAABBTree< DIMENSION > & aabb() const
return the AABB tree for the edges of the mesh
index_t tet(index_t region, index_t tet) const
index_t hex(index_t region, index_t hex) const
const std::vector< index_t > & vertex_map(const gmme_id &mesh_entity_id) const
void resize_all_mesh_entity_vertex_maps(const MeshEntityType &type)
void update_mesh_entity_maps_and_gmes(const std::vector< index_t > &old2new)
Updates all the vertex maps with regards to the global indexing changes.
GeoModelMeshVertices< DIMENSION > vertices
void clear_vertex_map(const gmme_id &mesh_entity_id)
std::unique_ptr< PointSetMesh< DIMENSION > > & mesh_
Attached Mesh.
GEO::vecng< DIMENSION, double > vecn
index_t create_vertex()
Creates a new vertex.
static std::unique_ptr< LineMeshBuilder > create_builder(LineMesh< DIMENSION > &mesh)
void add_vertices(LineMeshBuilder< DIMENSION > *builder, index_t size)
void initialize()
Initialize the cells from the cells of the GeoModel Region cells.
GeoModelMesh< DIMENSION > & gmm_
Attached GeoModelMesh.
index_t nb_hexs_
Number of hex in the GeoModelMesh.
index_t nb_pyramids_
Number of pyramid in the GeoModelMesh.
const VolumeAABBTree< DIMENSION > & aabb() const
return the AABB tree for the cells of the mesh
bool is_cell_facet_on_surface(index_t cell, index_t facet_index, index_t &colocated_facet_index, bool &side) const
virtual const vecn< DIMENSION > & vertex(index_t v_id) const =0
Gets a point.
GeoModelBuilderGeometry< DIMENSION > geometry
GeoModelMeshPolygonsBase(GeoModelMesh< DIMENSION > &gmm, GeoModel< DIMENSION > &gm, std::unique_ptr< SurfaceMesh< DIMENSION > > &mesh)
index_t vertex(index_t well, index_t edge, index_t vertex) const
void initialize_mesh_entity_vertex_map(const gmme_id &mesh_entity_id)
Initializes the given GeoModelMeshEntity vertex map.
CellType type(index_t cell) const
virtual const GeoModelMeshEntity< DIMENSION > & mesh_entity(const gmme_id &id) const
Generic access to a meshed entity.
index_t nb_edges(index_t line) const
void initialize_cell_facet()
void delete_vertices(const std::vector< bool > &to_delete)
Deletes a set of vertices.
GeoModelMeshVertices(GeoModelMesh< DIMENSION > &gmm, GeoModel< DIMENSION > &gm, std::unique_ptr< PointSetMesh< DIMENSION > > &mesh)
GeoModel< DIMENSION > & geomodel_
Attached GeoModel.
std::vector< std::vector< index_t > > line_vertex_maps_
index_t prism(index_t region, index_t prism) const
index_t nb_pyramid() const
GeoModelMeshVerticesBase(GeoModelMesh< DIMENSION > &gmm, GeoModel< DIMENSION > &gm, std::unique_ptr< PointSetMesh< DIMENSION > > &mesh)
index_t nb_facets(index_t cell) const
index_t nb_connectors_
Number of connector in the GeoModelMesh.
index_t nb_entity_vertices(const GeoModel< DIMENSION > &geomodel, const MeshEntityType &entity_type)
index_t cell(index_t region, index_t cell, CellType type=CellType::UNDEFINED) const
void set_mesh(MeshBase< DIMENSION > *mesh)
A GeoModelEntity of type CORNER.
index_t duplicated_corner_index(const ElementLocalVertex &cell_local_vertex) const
std::map< MeshEntityType, std::vector< std::vector< index_t > > *> vertex_maps_
void clear_all_mesh_entity_vertex_map()
Unbinds all the GeoModelMeshEntity vertex maps.
bool is_initialized() const
index_t vertex(const ElementLocalVertex &cell_local_vertex) const
static MeshEntityType type_name_static()
bool is_initialized() const
index_t nb_edges(index_t cell) const
GeoModelMeshCommon(GeoModelMesh< DIMENSION > &gmm, GeoModel< DIMENSION > &geomodel)
std::unique_ptr< VolumeMesh< DIMENSION > > & mesh_
Attached Mesh.
bool are_corners_to_duplicate(const std::vector< action_on_surface > &surfaces, std::vector< ActionOnSurface > &info)
virtual index_t nb_total_vertices() const
return the number of all vertices it is computed summing all entities.nb().
double length(index_t edge) const
GeoModelMeshBase(GeoModelMesh< DIMENSION > &gmm, GeoModel< DIMENSION > &geomodel)
index_t nb_facet_vertices(const CellLocalFacet &cell_local_facet) const
Entity_type_template type() const
GeoModelMesh(GeoModel< DIMENSION > &geomodel)
GeoModelMeshCells(GeoModelMesh< DIMENSION > &gmm, GeoModel< DIMENSION > &gm, std::unique_ptr< VolumeMesh< DIMENSION > > &mesh)
std::unique_ptr< LineMesh< DIMENSION > > & mesh_
Attached Mesh.
void test_and_initialize() const
std::vector< index_t > region_cell_ptr_
void initialize_duplication()
GEO::AttributesManager & mesh_entity_vertex_attribute_manager(const gmme_id &mesh_entity_id) const
Returns the vertex attribute of a GeoModelMeshEntity.
virtual index_t fill_vertices()
index_t index_in_line(index_t edge) const
auto to_underlying_type(Enum e) -> typename std::underlying_type< Enum >::type
double volume(index_t cell) const
void bind_all_mesh_entity_vertex_maps()
index_t nb() const
Number of cells stored.
vecn< DIMENSION > center(index_t edge) const
static MeshEntityType type_name_static()
index_t nb() const
Number of non colocated vertices stored.
static std::unique_ptr< VolumeMeshBuilder< DIMENSION > > create_builder(VolumeMesh< DIMENSION > &mesh)
GeoModelMeshPolygons(GeoModelMesh< DIMENSION > &gmm, GeoModel< DIMENSION > &gm, std::unique_ptr< SurfaceMesh< DIMENSION > > &mesh)
void sort_unique(CONTAINER &container, const CMP &cmp)
Sorts a container and suppresses all duplicated entities.
std::vector< index_t > cell_id_
Vector storing the cell index in region per cell.
index_t index_in_region(index_t cell) const
index_t adjacent(index_t cell, index_t facet) const
bool is_initialized() const
index_t nb_edges_
Number of edges in the GeoModelMesh.
index_t find(const container &in, const T &value)
Returns the position of the first entity matching.
index_t nb_tets_
Number of tet in the GeoModelMesh.
index_t nb_cells(CellType type=CellType::UNDEFINED) const
DuplicateMode mode_
Current duplicate mode applied on the mesh.
index_t connector(index_t region, index_t connector) const
index_t geomodel_vertex_index(const gmme_id &mesh_entity_id, index_t mesh_entity_vertex_index) const
Returns the index of a GeoModelMeshEntity vertex in the geomodel global indexing. ...
void test_and_initialize_cell_facet() const
bool test_and_initialize_mesh_entity_vertex_map(const gmme_id &mesh_entity_id)
Tests if the given GeoModelMeshEntity vertex map is initialized. If not, initializes it...
index_t create_vertices(index_t nb)
Creates a contiguous chunk of vertices.
index_t edge(index_t line, index_t edge) const
std::vector< index_t > duplicated_vertex_indices_
Vector of duplicated vertices.
GeoModelVertexMapper(GeoModelMeshVerticesBase &geomodel_vertices, const GeoModel< DIMENSION > &geomodel)
static MeshEntityType type_name_static()
void test_and_initialize() const
index_t nb_vertices(index_t cell) const
index_t vertex(const ElementLocalVertex &edge_local_vertex) const
void set_vertex(index_t v_id, const vecn< DIMENSION > &vertex)
Sets a point.
const vecn< DIMENSION > & vertex(index_t v) const
Coordinates of a vertex of the GeoModel.
index_t nb_polygons(PolygonType type=PolygonType::UNDEFINED) const
encapsulate adimensional mesh functionalities in order to provide an API on which we base the RINGMes...
std::vector< std::vector< index_t > > corner_vertex_maps_
Vertex maps.
index_t facet_vertex(const CellLocalFacet &cell_local_facet, index_t local_vertex) const
Gets a cell vertex by local facet index and local vertex index in the edge.
virtual index_t nb_cell_facets(index_t cell_id) const =0
Gets the number of facet in a cell.
std::vector< index_t > line_edge_ptr_
index_t nb_connector() const
std::vector< index_t > region_id_
Vector storing the region index per cell.
need to be duplicated (don't know which side yet)
virtual index_t nb_cell_facet_vertices(const CellLocalFacet &cell_local_facet) const =0
Gets the number of vertices of a facet in a cell.
void test_and_initialize_duplication() const
index_t edge_vertex(index_t cell, index_t local_edge, index_t local_vertex) const
Gets a cell vertex by local edge index and local vertex index in the edge.
std::vector< index_t > edge_id_
Vector storing the edge index in line per edge.
GeoModelVertexMapper vertex_mapper_
Mapper from/to GeoModelMeshEntity vertices.
virtual index_t nb_vertices() const =0
std::vector< index_t > & resize_vertex_map(const gmme_id &mesh_entity_id)
static bool is_fault(GEOL_FEATURE feature)
std::vector< std::vector< GMEVertex > > gme_vertices_
GeoModelEntity Vertices for each geomodel vertex.
index_t nb_total_vertices() const
GeoModelMeshVerticesBase< DIMENSION > & geomodel_vertices_
void test_and_initialize() const
std::vector< std::vector< index_t > > region_vertex_maps_
Vertex in a GeoModelEntity.
#define ringmesh_assert(x)
vec3 barycenter(index_t cell) const
const WellPart< DIMENSION > & part(index_t part_id) const
bool contains(const container &in, const T &value)
bool is_duplication_initialized() const
index_t nb() const
Number of edges stored.
index_t pyramid(index_t region, index_t pyramid) const
void clear()
Clears all the information about vertex mapping (vector maps and vectors of GME_Vertices.
GEO::vector< U > copy_std_vector_to_geo_vector(const std::vector< T > &in, index_t from, index_t to)
void fill_vertices_for_entity_type(const GeoModel< DIMENSION > &M, const MeshEntityType &entity_type, index_t &count)
std::vector< std::vector< index_t > > surface_vertex_maps_
The MeshEntityType described the type of the meshed entities There are 4 MeshEntityTypes correspondin...
bool is_mesh_entity_vertex_map_initialized(const gmme_id &mesh_entity_id) const
Tests if the given GeoModelMeshEntity vertex map exists.
void add_to_gme_vertices(const GMEVertex &gme_vertex, index_t geomodel_vertex_index)
void clear_vertices(bool keep_attributes, bool keep_memory)
Removes all the vertices and attributes.
std::vector< index_t > polygon_id_
Vector storing the colocalised polygon index per cell facet If a cell facet is on a surface...
Classes to build GeoModel from various inputs.
std::vector< index_t > line_id_
Vector storing the line index per edge.
const GeoModel< DIMENSION > & geomodel() const
std::unique_ptr< SurfaceMesh< DIMENSION > > & mesh_
Attached Mesh.
A GeoModelEntity of type LINE.
void erase_vertices(std::vector< index_t > &to_delete)
Delete vertices for which to_delete[i] != i The global vertices are deleted, gme_vertices_ is update...
GeoModelMeshEdges(GeoModelMesh< DIMENSION > &gmm, GeoModel< DIMENSION > &gm, std::unique_ptr< LineMesh< DIMENSION > > &mesh)
std::vector< index_t > get_neighbors(const vecn< DIMENSION > &v, double threshold_distance) const
index_t line(index_t edge) const
index_t nb_mesh_elements() const final
index_t region(index_t cell) const
virtual index_t nb_mesh_entities(const MeshEntityType &type) const
Returns the number of mesh entities of the given type.
virtual index_t cell_facet_vertex(const CellLocalFacet &cell_local_facet, index_t vertex_id) const =0
Gets a vertex by cell facet and local vertex index.
MeshSet< DIMENSION > mesh_set_
Mesh storing all the elements.
virtual void clear()
Clear the vertices - clear the gme_vertices_ - clear global vertex information in the all BMME...
const LineAABBTree< DIMENSION > & aabb() const
return the AABB tree for the edges of the mesh
index_t nb_duplicated_vertices() const
const GeoModel< DIMENSION > & geomodel_
This template is a specialization of a gme_id to the GeoModelMeshEntity.
bool is_surface_to_duplicate(index_t surface) const
const GeoModel< DIMENSION > & geomodel_
GeoModelMeshWells(GeoModelMesh< DIMENSION > &gmm, GeoModel< DIMENSION > &gm, std::unique_ptr< LineMesh< DIMENSION > > &mesh)
std::unique_ptr< LineMesh< DIMENSION > > & mesh_
Attached Mesh.
index_t duplicated_vertex(index_t duplicate_vertex_index) const
std::vector< index_t > well_ptr_
index_t nb_prisms_
Number of prism in the GeoModelMesh.
void clear(bool keep_attributes, bool keep_memory)
Removes all the entities and attributes of this mesh.
void test_and_initialize() const
virtual ~GeoModelMeshEdges()
const std::vector< GMEVertex > & mesh_entity_vertex_indices(index_t v) const
Returns all the corresponding vertices in GeoModelMeshEntities to a given geomodel vertex...
#define ringmesh_assert_not_reached
void set_vertex_map_value(const gmme_id &mesh_entity_id, index_t mesh_entity_vertex_index, index_t geomodel_entity_vertex_index)
Sets the geomodel vertex mapping value of a given vertex in a GeoModelMeshEntity. ...