message: Load wells from .smesh
diff: @@ -113,6 +113,73 @@ namespace {
  }
  } ;
  + class SmeshIOHandler: public WellGroupIOHandler {
  + public:
  + virtual void load( const std::string& filename, WellGroup& wells )
  + {
  + GEO::LineInput in( filename ) ;
  + if( !in.OK() ) {
  + throw RINGMeshException( "I/O", "Could not open file" ) ;
  + }
  +
  + Mesh1D* mesh = Mesh1D::create_mesh( GeogramMesh1D::type_name_static() ) ;
  + Mesh1DBuilder* builder = Mesh1DBuilder::create_builder( *mesh ) ;
  + std::string name ;
  +
  + bool is_first_part = true ;
  +
  + while( !in.eof() ) {
  + in.get_line() ;
  + in.get_fields() ;
  + if( in.nb_fields() == 0 ) continue ;
  + if( GEO::String::string_starts_with( in.field( 0 ), "#" ) ) {
  + continue ;
  + }
  + if( is_first_part ) {
  + index_t nb_vertices = in.field_as_uint( 0 ) ;
  + builder->create_vertices( nb_vertices ) ;
  + Box3d box ;
  +
  + for( index_t v = 0; v < nb_vertices; v++ ) {
  + do {
  + in.get_line() ;
  + in.get_fields() ;
  + } while( in.nb_fields() == 0 ) ;
  + vec3 point ;
  + point[0] = in.field_as_double( 1 ) ;
  + point[1] = in.field_as_double( 2 ) ;
  + point[2] = in.field_as_double( 3 ) ;
  + builder->set_vertex( v, point ) ;
  + box.add_point( point ) ;
  + }
  + is_first_part = false ;
  + } else {
  + index_t nb_edges = in.field_as_uint( 0 ) ;
  + builder->create_edges( nb_edges ) ;
  + for( index_t e = 0; e < nb_edges; e++ ) {
  + do {
  + in.get_line() ;
  + in.get_fields() ;
  + } while( in.nb_fields() == 0 ) ;
  + builder->set_edge_vertex( e, 0, in.field_as_uint( 1 ) ) ;
  + builder->set_edge_vertex( e, 1, in.field_as_uint( 2 ) ) ;
  + }
  + wells.add_well( *mesh, name ) ;
  + break ;
  + }
  + }
  + delete mesh ;
  + delete builder ;
  + }
  + virtual void save( const WellGroup& wells, const std::string& filename )
  + {
  + ringmesh_unused( wells ) ;
  + ringmesh_unused( filename ) ;
  + throw RINGMeshException( "I/O",
  + "Saving of a WellGroup from Smesh not implemented yet" ) ;
  + }
  + } ;
  +
  }
  namespace RINGMesh {
  @@ -160,5 +227,7 @@ namespace RINGMesh {
  */
  void WellGroupIOHandler::initialize()
  {
  - ringmesh_register_WellGroupIOHandler_creator( WLIOHandler, "wl" );}
  + ringmesh_register_WellGroupIOHandler_creator( WLIOHandler, "wl" );
  + ringmesh_register_WellGroupIOHandler_creator( SmeshIOHandler, "smesh" ) ;
  +}
  }
  