/src/contrib/geom-5.1.2.7/src/GEOMImpl/GEOMImpl_Gen.cpp

http://pythonocc.googlecode.com/ · C++ · 389 lines · 231 code · 56 blank · 102 comment · 48 complexity · 1eb5f8986c4672bdf714ab564d0c307e MD5 · raw file

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