37 void merge_colocated_vertices(
double epsilon, LineMesh3D& mesh )
39 std::vector< index_t > old2new;
40 index_t nb_colocated = NO_ID;
41 std::tie( nb_colocated, old2new ) =
42 mesh.vertex_nn_search().get_colocated_index_mapping( epsilon );
43 if( nb_colocated > 0 ) {
44 std::unique_ptr< LineMeshBuilder3D > builder =
45 LineMeshBuilder3D::create_builder( mesh );
46 for(
auto e : range( mesh.nb_edges() ) ) {
47 for(
auto i : range( 2 ) ) {
48 index_t v = mesh.edge_vertex( ElementLocalVertex( e, i ) );
49 builder->set_edge_vertex( EdgeLocalVertex( e, i ), old2new[v] );
52 std::vector< bool > delete_vertices( mesh.nb_vertices(), false );
53 for(
auto v : range( mesh.nb_vertices() ) ) {
54 if( old2new[v] != v ) {
55 delete_vertices[v] =
true;
58 builder->delete_vertices( delete_vertices );
62 class SmeshIOHandler final:
public WellGroupIOHandler {
64 void load(
const std::string& filename, WellGroup3D& wells )
final 66 GEO::LineInput in( filename );
68 throw RINGMeshException(
"I/O",
"Could not open file" );
71 std::unique_ptr< LineMesh3D > mesh = LineMesh3D::create_mesh(
72 GeogramLineMesh3D::type_name_static() );
73 std::unique_ptr< LineMeshBuilder3D > builder =
74 LineMeshBuilder3D::create_builder( *mesh );
75 std::string name = GEO::FileSystem::base_name( filename );
77 bool is_first_part =
true;
82 if( in.nb_fields() == 0 )
continue;
83 if( GEO::String::string_starts_with( in.field( 0 ),
"#" ) ) {
87 index_t nb_vertices = in.field_as_uint( 0 );
88 builder->create_vertices( nb_vertices );
91 for(
auto v : range( nb_vertices ) ) {
95 }
while( in.nb_fields() == 0 );
97 point[0] = in.field_as_double( 1 );
98 point[1] = in.field_as_double( 2 );
99 point[2] = in.field_as_double( 3 );
100 builder->set_vertex( v, point );
101 box.add_point( point );
103 is_first_part =
false;
105 index_t nb_edges = in.field_as_uint( 0 );
106 builder->create_edges( nb_edges );
107 for(
auto e : range( nb_edges ) ) {
111 }
while( in.nb_fields() == 0 );
112 builder->set_edge_vertex( EdgeLocalVertex( e, 0 ), in.field_as_uint( 1 ) );
113 builder->set_edge_vertex( EdgeLocalVertex( e, 1 ), in.field_as_uint( 2 ) );
115 merge_colocated_vertices( wells.geomodel()->epsilon(), *mesh );
116 wells.add_well( *mesh, name );
121 void save(
const WellGroup3D& wells,
const std::string& filename )
final 125 throw RINGMeshException(
"I/O",
126 "Saving of a WellGroup from Smesh not implemented yet" );
void ringmesh_unused(const T &)