1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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, or (at your option) any later version.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 //=============================================================================
24 // File : GEOMImpl_IShapesOperations.hxx
26 // Author : modified by Lioka RAZAFINDRAZAKA (CEA) 22/06/2007
28 //=============================================================================
30 #ifndef _GEOMImpl_IShapesOperations_HXX_
31 #define _GEOMImpl_IShapesOperations_HXX_
33 #include "GEOM_IOperations.hxx"
35 #include "GEOMAlgo_State.hxx"
37 #include <TopoDS_Shape.hxx>
38 #include <TopTools_ListOfShape.hxx>
39 #include <NCollection_DataMap.hxx>
40 #include <TColStd_HSequenceOfTransient.hxx>
41 #include <TColStd_HSequenceOfInteger.hxx>
43 #include <Handle_Geom_Surface.hxx>
51 class Handle(GEOM_Object);
52 class Handle(TColStd_HArray1OfInteger);
54 class GEOMImpl_IShapesOperations : public GEOM_IOperations
63 All = Groups | Fields | SubShapes,
66 Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
67 Standard_EXPORT ~GEOMImpl_IShapesOperations();
69 Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
70 Handle(GEOM_Object) thePoint2);
72 Standard_EXPORT Handle(GEOM_Object) MakeEdgeOnCurveByLength (Handle(GEOM_Object) theCurve,
73 const Standard_Real theLength,
74 Handle(GEOM_Object) theStartPoint);
76 Standard_EXPORT Handle(GEOM_Object) MakeEdgeWire (Handle(GEOM_Object) theWire,
77 const Standard_Real theLinearTolerance,
78 const Standard_Real theAngularTolerance);
80 Standard_EXPORT Handle(GEOM_Object) MakeWire (std::list<Handle(GEOM_Object)> theEdgesAndWires,
81 const Standard_Real theTolerance);
83 Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
85 Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (std::list<Handle(GEOM_Object)> theWires,
86 const bool isPlanarWanted);
88 Standard_EXPORT Handle(GEOM_Object) MakeFaceFromSurface
89 (Handle(GEOM_Object) theFace,
90 Handle(GEOM_Object) theWire);
92 Standard_EXPORT Handle(GEOM_Object) MakeShell (std::list<Handle(GEOM_Object)> theShapes);
94 Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (std::list<Handle(GEOM_Object)> theShells);
96 Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list<Handle(GEOM_Object)> theShapes);
98 Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (std::list< Handle(GEOM_Object) >& theShapes,
99 const Standard_Real theTolerance,
100 const Standard_Boolean doKeepNonSolids);
102 Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (std::list< Handle(GEOM_Object) >& theShapes,
103 const Standard_Real theTolerance,
104 std::list<Handle(GEOM_Object)>& theFaces,
105 const Standard_Boolean doKeepNonSolids,
106 const Standard_Boolean doGlueAllEdges);
108 Standard_EXPORT Handle(GEOM_Object) MakeGlueEdges (std::list< Handle(GEOM_Object) >& theShapes,
109 const Standard_Real theTolerance);
111 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueShapes (std::list< Handle(GEOM_Object) >& theShapes,
112 const Standard_Real theTolerance,
113 const TopAbs_ShapeEnum theType);
115 Standard_EXPORT Handle(GEOM_Object) MakeGlueEdgesByList (std::list< Handle(GEOM_Object) >& theShapes,
116 const Standard_Real theTolerance,
117 std::list<Handle(GEOM_Object)> & theEdges);
119 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects(Handle(GEOM_Object) theShape,
120 const Standard_Boolean theGroupsOnly);
121 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects(Handle(GEOM_Object) theShape,
122 const Standard_Integer theTypes = All);
125 EXPLODE_OLD_INCLUDE_MAIN,
126 EXPLODE_NEW_INCLUDE_MAIN,
127 EXPLODE_NEW_EXCLUDE_MAIN
130 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode
131 (Handle(GEOM_Object) theShape,
132 const Standard_Integer theShapeType,
133 const Standard_Boolean isSorted,
134 const ExplodeType theExplodeType = EXPLODE_NEW_INCLUDE_MAIN);
136 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs
137 (Handle(GEOM_Object) theShape,
138 const Standard_Integer theShapeType,
139 const Standard_Boolean isSorted,
140 const ExplodeType theExplodeType = EXPLODE_NEW_INCLUDE_MAIN);
142 Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape,
143 const Standard_Integer theID);
145 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeSubShapes
146 (Handle(GEOM_Object) theMainShape,
147 Handle(TColStd_HArray1OfInteger) theIndices);
149 Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
150 Handle(GEOM_Object) theSubShape);
152 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetSubShapesIndices (Handle(GEOM_Object) theMainShape,
153 std::list<Handle(GEOM_Object)> theSubShapes);
155 Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
156 Handle(GEOM_Object) theSubShape);
158 Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
160 Standard_EXPORT Standard_Integer NumberOfSubShapes (Handle(GEOM_Object) theShape,
161 const Standard_Integer theShapeType);
163 Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
165 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
167 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
168 GetSharedShapes (Handle(GEOM_Object) theShape1,
169 Handle(GEOM_Object) theShape2,
170 const Standard_Integer theShapeType);
172 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
173 GetSharedShapes (std::list<Handle(GEOM_Object)>& theShapes,
174 const Standard_Integer theShapeType);
176 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
177 GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
178 const Standard_Integer theShapeType,
179 const Handle(GEOM_Object)& theAx1,
180 const GEOMAlgo_State theState);
182 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
183 GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
184 const Standard_Integer theShapeType,
185 const Handle(GEOM_Object)& theAx1,
186 const Handle(GEOM_Object)& thePnt,
187 const GEOMAlgo_State theState);
190 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
191 GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
192 const Standard_Integer theShapeType,
193 const Handle(GEOM_Object)& theAxis,
194 const Standard_Real theRadius,
195 const GEOMAlgo_State theState);
197 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
198 GetShapesOnCylinderWithLocation (const Handle(GEOM_Object)& theShape,
199 const Standard_Integer theShapeType,
200 const Handle(GEOM_Object)& theAxis,
201 const Handle(GEOM_Object)& thePnt,
202 const Standard_Real theRadius,
203 const GEOMAlgo_State theState);
205 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
206 GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
207 const Standard_Integer theShapeType,
208 const Handle(GEOM_Object)& theCenter,
209 const Standard_Real theRadius,
210 const GEOMAlgo_State theState);
212 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
213 GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
214 const Standard_Integer theShapeType,
215 const Handle(GEOM_Object)& theAx1,
216 const GEOMAlgo_State theState);
218 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
219 GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
220 const Standard_Integer theShapeType,
221 const Handle(GEOM_Object)& theAx1,
222 const Handle(GEOM_Object)& thePnt,
223 const GEOMAlgo_State theState);
225 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
226 GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
227 const Standard_Integer theShapeType,
228 const Handle(GEOM_Object)& theAxis,
229 const Standard_Real theRadius,
230 const GEOMAlgo_State theState);
232 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
233 GetShapesOnCylinderWithLocationIDs (const Handle(GEOM_Object)& theShape,
234 const Standard_Integer theShapeType,
235 const Handle(GEOM_Object)& theAxis,
236 const Handle(GEOM_Object)& thePnt,
237 const Standard_Real theRadius,
238 const GEOMAlgo_State theState);
240 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
241 GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
242 const Standard_Integer theShapeType,
243 const Handle(GEOM_Object)& theCenter,
244 const Standard_Real theRadius,
245 const GEOMAlgo_State theState);
248 * \brief Find sub-shapes complying with given status about quadrangle
249 * \param theShape - the shape to explore
250 * \param theShapeType - type of sub-shape of theShape
251 * \param theTopLeftPoint - top left quadrangle corner
252 * \param theTopRigthPoint - top right quadrangle corner
253 * \param theBottomLeftPoint - bottom left quadrangle corner
254 * \param theBottomRigthPoint - bottom right quadrangle corner
255 * \param theState - required state
256 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
258 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
259 GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
260 const Standard_Integer theShapeType,
261 const Handle(GEOM_Object)& theTopLeftPoint,
262 const Handle(GEOM_Object)& theTopRigthPoint,
263 const Handle(GEOM_Object)& theBottomLeftPoint,
264 const Handle(GEOM_Object)& theBottomRigthPoint,
265 const GEOMAlgo_State theState);
268 * \brief Find IDs of sub-shapes complying with given status about quadrangle
269 * \param theShape - the shape to explore
270 * \param theShapeType - type of sub-shape of theShape
271 * \param theTopLeftPoint - top left quadrangle corner
272 * \param theTopRigthPoint - top right quadrangle corner
273 * \param theBottomLeftPoint - bottom left quadrangle corner
274 * \param theBottomRigthPoint - bottom right quadrangle corner
275 * \param theState - required state
276 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
278 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
279 GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
280 const Standard_Integer theShapeType,
281 const Handle(GEOM_Object)& theTopLeftPoint,
282 const Handle(GEOM_Object)& theTopRigthPoint,
283 const Handle(GEOM_Object)& theBottomLeftPoint,
284 const Handle(GEOM_Object)& theBottomRigthPoint,
285 const GEOMAlgo_State theState);
287 Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape,
288 const Standard_Integer theShapeType,
289 Handle(GEOM_Object) theAxis,
290 const Standard_Real theRadius);
292 Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape,
293 const Standard_Integer theShapeType,
294 Handle(GEOM_Object) theCenter,
295 const Standard_Real theRadius);
297 void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
299 Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
300 Handle(GEOM_Object) theShapeWhat);
302 Standard_EXPORT Handle(GEOM_Object) GetInPlaceOld (Handle(GEOM_Object) theShapeWhere,
303 Handle(GEOM_Object) theShapeWhat);
305 Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
306 Handle(GEOM_Object) theShapeWhat);
309 * \brief Searches a shape equal to theWhat in the context of theWhere
310 * \param theShapeWhere - a context shap
311 * \param theShapeWhat - a sample shape
312 * \retval Handle(GEOM_Object) - found shape
314 Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
315 const Handle(GEOM_Object)& theShapeWhat);
318 * \brief Searches a shape equal to theWhat in the context of theWhere
319 * \param theShapeWhere - a context shap
320 * \param theShapeWhat - a sample shape
321 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
323 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetSameIDs(const Handle(GEOM_Object)& theShapeWhere,
324 const Handle(GEOM_Object)& theShapeWhat);
327 * \brief Find IDs of sub-shapes complying with given status about surface
328 * \param theBox - the box to check state of sub-shapes against
329 * \param theShape - the shape to explore
330 * \param theShapeType - type of sub-shape of theShape
331 * \param theState - required state
332 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
334 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
335 GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
336 const Handle(GEOM_Object)& theShape,
337 const Standard_Integer theShapeType,
338 GEOMAlgo_State theState);
341 * \brief Find sub-shapes complying with given status about surface
342 * \param theBox - the box to check state of sub-shapes against
343 * \param theShape - the shape to explore
344 * \param theShapeType - type of sub-shape of theShape
345 * \param theState - required state
346 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
348 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
349 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
350 const Handle(GEOM_Object)& theShape,
351 const Standard_Integer theShapeType,
352 GEOMAlgo_State theState);
355 * \brief Find IDs of sub-shapes complying with given status about surface
356 * \param theCheckShape - the shape to check state of sub-shapes against
357 * \param theShape - the shape to explore
358 * \param theShapeType - type of sub-shape of theShape
359 * \param theState - required state
360 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
362 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
363 GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape,
364 const Handle(GEOM_Object)& theShape,
365 const Standard_Integer theShapeType,
366 GEOMAlgo_State theState);
369 * \brief Find sub-shapes complying with given status about surface
370 * \param theCheckShape - the shape to check state of sub-shapes against
371 * \param theShape - the shape to explore
372 * \param theShapeType - type of sub-shape of theShape
373 * \param theState - required state
374 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
376 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
377 GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape,
378 const Handle(GEOM_Object)& theShape,
379 const Standard_Integer theShapeType,
380 GEOMAlgo_State theState);
381 Standard_EXPORT Handle(GEOM_Object)
382 GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape,
383 const Handle(GEOM_Object)& theShape,
384 const Standard_Integer theShapeType,
385 GEOMAlgo_State theState);
388 Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes,
389 const Standard_Integer theObjectType,
390 const Standard_Integer theFunctionType,
391 const TCollection_AsciiString& theMethodName);
393 // ----------------------------------------------------
394 // methods common for all GetShapesOnXXX() functions
395 // ----------------------------------------------------
398 * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
399 * \param theShapeType - the shape type to check
400 * \retval bool - result of the check
402 bool checkTypeShapesOn(const Standard_Integer theShapeType);
405 * \brief Creates Geom_Plane
406 * \param theAx1 - edge defining plane normal
407 * \retval Handle(Geom_Surface) - resulting surface
409 Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
412 * \brief Creates Geom_CylindricalSurface
413 * \param theAx1 - edge defining cylinder axis
414 * \param theRadius - cylinder radius
415 * \retval Handle(Geom_Surface) - resulting surface
417 Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
418 const Standard_Real theRadius);
421 * \brief Find IDs of sub-shapes complying with given status about surface
422 * \param theSurface - the surface to check state of sub-shapes against
423 * \param theShape - the shape to explore
424 * \param theShapeType - type of sub-shape of theShape
425 * \param theState - required state
426 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
428 Handle(TColStd_HSequenceOfInteger)
429 getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
430 const TopoDS_Shape& theShape,
431 TopAbs_ShapeEnum theShapeType,
432 GEOMAlgo_State theState);
435 * \brief Find sub-shapes complying with given status about surface
436 * \param theSurface - the surface to check state of sub-shapes against
437 * \param theShape - the shape to explore
438 * \param theShapeType - type of sub-shape of theShape
439 * \param theState - required state
440 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
441 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
443 Handle(TColStd_HSequenceOfTransient)
444 getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
445 const Handle(GEOM_Object)& theShape,
446 TopAbs_ShapeEnum theShapeType,
447 GEOMAlgo_State theState,
448 TCollection_AsciiString & theShapeEntries);
451 * \brief Find IDs of sub-shapes complying with given status about quadrangle
452 * \param theShape - the shape to explore
453 * \param theShapeType - type of sub-shape of theShape
454 * \param theTopLeftPoint - top left quadrangle corner
455 * \param theTopRigthPoint - top right quadrangle corner
456 * \param theBottomLeftPoint - bottom left quadrangle corner
457 * \param theBottomRigthPoint - bottom right quadrangle corner
458 * \param theState - required state
459 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
461 Handle(TColStd_HSequenceOfInteger)
462 getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
463 const Standard_Integer theShapeType,
464 const Handle(GEOM_Object)& theTopLeftPoint,
465 const Handle(GEOM_Object)& theTopRigthPoint,
466 const Handle(GEOM_Object)& theBottomLeftPoint,
467 const Handle(GEOM_Object)& theBottomRigthPoint,
468 const GEOMAlgo_State theState);
471 * \brief Find IDs of sub-shapes complying with given status about surface
472 * \param theBox - the box to check state of sub-shapes against
473 * \param theShape - the shape to explore
474 * \param theShapeType - type of sub-shape of theShape
475 * \param theState - required state
476 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
478 Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
479 const Handle(GEOM_Object)& theShape,
480 const Standard_Integer theShapeType,
481 GEOMAlgo_State theState);
484 * \brief Find IDs of sub-shapes complying with given status about surface
485 * \param theCheckShape - the shape to check state of sub-shapes against
486 * \param theShape - the shape to explore
487 * \param theShapeType - type of sub-shape of theShape
488 * \param theState - required state
489 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
491 Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs
492 (const Handle(GEOM_Object)& theCheckShape,
493 const Handle(GEOM_Object)& theShape,
494 const Standard_Integer theShapeType,
495 GEOMAlgo_State theState);
498 * \brief Find shape objects and their entries by their ids
499 * \param theShape - the main shape
500 * \param theShapeIDs - theShapeIDs - incoming shape ids
501 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
502 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
504 Handle(TColStd_HSequenceOfTransient)
505 getObjectsShapesOn(const Handle(GEOM_Object)& theShape,
506 const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
507 TCollection_AsciiString & theShapeEntries);
510 * \brief Select the object created last
511 * \param theObj1 - Object 1
512 * \param theObj2 - Object 2
513 * \retval Handle(GEOM_Object) - selected object
515 static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
516 const Handle(GEOM_Object)& theObj2);