RINGMesh  Version 5.0.0
A programming library for geological model meshes
stratigraphic_column.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 
38 namespace RINGMesh
39 {
41  : name_( "none" ), rock_( RockFeature( "none" ) )
42  {
43  }
44 
46  : name_( std::move( name ) ), rock_( std::move( rock ) )
47  {
48  }
49 
51  std::string name,
52  const Interface3D& interface_base,
53  const Interface3D& interface_top,
54  const Layer3D& layer,
55  RELATION relation_top,
56  RELATION relation_base,
57  RockFeature rock,
58  double min_thick,
59  double max_thick )
60  : StratigraphicUnit( std::move( name ), std::move( rock ) ),
61  interface_top_( &interface_top ),
62  interface_base_( &interface_base ),
63  layer_( &layer ),
64  relation_top_( relation_top ),
65  relation_base_( relation_base ),
66  min_thick_( min_thick ),
67  max_thick_( max_thick )
68  {
69  // TODO Should we keep this layer_? [AB]
71  }
72 
74  const StratigraphicUnit& above, const StratigraphicUnit& to_add )
75  {
76  index_t index = get_index( above.get_name() );
77  ringmesh_assert( index != NO_ID );
78  const StratigraphicUnit* ptr_add = &to_add;
79  units_.insert( units_.begin() + index + 1, ptr_add );
80  }
81 
83  {
84  const StratigraphicUnit* ptr_add = &to_add;
85  units_.insert( units_.begin(), ptr_add );
86  }
87 
89  const StratigraphicUnit& to_add )
90  {
91  const StratigraphicUnit* ptr_add = &to_add;
92  units_.push_back( ptr_add );
93  }
94 
96  {
97  index_t index = get_index( unit.get_name() );
98  ringmesh_assert( index != NO_ID );
99  units_.erase( units_.begin() + index );
100  }
101 
103  const StratigraphicUnit& unit ) const
104  {
105  index_t index = get_index( unit.get_name() );
106  ringmesh_assert( index > 0 && index != NO_ID );
107  return units_[index - 1];
108  }
109 
111  const StratigraphicUnit& unit ) const
112  {
113  index_t index = get_index( unit.get_name() );
114  ringmesh_assert( index < units_.size() - 1 && index != NO_ID );
115  return units_[index + 1];
116  }
117 
119  const std::string& name ) const
120  {
121  index_t index = get_index( name );
122  ringmesh_assert( index != NO_ID );
123  return units_[index];
124  }
125 
127  {
128  double sum = 0;
129  for( const StratigraphicUnit* unit : units_ )
130  {
131  sum += unit->get_min_thick();
132  }
133  return sum;
134  }
135 
137  {
138  double sum = 0;
139  for( const StratigraphicUnit* unit : units_ )
140  {
141  sum += unit->get_max_thick();
142  }
143  return sum;
144  }
145 
146  index_t StratigraphicColumn::get_index( const std::string& name ) const
147  {
148  for( auto i : range( units_.size() ) )
149  {
150  if( units_[i]->get_name() == name )
151  {
152  return i;
153  }
154  }
156  return NO_ID;
157  }
158 } // namespace RINGMesh
Manages the RockFeature, which contains a RockType and more informations.
void insert_top_unit(const StratigraphicUnit &to_add)
Declarations of a stratigraphic column, stratigraphic unit, rock features and so on.
const StratigraphicUnit * get_unit(const index_t index) const
void ringmesh_unused(const T &)
Definition: common.h:105
const StratigraphicUnit * get_unit_below(const StratigraphicUnit &unit) const
void remove_unit(const StratigraphicUnit &unit)
StratigraphicUnit()
Constructor of StratigraphicUnit.
virtual const std::string & get_name() const
const StratigraphicUnit * get_unit_above(const StratigraphicUnit &unit) const
Representing Stratigraphic Units Each Unit has a name, two delimiting interfaces with two correspondi...
index_t get_index(const std::string &unit_name) const
#define ringmesh_assert(x)
void insert_base_unit(const StratigraphicUnit &to_add)
UnsubdividedStratigraphicUnit(std::string name, const Interface3D &interface_base, const Interface3D &interface_top, const Layer3D &layer, RELATION relation_top, RELATION relation_base, RockFeature rock, double min_thick, double max_thick)
Classes to build GeoModel from various inputs.
Definition: algorithm.h:48
void insert_unit_below(const StratigraphicUnit &above, const StratigraphicUnit &unit_to_add)
#define ringmesh_assert_not_reached