45 class StradivariusBuilder final:
public GeoModelBuilderFile< 2 > {
47 StradivariusBuilder( GeoModel2D& geomodel, std::string filename )
48 : GeoModelBuilderFile< 2 >( geomodel, std::move( filename ) )
53 void load_file()
override 59 horizon_m0_.emplace( Surface2D::type_name_static(), index_t( 0 ) );
60 removal.remove_mesh_entities( horizon_m0_ );
61 build_corners_from_lines();
66 GEO::LineInput file{ filename_ };
67 move_to( file,
"liste des points\n" );
70 auto nb_points = file.field_as_uint( 0 );
71 points_.resize( nb_points );
72 for(
auto p : range( nb_points ) ) {
76 points_[p] = {file.field_as_double( 1 ), - file.field_as_double( 2 )};
80 void load_interfaces() {
81 GEO::LineInput file{ filename_ };
82 move_to( file,
"liste des horizons\n" );
85 auto nb_horizons = file.field_as_uint( 0 );
86 topology.create_mesh_entities( Line2D::type_name_static(), nb_horizons );
88 for(
auto horizon_id : range( nb_horizons ) ) {
92 gmme_id horizon{ Line2D::type_name_static(), horizon_id };
93 int medium_1 {file.field_as_int( 0 )};
94 int medium_2 {file.field_as_int( 1 )};
95 auto nb_points = file.field_as_uint( 2 );
96 info.set_mesh_entity_name(horizon, file.field( 4 ));
98 std::vector<vec2> vertices(nb_points);
99 for(
auto point_i : range( nb_points )) {
102 auto point_id = file.field_as_uint( 0 );
103 vertices[point_i] = points_[point_id];
105 geometry.set_line(horizon_id, vertices);
107 if (((medium_1 == 0 && (medium_2 == -1))) || ((medium_1 == -1 && (medium_2 == 0)))) {
108 horizon_m0_.insert(horizon);
114 GEO::LineInput file{ filename_ };
115 move_to(file,
"liste des milieux\n");
118 auto nb_media = file.field_as_uint( 0 );
119 topology.create_mesh_entities( Surface2D::type_name_static(), nb_media + 1 );
121 for(
const auto& horizon : horizon_m0_ ) {
122 topology.add_mesh_entity_boundary_relation(
123 { Surface2D::type_name_static(), index_t( 0 )}, horizon,
127 for (
auto milieu_i : range( nb_media )) {
130 auto nb_interfaces = file.field_as_uint( 1 );
131 for (
auto interface_i : range( nb_interfaces )) {
135 auto interface_id = file.field_as_uint( 0 );
136 gmme_id horizon{ Line2D::type_name_static(), interface_id };
137 topology.add_mesh_entity_boundary_relation(
138 { Surface2D ::type_name_static(), milieu_i + 1}, horizon,
144 bool move_to(GEO::LineInput& file, std::string selector) {
145 while (!file.eof() && file.get_line()) {
146 if (selector.compare(file.current_line()) == 0) {
154 std::vector< vec2 > points_;
155 std::set< gmme_id > horizon_m0_;
161 class StradivariusIOHandler final:
public GeoModelIOHandler< 2 > {
163 void load(
const std::string& filename, GeoModel2D& geomodel )
final 165 StradivariusBuilder builder{ geomodel, filename };
166 builder.build_geomodel();
168 void save(
const GeoModel2D& geomodel,
const std::string& filename )
final 170 throw RINGMeshException(
"I/O",
171 "Cannot save a GeoModel for Stradivarius" );
void ringmesh_unused(const T &)