/src/contrib/geom-5.1.2.7/inc_pythonocc/GEOMImpl_IShapesOperations.hxx

http://pythonocc.googlecode.com/ · C++ Header · 455 lines · 208 code · 65 blank · 182 comment · 0 complexity · 455f4d82dea95593a2d9e532d90646ca MD5 · raw file

  1. // Copyright (C) 2007-2008 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. // File : GEOMImpl_IShapesOperations.hxx
  24. // Created :
  25. // Author : modified by Lioka RAZAFINDRAZAKA (CEA) 22/06/2007
  26. // Project : SALOME
  27. // $Header: /home/server/cvs/GEOM/GEOM_SRC/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx,v 1.13.2.3 2008/11/27 10:36:56 abd Exp $
  28. //=============================================================================
  29. //
  30. #ifndef _GEOMImpl_IShapesOperations_HXX_
  31. #define _GEOMImpl_IShapesOperations_HXX_
  32. #include "SGEOM_IOperations.hxx"
  33. #include "GEOMAlgo_State.hxx"
  34. #include <TopTools_ListOfShape.hxx>
  35. #include <TColStd_HSequenceOfTransient.hxx>
  36. #include <TColStd_HSequenceOfInteger.hxx>
  37. #include <list>
  38. #include <Handle_Geom_Surface.hxx>
  39. #include <gp_Pnt.hxx>
  40. class GEOM_Engine;
  41. class Handle(GEOM_Object);
  42. class Handle(TColStd_HArray1OfInteger);
  43. class GEOMImpl_IShapesOperations : public GEOM_IOperations
  44. {
  45. public:
  46. Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
  47. Standard_EXPORT ~GEOMImpl_IShapesOperations();
  48. Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
  49. Handle(GEOM_Object) thePoint2);
  50. Standard_EXPORT Handle(GEOM_Object) MakeWire (std::list<Handle(GEOM_Object)> theEdgesAndWires,
  51. const Standard_Real theTolerance);
  52. Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
  53. Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (std::list<Handle(GEOM_Object)> theWires,
  54. const bool isPlanarWanted);
  55. Standard_EXPORT Handle(GEOM_Object) MakeShell (std::list<Handle(GEOM_Object)> theShapes);
  56. Standard_EXPORT Handle(GEOM_Object) MakeSolidShell (Handle(GEOM_Object) theShell);
  57. Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (std::list<Handle(GEOM_Object)> theShells);
  58. Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list<Handle(GEOM_Object)> theShapes);
  59. Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
  60. const Standard_Real theTolerance,
  61. const Standard_Boolean doKeepNonSolids);
  62. Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
  63. const Standard_Real theTolerance);
  64. Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
  65. const Standard_Real theTolerance,
  66. std::list<Handle(GEOM_Object)> theFaces,
  67. const Standard_Boolean doKeepNonSolids);
  68. Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode (Handle(GEOM_Object) theShape,
  69. const Standard_Integer theShapeType,
  70. const Standard_Boolean isSorted);
  71. Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs (Handle(GEOM_Object) theShape,
  72. const Standard_Integer theShapeType,
  73. const Standard_Boolean isSorted);
  74. Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape,
  75. const Standard_Integer theID);
  76. Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
  77. Handle(GEOM_Object) theSubShape);
  78. Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
  79. Handle(GEOM_Object) theSubShape);
  80. Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
  81. Standard_EXPORT Standard_Integer NumberOfSubShapes (Handle(GEOM_Object) theShape,
  82. const Standard_Integer theShapeType);
  83. Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
  84. Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
  85. Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetSharedShapes (Handle(GEOM_Object) theShape1,
  86. Handle(GEOM_Object) theShape2,
  87. const Standard_Integer theShapeType);
  88. Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
  89. const Standard_Integer theShapeType,
  90. const Handle(GEOM_Object)& theAx1,
  91. const GEOMAlgo_State theState);
  92. Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
  93. GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
  94. const Standard_Integer theShapeType,
  95. const Handle(GEOM_Object)& theAx1,
  96. const Handle(GEOM_Object)& thePnt,
  97. const GEOMAlgo_State theState);
  98. Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
  99. GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
  100. const Standard_Integer theShapeType,
  101. const Handle(GEOM_Object)& theAxis,
  102. const Standard_Real theRadius,
  103. const GEOMAlgo_State theState);
  104. Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
  105. GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
  106. const Standard_Integer theShapeType,
  107. const Handle(GEOM_Object)& theCenter,
  108. const Standard_Real theRadius,
  109. const GEOMAlgo_State theState);
  110. Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
  111. GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
  112. const Standard_Integer theShapeType,
  113. const Handle(GEOM_Object)& theAx1,
  114. const GEOMAlgo_State theState);
  115. Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
  116. GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
  117. const Standard_Integer theShapeType,
  118. const Handle(GEOM_Object)& theAx1,
  119. const Handle(GEOM_Object)& thePnt,
  120. const GEOMAlgo_State theState);
  121. Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
  122. GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
  123. const Standard_Integer theShapeType,
  124. const Handle(GEOM_Object)& theAxis,
  125. const Standard_Real theRadius,
  126. const GEOMAlgo_State theState);
  127. Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
  128. GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
  129. const Standard_Integer theShapeType,
  130. const Handle(GEOM_Object)& theCenter,
  131. const Standard_Real theRadius,
  132. const GEOMAlgo_State theState);
  133. /*!
  134. * \brief Find subshapes complying with given status about quadrangle
  135. * \param theShape - the shape to explore
  136. * \param theShapeType - type of subshape of theShape
  137. * \param theTopLeftPoint - top left quadrangle corner
  138. * \param theTopRigthPoint - top right quadrangle corner
  139. * \param theBottomLeftPoint - bottom left quadrangle corner
  140. * \param theBottomRigthPoint - bottom right quadrangle corner
  141. * \param theState - required state
  142. * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
  143. */
  144. Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
  145. GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
  146. const Standard_Integer theShapeType,
  147. const Handle(GEOM_Object)& theTopLeftPoint,
  148. const Handle(GEOM_Object)& theTopRigthPoint,
  149. const Handle(GEOM_Object)& theBottomLeftPoint,
  150. const Handle(GEOM_Object)& theBottomRigthPoint,
  151. const GEOMAlgo_State theState);
  152. /*!
  153. * \brief Find IDs of subshapes complying with given status about quadrangle
  154. * \param theShape - the shape to explore
  155. * \param theShapeType - type of subshape of theShape
  156. * \param theTopLeftPoint - top left quadrangle corner
  157. * \param theTopRigthPoint - top right quadrangle corner
  158. * \param theBottomLeftPoint - bottom left quadrangle corner
  159. * \param theBottomRigthPoint - bottom right quadrangle corner
  160. * \param theState - required state
  161. * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
  162. */
  163. Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
  164. GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
  165. const Standard_Integer theShapeType,
  166. const Handle(GEOM_Object)& theTopLeftPoint,
  167. const Handle(GEOM_Object)& theTopRigthPoint,
  168. const Handle(GEOM_Object)& theBottomLeftPoint,
  169. const Handle(GEOM_Object)& theBottomRigthPoint,
  170. const GEOMAlgo_State theState);
  171. Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape,
  172. const Standard_Integer theShapeType,
  173. Handle(GEOM_Object) theAxis,
  174. const Standard_Real theRadius);
  175. Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape,
  176. const Standard_Integer theShapeType,
  177. Handle(GEOM_Object) theCenter,
  178. const Standard_Real theRadius);
  179. void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
  180. Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
  181. Handle(GEOM_Object) theShapeWhat);
  182. Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
  183. Handle(GEOM_Object) theShapeWhat);
  184. /*!
  185. * \brief Searches a shape equal to theWhat in the context of theWhere
  186. * \param theShapeWhere - a context shap
  187. * \param theShapeWhat - a sample shape
  188. * \retval Handle(GEOM_Object) - found shape
  189. */
  190. Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
  191. const Handle(GEOM_Object)& theShapeWhat);
  192. /*!
  193. * \brief Find IDs of subshapes complying with given status about surface
  194. * \param theBox - the box to check state of subshapes against
  195. * \param theShape - the shape to explore
  196. * \param theShapeType - type of subshape of theShape
  197. * \param theState - required state
  198. * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
  199. */
  200. Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
  201. GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
  202. const Handle(GEOM_Object)& theShape,
  203. const Standard_Integer theShapeType,
  204. GEOMAlgo_State theState);
  205. /*!
  206. * \brief Find subshapes complying with given status about surface
  207. * \param theBox - the box to check state of subshapes against
  208. * \param theShape - the shape to explore
  209. * \param theShapeType - type of subshape of theShape
  210. * \param theState - required state
  211. * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
  212. */
  213. Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
  214. GetShapesOnBox(const Handle(GEOM_Object)& theBox,
  215. const Handle(GEOM_Object)& theShape,
  216. const Standard_Integer theShapeType,
  217. GEOMAlgo_State theState);
  218. /*!
  219. * \brief Find IDs of subshapes complying with given status about surface
  220. * \param theCheckShape - the shape to check state of subshapes against
  221. * \param theShape - the shape to explore
  222. * \param theShapeType - type of subshape of theShape
  223. * \param theState - required state
  224. * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
  225. */
  226. Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
  227. GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape,
  228. const Handle(GEOM_Object)& theShape,
  229. const Standard_Integer theShapeType,
  230. GEOMAlgo_State theState);
  231. /*!
  232. * \brief Find subshapes complying with given status about surface
  233. * \param theCheckShape - the shape to check state of subshapes against
  234. * \param theShape - the shape to explore
  235. * \param theShapeType - type of subshape of theShape
  236. * \param theState - required state
  237. * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
  238. */
  239. Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
  240. GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape,
  241. const Handle(GEOM_Object)& theShape,
  242. const Standard_Integer theShapeType,
  243. GEOMAlgo_State theState);
  244. Standard_EXPORT Handle(GEOM_Object)
  245. GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape,
  246. const Handle(GEOM_Object)& theShape,
  247. const Standard_Integer theShapeType,
  248. GEOMAlgo_State theState);
  249. public:
  250. /*!
  251. * \brief Sort shapes in the list by their coordinates.
  252. * \param SL The list of shapes to sort.
  253. */
  254. Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
  255. /*!
  256. * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND.
  257. *
  258. * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is.
  259. *
  260. * \param theCompsolid The compsolid to be converted.
  261. * \retval TopoDS_Shape Returns the resulting compound.
  262. */
  263. Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
  264. /*!
  265. * \brief Build a triangulation on \a theShape if it is absent.
  266. * \param theShape The shape to check/build triangulation on.
  267. * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation.
  268. */
  269. Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
  270. private:
  271. Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes,
  272. const Standard_Integer theObjectType,
  273. const Standard_Integer theFunctionType,
  274. const TCollection_AsciiString& theMethodName);
  275. // ----------------------------------------------------
  276. // methods common for all GetShapesOnXXX() functions
  277. // ----------------------------------------------------
  278. /*!
  279. * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
  280. * \param theShapeType - the shape type to check
  281. * \retval bool - result of the check
  282. */
  283. bool checkTypeShapesOn(const Standard_Integer theShapeType);
  284. /*!
  285. * \brief Creates Geom_Plane
  286. * \param theAx1 - edge defining plane normal
  287. * \retval Handle(Geom_Surface) - resulting surface
  288. */
  289. Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
  290. /*!
  291. * \brief Creates Geom_CylindricalSurface
  292. * \param theAx1 - edge defining cylinder axis
  293. * \param theRadius - cylinder radius
  294. * \retval Handle(Geom_Surface) - resulting surface
  295. */
  296. Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
  297. const Standard_Real theRadius);
  298. /*!
  299. * \brief Find IDs of subshapes complying with given status about surface
  300. * \param theSurface - the surface to check state of subshapes against
  301. * \param theShape - the shape to explore
  302. * \param theShapeType - type of subshape of theShape
  303. * \param theState - required state
  304. * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
  305. */
  306. Handle(TColStd_HSequenceOfInteger)
  307. getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
  308. const TopoDS_Shape& theShape,
  309. TopAbs_ShapeEnum theShapeType,
  310. GEOMAlgo_State theState);
  311. /*!
  312. * \brief Find subshapes complying with given status about surface
  313. * \param theSurface - the surface to check state of subshapes against
  314. * \param theShape - the shape to explore
  315. * \param theShapeType - type of subshape of theShape
  316. * \param theState - required state
  317. * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
  318. * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
  319. */
  320. Handle(TColStd_HSequenceOfTransient)
  321. getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
  322. const Handle(GEOM_Object)& theShape,
  323. TopAbs_ShapeEnum theShapeType,
  324. GEOMAlgo_State theState,
  325. TCollection_AsciiString & theShapeEntries);
  326. /*!
  327. * \brief Find IDs of subshapes complying with given status about quadrangle
  328. * \param theShape - the shape to explore
  329. * \param theShapeType - type of subshape of theShape
  330. * \param theTopLeftPoint - top left quadrangle corner
  331. * \param theTopRigthPoint - top right quadrangle corner
  332. * \param theBottomLeftPoint - bottom left quadrangle corner
  333. * \param theBottomRigthPoint - bottom right quadrangle corner
  334. * \param theState - required state
  335. * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
  336. */
  337. Handle(TColStd_HSequenceOfInteger)
  338. getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
  339. const Standard_Integer theShapeType,
  340. const Handle(GEOM_Object)& theTopLeftPoint,
  341. const Handle(GEOM_Object)& theTopRigthPoint,
  342. const Handle(GEOM_Object)& theBottomLeftPoint,
  343. const Handle(GEOM_Object)& theBottomRigthPoint,
  344. const GEOMAlgo_State theState);
  345. /*!
  346. * \brief Find IDs of subshapes complying with given status about surface
  347. * \param theBox - the box to check state of subshapes against
  348. * \param theShape - the shape to explore
  349. * \param theShapeType - type of subshape of theShape
  350. * \param theState - required state
  351. * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
  352. */
  353. Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
  354. const Handle(GEOM_Object)& theShape,
  355. const Standard_Integer theShapeType,
  356. GEOMAlgo_State theState);
  357. /*!
  358. * \brief Find IDs of subshapes complying with given status about surface
  359. * \param theCheckShape - the shape to check state of subshapes against
  360. * \param theShape - the shape to explore
  361. * \param theShapeType - type of subshape of theShape
  362. * \param theState - required state
  363. * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
  364. */
  365. Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs
  366. (const Handle(GEOM_Object)& theCheckShape,
  367. const Handle(GEOM_Object)& theShape,
  368. const Standard_Integer theShapeType,
  369. GEOMAlgo_State theState);
  370. /*!
  371. * \brief Find shape objects and their entries by their ids
  372. * \param theShape - the main shape
  373. * \param theShapeIDs - theShapeIDs - incoming shape ids
  374. * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
  375. * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
  376. */
  377. Handle(TColStd_HSequenceOfTransient)
  378. getObjectsShapesOn(const Handle(GEOM_Object)& theShape,
  379. const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
  380. TCollection_AsciiString & theShapeEntries);
  381. /*!
  382. * \brief Select the object created last
  383. * \param theObj1 - Object 1
  384. * \param theObj2 - Object 2
  385. * \retval Handle(GEOM_Object) - selected object
  386. */
  387. static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
  388. const Handle(GEOM_Object)& theObj2);
  389. };
  390. #endif