RINGMesh  Version 5.0.0
A programming library for geological model meshes
geomodel_indexing_types.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>
40 
47 namespace RINGMesh
48 {
49  FORWARD_DECLARATION_DIMENSION_CLASS( GeoModelGeologicalEntity );
50 } // namespace RINGMesh
51 
52 namespace RINGMesh
53 {
57  struct GMEVertex
58  {
59  GMEVertex( gmme_id t, index_t vertex_id_in )
60  : gmme( std::move( t ) ), v_index( vertex_id_in )
61  {
62  }
63  bool operator==( const GMEVertex& rhs ) const
64  {
65  return gmme == rhs.gmme && v_index == rhs.v_index;
66  }
67  bool is_defined() const
68  {
69  return gmme.is_defined() && v_index != NO_ID;
70  }
74  index_t v_index{ NO_ID };
75  };
76 
77  template < index_t DIMENSION >
78  class RINGMESH_API entity_range : public range
79  {
80  protected:
81  entity_range( const GeoModel< DIMENSION >& geomodel, index_t last )
82  : range( last ), geomodel_( geomodel )
83  {
84  }
85 
86  protected:
88  };
89 
90  template < index_t DIMENSION >
91  class RINGMESH_API corner_range : public entity_range< DIMENSION >
92  {
93  public:
94  explicit corner_range( const GeoModel< DIMENSION >& geomodel )
95  : entity_range< DIMENSION >( geomodel, geomodel.nb_corners() )
96  {
97  }
99  {
100  return *this;
101  }
103  {
104  return *this;
105  }
107  {
108  return this->geomodel_.corner( this->iter_ );
109  }
110  };
111 
112  template < index_t DIMENSION >
113  class RINGMESH_API line_range : public entity_range< DIMENSION >
114  {
115  public:
116  explicit line_range( const GeoModel< DIMENSION >& geomodel )
117  : entity_range< DIMENSION >( geomodel, geomodel.nb_lines() )
118  {
119  }
121  {
122  return *this;
123  }
125  {
126  return *this;
127  }
129  {
130  return this->geomodel_.line( this->iter_ );
131  }
132  };
133 
134  template < index_t DIMENSION >
135  class RINGMESH_API surface_range : public entity_range< DIMENSION >
136  {
137  public:
138  explicit surface_range( const GeoModel< DIMENSION >& geomodel )
139  : entity_range< DIMENSION >( geomodel, geomodel.nb_surfaces() )
140  {
141  }
143  {
144  return *this;
145  }
147  {
148  return *this;
149  }
151  {
152  return this->geomodel_.surface( this->iter_ );
153  }
154  };
155 
156  template < index_t DIMENSION >
157  class RINGMESH_API region_range : public entity_range< DIMENSION >
158  {
159  public:
160  explicit region_range( const GeoModel< DIMENSION >& geomodel )
161  : entity_range< DIMENSION >( geomodel, geomodel.nb_regions() )
162  {
163  }
165  {
166  return *this;
167  }
169  {
170  return *this;
171  }
173  {
174  return this->geomodel_.region( this->iter_ );
175  }
176  };
177 
178  template < index_t DIMENSION >
179  class RINGMESH_API geol_entity_range : public entity_range< DIMENSION >
180  {
181  public:
183  GeologicalEntityType geological_entity_type )
184  : entity_range< DIMENSION >( geomodel,
185  geomodel.nb_geological_entities( geological_entity_type ) ),
186  type_( std::move( geological_entity_type ) )
187  {
188  }
190  {
191  return *this;
192  }
194  {
195  return *this;
196  }
198  {
199  return this->geomodel_.geological_entity(
200  this->type_, this->iter_ );
201  }
202 
203  protected:
204  const GeologicalEntityType type_{};
205  };
206 } // namespace RINGMesh
const surface_range< DIMENSION > & end() const
const GeoModelGeologicalEntity< DIMENSION > & operator*() const
gmme_id gmme
GeoModelEntity index in the GeoModel that owns it.
The GeologicalEntityType described the type of the Geological entities User can defined there own Geo...
Definition: entity_type.h:137
bool operator==(const GMEVertex &rhs) const
const GeoModel< DIMENSION > & geomodel_
const Surface< DIMENSION > & operator*() const
A GeoModelEntity of type CORNER.
line_range(const GeoModel< DIMENSION > &geomodel)
const region_range< DIMENSION > & end() const
region_range(const GeoModel< DIMENSION > &geomodel)
const geol_entity_range< DIMENSION > & begin() const
const surface_range< DIMENSION > & begin() const
const line_range< DIMENSION > & begin() const
entity_range(const GeoModel< DIMENSION > &geomodel, index_t last)
const corner_range< DIMENSION > & begin() const
index_t v_index
Index of the vertex in the GeoModelEntity.
const Corner< DIMENSION > & operator*() const
const geol_entity_range< DIMENSION > & end() const
const corner_range< DIMENSION > & end() const
const region_range< DIMENSION > & begin() const
const Region< DIMENSION > & operator*() const
Vertex in a GeoModelEntity.
geol_entity_range(const GeoModel< DIMENSION > &geomodel, GeologicalEntityType geological_entity_type)
surface_range(const GeoModel< DIMENSION > &geomodel)
A GeoModelEntity of type REGION.
const line_range< DIMENSION > & end() const
Classes to build GeoModel from various inputs.
Definition: algorithm.h:48
A GeoModelEntity of type LINE.
GMEVertex(gmme_id t, index_t vertex_id_in)
This template is a specialization of a gme_id to the GeoModelMeshEntity.
Definition: entity_type.h:285
FORWARD_DECLARATION_DIMENSION_CLASS(GeoModelMeshEntityAccess)
const Line< DIMENSION > & operator*() const
corner_range(const GeoModel< DIMENSION > &geomodel)
bool is_defined() const
Definition: entity_type.h:299