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