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
23 //=============================================================================
24 // File : GEOMImpl_IShapesOperations.hxx
26 // Author : modified by Lioka RAZAFINDRAZAKA (CEA) 22/06/2007
29 //=============================================================================
31 #ifndef _GEOMImpl_IShapesOperations_HXX_
32 #define _GEOMImpl_IShapesOperations_HXX_
34 #include "GEOM_IOperations.hxx"
36 #include "GEOMAlgo_State.hxx"
38 #include <TopTools_ListOfShape.hxx>
39 #include <TColStd_HSequenceOfTransient.hxx>
40 #include <TColStd_HSequenceOfInteger.hxx>
43 #include <Handle_Geom_Surface.hxx>
48 class Handle(GEOM_Object);
49 class Handle(TColStd_HArray1OfInteger);
51 class GEOMImpl_IShapesOperations : public GEOM_IOperations
54 Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
55 Standard_EXPORT ~GEOMImpl_IShapesOperations();
57 Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
58 Handle(GEOM_Object) thePoint2);
60 Standard_EXPORT Handle(GEOM_Object) MakeWire (std::list<Handle(GEOM_Object)> theEdgesAndWires,
61 const Standard_Real theTolerance);
63 Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
65 Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (std::list<Handle(GEOM_Object)> theWires,
66 const bool isPlanarWanted);
68 Standard_EXPORT Handle(GEOM_Object) MakeShell (std::list<Handle(GEOM_Object)> theShapes);
70 Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (std::list<Handle(GEOM_Object)> theShells);
72 Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list<Handle(GEOM_Object)> theShapes);
74 Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
75 const Standard_Real theTolerance,
76 const Standard_Boolean doKeepNonSolids);
78 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
79 const Standard_Real theTolerance);
81 Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
82 const Standard_Real theTolerance,
83 std::list<Handle(GEOM_Object)> theFaces,
84 const Standard_Boolean doKeepNonSolids);
86 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects
87 (Handle(GEOM_Object) theShape,
88 const Standard_Boolean theGroupsOnly);
90 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode (Handle(GEOM_Object) theShape,
91 const Standard_Integer theShapeType,
92 const Standard_Boolean isSorted);
94 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs (Handle(GEOM_Object) theShape,
95 const Standard_Integer theShapeType,
96 const Standard_Boolean isSorted);
98 Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape,
99 const Standard_Integer theID);
101 Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
102 Handle(GEOM_Object) theSubShape);
104 Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
105 Handle(GEOM_Object) theSubShape);
107 Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
109 Standard_EXPORT Standard_Integer NumberOfSubShapes (Handle(GEOM_Object) theShape,
110 const Standard_Integer theShapeType);
112 Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
114 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
116 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetSharedShapes (Handle(GEOM_Object) theShape1,
117 Handle(GEOM_Object) theShape2,
118 const Standard_Integer theShapeType);
120 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
121 const Standard_Integer theShapeType,
122 const Handle(GEOM_Object)& theAx1,
123 const GEOMAlgo_State theState);
125 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
126 GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
127 const Standard_Integer theShapeType,
128 const Handle(GEOM_Object)& theAx1,
129 const Handle(GEOM_Object)& thePnt,
130 const GEOMAlgo_State theState);
133 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
134 GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
135 const Standard_Integer theShapeType,
136 const Handle(GEOM_Object)& theAxis,
137 const Standard_Real theRadius,
138 const GEOMAlgo_State theState);
140 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
141 GetShapesOnCylinderWithLocation (const Handle(GEOM_Object)& theShape,
142 const Standard_Integer theShapeType,
143 const Handle(GEOM_Object)& theAxis,
144 const Handle(GEOM_Object)& thePnt,
145 const Standard_Real theRadius,
146 const GEOMAlgo_State theState);
148 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
149 GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
150 const Standard_Integer theShapeType,
151 const Handle(GEOM_Object)& theCenter,
152 const Standard_Real theRadius,
153 const GEOMAlgo_State theState);
155 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
156 GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
157 const Standard_Integer theShapeType,
158 const Handle(GEOM_Object)& theAx1,
159 const GEOMAlgo_State theState);
161 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
162 GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
163 const Standard_Integer theShapeType,
164 const Handle(GEOM_Object)& theAx1,
165 const Handle(GEOM_Object)& thePnt,
166 const GEOMAlgo_State theState);
168 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
169 GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
170 const Standard_Integer theShapeType,
171 const Handle(GEOM_Object)& theAxis,
172 const Standard_Real theRadius,
173 const GEOMAlgo_State theState);
175 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
176 GetShapesOnCylinderWithLocationIDs (const Handle(GEOM_Object)& theShape,
177 const Standard_Integer theShapeType,
178 const Handle(GEOM_Object)& theAxis,
179 const Handle(GEOM_Object)& thePnt,
180 const Standard_Real theRadius,
181 const GEOMAlgo_State theState);
183 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
184 GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
185 const Standard_Integer theShapeType,
186 const Handle(GEOM_Object)& theCenter,
187 const Standard_Real theRadius,
188 const GEOMAlgo_State theState);
191 * \brief Find subshapes complying with given status about quadrangle
192 * \param theShape - the shape to explore
193 * \param theShapeType - type of subshape of theShape
194 * \param theTopLeftPoint - top left quadrangle corner
195 * \param theTopRigthPoint - top right quadrangle corner
196 * \param theBottomLeftPoint - bottom left quadrangle corner
197 * \param theBottomRigthPoint - bottom right quadrangle corner
198 * \param theState - required state
199 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
201 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
202 GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
203 const Standard_Integer theShapeType,
204 const Handle(GEOM_Object)& theTopLeftPoint,
205 const Handle(GEOM_Object)& theTopRigthPoint,
206 const Handle(GEOM_Object)& theBottomLeftPoint,
207 const Handle(GEOM_Object)& theBottomRigthPoint,
208 const GEOMAlgo_State theState);
211 * \brief Find IDs of subshapes complying with given status about quadrangle
212 * \param theShape - the shape to explore
213 * \param theShapeType - type of subshape of theShape
214 * \param theTopLeftPoint - top left quadrangle corner
215 * \param theTopRigthPoint - top right quadrangle corner
216 * \param theBottomLeftPoint - bottom left quadrangle corner
217 * \param theBottomRigthPoint - bottom right quadrangle corner
218 * \param theState - required state
219 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
221 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
222 GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
223 const Standard_Integer theShapeType,
224 const Handle(GEOM_Object)& theTopLeftPoint,
225 const Handle(GEOM_Object)& theTopRigthPoint,
226 const Handle(GEOM_Object)& theBottomLeftPoint,
227 const Handle(GEOM_Object)& theBottomRigthPoint,
228 const GEOMAlgo_State theState);
230 Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape,
231 const Standard_Integer theShapeType,
232 Handle(GEOM_Object) theAxis,
233 const Standard_Real theRadius);
235 Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape,
236 const Standard_Integer theShapeType,
237 Handle(GEOM_Object) theCenter,
238 const Standard_Real theRadius);
240 void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
242 Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
243 Handle(GEOM_Object) theShapeWhat);
245 Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
246 Handle(GEOM_Object) theShapeWhat);
249 * \brief Searches a shape equal to theWhat in the context of theWhere
250 * \param theShapeWhere - a context shap
251 * \param theShapeWhat - a sample shape
252 * \retval Handle(GEOM_Object) - found shape
254 Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
255 const Handle(GEOM_Object)& theShapeWhat);
258 * \brief Find IDs of subshapes complying with given status about surface
259 * \param theBox - the box to check state of subshapes against
260 * \param theShape - the shape to explore
261 * \param theShapeType - type of subshape of theShape
262 * \param theState - required state
263 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
265 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
266 GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
267 const Handle(GEOM_Object)& theShape,
268 const Standard_Integer theShapeType,
269 GEOMAlgo_State theState);
272 * \brief Find subshapes complying with given status about surface
273 * \param theBox - the box to check state of subshapes against
274 * \param theShape - the shape to explore
275 * \param theShapeType - type of subshape of theShape
276 * \param theState - required state
277 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
279 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
280 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
281 const Handle(GEOM_Object)& theShape,
282 const Standard_Integer theShapeType,
283 GEOMAlgo_State theState);
286 * \brief Find IDs of subshapes complying with given status about surface
287 * \param theCheckShape - the shape to check state of subshapes against
288 * \param theShape - the shape to explore
289 * \param theShapeType - type of subshape of theShape
290 * \param theState - required state
291 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
293 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
294 GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape,
295 const Handle(GEOM_Object)& theShape,
296 const Standard_Integer theShapeType,
297 GEOMAlgo_State theState);
300 * \brief Find subshapes complying with given status about surface
301 * \param theCheckShape - the shape to check state of subshapes against
302 * \param theShape - the shape to explore
303 * \param theShapeType - type of subshape of theShape
304 * \param theState - required state
305 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
307 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
308 GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape,
309 const Handle(GEOM_Object)& theShape,
310 const Standard_Integer theShapeType,
311 GEOMAlgo_State theState);
312 Standard_EXPORT Handle(GEOM_Object)
313 GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape,
314 const Handle(GEOM_Object)& theShape,
315 const Standard_Integer theShapeType,
316 GEOMAlgo_State theState);
320 * \brief Sort shapes in the list by their coordinates.
321 * \param SL The list of shapes to sort.
323 Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
326 * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND.
328 * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is.
330 * \param theCompsolid The compsolid to be converted.
331 * \retval TopoDS_Shape Returns the resulting compound.
333 Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
336 * \brief Build a triangulation on \a theShape if it is absent.
337 * \param theShape The shape to check/build triangulation on.
338 * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation.
340 Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
343 Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes,
344 const Standard_Integer theObjectType,
345 const Standard_Integer theFunctionType,
346 const TCollection_AsciiString& theMethodName);
348 // ----------------------------------------------------
349 // methods common for all GetShapesOnXXX() functions
350 // ----------------------------------------------------
353 * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
354 * \param theShapeType - the shape type to check
355 * \retval bool - result of the check
357 bool checkTypeShapesOn(const Standard_Integer theShapeType);
360 * \brief Creates Geom_Plane
361 * \param theAx1 - edge defining plane normal
362 * \retval Handle(Geom_Surface) - resulting surface
364 Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
367 * \brief Creates Geom_CylindricalSurface
368 * \param theAx1 - edge defining cylinder axis
369 * \param theRadius - cylinder radius
370 * \retval Handle(Geom_Surface) - resulting surface
372 Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
373 const Standard_Real theRadius);
376 * \brief Find IDs of subshapes complying with given status about surface
377 * \param theSurface - the surface to check state of subshapes against
378 * \param theShape - the shape to explore
379 * \param theShapeType - type of subshape of theShape
380 * \param theState - required state
381 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
383 Handle(TColStd_HSequenceOfInteger)
384 getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
385 const TopoDS_Shape& theShape,
386 TopAbs_ShapeEnum theShapeType,
387 GEOMAlgo_State theState);
390 * \brief Find subshapes complying with given status about surface
391 * \param theSurface - the surface to check state of subshapes against
392 * \param theShape - the shape to explore
393 * \param theShapeType - type of subshape of theShape
394 * \param theState - required state
395 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
396 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
398 Handle(TColStd_HSequenceOfTransient)
399 getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
400 const Handle(GEOM_Object)& theShape,
401 TopAbs_ShapeEnum theShapeType,
402 GEOMAlgo_State theState,
403 TCollection_AsciiString & theShapeEntries);
406 * \brief Find IDs of subshapes complying with given status about quadrangle
407 * \param theShape - the shape to explore
408 * \param theShapeType - type of subshape of theShape
409 * \param theTopLeftPoint - top left quadrangle corner
410 * \param theTopRigthPoint - top right quadrangle corner
411 * \param theBottomLeftPoint - bottom left quadrangle corner
412 * \param theBottomRigthPoint - bottom right quadrangle corner
413 * \param theState - required state
414 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
416 Handle(TColStd_HSequenceOfInteger)
417 getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
418 const Standard_Integer theShapeType,
419 const Handle(GEOM_Object)& theTopLeftPoint,
420 const Handle(GEOM_Object)& theTopRigthPoint,
421 const Handle(GEOM_Object)& theBottomLeftPoint,
422 const Handle(GEOM_Object)& theBottomRigthPoint,
423 const GEOMAlgo_State theState);
426 * \brief Find IDs of subshapes complying with given status about surface
427 * \param theBox - the box to check state of subshapes against
428 * \param theShape - the shape to explore
429 * \param theShapeType - type of subshape of theShape
430 * \param theState - required state
431 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
433 Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
434 const Handle(GEOM_Object)& theShape,
435 const Standard_Integer theShapeType,
436 GEOMAlgo_State theState);
439 * \brief Find IDs of subshapes complying with given status about surface
440 * \param theCheckShape - the shape to check state of subshapes against
441 * \param theShape - the shape to explore
442 * \param theShapeType - type of subshape of theShape
443 * \param theState - required state
444 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
446 Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs
447 (const Handle(GEOM_Object)& theCheckShape,
448 const Handle(GEOM_Object)& theShape,
449 const Standard_Integer theShapeType,
450 GEOMAlgo_State theState);
453 * \brief Find shape objects and their entries by their ids
454 * \param theShape - the main shape
455 * \param theShapeIDs - theShapeIDs - incoming shape ids
456 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
457 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
459 Handle(TColStd_HSequenceOfTransient)
460 getObjectsShapesOn(const Handle(GEOM_Object)& theShape,
461 const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
462 TCollection_AsciiString & theShapeEntries);
465 * \brief Select the object created last
466 * \param theObj1 - Object 1
467 * \param theObj2 - Object 2
468 * \retval Handle(GEOM_Object) - selected object
470 static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
471 const Handle(GEOM_Object)& theObj2);