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) MakeShell (std::list<Handle(GEOM_Object)> theShapes);
90 Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (std::list<Handle(GEOM_Object)> theShells);
92 Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list<Handle(GEOM_Object)> theShapes);
94 Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (std::list< Handle(GEOM_Object) >& theShapes,
95 const Standard_Real theTolerance,
96 const Standard_Boolean doKeepNonSolids);
98 Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (std::list< Handle(GEOM_Object) >& theShapes,
99 const Standard_Real theTolerance,
100 std::list<Handle(GEOM_Object)>& theFaces,
101 const Standard_Boolean doKeepNonSolids,
102 const Standard_Boolean doGlueAllEdges);
104 Standard_EXPORT Handle(GEOM_Object) MakeGlueEdges (std::list< Handle(GEOM_Object) >& theShapes,
105 const Standard_Real theTolerance);
107 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueShapes (std::list< Handle(GEOM_Object) >& theShapes,
108 const Standard_Real theTolerance,
109 const TopAbs_ShapeEnum theType);
111 Standard_EXPORT Handle(GEOM_Object) MakeGlueEdgesByList (std::list< Handle(GEOM_Object) >& theShapes,
112 const Standard_Real theTolerance,
113 std::list<Handle(GEOM_Object)> & theEdges);
115 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects(Handle(GEOM_Object) theShape,
116 const Standard_Boolean theGroupsOnly);
117 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects(Handle(GEOM_Object) theShape,
118 const Standard_Integer theTypes = All);
121 EXPLODE_OLD_INCLUDE_MAIN,
122 EXPLODE_NEW_INCLUDE_MAIN,
123 EXPLODE_NEW_EXCLUDE_MAIN
126 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode
127 (Handle(GEOM_Object) theShape,
128 const Standard_Integer theShapeType,
129 const Standard_Boolean isSorted,
130 const ExplodeType theExplodeType = EXPLODE_NEW_INCLUDE_MAIN);
132 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs
133 (Handle(GEOM_Object) theShape,
134 const Standard_Integer theShapeType,
135 const Standard_Boolean isSorted,
136 const ExplodeType theExplodeType = EXPLODE_NEW_INCLUDE_MAIN);
138 Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape,
139 const Standard_Integer theID);
141 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeSubShapes
142 (Handle(GEOM_Object) theMainShape,
143 Handle(TColStd_HArray1OfInteger) theIndices);
145 Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
146 Handle(GEOM_Object) theSubShape);
148 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetSubShapesIndices (Handle(GEOM_Object) theMainShape,
149 std::list<Handle(GEOM_Object)> theSubShapes);
151 Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
152 Handle(GEOM_Object) theSubShape);
154 Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
156 Standard_EXPORT Standard_Integer NumberOfSubShapes (Handle(GEOM_Object) theShape,
157 const Standard_Integer theShapeType);
159 Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
161 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
163 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
164 GetSharedShapes (Handle(GEOM_Object) theShape1,
165 Handle(GEOM_Object) theShape2,
166 const Standard_Integer theShapeType);
168 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
169 GetSharedShapes (std::list<Handle(GEOM_Object)>& theShapes,
170 const Standard_Integer theShapeType);
172 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
173 GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
174 const Standard_Integer theShapeType,
175 const Handle(GEOM_Object)& theAx1,
176 const GEOMAlgo_State theState);
178 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
179 GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
180 const Standard_Integer theShapeType,
181 const Handle(GEOM_Object)& theAx1,
182 const Handle(GEOM_Object)& thePnt,
183 const GEOMAlgo_State theState);
186 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
187 GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
188 const Standard_Integer theShapeType,
189 const Handle(GEOM_Object)& theAxis,
190 const Standard_Real theRadius,
191 const GEOMAlgo_State theState);
193 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
194 GetShapesOnCylinderWithLocation (const Handle(GEOM_Object)& theShape,
195 const Standard_Integer theShapeType,
196 const Handle(GEOM_Object)& theAxis,
197 const Handle(GEOM_Object)& thePnt,
198 const Standard_Real theRadius,
199 const GEOMAlgo_State theState);
201 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
202 GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
203 const Standard_Integer theShapeType,
204 const Handle(GEOM_Object)& theCenter,
205 const Standard_Real theRadius,
206 const GEOMAlgo_State theState);
208 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
209 GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
210 const Standard_Integer theShapeType,
211 const Handle(GEOM_Object)& theAx1,
212 const GEOMAlgo_State theState);
214 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
215 GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
216 const Standard_Integer theShapeType,
217 const Handle(GEOM_Object)& theAx1,
218 const Handle(GEOM_Object)& thePnt,
219 const GEOMAlgo_State theState);
221 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
222 GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
223 const Standard_Integer theShapeType,
224 const Handle(GEOM_Object)& theAxis,
225 const Standard_Real theRadius,
226 const GEOMAlgo_State theState);
228 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
229 GetShapesOnCylinderWithLocationIDs (const Handle(GEOM_Object)& theShape,
230 const Standard_Integer theShapeType,
231 const Handle(GEOM_Object)& theAxis,
232 const Handle(GEOM_Object)& thePnt,
233 const Standard_Real theRadius,
234 const GEOMAlgo_State theState);
236 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
237 GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
238 const Standard_Integer theShapeType,
239 const Handle(GEOM_Object)& theCenter,
240 const Standard_Real theRadius,
241 const GEOMAlgo_State theState);
244 * \brief Find sub-shapes complying with given status about quadrangle
245 * \param theShape - the shape to explore
246 * \param theShapeType - type of sub-shape of theShape
247 * \param theTopLeftPoint - top left quadrangle corner
248 * \param theTopRigthPoint - top right quadrangle corner
249 * \param theBottomLeftPoint - bottom left quadrangle corner
250 * \param theBottomRigthPoint - bottom right quadrangle corner
251 * \param theState - required state
252 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
254 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
255 GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
256 const Standard_Integer theShapeType,
257 const Handle(GEOM_Object)& theTopLeftPoint,
258 const Handle(GEOM_Object)& theTopRigthPoint,
259 const Handle(GEOM_Object)& theBottomLeftPoint,
260 const Handle(GEOM_Object)& theBottomRigthPoint,
261 const GEOMAlgo_State theState);
264 * \brief Find IDs of sub-shapes complying with given status about quadrangle
265 * \param theShape - the shape to explore
266 * \param theShapeType - type of sub-shape of theShape
267 * \param theTopLeftPoint - top left quadrangle corner
268 * \param theTopRigthPoint - top right quadrangle corner
269 * \param theBottomLeftPoint - bottom left quadrangle corner
270 * \param theBottomRigthPoint - bottom right quadrangle corner
271 * \param theState - required state
272 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
274 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
275 GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
276 const Standard_Integer theShapeType,
277 const Handle(GEOM_Object)& theTopLeftPoint,
278 const Handle(GEOM_Object)& theTopRigthPoint,
279 const Handle(GEOM_Object)& theBottomLeftPoint,
280 const Handle(GEOM_Object)& theBottomRigthPoint,
281 const GEOMAlgo_State theState);
283 Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape,
284 const Standard_Integer theShapeType,
285 Handle(GEOM_Object) theAxis,
286 const Standard_Real theRadius);
288 Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape,
289 const Standard_Integer theShapeType,
290 Handle(GEOM_Object) theCenter,
291 const Standard_Real theRadius);
293 void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
295 Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
296 Handle(GEOM_Object) theShapeWhat);
298 Standard_EXPORT Handle(GEOM_Object) GetInPlaceOld (Handle(GEOM_Object) theShapeWhere,
299 Handle(GEOM_Object) theShapeWhat);
301 Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
302 Handle(GEOM_Object) theShapeWhat);
305 * \brief Searches a shape equal to theWhat in the context of theWhere
306 * \param theShapeWhere - a context shap
307 * \param theShapeWhat - a sample shape
308 * \retval Handle(GEOM_Object) - found shape
310 Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
311 const Handle(GEOM_Object)& theShapeWhat);
314 * \brief Searches a shape equal to theWhat in the context of theWhere
315 * \param theShapeWhere - a context shap
316 * \param theShapeWhat - a sample shape
317 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
319 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetSameIDs(const Handle(GEOM_Object)& theShapeWhere,
320 const Handle(GEOM_Object)& theShapeWhat);
323 * \brief Find IDs of sub-shapes complying with given status about surface
324 * \param theBox - the box to check state of sub-shapes against
325 * \param theShape - the shape to explore
326 * \param theShapeType - type of sub-shape of theShape
327 * \param theState - required state
328 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
330 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
331 GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
332 const Handle(GEOM_Object)& theShape,
333 const Standard_Integer theShapeType,
334 GEOMAlgo_State theState);
337 * \brief Find sub-shapes complying with given status about surface
338 * \param theBox - the box to check state of sub-shapes against
339 * \param theShape - the shape to explore
340 * \param theShapeType - type of sub-shape of theShape
341 * \param theState - required state
342 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
344 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
345 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
346 const Handle(GEOM_Object)& theShape,
347 const Standard_Integer theShapeType,
348 GEOMAlgo_State theState);
351 * \brief Find IDs of sub-shapes complying with given status about surface
352 * \param theCheckShape - the shape to check state of sub-shapes against
353 * \param theShape - the shape to explore
354 * \param theShapeType - type of sub-shape of theShape
355 * \param theState - required state
356 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
358 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
359 GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape,
360 const Handle(GEOM_Object)& theShape,
361 const Standard_Integer theShapeType,
362 GEOMAlgo_State theState);
365 * \brief Find sub-shapes complying with given status about surface
366 * \param theCheckShape - the shape to check state of sub-shapes against
367 * \param theShape - the shape to explore
368 * \param theShapeType - type of sub-shape of theShape
369 * \param theState - required state
370 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
372 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
373 GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape,
374 const Handle(GEOM_Object)& theShape,
375 const Standard_Integer theShapeType,
376 GEOMAlgo_State theState);
377 Standard_EXPORT Handle(GEOM_Object)
378 GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape,
379 const Handle(GEOM_Object)& theShape,
380 const Standard_Integer theShapeType,
381 GEOMAlgo_State theState);
384 Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes,
385 const Standard_Integer theObjectType,
386 const Standard_Integer theFunctionType,
387 const TCollection_AsciiString& theMethodName);
389 // ----------------------------------------------------
390 // methods common for all GetShapesOnXXX() functions
391 // ----------------------------------------------------
394 * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
395 * \param theShapeType - the shape type to check
396 * \retval bool - result of the check
398 bool checkTypeShapesOn(const Standard_Integer theShapeType);
401 * \brief Creates Geom_Plane
402 * \param theAx1 - edge defining plane normal
403 * \retval Handle(Geom_Surface) - resulting surface
405 Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
408 * \brief Creates Geom_CylindricalSurface
409 * \param theAx1 - edge defining cylinder axis
410 * \param theRadius - cylinder radius
411 * \retval Handle(Geom_Surface) - resulting surface
413 Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
414 const Standard_Real theRadius);
417 * \brief Find IDs of sub-shapes complying with given status about surface
418 * \param theSurface - the surface to check state of sub-shapes against
419 * \param theShape - the shape to explore
420 * \param theShapeType - type of sub-shape of theShape
421 * \param theState - required state
422 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
424 Handle(TColStd_HSequenceOfInteger)
425 getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
426 const TopoDS_Shape& theShape,
427 TopAbs_ShapeEnum theShapeType,
428 GEOMAlgo_State theState);
431 * \brief Find sub-shapes complying with given status about surface
432 * \param theSurface - the surface to check state of sub-shapes against
433 * \param theShape - the shape to explore
434 * \param theShapeType - type of sub-shape of theShape
435 * \param theState - required state
436 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
437 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
439 Handle(TColStd_HSequenceOfTransient)
440 getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
441 const Handle(GEOM_Object)& theShape,
442 TopAbs_ShapeEnum theShapeType,
443 GEOMAlgo_State theState,
444 TCollection_AsciiString & theShapeEntries);
447 * \brief Find IDs of sub-shapes complying with given status about quadrangle
448 * \param theShape - the shape to explore
449 * \param theShapeType - type of sub-shape of theShape
450 * \param theTopLeftPoint - top left quadrangle corner
451 * \param theTopRigthPoint - top right quadrangle corner
452 * \param theBottomLeftPoint - bottom left quadrangle corner
453 * \param theBottomRigthPoint - bottom right quadrangle corner
454 * \param theState - required state
455 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
457 Handle(TColStd_HSequenceOfInteger)
458 getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
459 const Standard_Integer theShapeType,
460 const Handle(GEOM_Object)& theTopLeftPoint,
461 const Handle(GEOM_Object)& theTopRigthPoint,
462 const Handle(GEOM_Object)& theBottomLeftPoint,
463 const Handle(GEOM_Object)& theBottomRigthPoint,
464 const GEOMAlgo_State theState);
467 * \brief Find IDs of sub-shapes complying with given status about surface
468 * \param theBox - the box to check state of sub-shapes against
469 * \param theShape - the shape to explore
470 * \param theShapeType - type of sub-shape of theShape
471 * \param theState - required state
472 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
474 Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
475 const Handle(GEOM_Object)& theShape,
476 const Standard_Integer theShapeType,
477 GEOMAlgo_State theState);
480 * \brief Find IDs of sub-shapes complying with given status about surface
481 * \param theCheckShape - the shape to check state of sub-shapes against
482 * \param theShape - the shape to explore
483 * \param theShapeType - type of sub-shape of theShape
484 * \param theState - required state
485 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
487 Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs
488 (const Handle(GEOM_Object)& theCheckShape,
489 const Handle(GEOM_Object)& theShape,
490 const Standard_Integer theShapeType,
491 GEOMAlgo_State theState);
494 * \brief Find shape objects and their entries by their ids
495 * \param theShape - the main shape
496 * \param theShapeIDs - theShapeIDs - incoming shape ids
497 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
498 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
500 Handle(TColStd_HSequenceOfTransient)
501 getObjectsShapesOn(const Handle(GEOM_Object)& theShape,
502 const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
503 TCollection_AsciiString & theShapeEntries);
506 * \brief Select the object created last
507 * \param theObj1 - Object 1
508 * \param theObj2 - Object 2
509 * \retval Handle(GEOM_Object) - selected object
511 static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
512 const Handle(GEOM_Object)& theObj2);