Salome HOME
Merge from BR_V7_main_Field branch (02/09/2013)
[modules/geom.git] / src / GEOMImpl / GEOMImpl_Gen.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifdef WNT
24 #pragma warning( disable:4786 )
25 #endif
26
27 #include <Standard_Stream.hxx>
28
29 #include <GEOMImpl_Gen.hxx>
30
31 #include "utilities.h"
32 #include <OpUtil.hxx>
33 #include <Utils_ExceptHandlers.hxx>
34
35 #include <TFunction_Driver.hxx>
36 #include <TFunction_DriverTable.hxx>
37
38 #include <GEOMImpl_PointDriver.hxx>
39 #include <GEOMImpl_VectorDriver.hxx>
40 #include <GEOMImpl_LineDriver.hxx>
41 #include <GEOMImpl_PlaneDriver.hxx>
42 #include <GEOMImpl_MarkerDriver.hxx>
43 #include <GEOMImpl_ArcDriver.hxx>
44 #include <GEOMImpl_CircleDriver.hxx>
45 #include <GEOMImpl_EllipseDriver.hxx>
46 #include <GEOMImpl_PolylineDriver.hxx>
47 #include <GEOMImpl_SplineDriver.hxx>
48 #include <GEOMImpl_SketcherDriver.hxx>
49 #include <GEOMImpl_3DSketcherDriver.hxx>
50 #include <GEOMImpl_BoxDriver.hxx>
51 #include <GEOMImpl_FaceDriver.hxx>
52 #include <GEOMImpl_DiskDriver.hxx>
53 #include <GEOMImpl_ConeDriver.hxx>
54 #include <GEOMImpl_CylinderDriver.hxx>
55 #include <GEOMImpl_PrismDriver.hxx>
56 #include <GEOMImpl_PipeDriver.hxx>
57 #include <GEOMImpl_PipePathDriver.hxx>
58 #include <GEOMImpl_ThruSectionsDriver.hxx>
59 #include <GEOMImpl_RevolutionDriver.hxx>
60 #include <GEOMImpl_ShapeDriver.hxx>
61 #include <GEOMImpl_BlockDriver.hxx>
62 #include <GEOMImpl_SphereDriver.hxx>
63 #include <GEOMImpl_TorusDriver.hxx>
64 #include <GEOMImpl_BooleanDriver.hxx>
65 #include <GEOMImpl_ChamferDriver.hxx>
66 #include <GEOMImpl_FilletDriver.hxx>
67 #include <GEOMImpl_Fillet1dDriver.hxx>
68 #include <GEOMImpl_Fillet2dDriver.hxx>
69 #include <GEOMImpl_TranslateDriver.hxx>
70 #include <GEOMImpl_RotateDriver.hxx>
71 #include <GEOMImpl_MirrorDriver.hxx>
72 #include <GEOMImpl_ProjectionDriver.hxx>
73 #include <GEOMImpl_OffsetDriver.hxx>
74 #include <GEOMImpl_ScaleDriver.hxx>
75 #include <GEOMImpl_PositionDriver.hxx>
76 #include <GEOMImpl_PartitionDriver.hxx>
77 #include <GEOMImpl_CopyDriver.hxx>
78 #include <GEOMImpl_ExportDriver.hxx>
79 #include <GEOMImpl_ImportDriver.hxx>
80 #include <GEOMImpl_ArchimedeDriver.hxx>
81 #include <GEOMImpl_HealingDriver.hxx>
82 #include <GEOMImpl_FillingDriver.hxx>
83 #include <GEOMImpl_GlueDriver.hxx>
84 #include <GEOMImpl_MeasureDriver.hxx>
85 #include <GEOMImpl_FieldDriver.hxx>
86 #include <GEOMImpl_XAODriver.hxx>
87
88 //=============================================================================
89 /*!
90  *  default constructor:
91  */
92 //=============================================================================
93
94 GEOMImpl_Gen::GEOMImpl_Gen()
95 {
96    MESSAGE("GEOMImpl_Gen::GEOMImpl_Gen");
97    _mapOfBasicOperations.clear();
98
99    // Basic elements
100    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PointDriver::GetID(), new GEOMImpl_PointDriver());
101    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_VectorDriver::GetID(), new GEOMImpl_VectorDriver());
102    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_LineDriver::GetID(), new GEOMImpl_LineDriver());
103    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PlaneDriver::GetID(), new GEOMImpl_PlaneDriver());
104    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MarkerDriver::GetID(), new GEOMImpl_MarkerDriver());
105
106    // Curves
107    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ArcDriver::GetID(), new GEOMImpl_ArcDriver());
108    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CircleDriver::GetID(), new GEOMImpl_CircleDriver());
109    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_EllipseDriver::GetID(), new GEOMImpl_EllipseDriver());
110    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PolylineDriver::GetID(), new GEOMImpl_PolylineDriver());
111    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SplineDriver::GetID(), new GEOMImpl_SplineDriver());
112    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SketcherDriver::GetID(), new GEOMImpl_SketcherDriver());
113    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_3DSketcherDriver::GetID(), new GEOMImpl_3DSketcherDriver());
114
115    // 3D Primitives
116    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BoxDriver::GetID(), new GEOMImpl_BoxDriver());
117    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FaceDriver::GetID(), new GEOMImpl_FaceDriver());
118    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_DiskDriver::GetID(), new GEOMImpl_DiskDriver());
119    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ConeDriver::GetID(), new GEOMImpl_ConeDriver());
120    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CylinderDriver::GetID(), new GEOMImpl_CylinderDriver());
121    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PrismDriver::GetID(), new GEOMImpl_PrismDriver());
122    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PipeDriver::GetID(), new GEOMImpl_PipeDriver());
123    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PipePathDriver::GetID(), new GEOMImpl_PipePathDriver());
124    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ThruSectionsDriver::GetID(), new GEOMImpl_ThruSectionsDriver());
125    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_RevolutionDriver::GetID(), new GEOMImpl_RevolutionDriver());
126    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SphereDriver::GetID(), new GEOMImpl_SphereDriver());
127    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_TorusDriver::GetID(), new GEOMImpl_TorusDriver());
128    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FillingDriver::GetID(), new GEOMImpl_FillingDriver());
129
130    // Shapes Operations
131    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ShapeDriver::GetID(), new GEOMImpl_ShapeDriver());
132    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_GlueDriver::GetID(), new GEOMImpl_GlueDriver());
133
134    // Blocks Operations
135    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BlockDriver::GetID(), new GEOMImpl_BlockDriver());
136
137    // Boolean Operations, Partition
138    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BooleanDriver::GetID(), new GEOMImpl_BooleanDriver());
139    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PartitionDriver::GetID(), new GEOMImpl_PartitionDriver());
140
141    // Local Operations
142    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ChamferDriver::GetID(), new GEOMImpl_ChamferDriver());
143    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FilletDriver::GetID(), new GEOMImpl_FilletDriver());
144    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_Fillet1dDriver::GetID(), new GEOMImpl_Fillet1dDriver());
145    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_Fillet2dDriver::GetID(), new GEOMImpl_Fillet2dDriver());
146    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ArchimedeDriver::GetID(), new GEOMImpl_ArchimedeDriver());
147
148    // Geometrical Transformations, Offset, Scale
149    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_TranslateDriver::GetID(), new GEOMImpl_TranslateDriver());
150    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_RotateDriver::GetID(), new GEOMImpl_RotateDriver());
151    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MirrorDriver::GetID(), new GEOMImpl_MirrorDriver());
152    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ProjectionDriver::GetID(), new GEOMImpl_ProjectionDriver());
153    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_OffsetDriver::GetID(), new GEOMImpl_OffsetDriver());
154    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ScaleDriver::GetID(), new GEOMImpl_ScaleDriver());
155    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PositionDriver::GetID(), new GEOMImpl_PositionDriver());
156
157    // Insert Operations (Copy, Import/Export)
158    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CopyDriver::GetID(), new GEOMImpl_CopyDriver());
159    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ImportDriver::GetID(), new GEOMImpl_ImportDriver());
160    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ExportDriver::GetID(), new GEOMImpl_ExportDriver());
161
162    // Shape Healing
163    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_HealingDriver::GetID(), new GEOMImpl_HealingDriver());
164
165    // Measurements
166    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MeasureDriver::GetID(), new GEOMImpl_MeasureDriver());
167
168    // Field
169    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FieldDriver::GetID(), new GEOMImpl_FieldDriver());
170
171    // XAO operations
172    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_XAODriver::GetID(), new GEOMImpl_XAODriver());
173
174    /*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/
175
176    SetEngine(this);
177 }
178
179 //=============================================================================
180 /*!
181  *
182  */
183 //=============================================================================
184
185 GEOMImpl_Gen::~GEOMImpl_Gen()
186 {
187   MESSAGE("GEOMImpl_Gen::~GEOMImpl_Gen");
188
189   std::map<int, GEOMImpl_IBasicOperations*>::iterator aBasicIter = _mapOfBasicOperations.begin();
190   for (; aBasicIter != _mapOfBasicOperations.end(); aBasicIter++)
191     delete (*aBasicIter).second;
192
193   std::map<int, GEOMImpl_ITransformOperations*>::iterator aTransformIter = _mapOfTransformOperations.begin();
194   for (; aTransformIter != _mapOfTransformOperations.end(); aTransformIter++)
195     delete (*aTransformIter).second;
196
197   std::map<int, GEOMImpl_I3DPrimOperations*>::iterator a3DPrimIter = _mapOf3DPrimOperations.begin();
198   for (; a3DPrimIter != _mapOf3DPrimOperations.end(); a3DPrimIter++)
199     delete (*a3DPrimIter).second;
200
201   std::map<int, GEOMImpl_IShapesOperations*>::iterator aShapesIter = _mapOfShapesOperations.begin();
202   for (; aShapesIter != _mapOfShapesOperations.end(); aShapesIter++)
203     delete (*aShapesIter).second;
204
205   std::map<int, GEOMImpl_IBlocksOperations*>::iterator aBlocksIter = _mapOfBlocksOperations.begin();
206   for (; aBlocksIter != _mapOfBlocksOperations.end(); aBlocksIter++)
207     delete (*aBlocksIter).second;
208
209   std::map<int, GEOMImpl_IBooleanOperations*>::iterator aBooleanIter = _mapOfBooleanOperations.begin();
210   for (; aBooleanIter != _mapOfBooleanOperations.end(); aBooleanIter++)
211     delete (*aBooleanIter).second;
212
213   std::map<int, GEOMImpl_IHealingOperations*>::iterator aHealingIter = _mapOfHealingOperations.begin();
214   for (; aHealingIter != _mapOfHealingOperations.end(); aHealingIter++)
215     delete (*aHealingIter).second;
216
217   std::map<int, GEOMImpl_ICurvesOperations*>::iterator aCurvesIter = _mapOfCurvesOperations.begin();
218   for (; aCurvesIter != _mapOfCurvesOperations.end(); aCurvesIter++)
219     delete (*aCurvesIter).second;
220
221   std::map<int, GEOMImpl_ILocalOperations*>::iterator aLocalIter = _mapOfLocalOperations.begin();
222   for (; aLocalIter != _mapOfLocalOperations.end(); aLocalIter++)
223     delete (*aLocalIter).second;
224
225   std::map<int, GEOMImpl_IInsertOperations*>::iterator aInsertIter = _mapOfInsertOperations.begin();
226   for (; aInsertIter != _mapOfInsertOperations.end(); aInsertIter++)
227     delete (*aInsertIter).second;
228
229   std::map<int, GEOMImpl_IMeasureOperations*>::iterator aMeasureIter = _mapOfMeasureOperations.begin();
230   for (; aMeasureIter != _mapOfMeasureOperations.end(); aMeasureIter++)
231     delete (*aMeasureIter).second;
232
233   std::map<int, GEOMImpl_IGroupOperations*>::iterator aGroupIter = _mapOfGroupOperations.begin();
234   for (; aGroupIter != _mapOfGroupOperations.end(); aGroupIter++)
235     delete (*aGroupIter).second;
236
237   std::map<int, GEOMImpl_IFieldOperations*>::iterator aFieldIter = _mapOfFieldOperations.begin();
238   for (; aFieldIter != _mapOfFieldOperations.end(); aFieldIter++)
239     delete (*aFieldIter).second;
240 }
241
242 //=============================================================================
243 /*!
244  * GetIBasicOperations
245  */
246 //=============================================================================
247 GEOMImpl_IBasicOperations* GEOMImpl_Gen::GetIBasicOperations(int theDocID)
248 {
249   if(_mapOfBasicOperations.find(theDocID) == _mapOfBasicOperations.end()) {
250     _mapOfBasicOperations[theDocID] = new GEOMImpl_IBasicOperations(this, theDocID);
251   }
252
253   return _mapOfBasicOperations[theDocID];
254 }
255
256 //=============================================================================
257 /*!
258  * GetITransformOperations
259  */
260 //=============================================================================
261 GEOMImpl_ITransformOperations* GEOMImpl_Gen::GetITransformOperations(int theDocID)
262 {
263   if(_mapOfTransformOperations.find(theDocID) == _mapOfTransformOperations.end()) {
264     _mapOfTransformOperations[theDocID] = new GEOMImpl_ITransformOperations(this, theDocID);
265   }
266
267   return _mapOfTransformOperations[theDocID];
268 }
269
270 //=============================================================================
271 /*!
272  * GetIBooleanOperations
273  */
274 //=============================================================================
275 GEOMImpl_IBooleanOperations* GEOMImpl_Gen::GetIBooleanOperations(int theDocID)
276 {
277   if(_mapOfBooleanOperations.find(theDocID) == _mapOfBooleanOperations.end()) {
278     _mapOfBooleanOperations[theDocID] = new GEOMImpl_IBooleanOperations(this, theDocID);
279   }
280
281   return _mapOfBooleanOperations[theDocID];
282 }
283
284 //=============================================================================
285 /*!
286  * GetIHealingOperations
287  */
288 //=============================================================================
289 GEOMImpl_IHealingOperations* GEOMImpl_Gen::GetIHealingOperations(int theDocID)
290 {
291   if(_mapOfHealingOperations.find(theDocID) == _mapOfHealingOperations.end()) {
292     _mapOfHealingOperations[theDocID] = new GEOMImpl_IHealingOperations(this, theDocID);
293   }
294
295   return _mapOfHealingOperations[theDocID];
296 }
297
298 //=============================================================================
299 /*!
300  * GetI3DPrimOperations
301  */
302 //=============================================================================
303 GEOMImpl_I3DPrimOperations* GEOMImpl_Gen::GetI3DPrimOperations(int theDocID)
304 {
305   if(_mapOf3DPrimOperations.find(theDocID) == _mapOf3DPrimOperations.end()) {
306     _mapOf3DPrimOperations[theDocID] = new GEOMImpl_I3DPrimOperations(this, theDocID);
307   }
308
309   return _mapOf3DPrimOperations[theDocID];
310 }
311
312 //=============================================================================
313 /*!
314  * GetIShapesOperations
315  */
316 //=============================================================================
317 GEOMImpl_IShapesOperations* GEOMImpl_Gen::GetIShapesOperations(int theDocID)
318 {
319   if(_mapOfShapesOperations.find(theDocID) == _mapOfShapesOperations.end()) {
320     _mapOfShapesOperations[theDocID] = new GEOMImpl_IShapesOperations(this, theDocID);
321   }
322
323   return _mapOfShapesOperations[theDocID];
324 }
325
326 //=============================================================================
327 /*!
328  * GetIBlocksOperations
329  */
330 //=============================================================================
331 GEOMImpl_IBlocksOperations* GEOMImpl_Gen::GetIBlocksOperations(int theDocID)
332 {
333   if(_mapOfBlocksOperations.find(theDocID) == _mapOfBlocksOperations.end()) {
334     _mapOfBlocksOperations[theDocID] = new GEOMImpl_IBlocksOperations(this, theDocID);
335   }
336
337   return _mapOfBlocksOperations[theDocID];
338 }
339
340 //=============================================================================
341 /*!
342  * GetICurvesOperations
343  */
344 //=============================================================================
345 GEOMImpl_ICurvesOperations* GEOMImpl_Gen::GetICurvesOperations(int theDocID)
346 {
347   if(_mapOfCurvesOperations.find(theDocID) == _mapOfCurvesOperations.end()) {
348     _mapOfCurvesOperations[theDocID] = new GEOMImpl_ICurvesOperations(this, theDocID);
349   }
350
351   return _mapOfCurvesOperations[theDocID];
352 }
353
354 //=============================================================================
355 /*!
356  * GetILocalOperations
357  */
358 //=============================================================================
359 GEOMImpl_ILocalOperations* GEOMImpl_Gen::GetILocalOperations(int theDocID)
360 {
361   if(_mapOfLocalOperations.find(theDocID) == _mapOfLocalOperations.end()) {
362     _mapOfLocalOperations[theDocID] = new GEOMImpl_ILocalOperations(this, theDocID);
363   }
364
365   return _mapOfLocalOperations[theDocID];
366 }
367
368 //=============================================================================
369 /*!
370  * GetIInsertOperations
371  */
372 //=============================================================================
373 GEOMImpl_IInsertOperations* GEOMImpl_Gen::GetIInsertOperations(int theDocID)
374 {
375   if(_mapOfInsertOperations.find(theDocID) == _mapOfInsertOperations.end()) {
376     _mapOfInsertOperations[theDocID] = new GEOMImpl_IInsertOperations(this, theDocID);
377   }
378
379   return _mapOfInsertOperations[theDocID];
380 }
381
382 //=============================================================================
383 /*!
384  * GetIMeasureOperations
385  */
386 //=============================================================================
387 GEOMImpl_IMeasureOperations* GEOMImpl_Gen::GetIMeasureOperations(int theDocID)
388 {
389   if(_mapOfMeasureOperations.find(theDocID) == _mapOfMeasureOperations.end()) {
390     _mapOfMeasureOperations[theDocID] = new GEOMImpl_IMeasureOperations(this, theDocID);
391   }
392
393   return _mapOfMeasureOperations[theDocID];
394 }
395
396 //=============================================================================
397 /*!
398  * GetIGroupOperations
399  */
400 //=============================================================================
401 GEOMImpl_IGroupOperations* GEOMImpl_Gen::GetIGroupOperations(int theDocID)
402 {
403   if(_mapOfGroupOperations.find(theDocID) == _mapOfGroupOperations.end()) {
404     _mapOfGroupOperations[theDocID] = new GEOMImpl_IGroupOperations(this, theDocID);
405   }
406
407   return _mapOfGroupOperations[theDocID];
408 }
409
410 //=============================================================================
411 /*!
412  * GetIFieldOperations
413  */
414 //=============================================================================
415 GEOMImpl_IFieldOperations* GEOMImpl_Gen::GetIFieldOperations(int theDocID)
416 {
417   if(_mapOfFieldOperations.find(theDocID) == _mapOfFieldOperations.end()) {
418     _mapOfFieldOperations[theDocID] = new GEOMImpl_IFieldOperations(this, theDocID);
419   }
420
421   return _mapOfFieldOperations[theDocID];
422 }