1 // Copyright (C) 2007-2008 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
28 //=============================================================================
30 #ifndef _GEOMImpl_IShapesOperations_HXX_
31 #define _GEOMImpl_IShapesOperations_HXX_
33 #include "GEOM_IOperations.hxx"
35 #include "GEOMAlgo_State.hxx"
37 #include <TopTools_ListOfShape.hxx>
38 #include <TColStd_HSequenceOfTransient.hxx>
39 #include <TColStd_HSequenceOfInteger.hxx>
42 #include <Handle_Geom_Surface.hxx>
47 class Handle(GEOM_Object);
48 class Handle(TColStd_HArray1OfInteger);
50 class GEOMImpl_IShapesOperations : public GEOM_IOperations
53 Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
54 Standard_EXPORT ~GEOMImpl_IShapesOperations();
56 Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
57 Handle(GEOM_Object) thePoint2);
59 Standard_EXPORT Handle(GEOM_Object) MakeWire (std::list<Handle(GEOM_Object)> theEdgesAndWires,
60 const Standard_Real theTolerance);
62 Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
64 Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (std::list<Handle(GEOM_Object)> theWires,
65 const bool isPlanarWanted);
67 Standard_EXPORT Handle(GEOM_Object) MakeShell (std::list<Handle(GEOM_Object)> theShapes);
69 Standard_EXPORT Handle(GEOM_Object) MakeSolidShell (Handle(GEOM_Object) theShell);
71 Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (std::list<Handle(GEOM_Object)> theShells);
73 Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list<Handle(GEOM_Object)> theShapes);
75 Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
76 const Standard_Real theTolerance,
77 const Standard_Boolean doKeepNonSolids);
79 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
80 const Standard_Real theTolerance);
82 Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
83 const Standard_Real theTolerance,
84 std::list<Handle(GEOM_Object)> theFaces,
85 const Standard_Boolean doKeepNonSolids);
87 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode (Handle(GEOM_Object) theShape,
88 const Standard_Integer theShapeType,
89 const Standard_Boolean isSorted);
91 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs (Handle(GEOM_Object) theShape,
92 const Standard_Integer theShapeType,
93 const Standard_Boolean isSorted);
95 Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape,
96 const Standard_Integer theID);
98 Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
99 Handle(GEOM_Object) theSubShape);
101 Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
102 Handle(GEOM_Object) theSubShape);
104 Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
106 Standard_EXPORT Standard_Integer NumberOfSubShapes (Handle(GEOM_Object) theShape,
107 const Standard_Integer theShapeType);
109 Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
111 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
113 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetSharedShapes (Handle(GEOM_Object) theShape1,
114 Handle(GEOM_Object) theShape2,
115 const Standard_Integer theShapeType);
117 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
118 const Standard_Integer theShapeType,
119 const Handle(GEOM_Object)& theAx1,
120 const GEOMAlgo_State theState);
122 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
123 GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
124 const Standard_Integer theShapeType,
125 const Handle(GEOM_Object)& theAx1,
126 const Handle(GEOM_Object)& thePnt,
127 const GEOMAlgo_State theState);
130 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
131 GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
132 const Standard_Integer theShapeType,
133 const Handle(GEOM_Object)& theAxis,
134 const Standard_Real theRadius,
135 const GEOMAlgo_State theState);
137 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
138 GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
139 const Standard_Integer theShapeType,
140 const Handle(GEOM_Object)& theCenter,
141 const Standard_Real theRadius,
142 const GEOMAlgo_State theState);
144 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
145 GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
146 const Standard_Integer theShapeType,
147 const Handle(GEOM_Object)& theAx1,
148 const GEOMAlgo_State theState);
150 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
151 GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
152 const Standard_Integer theShapeType,
153 const Handle(GEOM_Object)& theAx1,
154 const Handle(GEOM_Object)& thePnt,
155 const GEOMAlgo_State theState);
157 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
158 GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
159 const Standard_Integer theShapeType,
160 const Handle(GEOM_Object)& theAxis,
161 const Standard_Real theRadius,
162 const GEOMAlgo_State theState);
164 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
165 GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
166 const Standard_Integer theShapeType,
167 const Handle(GEOM_Object)& theCenter,
168 const Standard_Real theRadius,
169 const GEOMAlgo_State theState);
172 * \brief Find subshapes complying with given status about quadrangle
173 * \param theShape - the shape to explore
174 * \param theShapeType - type of subshape of theShape
175 * \param theTopLeftPoint - top left quadrangle corner
176 * \param theTopRigthPoint - top right quadrangle corner
177 * \param theBottomLeftPoint - bottom left quadrangle corner
178 * \param theBottomRigthPoint - bottom right quadrangle corner
179 * \param theState - required state
180 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
182 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
183 GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
184 const Standard_Integer theShapeType,
185 const Handle(GEOM_Object)& theTopLeftPoint,
186 const Handle(GEOM_Object)& theTopRigthPoint,
187 const Handle(GEOM_Object)& theBottomLeftPoint,
188 const Handle(GEOM_Object)& theBottomRigthPoint,
189 const GEOMAlgo_State theState);
192 * \brief Find IDs of subshapes complying with given status about quadrangle
193 * \param theShape - the shape to explore
194 * \param theShapeType - type of subshape of theShape
195 * \param theTopLeftPoint - top left quadrangle corner
196 * \param theTopRigthPoint - top right quadrangle corner
197 * \param theBottomLeftPoint - bottom left quadrangle corner
198 * \param theBottomRigthPoint - bottom right quadrangle corner
199 * \param theState - required state
200 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
202 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
203 GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
204 const Standard_Integer theShapeType,
205 const Handle(GEOM_Object)& theTopLeftPoint,
206 const Handle(GEOM_Object)& theTopRigthPoint,
207 const Handle(GEOM_Object)& theBottomLeftPoint,
208 const Handle(GEOM_Object)& theBottomRigthPoint,
209 const GEOMAlgo_State theState);
211 Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape,
212 const Standard_Integer theShapeType,
213 Handle(GEOM_Object) theAxis,
214 const Standard_Real theRadius);
216 Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape,
217 const Standard_Integer theShapeType,
218 Handle(GEOM_Object) theCenter,
219 const Standard_Real theRadius);
221 void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
223 Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
224 Handle(GEOM_Object) theShapeWhat);
226 Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
227 Handle(GEOM_Object) theShapeWhat);
230 * \brief Searches a shape equal to theWhat in the context of theWhere
231 * \param theShapeWhere - a context shap
232 * \param theShapeWhat - a sample shape
233 * \retval Handle(GEOM_Object) - found shape
235 Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
236 const Handle(GEOM_Object)& theShapeWhat);
239 * \brief Find IDs of subshapes complying with given status about surface
240 * \param theBox - the box to check state of subshapes against
241 * \param theShape - the shape to explore
242 * \param theShapeType - type of subshape of theShape
243 * \param theState - required state
244 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
246 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
247 GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
248 const Handle(GEOM_Object)& theShape,
249 const Standard_Integer theShapeType,
250 GEOMAlgo_State theState);
253 * \brief Find subshapes complying with given status about surface
254 * \param theBox - the box to check state of subshapes against
255 * \param theShape - the shape to explore
256 * \param theShapeType - type of subshape of theShape
257 * \param theState - required state
258 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
260 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
261 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
262 const Handle(GEOM_Object)& theShape,
263 const Standard_Integer theShapeType,
264 GEOMAlgo_State theState);
267 * \brief Find IDs of subshapes complying with given status about surface
268 * \param theCheckShape - the shape to check state of subshapes against
269 * \param theShape - the shape to explore
270 * \param theShapeType - type of subshape of theShape
271 * \param theState - required state
272 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
274 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
275 GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape,
276 const Handle(GEOM_Object)& theShape,
277 const Standard_Integer theShapeType,
278 GEOMAlgo_State theState);
281 * \brief Find subshapes complying with given status about surface
282 * \param theCheckShape - the shape to check state of subshapes against
283 * \param theShape - the shape to explore
284 * \param theShapeType - type of subshape of theShape
285 * \param theState - required state
286 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
288 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
289 GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape,
290 const Handle(GEOM_Object)& theShape,
291 const Standard_Integer theShapeType,
292 GEOMAlgo_State theState);
293 Standard_EXPORT Handle(GEOM_Object)
294 GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape,
295 const Handle(GEOM_Object)& theShape,
296 const Standard_Integer theShapeType,
297 GEOMAlgo_State theState);
301 * \brief Sort shapes in the list by their coordinates.
302 * \param SL The list of shapes to sort.
304 Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
307 * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND.
309 * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is.
311 * \param theCompsolid The compsolid to be converted.
312 * \retval TopoDS_Shape Returns the resulting compound.
314 Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
317 * \brief Build a triangulation on \a theShape if it is absent.
318 * \param theShape The shape to check/build triangulation on.
319 * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation.
321 Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
324 Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes,
325 const Standard_Integer theObjectType,
326 const Standard_Integer theFunctionType,
327 const TCollection_AsciiString& theMethodName);
329 // ----------------------------------------------------
330 // methods common for all GetShapesOnXXX() functions
331 // ----------------------------------------------------
334 * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
335 * \param theShapeType - the shape type to check
336 * \retval bool - result of the check
338 bool checkTypeShapesOn(const Standard_Integer theShapeType);
341 * \brief Creates Geom_Plane
342 * \param theAx1 - edge defining plane normal
343 * \retval Handle(Geom_Surface) - resulting surface
345 Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
348 * \brief Creates Geom_CylindricalSurface
349 * \param theAx1 - edge defining cylinder axis
350 * \param theRadius - cylinder radius
351 * \retval Handle(Geom_Surface) - resulting surface
353 Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
354 const Standard_Real theRadius);
357 * \brief Find IDs of subshapes complying with given status about surface
358 * \param theSurface - the surface to check state of subshapes against
359 * \param theShape - the shape to explore
360 * \param theShapeType - type of subshape of theShape
361 * \param theState - required state
362 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
364 Handle(TColStd_HSequenceOfInteger)
365 getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
366 const TopoDS_Shape& theShape,
367 TopAbs_ShapeEnum theShapeType,
368 GEOMAlgo_State theState);
371 * \brief Find subshapes complying with given status about surface
372 * \param theSurface - the surface to check state of subshapes against
373 * \param theShape - the shape to explore
374 * \param theShapeType - type of subshape of theShape
375 * \param theState - required state
376 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
377 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
379 Handle(TColStd_HSequenceOfTransient)
380 getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
381 const Handle(GEOM_Object)& theShape,
382 TopAbs_ShapeEnum theShapeType,
383 GEOMAlgo_State theState,
384 TCollection_AsciiString & theShapeEntries);
387 * \brief Find IDs of subshapes complying with given status about quadrangle
388 * \param theShape - the shape to explore
389 * \param theShapeType - type of subshape of theShape
390 * \param theTopLeftPoint - top left quadrangle corner
391 * \param theTopRigthPoint - top right quadrangle corner
392 * \param theBottomLeftPoint - bottom left quadrangle corner
393 * \param theBottomRigthPoint - bottom right quadrangle corner
394 * \param theState - required state
395 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
397 Handle(TColStd_HSequenceOfInteger)
398 getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
399 const Standard_Integer theShapeType,
400 const Handle(GEOM_Object)& theTopLeftPoint,
401 const Handle(GEOM_Object)& theTopRigthPoint,
402 const Handle(GEOM_Object)& theBottomLeftPoint,
403 const Handle(GEOM_Object)& theBottomRigthPoint,
404 const GEOMAlgo_State theState);
407 * \brief Find IDs of subshapes complying with given status about surface
408 * \param theBox - the box to check state of subshapes against
409 * \param theShape - the shape to explore
410 * \param theShapeType - type of subshape of theShape
411 * \param theState - required state
412 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
414 Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
415 const Handle(GEOM_Object)& theShape,
416 const Standard_Integer theShapeType,
417 GEOMAlgo_State theState);
420 * \brief Find IDs of subshapes complying with given status about surface
421 * \param theCheckShape - the shape to check state of subshapes against
422 * \param theShape - the shape to explore
423 * \param theShapeType - type of subshape of theShape
424 * \param theState - required state
425 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
427 Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs
428 (const Handle(GEOM_Object)& theCheckShape,
429 const Handle(GEOM_Object)& theShape,
430 const Standard_Integer theShapeType,
431 GEOMAlgo_State theState);
434 * \brief Find shape objects and their entries by their ids
435 * \param theShape - the main shape
436 * \param theShapeIDs - theShapeIDs - incoming shape ids
437 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
438 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
440 Handle(TColStd_HSequenceOfTransient)
441 getObjectsShapesOn(const Handle(GEOM_Object)& theShape,
442 const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
443 TCollection_AsciiString & theShapeEntries);
446 * \brief Select the object created last
447 * \param theObj1 - Object 1
448 * \param theObj2 - Object 2
449 * \retval Handle(GEOM_Object) - selected object
451 static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
452 const Handle(GEOM_Object)& theObj2);