Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/geom.git] / src / GEOMImpl / GEOMImpl_Gen.cxx
1 // Copyright (C) 2007-2012  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_ThruSectionsDriver.hxx>
58 #include <GEOMImpl_RevolutionDriver.hxx>
59 #include <GEOMImpl_ShapeDriver.hxx>
60 #include <GEOMImpl_BlockDriver.hxx>
61 #include <GEOMImpl_SphereDriver.hxx>
62 #include <GEOMImpl_TorusDriver.hxx>
63 #include <GEOMImpl_BooleanDriver.hxx>
64 #include <GEOMImpl_ChamferDriver.hxx>
65 #include <GEOMImpl_FilletDriver.hxx>
66 #include <GEOMImpl_Fillet1dDriver.hxx>
67 #include <GEOMImpl_Fillet2dDriver.hxx>
68 #include <GEOMImpl_TranslateDriver.hxx>
69 #include <GEOMImpl_RotateDriver.hxx>
70 #include <GEOMImpl_MirrorDriver.hxx>
71 #include <GEOMImpl_ProjectionDriver.hxx>
72 #include <GEOMImpl_OffsetDriver.hxx>
73 #include <GEOMImpl_ScaleDriver.hxx>
74 #include <GEOMImpl_PositionDriver.hxx>
75 #include <GEOMImpl_PartitionDriver.hxx>
76 #include <GEOMImpl_CopyDriver.hxx>
77 #include <GEOMImpl_ExportDriver.hxx>
78 #include <GEOMImpl_ImportDriver.hxx>
79 #include <GEOMImpl_ArchimedeDriver.hxx>
80 #include <GEOMImpl_HealingDriver.hxx>
81 #include <GEOMImpl_FillingDriver.hxx>
82 #include <GEOMImpl_GlueDriver.hxx>
83 #include <GEOMImpl_MeasureDriver.hxx>
84 // Advanced operations
85 #include <GEOMImpl_PipeTShapeDriver.hxx>
86 #include <GEOMImpl_DividedDiskDriver.hxx>
87 // #include <GEOMImpl_DividedCylinderDriver.hxx>
88 /*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/
89
90 //=============================================================================
91 /*!
92  *  default constructor:
93  */
94 //=============================================================================
95
96 GEOMImpl_Gen::GEOMImpl_Gen()
97 {
98    MESSAGE("GEOMImpl_Gen::GEOMImpl_Gen");
99    _mapOfBasicOperations.clear();
100
101    // Basic elements
102    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PointDriver::GetID(), new GEOMImpl_PointDriver());
103    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_VectorDriver::GetID(), new GEOMImpl_VectorDriver());
104    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_LineDriver::GetID(), new GEOMImpl_LineDriver());
105    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PlaneDriver::GetID(), new GEOMImpl_PlaneDriver());
106    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MarkerDriver::GetID(), new GEOMImpl_MarkerDriver());
107
108    // Curves
109    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ArcDriver::GetID(), new GEOMImpl_ArcDriver());
110    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CircleDriver::GetID(), new GEOMImpl_CircleDriver());
111    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_EllipseDriver::GetID(), new GEOMImpl_EllipseDriver());
112    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PolylineDriver::GetID(), new GEOMImpl_PolylineDriver());
113    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SplineDriver::GetID(), new GEOMImpl_SplineDriver());
114    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SketcherDriver::GetID(), new GEOMImpl_SketcherDriver());
115    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_3DSketcherDriver::GetID(), new GEOMImpl_3DSketcherDriver());
116
117    // 3D Primitives
118    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BoxDriver::GetID(), new GEOMImpl_BoxDriver());
119    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FaceDriver::GetID(), new GEOMImpl_FaceDriver());
120    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_DiskDriver::GetID(), new GEOMImpl_DiskDriver());
121    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ConeDriver::GetID(), new GEOMImpl_ConeDriver());
122    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CylinderDriver::GetID(), new GEOMImpl_CylinderDriver());
123    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PrismDriver::GetID(), new GEOMImpl_PrismDriver());
124    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PipeDriver::GetID(), new GEOMImpl_PipeDriver());
125    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ThruSectionsDriver::GetID(), new GEOMImpl_ThruSectionsDriver());
126    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_RevolutionDriver::GetID(), new GEOMImpl_RevolutionDriver());
127    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SphereDriver::GetID(), new GEOMImpl_SphereDriver());
128    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_TorusDriver::GetID(), new GEOMImpl_TorusDriver());
129    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FillingDriver::GetID(), new GEOMImpl_FillingDriver());
130
131    // Shapes Operations
132    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ShapeDriver::GetID(), new GEOMImpl_ShapeDriver());
133    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_GlueDriver::GetID(), new GEOMImpl_GlueDriver());
134
135    // Blocks Operations
136    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BlockDriver::GetID(), new GEOMImpl_BlockDriver());
137
138    // Boolean Operations, Partition
139    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BooleanDriver::GetID(), new GEOMImpl_BooleanDriver());
140    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PartitionDriver::GetID(), new GEOMImpl_PartitionDriver());
141
142    // Local Operations
143    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ChamferDriver::GetID(), new GEOMImpl_ChamferDriver());
144    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FilletDriver::GetID(), new GEOMImpl_FilletDriver());
145    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_Fillet1dDriver::GetID(), new GEOMImpl_Fillet1dDriver());
146    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_Fillet2dDriver::GetID(), new GEOMImpl_Fillet2dDriver());
147    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ArchimedeDriver::GetID(), new GEOMImpl_ArchimedeDriver());
148
149    // Geometrical Transformations, Offset, Scale
150    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_TranslateDriver::GetID(), new GEOMImpl_TranslateDriver());
151    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_RotateDriver::GetID(), new GEOMImpl_RotateDriver());
152    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MirrorDriver::GetID(), new GEOMImpl_MirrorDriver());
153    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ProjectionDriver::GetID(), new GEOMImpl_ProjectionDriver());
154    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_OffsetDriver::GetID(), new GEOMImpl_OffsetDriver());
155    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ScaleDriver::GetID(), new GEOMImpl_ScaleDriver());
156    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PositionDriver::GetID(), new GEOMImpl_PositionDriver());
157
158    // Insert Operations (Copy, Import/Export)
159    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CopyDriver::GetID(), new GEOMImpl_CopyDriver());
160    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ImportDriver::GetID(), new GEOMImpl_ImportDriver());
161    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ExportDriver::GetID(), new GEOMImpl_ExportDriver());
162
163    // Shape Healing
164    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_HealingDriver::GetID(), new GEOMImpl_HealingDriver());
165
166    // Measurements
167    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MeasureDriver::GetID(), new GEOMImpl_MeasureDriver());
168
169    // Advanced operations
170    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PipeTShapeDriver::GetID(), new GEOMImpl_PipeTShapeDriver());
171    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_DividedDiskDriver::GetID(), new GEOMImpl_DividedDiskDriver());
172 //    TFunction_DriverTable::Get()->AddDriver(GEOMImpl_DividedCylinderDriver::GetID(), new GEOMImpl_DividedCylinderDriver());
173    /*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/
174
175    SetEngine(this);
176 }
177
178 //=============================================================================
179 /*!
180  *
181  */
182 //=============================================================================
183
184 GEOMImpl_Gen::~GEOMImpl_Gen()
185 {
186   MESSAGE("GEOMImpl_Gen::~GEOMImpl_Gen");
187
188   std::map<int, GEOMImpl_IBasicOperations*>::iterator aBasicIter = _mapOfBasicOperations.begin();
189   for (; aBasicIter != _mapOfBasicOperations.end(); aBasicIter++)
190     delete (*aBasicIter).second;
191
192   std::map<int, GEOMImpl_ITransformOperations*>::iterator aTransformIter = _mapOfTransformOperations.begin();
193   for (; aTransformIter != _mapOfTransformOperations.end(); aTransformIter++)
194     delete (*aTransformIter).second;
195
196   std::map<int, GEOMImpl_I3DPrimOperations*>::iterator a3DPrimIter = _mapOf3DPrimOperations.begin();
197   for (; a3DPrimIter != _mapOf3DPrimOperations.end(); a3DPrimIter++)
198     delete (*a3DPrimIter).second;
199
200   std::map<int, GEOMImpl_IShapesOperations*>::iterator aShapesIter = _mapOfShapesOperations.begin();
201   for (; aShapesIter != _mapOfShapesOperations.end(); aShapesIter++)
202     delete (*aShapesIter).second;
203
204   std::map<int, GEOMImpl_IBlocksOperations*>::iterator aBlocksIter = _mapOfBlocksOperations.begin();
205   for (; aBlocksIter != _mapOfBlocksOperations.end(); aBlocksIter++)
206     delete (*aBlocksIter).second;
207
208   std::map<int, GEOMImpl_IBooleanOperations*>::iterator aBooleanIter = _mapOfBooleanOperations.begin();
209   for (; aBooleanIter != _mapOfBooleanOperations.end(); aBooleanIter++)
210     delete (*aBooleanIter).second;
211
212   std::map<int, GEOMImpl_IHealingOperations*>::iterator aHealingIter = _mapOfHealingOperations.begin();
213   for (; aHealingIter != _mapOfHealingOperations.end(); aHealingIter++)
214     delete (*aHealingIter).second;
215
216   std::map<int, GEOMImpl_ICurvesOperations*>::iterator aCurvesIter = _mapOfCurvesOperations.begin();
217   for (; aCurvesIter != _mapOfCurvesOperations.end(); aCurvesIter++)
218     delete (*aCurvesIter).second;
219
220   std::map<int, GEOMImpl_ILocalOperations*>::iterator aLocalIter = _mapOfLocalOperations.begin();
221   for (; aLocalIter != _mapOfLocalOperations.end(); aLocalIter++)
222     delete (*aLocalIter).second;
223
224   std::map<int, GEOMImpl_IInsertOperations*>::iterator aInsertIter = _mapOfInsertOperations.begin();
225   for (; aInsertIter != _mapOfInsertOperations.end(); aInsertIter++)
226     delete (*aInsertIter).second;
227
228   std::map<int, GEOMImpl_IMeasureOperations*>::iterator aMeasureIter = _mapOfMeasureOperations.begin();
229   for (; aMeasureIter != _mapOfMeasureOperations.end(); aMeasureIter++)
230     delete (*aMeasureIter).second;
231
232   std::map<int, GEOMImpl_IGroupOperations*>::iterator aGroupIter = _mapOfGroupOperations.begin();
233   for (; aGroupIter != _mapOfGroupOperations.end(); aGroupIter++)
234     delete (*aGroupIter).second;
235 }
236
237 //=============================================================================
238 /*!
239  * GetIBasicOperations
240  */
241 //=============================================================================
242 GEOMImpl_IBasicOperations* GEOMImpl_Gen::GetIBasicOperations(int theDocID)
243 {
244   if(_mapOfBasicOperations.find(theDocID) == _mapOfBasicOperations.end()) {
245     _mapOfBasicOperations[theDocID] = new GEOMImpl_IBasicOperations(this, theDocID);
246   }
247
248   return _mapOfBasicOperations[theDocID];
249 }
250
251 //=============================================================================
252 /*!
253  * GetITransformOperations
254  */
255 //=============================================================================
256 GEOMImpl_ITransformOperations* GEOMImpl_Gen::GetITransformOperations(int theDocID)
257 {
258   if(_mapOfTransformOperations.find(theDocID) == _mapOfTransformOperations.end()) {
259     _mapOfTransformOperations[theDocID] = new GEOMImpl_ITransformOperations(this, theDocID);
260   }
261
262   return _mapOfTransformOperations[theDocID];
263 }
264
265 //=============================================================================
266 /*!
267  * GetIBooleanOperations
268  */
269 //=============================================================================
270 GEOMImpl_IBooleanOperations* GEOMImpl_Gen::GetIBooleanOperations(int theDocID)
271 {
272   if(_mapOfBooleanOperations.find(theDocID) == _mapOfBooleanOperations.end()) {
273     _mapOfBooleanOperations[theDocID] = new GEOMImpl_IBooleanOperations(this, theDocID);
274   }
275
276   return _mapOfBooleanOperations[theDocID];
277 }
278
279 //=============================================================================
280 /*!
281  * GetIHealingOperations
282  */
283 //=============================================================================
284 GEOMImpl_IHealingOperations* GEOMImpl_Gen::GetIHealingOperations(int theDocID)
285 {
286   if(_mapOfHealingOperations.find(theDocID) == _mapOfHealingOperations.end()) {
287     _mapOfHealingOperations[theDocID] = new GEOMImpl_IHealingOperations(this, theDocID);
288   }
289
290   return _mapOfHealingOperations[theDocID];
291 }
292
293 //=============================================================================
294 /*!
295  * GetI3DPrimOperations
296  */
297 //=============================================================================
298 GEOMImpl_I3DPrimOperations* GEOMImpl_Gen::GetI3DPrimOperations(int theDocID)
299 {
300   if(_mapOf3DPrimOperations.find(theDocID) == _mapOf3DPrimOperations.end()) {
301     _mapOf3DPrimOperations[theDocID] = new GEOMImpl_I3DPrimOperations(this, theDocID);
302   }
303
304   return _mapOf3DPrimOperations[theDocID];
305 }
306
307 //=============================================================================
308 /*!
309  * GetIShapesOperations
310  */
311 //=============================================================================
312 GEOMImpl_IShapesOperations* GEOMImpl_Gen::GetIShapesOperations(int theDocID)
313 {
314   if(_mapOfShapesOperations.find(theDocID) == _mapOfShapesOperations.end()) {
315     _mapOfShapesOperations[theDocID] = new GEOMImpl_IShapesOperations(this, theDocID);
316   }
317
318   return _mapOfShapesOperations[theDocID];
319 }
320
321 //=============================================================================
322 /*!
323  * GetIBlocksOperations
324  */
325 //=============================================================================
326 GEOMImpl_IBlocksOperations* GEOMImpl_Gen::GetIBlocksOperations(int theDocID)
327 {
328   if(_mapOfBlocksOperations.find(theDocID) == _mapOfBlocksOperations.end()) {
329     _mapOfBlocksOperations[theDocID] = new GEOMImpl_IBlocksOperations(this, theDocID);
330   }
331
332   return _mapOfBlocksOperations[theDocID];
333 }
334
335 //=============================================================================
336 /*!
337  * GetICurvesOperations
338  */
339 //=============================================================================
340 GEOMImpl_ICurvesOperations* GEOMImpl_Gen::GetICurvesOperations(int theDocID)
341 {
342   if(_mapOfCurvesOperations.find(theDocID) == _mapOfCurvesOperations.end()) {
343     _mapOfCurvesOperations[theDocID] = new GEOMImpl_ICurvesOperations(this, theDocID);
344   }
345
346   return _mapOfCurvesOperations[theDocID];
347 }
348
349 //=============================================================================
350 /*!
351  * GetILocalOperations
352  */
353 //=============================================================================
354 GEOMImpl_ILocalOperations* GEOMImpl_Gen::GetILocalOperations(int theDocID)
355 {
356   if(_mapOfLocalOperations.find(theDocID) == _mapOfLocalOperations.end()) {
357     _mapOfLocalOperations[theDocID] = new GEOMImpl_ILocalOperations(this, theDocID);
358   }
359
360   return _mapOfLocalOperations[theDocID];
361 }
362
363 //=============================================================================
364 /*!
365  * GetIInsertOperations
366  */
367 //=============================================================================
368 GEOMImpl_IInsertOperations* GEOMImpl_Gen::GetIInsertOperations(int theDocID)
369 {
370   if(_mapOfInsertOperations.find(theDocID) == _mapOfInsertOperations.end()) {
371     _mapOfInsertOperations[theDocID] = new GEOMImpl_IInsertOperations(this, theDocID);
372   }
373
374   return _mapOfInsertOperations[theDocID];
375 }
376
377 //=============================================================================
378 /*!
379  * GetIMeasureOperations
380  */
381 //=============================================================================
382 GEOMImpl_IMeasureOperations* GEOMImpl_Gen::GetIMeasureOperations(int theDocID)
383 {
384   if(_mapOfMeasureOperations.find(theDocID) == _mapOfMeasureOperations.end()) {
385     _mapOfMeasureOperations[theDocID] = new GEOMImpl_IMeasureOperations(this, theDocID);
386   }
387
388   return _mapOfMeasureOperations[theDocID];
389 }
390
391 //=============================================================================
392 /*!
393  * GetIGroupOperations
394  */
395 //=============================================================================
396 GEOMImpl_IGroupOperations* GEOMImpl_Gen::GetIGroupOperations(int theDocID)
397 {
398   if(_mapOfGroupOperations.find(theDocID) == _mapOfGroupOperations.end()) {
399     _mapOfGroupOperations[theDocID] = new GEOMImpl_IGroupOperations(this, theDocID);
400   }
401
402   return _mapOfGroupOperations[theDocID];
403 }
404
405 //=============================================================================
406 /*!
407  * GetIAdvancedOperations
408  */
409 //=============================================================================
410 GEOMImpl_IAdvancedOperations* GEOMImpl_Gen::GetIAdvancedOperations(int theDocID)
411 {
412   if(_mapOfAdvancedOperations.find(theDocID) == _mapOfAdvancedOperations.end()) {
413     _mapOfAdvancedOperations[theDocID] = new GEOMImpl_IAdvancedOperations(this, theDocID);
414   }
415
416   return _mapOfAdvancedOperations[theDocID];
417 }
418