Salome HOME
Merge with OCC_development_01
[modules/geom.git] / src / GEOMImpl / GEOMImpl_Gen.cxx
1 using namespace std;
2
3 #include "GEOMImpl_Gen.hxx"
4
5 #include "utilities.h"
6 #include "OpUtil.hxx"
7 #include "Utils_ExceptHandlers.hxx"
8
9 #include <TFunction_Driver.hxx>
10 #include <TFunction_DriverTable.hxx>
11
12 #include "GEOMImpl_PointDriver.hxx"
13 #include "GEOMImpl_VectorDriver.hxx"
14 #include "GEOMImpl_LineDriver.hxx"
15 #include "GEOMImpl_PlaneDriver.hxx"
16 #include "GEOMImpl_MarkerDriver.hxx"
17 #include "GEOMImpl_ArcDriver.hxx"
18 #include "GEOMImpl_CircleDriver.hxx"
19 #include "GEOMImpl_EllipseDriver.hxx"
20 #include "GEOMImpl_PolylineDriver.hxx"
21 #include "GEOMImpl_SplineDriver.hxx"
22 #include "GEOMImpl_SketcherDriver.hxx"
23 #include "GEOMImpl_BoxDriver.hxx"
24 #include "GEOMImpl_ConeDriver.hxx"
25 #include "GEOMImpl_CylinderDriver.hxx"
26 #include "GEOMImpl_PrismDriver.hxx"
27 #include "GEOMImpl_PipeDriver.hxx"
28 #include "GEOMImpl_RevolutionDriver.hxx"
29 #include "GEOMImpl_ShapeDriver.hxx"
30 #include "GEOMImpl_BlockDriver.hxx"
31 #include "GEOMImpl_SphereDriver.hxx"
32 #include "GEOMImpl_TorusDriver.hxx"
33 #include "GEOMImpl_BooleanDriver.hxx"
34 #include "GEOMImpl_ChamferDriver.hxx"
35 #include "GEOMImpl_FilletDriver.hxx"
36 #include "GEOMImpl_TranslateDriver.hxx"
37 #include "GEOMImpl_RotateDriver.hxx"
38 #include "GEOMImpl_MirrorDriver.hxx"
39 #include "GEOMImpl_OffsetDriver.hxx"
40 #include "GEOMImpl_ScaleDriver.hxx"
41 #include "GEOMImpl_PositionDriver.hxx"
42 #include "GEOMImpl_PartitionDriver.hxx"
43 #include "GEOMImpl_CopyDriver.hxx"
44 #include "GEOMImpl_ExportDriver.hxx"
45 #include "GEOMImpl_ImportDriver.hxx"
46 #include "GEOMImpl_ArchimedeDriver.hxx"
47 #include "GEOMImpl_HealingDriver.hxx"
48 #include "GEOMImpl_FillingDriver.hxx"
49 #include "GEOMImpl_GlueDriver.hxx"
50 #include "GEOMImpl_MeasureDriver.hxx"
51
52 //=============================================================================
53 /*!
54  *  default constructor:
55  */
56 //=============================================================================
57
58 GEOMImpl_Gen::GEOMImpl_Gen()
59 {
60    MESSAGE("GEOMImpl_Gen::GEOMImpl_Gen");
61    _mapOfBasicOperations.clear();
62
63    // Basic elements
64    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PointDriver::GetID(), new GEOMImpl_PointDriver());
65    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_VectorDriver::GetID(), new GEOMImpl_VectorDriver());
66    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_LineDriver::GetID(), new GEOMImpl_LineDriver());
67    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PlaneDriver::GetID(), new GEOMImpl_PlaneDriver());
68    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MarkerDriver::GetID(), new GEOMImpl_MarkerDriver());
69
70    // Curves
71    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ArcDriver::GetID(), new GEOMImpl_ArcDriver());
72    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CircleDriver::GetID(), new GEOMImpl_CircleDriver());
73    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_EllipseDriver::GetID(), new GEOMImpl_EllipseDriver());
74    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PolylineDriver::GetID(), new GEOMImpl_PolylineDriver());
75    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SplineDriver::GetID(), new GEOMImpl_SplineDriver());
76    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SketcherDriver::GetID(), new GEOMImpl_SketcherDriver());
77
78    // 3D Primitives
79    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BoxDriver::GetID(), new GEOMImpl_BoxDriver());
80    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ConeDriver::GetID(), new GEOMImpl_ConeDriver());
81    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CylinderDriver::GetID(), new GEOMImpl_CylinderDriver());
82    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PrismDriver::GetID(), new GEOMImpl_PrismDriver());
83    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PipeDriver::GetID(), new GEOMImpl_PipeDriver());
84    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_RevolutionDriver::GetID(), new GEOMImpl_RevolutionDriver());
85    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SphereDriver::GetID(), new GEOMImpl_SphereDriver());
86    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_TorusDriver::GetID(), new GEOMImpl_TorusDriver());
87    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FillingDriver::GetID(), new GEOMImpl_FillingDriver());
88
89    // Shapes Operations
90    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ShapeDriver::GetID(), new GEOMImpl_ShapeDriver());
91    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_GlueDriver::GetID(), new GEOMImpl_GlueDriver());
92
93    // Blocks Operations
94    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BlockDriver::GetID(), new GEOMImpl_BlockDriver());
95
96    // Boolean Operations, Partition
97    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BooleanDriver::GetID(), new GEOMImpl_BooleanDriver());
98    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PartitionDriver::GetID(), new GEOMImpl_PartitionDriver());
99
100    // Local Operations
101    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ChamferDriver::GetID(), new GEOMImpl_ChamferDriver());
102    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FilletDriver::GetID(), new GEOMImpl_FilletDriver());
103    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ArchimedeDriver::GetID(), new GEOMImpl_ArchimedeDriver());
104
105    // Geometrical Transformations, Offset, Scale
106    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_TranslateDriver::GetID(), new GEOMImpl_TranslateDriver());
107    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_RotateDriver::GetID(), new GEOMImpl_RotateDriver());
108    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MirrorDriver::GetID(), new GEOMImpl_MirrorDriver());
109    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_OffsetDriver::GetID(), new GEOMImpl_OffsetDriver());
110    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ScaleDriver::GetID(), new GEOMImpl_ScaleDriver());
111    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PositionDriver::GetID(), new GEOMImpl_PositionDriver());
112
113    // Insert Operations (Copy, Import/Export)
114    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CopyDriver::GetID(), new GEOMImpl_CopyDriver());
115    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ImportDriver::GetID(), new GEOMImpl_ImportDriver());
116    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ExportDriver::GetID(), new GEOMImpl_ExportDriver());
117
118    // Shape Healing
119    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_HealingDriver::GetID(), new GEOMImpl_HealingDriver());
120
121    // Measurements
122    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MeasureDriver::GetID(), new GEOMImpl_MeasureDriver());
123
124    SetEngine(this);
125 }
126
127 //=============================================================================
128 /*!
129  *
130  */
131 //=============================================================================
132
133 GEOMImpl_Gen::~GEOMImpl_Gen()
134 {
135   MESSAGE("GEOMImpl_Gen::~GEOMImpl_Gen");
136
137   std::map<int, GEOMImpl_IBasicOperations*>::iterator aBasicIter = _mapOfBasicOperations.begin();
138   for (; aBasicIter != _mapOfBasicOperations.end(); aBasicIter++)
139     delete (*aBasicIter).second;
140
141   std::map<int, GEOMImpl_ITransformOperations*>::iterator aTransformIter = _mapOfTransformOperations.begin();
142   for (; aTransformIter != _mapOfTransformOperations.end(); aTransformIter++)
143     delete (*aTransformIter).second;
144
145   std::map<int, GEOMImpl_I3DPrimOperations*>::iterator a3DPrimIter = _mapOf3DPrimOperations.begin();
146   for (; a3DPrimIter != _mapOf3DPrimOperations.end(); a3DPrimIter++)
147     delete (*a3DPrimIter).second;
148
149   std::map<int, GEOMImpl_IShapesOperations*>::iterator aShapesIter = _mapOfShapesOperations.begin();
150   for (; aShapesIter != _mapOfShapesOperations.end(); aShapesIter++)
151     delete (*aShapesIter).second;
152
153   std::map<int, GEOMImpl_IBlocksOperations*>::iterator aBlocksIter = _mapOfBlocksOperations.begin();
154   for (; aBlocksIter != _mapOfBlocksOperations.end(); aBlocksIter++)
155     delete (*aBlocksIter).second;
156
157   std::map<int, GEOMImpl_IBooleanOperations*>::iterator aBooleanIter = _mapOfBooleanOperations.begin();
158   for (; aBooleanIter != _mapOfBooleanOperations.end(); aBooleanIter++)
159     delete (*aBooleanIter).second;
160
161   std::map<int, GEOMImpl_IHealingOperations*>::iterator aHealingIter = _mapOfHealingOperations.begin();
162   for (; aHealingIter != _mapOfHealingOperations.end(); aHealingIter++)
163     delete (*aHealingIter).second;
164
165   std::map<int, GEOMImpl_ICurvesOperations*>::iterator aCurvesIter = _mapOfCurvesOperations.begin();
166   for (; aCurvesIter != _mapOfCurvesOperations.end(); aCurvesIter++)
167     delete (*aCurvesIter).second;
168
169   std::map<int, GEOMImpl_ILocalOperations*>::iterator aLocalIter = _mapOfLocalOperations.begin();
170   for (; aLocalIter != _mapOfLocalOperations.end(); aLocalIter++)
171     delete (*aLocalIter).second;
172
173   std::map<int, GEOMImpl_IInsertOperations*>::iterator aInsertIter = _mapOfInsertOperations.begin();
174   for (; aInsertIter != _mapOfInsertOperations.end(); aInsertIter++)
175     delete (*aInsertIter).second;
176
177   std::map<int, GEOMImpl_IMeasureOperations*>::iterator aMeasureIter = _mapOfMeasureOperations.begin();
178   for (; aMeasureIter != _mapOfMeasureOperations.end(); aMeasureIter++)
179     delete (*aMeasureIter).second;
180
181   std::map<int, GEOMImpl_IGroupOperations*>::iterator aGroupIter = _mapOfGroupOperations.begin();
182   for (; aGroupIter != _mapOfGroupOperations.end(); aGroupIter++)
183     delete (*aGroupIter).second;
184 }
185
186 //=============================================================================
187 /*!
188  * GetIBasicOperations
189  */
190 //=============================================================================
191 GEOMImpl_IBasicOperations* GEOMImpl_Gen::GetIBasicOperations(int theDocID)
192 {
193   if(_mapOfBasicOperations.find(theDocID) == _mapOfBasicOperations.end()) {
194     _mapOfBasicOperations[theDocID] = new GEOMImpl_IBasicOperations(this, theDocID);
195   }
196
197   return _mapOfBasicOperations[theDocID];
198 }
199
200 //=============================================================================
201 /*!
202  * GetITransformOperations
203  */
204 //=============================================================================
205 GEOMImpl_ITransformOperations* GEOMImpl_Gen::GetITransformOperations(int theDocID)
206 {
207   if(_mapOfTransformOperations.find(theDocID) == _mapOfTransformOperations.end()) {
208     _mapOfTransformOperations[theDocID] = new GEOMImpl_ITransformOperations(this, theDocID);
209   }
210
211   return _mapOfTransformOperations[theDocID];
212 }
213
214 //=============================================================================
215 /*!
216  * GetIBooleanOperations
217  */
218 //=============================================================================
219 GEOMImpl_IBooleanOperations* GEOMImpl_Gen::GetIBooleanOperations(int theDocID)
220 {
221   if(_mapOfBooleanOperations.find(theDocID) == _mapOfBooleanOperations.end()) {
222     _mapOfBooleanOperations[theDocID] = new GEOMImpl_IBooleanOperations(this, theDocID);
223   }
224
225   return _mapOfBooleanOperations[theDocID];
226 }
227
228 //=============================================================================
229 /*!
230  * GetIHealingOperations
231  */
232 //=============================================================================
233 GEOMImpl_IHealingOperations* GEOMImpl_Gen::GetIHealingOperations(int theDocID)
234 {
235   if(_mapOfHealingOperations.find(theDocID) == _mapOfHealingOperations.end()) {
236     _mapOfHealingOperations[theDocID] = new GEOMImpl_IHealingOperations(this, theDocID);
237   }
238
239   return _mapOfHealingOperations[theDocID];
240 }
241
242 //=============================================================================
243 /*!
244  * GetI3DPrimOperations
245  */
246 //=============================================================================
247 GEOMImpl_I3DPrimOperations* GEOMImpl_Gen::GetI3DPrimOperations(int theDocID)
248 {
249   if(_mapOf3DPrimOperations.find(theDocID) == _mapOf3DPrimOperations.end()) {
250     _mapOf3DPrimOperations[theDocID] = new GEOMImpl_I3DPrimOperations(this, theDocID);
251   }
252
253   return _mapOf3DPrimOperations[theDocID];
254 }
255
256 //=============================================================================
257 /*!
258  * GetIShapesOperations
259  */
260 //=============================================================================
261 GEOMImpl_IShapesOperations* GEOMImpl_Gen::GetIShapesOperations(int theDocID)
262 {
263   if(_mapOfShapesOperations.find(theDocID) == _mapOfShapesOperations.end()) {
264     _mapOfShapesOperations[theDocID] = new GEOMImpl_IShapesOperations(this, theDocID);
265   }
266
267   return _mapOfShapesOperations[theDocID];
268 }
269
270 //=============================================================================
271 /*!
272  * GetIBlocksOperations
273  */
274 //=============================================================================
275 GEOMImpl_IBlocksOperations* GEOMImpl_Gen::GetIBlocksOperations(int theDocID)
276 {
277   if(_mapOfBlocksOperations.find(theDocID) == _mapOfBlocksOperations.end()) {
278     _mapOfBlocksOperations[theDocID] = new GEOMImpl_IBlocksOperations(this, theDocID);
279   }
280
281   return _mapOfBlocksOperations[theDocID];
282 }
283
284 //=============================================================================
285 /*!
286  * GetICurvesOperations
287  */
288 //=============================================================================
289 GEOMImpl_ICurvesOperations* GEOMImpl_Gen::GetICurvesOperations(int theDocID)
290 {
291   if(_mapOfCurvesOperations.find(theDocID) == _mapOfCurvesOperations.end()) {
292     _mapOfCurvesOperations[theDocID] = new GEOMImpl_ICurvesOperations(this, theDocID);
293   }
294
295   return _mapOfCurvesOperations[theDocID];
296 }
297
298 //=============================================================================
299 /*!
300  * GetILocalOperations
301  */
302 //=============================================================================
303 GEOMImpl_ILocalOperations* GEOMImpl_Gen::GetILocalOperations(int theDocID)
304 {
305   if(_mapOfLocalOperations.find(theDocID) == _mapOfLocalOperations.end()) {
306     _mapOfLocalOperations[theDocID] = new GEOMImpl_ILocalOperations(this, theDocID);
307   }
308
309   return _mapOfLocalOperations[theDocID];
310 }
311
312 //=============================================================================
313 /*!
314  * GetIInsertOperations
315  */
316 //=============================================================================
317 GEOMImpl_IInsertOperations* GEOMImpl_Gen::GetIInsertOperations(int theDocID)
318 {
319   if(_mapOfInsertOperations.find(theDocID) == _mapOfInsertOperations.end()) {
320     _mapOfInsertOperations[theDocID] = new GEOMImpl_IInsertOperations(this, theDocID);
321   }
322
323   return _mapOfInsertOperations[theDocID];
324 }
325
326 //=============================================================================
327 /*!
328  * GetIMeasureOperations
329  */
330 //=============================================================================
331 GEOMImpl_IMeasureOperations* GEOMImpl_Gen::GetIMeasureOperations(int theDocID)
332 {
333   if(_mapOfMeasureOperations.find(theDocID) == _mapOfMeasureOperations.end()) {
334     _mapOfMeasureOperations[theDocID] = new GEOMImpl_IMeasureOperations(this, theDocID);
335   }
336
337   return _mapOfMeasureOperations[theDocID];
338 }
339
340 //=============================================================================
341 /*!
342  * GetIGroupOperations
343  */
344 //=============================================================================
345 GEOMImpl_IGroupOperations* GEOMImpl_Gen::GetIGroupOperations(int theDocID)
346 {
347   if(_mapOfGroupOperations.find(theDocID) == _mapOfGroupOperations.end()) {
348     _mapOfGroupOperations[theDocID] = new GEOMImpl_IGroupOperations(this, theDocID);
349   }
350
351   return _mapOfGroupOperations[theDocID];
352 }