RINGMesh  Version 5.0.0
A programming library for geological model meshes
io.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2017, Association Scientifique pour la Geologie et ses
3  * Applications (ASGA). All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of ASGA nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ASGA BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * http://www.ring-team.org
28  *
29  * RING Project
30  * Ecole Nationale Superieure de Geologie - GeoRessources
31  * 2 Rue du Doyen Marcel Roubault - TSA 70605
32  * 54518 VANDOEUVRE-LES-NANCY
33  * FRANCE
34  */
35 
36 #pragma once
37 
38 #include <ringmesh/basic/common.h>
39 
40 #include <memory>
41 
42 #include <ringmesh/basic/factory.h>
43 
44 const char COMMA = ',';
45 const char EOL = '\n';
46 const char SPACE = ' ';
47 const char TAB = '\t';
48 
54 namespace RINGMesh
55 {
56  class StratigraphicColumn;
59 
60  ALIAS_3D( GeoModel );
61  ALIAS_3D( WellGroup );
62 } // namespace RINGMesh
63 
64 namespace GEO
65 {
66  class MeshSubElementsStore;
67 } // namespace GEO
68 
69 namespace RINGMesh
70 {
77  bool RINGMESH_API compare_files(
78  const std::string& f1, const std::string& f2 );
84  template < index_t DIMENSION >
85  bool geomodel_load(
86  GeoModel< DIMENSION >& geomodel, const std::string& filename );
92  template < index_t DIMENSION >
93  void geomodel_save(
94  const GeoModel< DIMENSION >& geomodel, const std::string& filename );
100  void RINGMESH_API well_load(
101  const std::string& filename, WellGroup3D& wells );
102 
106  index_t RINGMESH_API find_geomodel_dimension( const std::string& filename );
107 
108  template < index_t DIMENSION >
110  {
112 
113  public:
114  virtual ~GeoModelIOHandler() = default;
115 
116  static void initialize();
117 
118  static std::unique_ptr< GeoModelIOHandler< DIMENSION > > get_handler(
119  const std::string& filename );
120 
121  bool load_geomodel(
122  const std::string& filename, GeoModel< DIMENSION >& geomodel );
123 
124  void save_geomodel( const GeoModel< DIMENSION >& geomodel,
125  const std::string& filename );
126 
127  virtual index_t dimension( const std::string& filename ) const
128  {
129  ringmesh_unused( filename );
130  return DIMENSION;
131  }
132 
133  protected:
134  GeoModelIOHandler() = default;
135  virtual void load(
136  const std::string& filename, GeoModel< DIMENSION >& geomodel ) = 0;
137 
138  virtual void save( const GeoModel< DIMENSION >& geomodel,
139  const std::string& filename ) = 0;
140 
141  private:
142  static std::unique_ptr< GeoModelIOHandler > create(
143  const std::string& format );
144  };
145 
147 
148  template < index_t DIMENSION >
151 
153 
154  /***************************************************************************/
155  class RINGMESH_API WellGroupIOHandler
156  {
158 
159  public:
160  virtual ~WellGroupIOHandler() = default;
161 
162  static void initialize();
163 
164  static std::unique_ptr< WellGroupIOHandler > get_handler(
165  const std::string& filename );
166 
167  virtual void load( const std::string& filename, WellGroup3D& mesh ) = 0;
168 
169  virtual void save(
170  const WellGroup3D& mesh, const std::string& filename ) = 0;
171 
172  protected:
173  WellGroupIOHandler() = default;
174 
175  private:
176  static std::unique_ptr< WellGroupIOHandler > create(
177  const std::string& format );
178  };
181 
182  /***************************************************************************/
183 
184  void RINGMESH_API mesh_initialize();
185 
186  /*********************************************************************************************/
187  class RINGMESH_API StratigraphicColumnIOHandler
188  {
190 
191  public:
192  virtual ~StratigraphicColumnIOHandler() = default;
193 
194  static void initialize();
195 
196  static std::unique_ptr< StratigraphicColumnIOHandler > get_handler(
197  const std::string& filename );
198 
199  virtual void load( const std::string& filename,
200  StratigraphicColumn& column,
201  GeoModel3D& geomodel ) = 0;
202 
203  virtual void save( const StratigraphicColumn& column,
204  const std::string& filename ) = 0;
205 
206  protected:
207  StratigraphicColumnIOHandler() = default;
208 
209  private:
210  static std::unique_ptr< StratigraphicColumnIOHandler > create(
211  const std::string& format );
212  };
215 } // namespace RINGMesh
#define ringmesh_disable_copy_and_move(Class)
Definition: common.h:76
void RINGMESH_API mesh_initialize()
Definition: io.cpp:84
const char SPACE
Definition: io.h:46
virtual index_t dimension(const std::string &filename) const
Definition: io.h:127
void ringmesh_unused(const T &)
Definition: common.h:105
ALIAS_3D(GeoModel)
ALIAS_2D_AND_3D(Box)
bool geomodel_load(GeoModel< DIMENSION > &geomodel, const std::string &filename)
Definition: io.cpp:131
const char COMMA
Definition: io.h:44
A stratigraphic column is composed of several stratigraphic units.
void geomodel_save(const GeoModel< DIMENSION > &geomodel, const std::string &filename)
Definition: io.cpp:146
void load_geomodel(GeoModel3D &geomodel)
void RINGMESH_API well_load(const std::string &filename, WellGroup3D &wells)
index_t RINGMESH_API find_geomodel_dimension(const std::string &filename)
Definition: io.cpp:110
bool RINGMESH_API compare_files(const std::string &f1, const std::string &f2)
Definition: io.cpp:59
Classes to build GeoModel from various inputs.
Definition: algorithm.h:48
const char TAB
Definition: io.h:47
FORWARD_DECLARATION_DIMENSION_CLASS(GeoModelMeshEntityAccess)
const char EOL
Definition: io.h:45