38 #include <geogram/basic/attributes.h> 53 gmme_id find_corner(
const GeoModel3D& geomodel,
const vec3& point )
55 for(
const auto& corner : geomodel.corners() )
57 if( corner.vertex( 0 ) == point )
65 std::string read_name_with_spaces(
66 index_t field_id,
const GEO::LineInput& line )
68 std::ostringstream oss;
71 oss << line.field( field_id++ );
72 }
while( field_id < line.nb_fields() );
76 vec3 read_vertex_coordinates(
77 GEO::LineInput& in, index_t start_field,
int z_sign )
80 vertex.x = in.field_as_double( start_field++ );
81 vertex.y = in.field_as_double( start_field++ );
82 vertex.z = z_sign * in.field_as_double( start_field );
86 std::vector< double > read_vertex_attributes(
87 GEO::LineInput& in, index_t start_field, index_t nb_attribute_fields )
89 std::vector< double > vertex( nb_attribute_fields );
90 for(
auto& cur_attribute : vertex )
94 cur_attribute = in.field_as_double( start_field++ );
110 template < index_t DIMENSION >
113 const std::string& geol_entity_name )
115 for(
auto& geol_entity : geomodel.
geol_entities( geol_entity_type ) )
117 if( geol_entity.name() == geol_entity_name )
119 return geol_entity.gmge();
130 Border( index_t part, index_t corner, index_t p0, index_t p1 )
131 : part_id_( part ), corner_id_( corner ), p0_( p0 ), p1_( p1 )
155 vec3 get_point_from_gocad_id(
const GeoModel3D& geomodel,
157 index_t point_gocad_id )
159 index_t point_local_id = vertex_map.
local_id( point_gocad_id );
160 index_t point_region = vertex_map.
region( point_gocad_id );
162 return geomodel.region( point_region ).vertex( point_local_id );
179 void get_surface_point_and_polygon_from_gocad_index(
180 index_t vertex_gocad_id,
181 const GeoModel3D& geomodel,
183 std::vector< index_t >& gocad_vertices2cur_surf_points,
184 std::vector< vec3 >& cur_surf_points,
185 std::vector< index_t >& cur_surf_polygons )
187 if( vertex_gocad_id >= gocad_vertices2cur_surf_points.size() )
189 gocad_vertices2cur_surf_points.resize( vertex_gocad_id + 1, NO_ID );
192 if( gocad_vertices2cur_surf_points[vertex_gocad_id] == NO_ID )
195 vec3 point = get_point_from_gocad_id(
196 geomodel, load_storage.
vertex_map_, vertex_gocad_id );
197 auto index =
static_cast< index_t
>( cur_surf_points.size() );
198 cur_surf_polygons.push_back( index );
199 gocad_vertices2cur_surf_points[vertex_gocad_id] = index;
200 cur_surf_points.push_back( point );
205 cur_surf_polygons.push_back(
206 gocad_vertices2cur_surf_points[vertex_gocad_id] );
220 void get_surface_points_and_polygons_from_gocad_indices(
221 const GeoModel3D& geomodel,
223 std::vector< vec3 >& cur_surf_points,
224 std::vector< index_t >& cur_surf_polygons )
226 std::vector< index_t > gocad_vertices2cur_surf_points;
227 for(
auto corner_gocad_id :
230 get_surface_point_and_polygon_from_gocad_index( corner_gocad_id,
231 geomodel, load_storage, gocad_vertices2cur_surf_points,
232 cur_surf_points, cur_surf_polygons );
242 GeoModel3D& geomodel,
245 std::vector< vec3 > cur_surf_points;
246 std::vector< index_t > cur_surf_polygons;
247 get_surface_points_and_polygons_from_gocad_indices(
248 geomodel, load_storage, cur_surf_points, cur_surf_polygons );
250 cur_surf_points, cur_surf_polygons,
269 void compute_region_cell_facet_centers(
const GeoModel3D& geomodel,
271 std::vector< vec3 >& cell_facet_centers )
273 const Region3D& region = geomodel.region( region_id );
275 const index_t nb_cells = region.nb_mesh_elements();
276 cell_facet_centers.reserve( 4 * nb_cells );
277 for(
auto c :
range( nb_cells ) )
279 for(
auto f :
range( region.nb_cell_facets( c ) ) )
281 cell_facet_centers.push_back(
293 std::vector< std::unique_ptr< NNSearch3D > >
294 compute_cell_facet_centers_region_nn_searchs(
295 const GeoModel3D& geomodel )
297 std::vector< std::unique_ptr< NNSearch3D > > region_nn_searchs(
298 geomodel.nb_regions() );
299 for(
auto r :
range( geomodel.nb_regions() ) )
301 std::vector< vec3 > cell_facet_centers;
302 compute_region_cell_facet_centers(
303 geomodel, r, cell_facet_centers );
304 region_nn_searchs[r].reset(
305 new NNSearch3D( cell_facet_centers,
true ) );
307 return region_nn_searchs;
320 std::tuple< index_t, std::vector< index_t > >
321 are_surface_sides_region_boundaries(
322 const Surface3D& surface,
const NNSearch3D& region_nn_search )
324 vec3 first_polygon_center = surface.mesh_element_barycenter( 0 );
325 std::vector< index_t > colocated_cell_facet_centers;
326 colocated_cell_facet_centers = region_nn_search.get_neighbors(
327 first_polygon_center, surface.geomodel().epsilon() );
328 return std::make_tuple(
329 static_cast< index_t >( colocated_cell_facet_centers.size() ),
330 colocated_cell_facet_centers );
345 bool determine_surface_side_to_add(
const GeoModel3D& geomodel,
348 index_t cell_facet_center_id )
350 index_t local_facet_id = cell_facet_center_id % 4;
351 index_t cell_id = ( cell_facet_center_id - local_facet_id ) / 4;
352 vec3 cell_facet_normal =
353 geomodel.region( region_id )
356 vec3 first_polygon_normal =
357 geomodel.surface( surface_id ).mesh().polygon_normal( 0 );
358 return dot( first_polygon_normal, cell_facet_normal ) > 0;
369 void fill_region_and_surface_boundaries_links( index_t region_id,
374 geomodel_builder.
topology.add_mesh_entity_boundary_relation(
375 gmme_id( Region3D::type_name_static(), region_id ),
376 gmme_id( Surface3D::type_name_static(), surface_id ), surf_side );
387 void add_both_surface_sides_to_region_boundaries( index_t region_id,
392 fill_region_and_surface_boundaries_links(
393 region_id, surface_id,
true, geomodel_builder );
394 fill_region_and_surface_boundaries_links(
395 region_id, surface_id,
false, geomodel_builder );
409 void add_one_surface_side_to_region_boundaries( index_t region_id,
411 index_t cell_facet_center_id,
413 const GeoModel3D& geomodel )
415 bool side = determine_surface_side_to_add(
416 geomodel, region_id, surface_id, cell_facet_center_id );
417 fill_region_and_surface_boundaries_links(
418 region_id, surface_id, side, geomodel_builder );
431 void add_surface_sides_to_region_boundaries( index_t surface_id,
433 const std::vector< index_t >& colocated_cell_facet_centers,
434 const GeoModel3D& geomodel,
437 switch( colocated_cell_facet_centers.size() )
440 add_one_surface_side_to_region_boundaries( region_id, surface_id,
441 colocated_cell_facet_centers[0], geomodel_builder, geomodel );
444 add_both_surface_sides_to_region_boundaries(
445 region_id, surface_id, geomodel_builder );
461 void add_surface_to_region_boundaries( index_t surface_id,
462 const std::vector< std::unique_ptr< NNSearch3D > >& region_nn_searchs,
463 const GeoModel3D& geomodel,
466 index_t cur_region{ 0 };
467 index_t nb_added_surf_sides{ 0 };
469 while( cur_region < geomodel.nb_regions() && nb_added_surf_sides < 2 )
471 index_t nb_surf_sides_are_boundary = NO_ID;
472 std::vector< index_t > colocated_cell_facet_centers;
474 nb_surf_sides_are_boundary, colocated_cell_facet_centers ) =
475 are_surface_sides_region_boundaries(
476 geomodel.surface( surface_id ),
477 *region_nn_searchs[cur_region] );
478 if( nb_surf_sides_are_boundary > 0 )
480 add_surface_sides_to_region_boundaries( surface_id, cur_region,
481 colocated_cell_facet_centers, geomodel, geomodel_builder );
482 nb_added_surf_sides += nb_surf_sides_are_boundary;
486 if( nb_added_surf_sides == 0 )
496 void compute_boundaries_of_geomodel_regions(
499 std::vector< std::unique_ptr< NNSearch3D > > reg_nn_searchs =
500 compute_cell_facet_centers_region_nn_searchs( geomodel );
501 for(
const auto& surface : geomodel.surfaces() )
503 add_surface_to_region_boundaries(
504 surface.index(), reg_nn_searchs, geomodel, geomodel_builder );
517 std::vector< bool > determine_if_surface_sides_bound_regions(
518 const GeoModel3D& geomodel )
520 std::vector< bool > surface_sides( 2 * geomodel.nb_surfaces(), false );
521 for(
const auto& region : geomodel.regions() )
523 for(
auto s :
range( region.nb_boundaries() ) )
525 if( region.side( s ) )
527 surface_sides[2 * region.boundary( s ).index() + 1] =
true;
529 else if( !region.side( s ) )
531 surface_sides[2 * region.boundary( s ).index()] =
true;
539 return surface_sides;
558 bool is_edge_in_several_surfaces(
const GeoModel3D& geomodel,
562 const std::vector< std::unique_ptr< NNSearch3D > >& surface_nns,
563 const std::vector< Box3D >& surface_boxes )
565 const Surface3D& surface = geomodel.surface( surface_id );
566 const SurfaceMesh3D& mesh = surface.mesh();
567 const vec3 barycenter =
569 std::vector< index_t > result;
570 index_t tested_surf{ 0 };
571 while( result.empty() && tested_surf < surface_nns.size() )
573 if( surface_boxes[tested_surf].
contains( barycenter ) )
575 result = surface_nns[tested_surf]->get_neighbors(
576 barycenter, geomodel.epsilon() );
580 return !result.empty();
590 std::vector< vec3 > get_surface_border_edge_barycenters(
591 const GeoModel3D& geomodel, index_t surface_id )
593 std::vector< vec3 > border_edge_barycenters;
594 const Surface3D& surface = geomodel.surface( surface_id );
595 const SurfaceMesh3D& mesh = surface.mesh();
596 for(
auto p :
range( surface.nb_mesh_elements() ) )
598 for(
auto e :
range( surface.nb_mesh_element_vertices( p ) ) )
602 border_edge_barycenters.push_back(
603 mesh.polygon_edge_barycenter(
608 return border_edge_barycenters;
611 void assign_mesh_surface(
614 std::vector< vec3 > vertices(
630 void assign_attributes_to_mesh(
const Region3D& region,
632 const std::vector< std::vector< double > >& region_attributes )
634 index_t read_fields{ 0 };
635 for(
auto attrib_itr :
640 if( region.vertex_attribute_manager().is_defined( name ) )
642 Logger::warn(
"Transfer attribute",
"The attribute ", name,
643 " already exists on the ", region.gmme() );
646 GEO::Attribute< double > attr;
647 index_t nb_dimensions =
649 attr.create_vector_attribute( region.vertex_attribute_manager(),
655 region.vertex_attribute_manager().resize(
656 static_cast< index_t >( region_attributes.size() )
659 for(
auto v_itr :
range( region_attributes.size() ) )
661 for(
auto attrib_dim_itr :
range( nb_dimensions ) )
663 attr[v_itr * nb_dimensions + attrib_dim_itr] =
664 region_attributes[v_itr][read_fields + attrib_dim_itr];
667 read_fields += nb_dimensions;
672 index_t GOCAD_OFFSET{ 1 };
686 if( line.field_matches( 1,
"Elevation" ) )
690 else if( line.field_matches( 1,
"Depth" ) )
714 std::string interface_name = read_name_with_spaces( 1, line );
716 gmge_id interface_id = builder_.geology.create_geological_entity(
717 Interface3D::type_name_static() );
718 builder_.info.set_geological_entity_name(
719 interface_id, interface_name );
735 if( !load_storage.is_header_read_ )
739 std::string geol = line.field( 2 );
740 std::string interface_name = read_name_with_spaces( 3, line );
741 create_surface( interface_name, geol );
747 assign_mesh_surface( builder_, load_storage );
749 static_cast< index_t
>( load_storage.
vertices_.size() );
750 load_storage.tface_vertex_ptr_ = nb_vertices;
756 const std::string& interface_name,
const std::string& type )
758 gmge_id parent = find_geological_entity(
759 geomodel_, Interface3D::type_name_static(), interface_name );
760 if( !interface_name.empty() )
765 gmme_id children = builder_.topology.create_mesh_entity(
766 Surface3D::type_name_static() );
767 builder_.geology.add_parent_children_relation( parent, children );
768 builder_.geology.set_geological_entity_geol_feature( parent,
769 GeoModelGeologicalEntity3D::determine_geological_type( type ) );
788 gmge_id layer_id = builder_.geology.create_geological_entity(
789 Layer3D::type_name_static() );
790 builder_.info.set_geological_entity_name(
791 layer_id, line.field( 1 ) );
792 bool end_layer =
false;
797 for(
auto i :
range( 5 ) )
799 index_t region_id = line.field_as_uint( i );
806 region_id -= geomodel_.nb_surfaces() + 1;
808 builder_.geology.add_parent_children_relation(
809 layer_id,
gmme_id( Region3D::type_name_static(),
810 region_id - GOCAD_OFFSET ) );
829 if( !load_storage.is_header_read_ )
831 load_storage.is_header_read_ =
true;
835 assign_mesh_surface( builder_, load_storage );
837 load_storage.tface_vertex_ptr_ = 0;
854 index_t v_id = line.field_as_uint( 1 ) - GOCAD_OFFSET;
855 if( !find_corner( geomodel_, load_storage.
vertices_[v_id] )
859 gmme_id corner_gme = builder_.topology.create_mesh_entity(
860 Corner3D::type_name_static() );
861 builder_.geometry.set_corner(
882 std::string name = read_name_with_spaces( 2, line );
884 std::vector< std::pair< index_t, bool > > region_boundaries =
885 get_region_boundaries( line );
889 if( name !=
"Universe" )
891 gmme_id region_id = builder_.topology.create_mesh_entity(
892 Region3D::type_name_static() );
893 builder_.info.set_mesh_entity_name( region_id, name );
894 for(
const std::pair< index_t, bool >& info :
898 Surface3D::type_name_static(), info.first );
899 builder_.topology.add_mesh_entity_boundary_relation(
900 region_id, surface_id, info.second );
905 std::vector< std::pair< index_t, bool > > get_region_boundaries(
906 GEO::LineInput& line )
908 std::vector< std::pair< index_t, bool > > region_boundaries;
909 bool end_region =
false;
914 for(
auto i :
range( 5 ) )
916 signed_index_t signed_id = line.field_as_int( i );
922 bool side = signed_id > 0;
923 auto id =
static_cast< index_t
>( std::abs( signed_id ) )
925 region_boundaries.emplace_back(
id, side );
928 return region_boundaries;
949 index_t initialize_region(
const std::string& region_name,
953 Region3D::type_name_static() );
954 geomodel_builder.
info.set_mesh_entity_name(
955 cur_region, region_name );
956 return cur_region.
index();
960 class LoadTSolidRegion final :
public LoadRegion
965 : LoadRegion( gm_builder, geomodel )
975 builder_.geometry.set_region_geometry( load_storage.
cur_region_,
977 assign_attributes_to_mesh(
978 geomodel_.region( load_storage.
cur_region_ ), load_storage,
982 std::string region_name;
983 if( line.nb_fields() == 1 )
985 region_name =
"Unnamed";
989 region_name = line.field( 1 );
994 initialize_region( region_name, builder_ );
1007 class LoadLightTSolidRegion final :
public LoadRegion
1010 LoadLightTSolidRegion(
1012 : LoadRegion( gm_builder, geomodel )
1027 std::string region_name = line.field( 2 );
1032 std::tie( found, region_id ) =
1037 region_id = initialize_region( region_name, builder_ );
1039 region_id, region_name );
1066 read_vertex_coordinates( line, 2, load_storage.
z_sign_ );
1067 load_storage.
vertices_.push_back( vertex );
1070 std::vector< double > attribute = read_vertex_attributes(
1089 index_t vertex_id = line.field_as_uint( 2 ) - GOCAD_OFFSET;
1091 load_storage.
vertices_.push_back( vertex );
1098 LoadAttributeTSolid(
1109 line.nb_fields() - 1 );
1110 for(
auto attrib_name_itr :
range( 1, line.nb_fields() ) )
1113 line.field( attrib_name_itr ) );
1119 execute( line, load_storage );
1126 LoadAttributeDimensionTSolid(
1137 for(
auto attrib_size_itr :
range( 1, line.nb_fields() ) )
1140 line.field_as_uint( attrib_size_itr ) );
1142 line.field_as_uint( attrib_size_itr );
1148 execute( line, load_storage );
1166 static_cast< index_t
>( load_storage.
vertices_.size() );
1170 ->execute( line, load_storage );
1176 line.field_as_uint( 1 ) - GOCAD_OFFSET,
1179 ->execute( line, load_storage );
1195 read_and_add_atom_to_region_vertices( geomodel_, line, load_storage,
1203 line.field_as_uint( 1 ) - GOCAD_OFFSET,
1204 line.field_as_uint( 2 ) - GOCAD_OFFSET );
1206 line.field_as_uint( 1 ) - GOCAD_OFFSET,
1211 std::vector< double > null_attrib(
1213 load_storage.
attributes_.push_back( null_attrib );
1230 void read_and_add_atom_to_region_vertices(
const GeoModel3D& geomodel,
1231 const GEO::LineInput& line,
1233 std::vector< vec3 >& region_vertices,
1234 std::vector< std::vector< double > >& region_attributes,
1237 const index_t referring_vertex =
1238 line.field_as_uint( 2 ) - GOCAD_OFFSET;
1239 const index_t referred_vertex_local_id =
1240 vertex_map.
local_id( referring_vertex );
1241 const index_t referred_vertex_region_id =
1242 vertex_map.
region( referring_vertex );
1243 if( referred_vertex_region_id < load_storage.
cur_region_ )
1247 auto index =
static_cast< index_t
>( region_vertices.size() );
1250 region_vertices.push_back(
1251 geomodel.region( referred_vertex_region_id )
1252 .vertex( referred_vertex_local_id ) );
1254 std::vector< double > attribute_v;
1255 for(
auto attrib_itr :
1262 GEO::Attribute< double > attr(
1263 geomodel.region( referred_vertex_region_id )
1264 .vertex_attribute_manager(),
1266 for(
auto dim_itr :
range( dim ) )
1268 attribute_v.push_back(
1269 attr[referred_vertex_local_id * dim + dim_itr] );
1272 region_attributes.push_back( attribute_v );
1278 referred_vertex_local_id, referred_vertex_region_id );
1295 std::vector< index_t > corners =
1305 line.field_as_uint( 1 ) - GOCAD_OFFSET;
1307 line.field_as_uint( 2 ) - GOCAD_OFFSET;
1309 line.field_as_uint( 3 ) - GOCAD_OFFSET;
1311 line.field_as_uint( 4 ) - GOCAD_OFFSET;
1325 std::vector< index_t > read_tetraedra(
1326 const GEO::LineInput& in,
const VertexMap& vertex_map )
1328 std::vector< index_t > corners_id( 4 );
1331 vertex_map.
local_id( in.field_as_uint( 1 ) - GOCAD_OFFSET );
1333 vertex_map.
local_id( in.field_as_uint( 2 ) - GOCAD_OFFSET );
1335 vertex_map.
local_id( in.field_as_uint( 3 ) - GOCAD_OFFSET );
1337 vertex_map.
local_id( in.field_as_uint( 4 ) - GOCAD_OFFSET );
1356 if( geomodel_.name().empty() )
1358 builder_.info.set_geomodel_name(
1359 read_name_with_spaces( 1, line ) );
1380 builder_.geometry.set_region_geometry( load_storage.
cur_region_,
1382 assign_attributes_to_mesh(
1383 geomodel_.region( load_storage.
cur_region_ ), load_storage,
1395 get_light_tsolid_workflow_to_catch_up_with_tsolid_workflow(
1400 std::vector< index_t > get_region_local_indices(
1401 const std::vector< VertexMap::RegionLocalVertex >&
1402 region_local_vertices )
1404 std::vector< index_t > result;
1405 result.reserve( region_local_vertices.size() );
1406 for(
auto& vertex : region_local_vertices )
1408 result.push_back( vertex.local_id );
1412 std::vector< vec3 > get_region_vertices(
1413 const std::vector< VertexMap::RegionLocalVertex >&
1414 region_local_vertices )
1416 std::vector< vec3 > result;
1417 result.reserve( region_local_vertices.size() );
1418 for(
auto& vertex : region_local_vertices )
1420 result.push_back( vertex.tetra_vertex );
1425 void get_light_tsolid_workflow_to_catch_up_with_tsolid_workflow(
1430 std::vector< std::vector< index_t > > region_tetra_corners_local;
1431 std::vector< std::vector< vec3 > > region_vertices;
1432 std::vector< std::vector< std::vector< double > > >
1435 region_tetra_corners_local.resize(
1446 std::vector< VertexMap::RegionLocalVertex >
1447 region_local_indices =
1452 region_vertices[region_id] =
1453 get_region_vertices( region_local_indices );
1455 get_region_local_indices( region_local_indices );
1462 region_attributes[region_id] );
1474 region_id, region_tetra_corners_local[region_id] );
1476 builder_.geometry.set_region_geometry( region_id,
1477 region_vertices[region_id],
1478 region_tetra_corners_local[region_id] );
1480 assign_attributes_to_mesh( geomodel_.region( region_id ),
1481 load_storage, region_attributes[region_id] );
1503 builder_.geology.create_geological_entity(
1504 Interface3D::type_name_static() );
1506 builder_.info.set_geological_entity_name(
1507 created_interface, line.field( 1 ) );
1513 execute( line, load_storage );
1533 build_surface( builder_, geomodel_, load_storage );
1536 gmme_id new_surface = builder_.topology.create_mesh_entity(
1537 Surface3D::type_name_static() );
1539 builder_.geology.add_parent_children_relation(
1540 gmge_id( Interface3D::type_name_static(),
1548 execute( line, load_storage );
1569 build_surface( builder_, geomodel_, load_storage );
1576 execute( line, load_storage );
1605 void read_triangle(
const GEO::LineInput& in,
1606 std::vector< index_t >& cur_surf_polygons )
1608 cur_surf_polygons.push_back( in.field_as_uint( 1 ) - GOCAD_OFFSET );
1609 cur_surf_polygons.push_back( in.field_as_uint( 2 ) - GOCAD_OFFSET );
1610 cur_surf_polygons.push_back( in.field_as_uint( 3 ) - GOCAD_OFFSET );
1614 void tsolid_import_factory_initialize()
1616 TSolidLineFactory::register_creator< LoadTSolidRegion >(
"TVOLUME" );
1617 TSolidLineFactory::register_creator< LoadLightTSolidRegion >(
"#" );
1618 TSolidLineFactory::register_creator< LoadAttributeTSolid >(
1620 TSolidLineFactory::register_creator< LoadAttributeDimensionTSolid >(
1622 TSolidLineFactory::register_creator< LoadTSolidVertex >(
"VRTX" );
1623 TSolidLineFactory::register_creator< LoadTSolidVertex >(
"PVRTX" );
1624 TSolidLineFactory::register_creator< LoadTSAtomic >(
"SHAREDVRTX" );
1625 TSolidLineFactory::register_creator< LoadTSAtomic >(
"SHAREDPVRTX" );
1626 TSolidLineFactory::register_creator< LoadTSAtomic >(
"ATOM" );
1627 TSolidLineFactory::register_creator< LoadTSAtomic >(
"PATOM" );
1628 TSolidLineFactory::register_creator< LoadTetra >(
"TETRA" );
1629 TSolidLineFactory::register_creator< LoadLastRegion >(
"MODEL" );
1630 TSolidLineFactory::register_creator< LoadInterface >(
"SURFACE" );
1631 TSolidLineFactory::register_creator< LoadSurface >(
"TFACE" );
1632 TSolidLineFactory::register_creator< LoadLastSurface >(
"END" );
1635 void ml_import_factory_initialize()
1637 MLLineFactory::register_creator< LoadTSurf >(
"TSURF" );
1638 MLLineFactory::register_creator< LoadMLSurface >(
"TFACE" );
1639 MLLineFactory::register_creator< LoadMLRegion >(
"REGION" );
1640 MLLineFactory::register_creator< LoadLayer >(
"LAYER" );
1641 MLLineFactory::register_creator< MLEndSection >(
"END" );
1642 MLLineFactory::register_creator< LoadMLAtom >(
"ATOM" );
1643 MLLineFactory::register_creator< LoadMLAtom >(
"PATOM" );
1658 GeoModelBuilderTSolid& gm_builder, GeoModel3D& geomodel )
1670 while( !file_line_.eof() && file_line_.get_line() )
1672 file_line_.get_fields();
1673 if( file_line_.nb_fields() > 0 )
1682 cur_surf_polygon_ptr_.push_back( 0 );
1686 GeoModel3D& geomodel, std::string filename )
1699 while( !line.eof() && line.get_line() )
1702 if( line.nb_fields() > 0 )
1704 if( line.field_matches( 0,
"VRTX" )
1705 || line.field_matches( 0,
"PVRTX" )
1706 || line.field_matches( 0,
"PATOM" )
1707 || line.field_matches( 0,
"ATOM" )
1708 || line.field_matches( 0,
"SHAREDPVRTX" )
1709 || line.field_matches( 0,
"SHAREDVRTX" ) )
1726 compute_boundaries_of_geomodel_regions( *
this, ( *this ).geomodel_ );
1733 while( !line.eof() && line.get_line() )
1736 if( line.nb_fields() > 0 )
1738 if( line.field_matches( 0,
"GOCAD" ) )
1740 if( line.field_matches( 1,
"TSolid" ) )
1747 line.field_matches( 1,
"LightTSolid" ) );
1774 const std::vector< std::unique_ptr< NNSearch3D > >& surface_nns,
1775 const std::vector< Box3D >& surface_boxes )
1777 const Surface3D& surface =
geomodel_.surface( surface_id );
1778 const SurfaceMesh3D& mesh = surface.mesh();
1780 for( index_t p :
range( surface.nb_mesh_elements() ) )
1782 std::vector< index_t > adjacent_polygons_id( 3 );
1783 for( index_t e :
range( 3 ) )
1785 adjacent_polygons_id[e] =
1789 bool internal_border =
1790 is_edge_in_several_surfaces(
geomodel_, surface_id, p,
1791 e, surface_nns, surface_boxes );
1792 if( internal_border )
1794 adjacent_polygons_id[e] = NO_ID;
1798 geometry.set_surface_element_adjacency(
1799 surface_id, p, adjacent_polygons_id );
1805 std::vector< std::unique_ptr< NNSearch3D > >& surface_nns,
1806 std::vector< Box3D >& surface_boxes )
const 1808 surface_nns.resize(
geomodel_.nb_surfaces() );
1809 surface_boxes.resize(
geomodel_.nb_surfaces() );
1811 for(
const auto& surface :
geomodel_.surfaces() )
1813 for( index_t v :
range( surface.nb_vertices() ) )
1815 surface_boxes[surface.index()].add_point( surface.vertex( v ) );
1817 std::vector< vec3 > border_edge_barycenters =
1818 get_surface_border_edge_barycenters(
1820 surface_nns[surface.index()].reset(
1821 new NNSearch3D( border_edge_barycenters,
true ) );
1827 std::vector< std::unique_ptr< NNSearch3D > > nn_searchs;
1828 std::vector< Box3D > boxes;
1830 for(
const auto& surface :
geomodel_.surfaces() )
1833 surface.index(), nn_searchs, boxes );
1847 geomodel_.mesh.vertices.test_and_initialize();
1855 std::unique_ptr< MLLineParser > tsolid_parser(
1859 tsolid_parser->execute(
file_line_, ml_load_storage_ );
1863 std::unique_ptr< GocadLineParser > gocad_parser =
1867 gocad_parser->execute(
file_line_, ml_load_storage_ );
1874 GocadLineFactory::register_creator< LoadZSign >(
"ZPOSITIVE" );
1875 GocadLineFactory::register_creator< LoadVertex >(
"VRTX" );
1876 GocadLineFactory::register_creator< LoadVertex >(
"PVRTX" );
1877 GocadLineFactory::register_creator< LoadName >(
"name:" );
1878 GocadLineFactory::register_creator< LoadTriangle >(
"TRGL" );
1879 tsolid_import_factory_initialize();
1880 ml_import_factory_initialize();
index_t nb_regions() const
void end_polygon()
Ends a polygon (by adding the size of list of polygon corners at the end of the vector) ...
Factory< std::string, MLLineParser, GeoModelBuilderML &, GeoModel3D &> ml_factory
static std::unique_ptr< BaseClass > create(const Key &key, const Args &... args)
index_t cur_gocad_vrtx_id1_
std::vector< std::vector< double > > attributes_
GeoModel< DIMENSION > & geomodel_
index_t cur_gocad_vrtx_id4_
GeoModelBuilderGeometry< DIMENSION > geometry
The GeologicalEntityType described the type of the Geological entities User can defined there own Geo...
void read_number_of_vertices()
Structure used to load a GeoModel by GeoModelBuilderTSolid.
void reserve(index_t capacity)
index_t local_id(index_t gocad_vertex_id) const
TSolidLoadingStorage tsolid_load_storage_
void get_vertices_attributes_list_from_gocad_ids(const std::vector< std::vector< double > > &stored_attributes, index_t region_id, const std::map< index_t, index_t > &lighttsolid_atom_map, std::vector< std::vector< double > > ®ion_tetra_attributes) const
void get_tetra_corners_with_this_region_id(index_t region_id, std::vector< index_t > ®ion_tetra_corners_local) const
void ringmesh_unused(const T &)
GeoModelBuilderTopology< DIMENSION > topology
void fill_with_lighttsolid_region_ids()
index_t tface_vertex_ptr_
Offset to read in the tface vertices in the tsurf vertices.
void fill_with_lighttsolid_local_ids()
GEO::LineInput file_line_
static void warn(const std::string &feature, const Args &... args)
void RINGMESH_API initialize_gocad_import_factories()
const std::vector< index_t > & get_regions() const
std::tuple< bool, index_t > find_region_id_from_name(const std::string ®ion_name)
GeoModelBuilderTSolid(GeoModel3D &geomodel, std::string filename)
geol_entity_range< DIMENSION > geol_entities(const GeologicalEntityType &geol_type) const
void load_file() final
Loads and builds a GeoModel from a Gocad .ml file.
std::map< index_t, index_t > lighttsolid_atom_map_
Build a GeoModel from a Gocad Model3D (file_model.ml)
void record_vertex_with_its_region(index_t gocad_vertex_id, index_t region_id)
index_t region(index_t gocad_vertex_id) const
Factory< std::string, TSolidLineParser, GeoModelBuilderTSolid &, GeoModel3D &> tsolid_factory
std::vector< index_t > vertex_attribute_dims_
void compute_polygon_edge_centers_nn_and_surface_boxes(std::vector< std::unique_ptr< NNSearch3D > > &surface_nns, std::vector< Box3D > &surface_boxes) const
Computes the NNSearchs of the centers of polygon edges for each surface and their Box3d...
index_t nb_attribute_fields_
std::vector< vec3 > vertices_
MLLineParser(GeoModelBuilderML &gm_builder, GeoModel3D &geomodel)
std::vector< index_t > tetra_corners_
std::array< std::unique_ptr< GeoModelBuilderTSolidImpl >, NB_TYPE > type_impl_
Builds a meshed GeoModel from a Gocad TSolid (file.so)
GeoModelBuilderGeology< DIMENSION > geology
#define ringmesh_assert(x)
index_t cur_gocad_vrtx_id2_
void add_vertex(index_t local_vertex_id, index_t region_id)
index_t cur_gocad_vrtx_id3_
void compute_surfaces_internal_borders()
Computes internal borders of the geomodel surfaces.
bool contains(const container &in, const T &value)
TSolidLineParser(GeoModelBuilderTSolid &gm_builder, GeoModel3D &geomodel)
GeoModelBuilderInfo< DIMENSION > info
vecn< DIMENSION > cell_facet_barycenter(const CellLocalFacet &cell_local_facet) const
void add_new_region(index_t region_id, const std::string ®ion_name)
void reserve_nb_vertices(index_t capacity)
std::vector< std::string > vertex_attribute_names_
void read_file()
Parses the file and loads the GeoModel.
This template is a specialization of a gme_id to the GeoModelGeologicalEntity.
Classes to build GeoModel from various inputs.
void deal_with_same_region_atoms(const std::map< index_t, index_t > &lighttsolid_atom_map)
void compute_surface_internal_borders(index_t surface_id, const std::vector< std::unique_ptr< NNSearch3D > > &surface_nns, const std::vector< Box3D > &surface_boxes)
Computes internal borders of a given surface.
void build_lines_and_corners_from_surfaces()
void read_line() final
Reads the first word of the current line (keyword) and executes the good action with the information ...
Structure which maps the vertex indices in Gocad::TSolid to the pair (region, index in region) in the...
std::vector< RegionLocalVertex > get_vertices_list_and_local_ids_from_gocad_ids(const std::vector< vec3 > &stored_vertices, const index_t region_id, const std::map< index_t, index_t > &lighttsolid_atom_map) const
This template is a specialization of a gme_id to the GeoModelMeshEntity.
std::vector< std::vector< index_t > > local_ids_
std::vector< index_t > cur_surf_polygon_ptr_
void read_line() final
Reads the first word of the current line (keyword) and executes the good action with the information ...
std::vector< index_t > cur_surf_polygon_corners_gocad_id_
#define ringmesh_assert_not_reached