RINGMesh  Version 5.0.0
A programming library for geological model meshes
geomodel_geological_entity.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 
41 #pragma once
42 
43 #include <ringmesh/basic/common.h>
44 
45 #include <memory>
46 
47 #include <ringmesh/basic/factory.h>
48 
51 
52 namespace RINGMesh
53 {
55  FORWARD_DECLARATION_DIMENSION_CLASS( GeoModelMeshEntity );
56  FORWARD_DECLARATION_DIMENSION_CLASS( GeoModelBuilderTopology );
57  FORWARD_DECLARATION_DIMENSION_CLASS( GeoModelBuilderGeology );
58  FORWARD_DECLARATION_DIMENSION_CLASS( GeoModelBuilderRemovalBase );
59  FORWARD_DECLARATION_DIMENSION_CLASS( GeoModelBuilderRemoval );
60  FORWARD_DECLARATION_DIMENSION_CLASS( GeoModelBuilderInfo );
61 } // namespace RINGMesh
62 
63 namespace RINGMesh
64 {
65  template < index_t DIMENSION >
66  class RINGMESH_API GeoModelGeologicalEntity
67  : public GeoModelEntity< DIMENSION >
68  {
69  public:
70  friend class GeoModelGeologicalEntityAccess< DIMENSION >;
71 
75  enum struct GEOL_FEATURE
76  {
78  ALL_GEOL,
80  NO_GEOL,
82  STRATI,
84  UNCONFORMITY,
86  NORMAL_FAULT,
88  REVERSE_FAULT,
90  FAULT,
92  VOI
93  };
94 
112  static GEOL_FEATURE determine_geological_type( const std::string& in );
117  static std::string geol_name( GEOL_FEATURE feature );
118  static bool is_fault( GEOL_FEATURE feature );
119  static bool is_stratigraphic_limit( GEOL_FEATURE feature )
120  {
121  return feature == GEOL_FEATURE::STRATI
122  || feature == GEOL_FEATURE::UNCONFORMITY;
123  }
124 
126  {
127  return geological_feature() != GEOL_FEATURE::NO_GEOL;
128  }
129 
131  {
132  return geol_feature_;
133  }
134 
135  static void initialize();
136 
137  gmge_id gmge() const
138  {
139  return gmge_id( type_name(), this->index() );
140  }
141 
143  {
144  return gmge().type();
145  }
146 
147  virtual MeshEntityType child_type_name() const = 0;
148  virtual bool is_on_voi() const;
149  virtual bool is_connectivity_valid() const;
150  virtual bool is_valid() const;
152  {
154  }
156  {
157  return type_name_static();
158  }
159  index_t nb_children() const
160  {
161  return static_cast< index_t >( children_.size() );
162  }
163  const gmme_id& child_gmme( index_t x ) const;
164  const GeoModelMeshEntity< DIMENSION >& child( index_t x ) const;
165 
166  virtual bool is_identification_valid() const;
167 
168  protected:
170  const GeoModel< DIMENSION >& geomodel )
171  : GeoModelEntity< DIMENSION >( geomodel, NO_ID )
172  {
173  }
174 
175  virtual bool is_index_valid() const;
176 
177  private:
180  {
181  this->copy_name( from );
182  geol_feature_ = from.geol_feature_;
183  children_ = from.children_;
184  }
185 
186  protected:
188  std::vector< index_t > children_{};
189 
191  GEOL_FEATURE geol_feature_{ GEOL_FEATURE::NO_GEOL };
192  };
193 
195 
196  template < index_t DIMENSION >
200 
202 
203  template < index_t DIMENSION >
204  class RINGMESH_API Contact : public GeoModelGeologicalEntity< DIMENSION >
205  {
206  public:
207  explicit Contact( const GeoModel< DIMENSION >& geomodel )
208  : GeoModelGeologicalEntity< DIMENSION >( geomodel )
209  {
210  }
211 
212  static GeologicalEntityType type_name_static()
213  {
214  return GeologicalEntityType( "Contact" );
215  }
216  GeologicalEntityType type_name() const override
217  {
218  return type_name_static();
219  }
220  MeshEntityType child_type_name() const override;
221  };
222 
224 
225  template < index_t DIMENSION >
226  class RINGMESH_API Interface : public GeoModelGeologicalEntity< DIMENSION >
227  {
228  public:
229  explicit Interface( const GeoModel< DIMENSION >& geomodel )
230  : GeoModelGeologicalEntity< DIMENSION >( geomodel )
231  {
232  }
233 
234  static GeologicalEntityType type_name_static()
235  {
236  return GeologicalEntityType( "Interface" );
237  }
238  GeologicalEntityType type_name() const override
239  {
240  return type_name_static();
241  }
242  MeshEntityType child_type_name() const override;
243  };
244 
246 
247  template < index_t DIMENSION >
248  class RINGMESH_API Layer : public GeoModelGeologicalEntity< DIMENSION >
249  {
250  public:
251  explicit Layer( const GeoModel< DIMENSION >& geomodel )
252  : GeoModelGeologicalEntity< DIMENSION >( geomodel )
253  {
254  }
255 
256  static GeologicalEntityType type_name_static()
257  {
258  return GeologicalEntityType( "Layer" );
259  }
260  GeologicalEntityType type_name() const override
261  {
262  return type_name_static();
263  }
264  MeshEntityType child_type_name() const override;
265  };
266 
268 
269  template < index_t DIMENSION >
271  {
273  friend class GeoModelBuilderTopology< DIMENSION >;
274  friend class GeoModelBuilderGeology< DIMENSION >;
275  friend class GeoModelBuilderInfo< DIMENSION >;
276  friend class GeoModelBuilderRemovalBase< DIMENSION >;
277 
278  private:
280  GeoModelGeologicalEntity< DIMENSION >& gmge )
281  : gmge_( gmge )
282  {
283  }
284  ~GeoModelGeologicalEntityAccess() = default;
285 
286  std::string& modifiable_name()
287  {
288  return gmge_.name_;
289  }
290 
291  index_t& modifiable_index()
292  {
293  return gmge_.id_;
294  }
295 
298  {
299  return gmge_.geol_feature_;
300  }
301 
302  std::vector< index_t >& modifiable_children()
303  {
304  return gmge_.children_;
305  }
306 
307  static std::unique_ptr< GeoModelGeologicalEntity< DIMENSION > >
308  create_geological_entity( const GeologicalEntityType& type,
309  const GeoModel< DIMENSION >& geomodel,
310  index_t index_in_geomodel );
311 
312  void copy( const GeoModelGeologicalEntity< DIMENSION >& from )
313  {
314  gmge_.copy_geological_entity( from );
315  }
316 
317  private:
318  GeoModelGeologicalEntity< DIMENSION >& gmge_;
319  };
320 
321 } // namespace RINGMesh
GeoModelGeologicalEntity< DIMENSION > & gmge_
#define ringmesh_disable_copy_and_move(Class)
Definition: common.h:76
static GeologicalEntityType type_name_static()
Contact(const GeoModel< DIMENSION > &geomodel)
Abstract base class for GeoModelMeshEntity.
static GeologicalEntityType type_name_static()
virtual GeologicalEntityType type_name() const
The GeologicalEntityType described the type of the Geological entities User can defined there own Geo...
Definition: entity_type.h:137
GeoModelGeologicalEntity< DIMENSION >::GEOL_FEATURE & modifiable_geol_feature()
static GeologicalEntityType type_name_static()
static ForbiddenGeologicalEntityType & type_name_static()
Definition: entity_type.h:172
GeologicalEntityType type_name() const override
GeoModelGeologicalEntityAccess(GeoModelGeologicalEntity< DIMENSION > &gmge)
ALIAS_2D_AND_3D(Box)
Interface(const GeoModel< DIMENSION > &geomodel)
static bool is_stratigraphic_limit(GEOL_FEATURE feature)
GEOL_FEATURE
Geological feature types for GeoModelEntity.
void copy_geological_entity(const GeoModelGeologicalEntity< DIMENSION > &from)
void copy(const GeoModelGeologicalEntity< DIMENSION > &from)
GeologicalEntityType type_name() const override
GeologicalEntityType type_name() const override
Builder tools to remove entities from a GeoModel.
The MeshEntityType described the type of the meshed entities There are 4 MeshEntityTypes correspondin...
Definition: entity_type.h:117
This template is a specialization of a gme_id to the GeoModelGeologicalEntity.
Definition: entity_type.h:262
Classes to build GeoModel from various inputs.
Definition: algorithm.h:48
GEOL_FEATURE geol_feature_
Geological feature of this object - default is NO_GEOL.
Abstract base class describing one entity of a GeoModel.
GeoModelGeologicalEntity(const GeoModel< DIMENSION > &geomodel)
This template is a specialization of a gme_id to the GeoModelMeshEntity.
Definition: entity_type.h:285
FORWARD_DECLARATION_DIMENSION_CLASS(GeoModelMeshEntityAccess)
std::vector< index_t > children_
Children relations of this entity.
Layer(const GeoModel< DIMENSION > &geomodel)
static GeologicalEntityType type_name_static()