1 // Copyright (C) 2007-2010 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.
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
22 //=============================================================================
23 // File : GEOMImpl_IShapesOperations.hxx
25 // Author : modified by Lioka RAZAFINDRAZAKA (CEA) 22/06/2007
27 //=============================================================================
29 #ifndef _GEOMImpl_IShapesOperations_HXX_
30 #define _GEOMImpl_IShapesOperations_HXX_
32 #include "GEOM_IOperations.hxx"
34 #include "GEOMAlgo_State.hxx"
36 #include <TopTools_ListOfShape.hxx>
37 #include <TColStd_HSequenceOfTransient.hxx>
38 #include <TColStd_HSequenceOfInteger.hxx>
41 #include <Handle_Geom_Surface.hxx>
46 class Handle(GEOM_Object);
47 class Handle(TColStd_HArray1OfInteger);
49 class GEOMImpl_IShapesOperations : public GEOM_IOperations
52 Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
53 Standard_EXPORT ~GEOMImpl_IShapesOperations();
55 Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
56 Handle(GEOM_Object) thePoint2);
58 Standard_EXPORT Handle(GEOM_Object) MakeEdgeOnCurveByLength (Handle(GEOM_Object) theCurve,
59 const Standard_Real theLength,
60 Handle(GEOM_Object) theStartPoint);
62 Standard_EXPORT Handle(GEOM_Object) MakeEdgeWire (Handle(GEOM_Object) theWire,
63 const Standard_Real theLinearTolerance,
64 const Standard_Real theAngularTolerance);
66 Standard_EXPORT Handle(GEOM_Object) MakeWire (std::list<Handle(GEOM_Object)> theEdgesAndWires,
67 const Standard_Real theTolerance);
69 Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
71 Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (std::list<Handle(GEOM_Object)> theWires,
72 const bool isPlanarWanted);
74 Standard_EXPORT Handle(GEOM_Object) MakeShell (std::list<Handle(GEOM_Object)> theShapes);
76 Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (std::list<Handle(GEOM_Object)> theShells);
78 Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list<Handle(GEOM_Object)> theShapes);
80 Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
81 const Standard_Real theTolerance,
82 const Standard_Boolean doKeepNonSolids);
84 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
85 const Standard_Real theTolerance);
87 Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
88 const Standard_Real theTolerance,
89 std::list<Handle(GEOM_Object)> theFaces,
90 const Standard_Boolean doKeepNonSolids);
92 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects
93 (Handle(GEOM_Object) theShape,
94 const Standard_Boolean theGroupsOnly);
97 EXPLODE_OLD_INCLUDE_MAIN,
98 EXPLODE_NEW_INCLUDE_MAIN,
99 EXPLODE_NEW_EXCLUDE_MAIN
102 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode
103 (Handle(GEOM_Object) theShape,
104 const Standard_Integer theShapeType,
105 const Standard_Boolean isSorted,
106 const ExplodeType theExplodeType = EXPLODE_NEW_INCLUDE_MAIN);
108 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs
109 (Handle(GEOM_Object) theShape,
110 const Standard_Integer theShapeType,
111 const Standard_Boolean isSorted,
112 const ExplodeType theExplodeType = EXPLODE_NEW_INCLUDE_MAIN);
114 Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape,
115 const Standard_Integer theID);
117 Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
118 Handle(GEOM_Object) theSubShape);
120 Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
121 Handle(GEOM_Object) theSubShape);
123 Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
125 Standard_EXPORT Standard_Integer NumberOfSubShapes (Handle(GEOM_Object) theShape,
126 const Standard_Integer theShapeType);
128 Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
130 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
132 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
133 GetSharedShapes (Handle(GEOM_Object) theShape1,
134 Handle(GEOM_Object) theShape2,
135 const Standard_Integer theShapeType);
137 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
138 GetSharedShapes (std::list<Handle(GEOM_Object)> theShapes,
139 const Standard_Integer theShapeType);
141 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
142 GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
143 const Standard_Integer theShapeType,
144 const Handle(GEOM_Object)& theAx1,
145 const GEOMAlgo_State theState);
147 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
148 GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
149 const Standard_Integer theShapeType,
150 const Handle(GEOM_Object)& theAx1,
151 const Handle(GEOM_Object)& thePnt,
152 const GEOMAlgo_State theState);
155 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
156 GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
157 const Standard_Integer theShapeType,
158 const Handle(GEOM_Object)& theAxis,
159 const Standard_Real theRadius,
160 const GEOMAlgo_State theState);
162 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
163 GetShapesOnCylinderWithLocation (const Handle(GEOM_Object)& theShape,
164 const Standard_Integer theShapeType,
165 const Handle(GEOM_Object)& theAxis,
166 const Handle(GEOM_Object)& thePnt,
167 const Standard_Real theRadius,
168 const GEOMAlgo_State theState);
170 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
171 GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
172 const Standard_Integer theShapeType,
173 const Handle(GEOM_Object)& theCenter,
174 const Standard_Real theRadius,
175 const GEOMAlgo_State theState);
177 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
178 GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
179 const Standard_Integer theShapeType,
180 const Handle(GEOM_Object)& theAx1,
181 const GEOMAlgo_State theState);
183 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
184 GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
185 const Standard_Integer theShapeType,
186 const Handle(GEOM_Object)& theAx1,
187 const Handle(GEOM_Object)& thePnt,
188 const GEOMAlgo_State theState);
190 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
191 GetShapesOnCylinderIDs (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_HSequenceOfInteger)
198 GetShapesOnCylinderWithLocationIDs (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_HSequenceOfInteger)
206 GetShapesOnSphereIDs (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);
213 * \brief Find subshapes complying with given status about quadrangle
214 * \param theShape - the shape to explore
215 * \param theShapeType - type of subshape of theShape
216 * \param theTopLeftPoint - top left quadrangle corner
217 * \param theTopRigthPoint - top right quadrangle corner
218 * \param theBottomLeftPoint - bottom left quadrangle corner
219 * \param theBottomRigthPoint - bottom right quadrangle corner
220 * \param theState - required state
221 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
223 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
224 GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
225 const Standard_Integer theShapeType,
226 const Handle(GEOM_Object)& theTopLeftPoint,
227 const Handle(GEOM_Object)& theTopRigthPoint,
228 const Handle(GEOM_Object)& theBottomLeftPoint,
229 const Handle(GEOM_Object)& theBottomRigthPoint,
230 const GEOMAlgo_State theState);
233 * \brief Find IDs of subshapes complying with given status about quadrangle
234 * \param theShape - the shape to explore
235 * \param theShapeType - type of subshape of theShape
236 * \param theTopLeftPoint - top left quadrangle corner
237 * \param theTopRigthPoint - top right quadrangle corner
238 * \param theBottomLeftPoint - bottom left quadrangle corner
239 * \param theBottomRigthPoint - bottom right quadrangle corner
240 * \param theState - required state
241 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
243 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
244 GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
245 const Standard_Integer theShapeType,
246 const Handle(GEOM_Object)& theTopLeftPoint,
247 const Handle(GEOM_Object)& theTopRigthPoint,
248 const Handle(GEOM_Object)& theBottomLeftPoint,
249 const Handle(GEOM_Object)& theBottomRigthPoint,
250 const GEOMAlgo_State theState);
252 Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape,
253 const Standard_Integer theShapeType,
254 Handle(GEOM_Object) theAxis,
255 const Standard_Real theRadius);
257 Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape,
258 const Standard_Integer theShapeType,
259 Handle(GEOM_Object) theCenter,
260 const Standard_Real theRadius);
262 void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
264 Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
265 Handle(GEOM_Object) theShapeWhat);
267 Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
268 Handle(GEOM_Object) theShapeWhat);
271 * \brief Searches a shape equal to theWhat in the context of theWhere
272 * \param theShapeWhere - a context shap
273 * \param theShapeWhat - a sample shape
274 * \retval Handle(GEOM_Object) - found shape
276 Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
277 const Handle(GEOM_Object)& theShapeWhat);
280 * \brief Find IDs of subshapes complying with given status about surface
281 * \param theBox - the box to check state of subshapes against
282 * \param theShape - the shape to explore
283 * \param theShapeType - type of subshape of theShape
284 * \param theState - required state
285 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
287 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
288 GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
289 const Handle(GEOM_Object)& theShape,
290 const Standard_Integer theShapeType,
291 GEOMAlgo_State theState);
294 * \brief Find subshapes complying with given status about surface
295 * \param theBox - the box to check state of subshapes against
296 * \param theShape - the shape to explore
297 * \param theShapeType - type of subshape of theShape
298 * \param theState - required state
299 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
301 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
302 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
303 const Handle(GEOM_Object)& theShape,
304 const Standard_Integer theShapeType,
305 GEOMAlgo_State theState);
308 * \brief Find IDs of subshapes complying with given status about surface
309 * \param theCheckShape - the shape to check state of subshapes against
310 * \param theShape - the shape to explore
311 * \param theShapeType - type of subshape of theShape
312 * \param theState - required state
313 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
315 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
316 GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape,
317 const Handle(GEOM_Object)& theShape,
318 const Standard_Integer theShapeType,
319 GEOMAlgo_State theState);
322 * \brief Find subshapes complying with given status about surface
323 * \param theCheckShape - the shape to check state of subshapes against
324 * \param theShape - the shape to explore
325 * \param theShapeType - type of subshape of theShape
326 * \param theState - required state
327 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
329 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
330 GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape,
331 const Handle(GEOM_Object)& theShape,
332 const Standard_Integer theShapeType,
333 GEOMAlgo_State theState);
334 Standard_EXPORT Handle(GEOM_Object)
335 GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape,
336 const Handle(GEOM_Object)& theShape,
337 const Standard_Integer theShapeType,
338 GEOMAlgo_State theState);
342 * \brief Sort shapes in the list by their coordinates.
343 * \param SL The list of shapes to sort.
345 Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL,
346 const Standard_Boolean isOldSorting = Standard_True);
349 * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND.
351 * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is.
353 * \param theCompsolid The compsolid to be converted.
354 * \retval TopoDS_Shape Returns the resulting compound.
356 Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
359 * \brief Build a triangulation on \a theShape if it is absent.
360 * \param theShape The shape to check/build triangulation on.
361 * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation.
363 Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
366 Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes,
367 const Standard_Integer theObjectType,
368 const Standard_Integer theFunctionType,
369 const TCollection_AsciiString& theMethodName);
371 // ----------------------------------------------------
372 // methods common for all GetShapesOnXXX() functions
373 // ----------------------------------------------------
376 * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
377 * \param theShapeType - the shape type to check
378 * \retval bool - result of the check
380 bool checkTypeShapesOn(const Standard_Integer theShapeType);
383 * \brief Creates Geom_Plane
384 * \param theAx1 - edge defining plane normal
385 * \retval Handle(Geom_Surface) - resulting surface
387 Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
390 * \brief Creates Geom_CylindricalSurface
391 * \param theAx1 - edge defining cylinder axis
392 * \param theRadius - cylinder radius
393 * \retval Handle(Geom_Surface) - resulting surface
395 Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
396 const Standard_Real theRadius);
399 * \brief Find IDs of subshapes complying with given status about surface
400 * \param theSurface - the surface to check state of subshapes against
401 * \param theShape - the shape to explore
402 * \param theShapeType - type of subshape of theShape
403 * \param theState - required state
404 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
406 Handle(TColStd_HSequenceOfInteger)
407 getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
408 const TopoDS_Shape& theShape,
409 TopAbs_ShapeEnum theShapeType,
410 GEOMAlgo_State theState);
413 * \brief Find subshapes complying with given status about surface
414 * \param theSurface - the surface to check state of subshapes against
415 * \param theShape - the shape to explore
416 * \param theShapeType - type of subshape of theShape
417 * \param theState - required state
418 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
419 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
421 Handle(TColStd_HSequenceOfTransient)
422 getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
423 const Handle(GEOM_Object)& theShape,
424 TopAbs_ShapeEnum theShapeType,
425 GEOMAlgo_State theState,
426 TCollection_AsciiString & theShapeEntries);
429 * \brief Find IDs of subshapes complying with given status about quadrangle
430 * \param theShape - the shape to explore
431 * \param theShapeType - type of subshape of theShape
432 * \param theTopLeftPoint - top left quadrangle corner
433 * \param theTopRigthPoint - top right quadrangle corner
434 * \param theBottomLeftPoint - bottom left quadrangle corner
435 * \param theBottomRigthPoint - bottom right quadrangle corner
436 * \param theState - required state
437 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
439 Handle(TColStd_HSequenceOfInteger)
440 getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
441 const Standard_Integer theShapeType,
442 const Handle(GEOM_Object)& theTopLeftPoint,
443 const Handle(GEOM_Object)& theTopRigthPoint,
444 const Handle(GEOM_Object)& theBottomLeftPoint,
445 const Handle(GEOM_Object)& theBottomRigthPoint,
446 const GEOMAlgo_State theState);
449 * \brief Find IDs of subshapes complying with given status about surface
450 * \param theBox - the box to check state of subshapes against
451 * \param theShape - the shape to explore
452 * \param theShapeType - type of subshape of theShape
453 * \param theState - required state
454 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
456 Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
457 const Handle(GEOM_Object)& theShape,
458 const Standard_Integer theShapeType,
459 GEOMAlgo_State theState);
462 * \brief Find IDs of subshapes complying with given status about surface
463 * \param theCheckShape - the shape to check state of subshapes against
464 * \param theShape - the shape to explore
465 * \param theShapeType - type of subshape of theShape
466 * \param theState - required state
467 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
469 Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs
470 (const Handle(GEOM_Object)& theCheckShape,
471 const Handle(GEOM_Object)& theShape,
472 const Standard_Integer theShapeType,
473 GEOMAlgo_State theState);
476 * \brief Find shape objects and their entries by their ids
477 * \param theShape - the main shape
478 * \param theShapeIDs - theShapeIDs - incoming shape ids
479 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
480 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
482 Handle(TColStd_HSequenceOfTransient)
483 getObjectsShapesOn(const Handle(GEOM_Object)& theShape,
484 const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
485 TCollection_AsciiString & theShapeEntries);
488 * \brief Select the object created last
489 * \param theObj1 - Object 1
490 * \param theObj2 - Object 2
491 * \retval Handle(GEOM_Object) - selected object
493 static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
494 const Handle(GEOM_Object)& theObj2);