RINGMesh  Version 5.0.0
A programming library for geological model meshes
entity_type_manager.cpp
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 
37 
41 
42 namespace RINGMesh
43 {
44  template <>
46  {
47  initialize_base();
48  register_boundary(
49  Region3D::type_name_static(), Surface3D::type_name_static() );
50  }
51 
52  template <>
54  {
55  initialize_base();
56  }
57 
58  template < index_t DIMENSION >
60  {
61  register_boundary( Corner< DIMENSION >::type_name_static(),
63  register_boundary( Line< DIMENSION >::type_name_static(),
65  register_boundary( Surface< DIMENSION >::type_name_static(),
67  }
68 
69  template < index_t DIMENSION >
71  {
72  register_incident_entity( Corner< DIMENSION >::type_name_static(),
74  register_incident_entity( Line< DIMENSION >::type_name_static(),
76  }
77 
78  template <>
80  {
81  initialize_base();
82  register_incident_entity(
83  Surface3D::type_name_static(), Region3D::type_name_static() );
84  register_incident_entity( Region3D::type_name_static(),
86  }
87 
88  template <>
90  {
91  initialize_base();
92  register_incident_entity( Surface2D::type_name_static(),
94  }
95 
96  template <>
98  {
99  initialize_base();
100  mesh_entity_types_.push_back( Region3D::type_name_static() );
101  }
102 
103  template < index_t DIMENSION >
105  {
106  initialize_base();
107  }
108 
109  template < index_t DIMENSION >
111  {
112  mesh_entity_types_.push_back( Corner< DIMENSION >::type_name_static() );
113  mesh_entity_types_.push_back( Line< DIMENSION >::type_name_static() );
114  mesh_entity_types_.push_back(
116  }
117 
119  {
120  return static_cast< index_t >( geological_entity_types_.size() );
121  }
122 
123  const std::vector< GeologicalEntityType >&
125  {
127  }
128 
130  index_t index ) const
131  {
132  return geological_entity_types_.at( index );
133  }
134 
136  const GeologicalEntityType& type ) const
137  {
138  return find( geological_entity_types_, type );
139  }
140 
142  const GeologicalEntityType& type ) const
143  {
144  return contains( geological_entity_types_, type );
145  }
146 
147  std::vector< GeologicalEntityType > RelationshipManager::parent_types(
148  const MeshEntityType& child_type ) const
149  {
150  MeshEntityToParents::const_iterator itr{ child_to_parents_.find(
151  child_type ) };
152  std::vector< GeologicalEntityType > result;
153  if( itr != child_to_parents_.end() )
154  {
155  result.insert(
156  result.begin(), itr->second.begin(), itr->second.end() );
157  }
158  return result;
159  }
160 
162  const MeshEntityType& child_type ) const
163  {
164  return static_cast< index_t >( parent_types( child_type ).size() );
165  }
166 
168  const GeologicalEntityType& parent_type ) const
169  {
170  GeologicalEntityToChild::const_iterator itr{ parent_to_child_.find(
171  parent_type ) };
172  if( itr == parent_to_child_.end() )
173  {
175  }
176  else
177  {
178  return itr->second;
179  }
180  }
181 
182  template class RINGMESH_API MeshEntityTypes< 2 >;
183  template class RINGMESH_API MeshEntityTypeManagerBase< 2 >;
184  template class RINGMESH_API MeshEntityTypeManager< 2 >;
185  template struct RINGMESH_API MeshEntityTypeIncidentEntityMap< 2 >;
186  template struct RINGMESH_API MeshEntityTypeBoundaryMap< 2 >;
187 
188  template class RINGMESH_API MeshEntityTypes< 3 >;
189  template class RINGMESH_API MeshEntityTypeManagerBase< 3 >;
190  template struct RINGMESH_API MeshEntityTypeIncidentEntityMap< 3 >;
191  template struct RINGMESH_API MeshEntityTypeBoundaryMap< 3 >;
192 } // namespace RINGMesh
std::vector< GeologicalEntityType > parent_types(const MeshEntityType &child_type) const
index_t nb_parent_types(const MeshEntityType &child_type) const
The GeologicalEntityType described the type of the Geological entities User can defined there own Geo...
Definition: entity_type.h:137
A GeoModelEntity of type CORNER.
const MeshEntityType child_type(const GeologicalEntityType &parent_type) const
index_t geological_entity_type_index(const GeologicalEntityType &type) const
index_t find(const container &in, const T &value)
Returns the position of the first entity matching.
Definition: algorithm.h:55
const std::vector< GeologicalEntityType > & geological_entity_types() const
bool is_valid_type(const GeologicalEntityType &type) const
struct used to map the type of a Mesh Entity to the type of its incident mesh entity "Line" is incide...
const GeologicalEntityType & geological_entity_type(index_t index) const
bool contains(const container &in, const T &value)
Definition: algorithm.h:87
struct used to map the type of a Mesh Entity to the type of its boundary "Corner" is boundary of "Lin...
The MeshEntityType described the type of the meshed entities There are 4 MeshEntityTypes correspondin...
Definition: entity_type.h:117
Classes to build GeoModel from various inputs.
Definition: algorithm.h:48
static ForbiddenMeshEntityType & type_name_static()
Definition: entity_type.h:154
A GeoModelEntity of type LINE.
this class contains only static methods to manage the type of the GeoModelMeshEntity. It gives access to the number of meshed entities of each type and also their (in) boundary
std::vector< GeologicalEntityType > geological_entity_types_