GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
MeasurementSurfaceStore.cc
1 
2 #include "gearsurf/MeasurementSurfaceStore.h"
3 
4 #include <sstream>
5 #include <vector>
6 #include <algorithm>
7 
8 #include "gear/GEAR.h"
9 
10 #include "gearsurf/MeasurementSurface.h"
11 #include "gearsurf/BoundaryRectangle.h"
12 #include "gearsurf/BoundaryTrapezoid.h"
13 
14 #include "gearsurf/CartesianCoordinateSystem.h"
15 
16 
17 
18 namespace gear{
19 
21 
22  _store_filled = right._store_filled;
23 
24  _measurement_surface_map = right._measurement_surface_map;
25 
26  _fillerName = right._fillerName;
27 
28  }
29 
30 
32 
33  ms_map_it it = _measurement_surface_map.begin();
34  std::vector<MeasurementSurface*> deleted_objects;
35 
36  for( ; it!=_measurement_surface_map.end(); ++it)
37 
38  if( std::find( deleted_objects.begin(), deleted_objects.end(), (*it).second ) != deleted_objects.end() ) {
39  delete (*it).second ;
40  deleted_objects.push_back((*it).second) ;
41  }
42  }
43 
45 
46  ms_map_it it = _measurement_surface_map.find(ID) ;
47 
48  if ( it == _measurement_surface_map.end() ) {
49 
50  std::stringstream s;
51  s << "GetMeasurementSurface: The surface with ID " << ID << " is not in the map!";
52  gear::Exception exp( s.str() ) ;
53 
54  throw exp ;
55  }
56  else {
57  return (*it).second ;
58  }
59 
60  }
61 
62 
63  void MeasurementSurfaceStore::addMeasurementSurface(MeasurementSurface* ms) {
64 
65  int ID = ms->getID();
66 
67  ms_map_it it = _measurement_surface_map.find(ID) ;
68 
69 
70  if ( it != _measurement_surface_map.end() ) {
71 
72  std::stringstream s;
73  s << "addMeasurementSurface: The surface with ID " << ID << " can't be added as it already is in the map!";
74  gear::Exception exp( s.str() ) ;
75  throw exp;
76 
77  }
78  else {
79  _measurement_surface_map[ID] = ms ;
80  }
81  }
82 
83 
85 
86  if ( _store_filled == false ) {
87  gear::Exception exp( "MeasurementSurfaceStore::getFillerName(): Store has not yet been filled!" ) ;
88  throw exp ;
89  }
90 
91  return _fillerName;
92 
93  }
94 
96 
97  if( _store_filled ) {
98 
99  std::stringstream s;
100  s << "FillStore: Store already filled with MeasurementSurfaceStoreFiller " << _fillerName ;
101  gear::Exception exp( s.str() ) ;
102 
103  throw exp ;
104 
105  }
106  else {
107 
108  _fillerName = filler->getName();
109  std::vector<MeasurementSurface*> surface_list;
110  filler->getMeasurementSurfaces(surface_list);
111 
112  std::vector<MeasurementSurface*>::iterator it;
113 
114  for (it = surface_list.begin(); it!=surface_list.end(); ++it) {
115  this->addMeasurementSurface(*it);
116  }
117 
118  _store_filled = true;
119 
120  }
121 
122  }
123 
124 
125 } // end of gear namespace
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
Base exception class for GEAR - all other exceptions extend this.
Definition: GEAR.h:41
MeasurementSurface const * GetMeasurementSurface(int ID) const
Get Measurement Surface via ID.
MeasurementSurfaceStore()
Default Constructor.
void FillStore(MeasurementSurfaceStoreFiller *filler)
Fill Store.
std::string getFillerName() const
Get the Name of the Filler used to fill the store.