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