]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMImpl/GEOMImpl_IShapesOperations.hxx
Salome HOME
Mantis issues 0020939(GetSharedShapes) and 0020842(AllSorted meaning).
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IShapesOperations.hxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21
22 //=============================================================================
23 // File      : GEOMImpl_IShapesOperations.hxx
24 // Created   :
25 // Author    : modified by Lioka RAZAFINDRAZAKA (CEA) 22/06/2007
26 // Project   : SALOME
27 // $Header$
28 //=============================================================================
29
30 #ifndef _GEOMImpl_IShapesOperations_HXX_
31 #define _GEOMImpl_IShapesOperations_HXX_
32
33 #include "GEOM_IOperations.hxx"
34
35 #include "GEOMAlgo_State.hxx"
36
37 #include <TopTools_ListOfShape.hxx>
38 #include <TColStd_HSequenceOfTransient.hxx>
39 #include <TColStd_HSequenceOfInteger.hxx>
40
41 #include <list>
42 #include <Handle_Geom_Surface.hxx>
43
44 #include <gp_Pnt.hxx>
45
46 class GEOM_Engine;
47 class Handle(GEOM_Object);
48 class Handle(TColStd_HArray1OfInteger);
49
50 class GEOMImpl_IShapesOperations : public GEOM_IOperations
51 {
52  public:
53   Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
54   Standard_EXPORT ~GEOMImpl_IShapesOperations();
55
56   Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
57                                                 Handle(GEOM_Object) thePoint2);
58
59   Standard_EXPORT Handle(GEOM_Object) MakeWire (std::list<Handle(GEOM_Object)> theEdgesAndWires,
60                                                 const Standard_Real            theTolerance);
61
62   Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
63
64   Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (std::list<Handle(GEOM_Object)> theWires,
65                                                      const bool isPlanarWanted);
66
67   Standard_EXPORT Handle(GEOM_Object) MakeShell (std::list<Handle(GEOM_Object)> theShapes);
68
69   Standard_EXPORT Handle(GEOM_Object) MakeSolidShell (Handle(GEOM_Object) theShell);
70
71   Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (std::list<Handle(GEOM_Object)> theShells);
72
73   Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list<Handle(GEOM_Object)> theShapes);
74
75   Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
76                                                      const Standard_Real theTolerance,
77                                                      const Standard_Boolean doKeepNonSolids);
78
79   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
80                                                                      const Standard_Real theTolerance);
81
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);
86
87   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode
88     (Handle(GEOM_Object)    theShape,
89      const Standard_Integer theShapeType,
90      const Standard_Boolean isSorted,
91      const Standard_Boolean isOldSorting = Standard_False);
92
93   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs
94     (Handle(GEOM_Object)    theShape,
95      const Standard_Integer theShapeType,
96      const Standard_Boolean isSorted,
97      const Standard_Boolean isOldSorting = Standard_False);
98
99   Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object)    theMainShape,
100                                                    const Standard_Integer theID);
101
102   Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
103                                                      Handle(GEOM_Object) theSubShape);
104
105   Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
106                                                      Handle(GEOM_Object) theSubShape);
107
108   Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
109
110   Standard_EXPORT Standard_Integer NumberOfSubShapes (Handle(GEOM_Object)    theShape,
111                                                       const Standard_Integer theShapeType);
112
113   Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
114
115   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
116
117   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
118     GetSharedShapes (Handle(GEOM_Object)    theShape1,
119                      Handle(GEOM_Object)    theShape2,
120                      const Standard_Integer theShapeType);
121
122   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
123     GetSharedShapes (std::list<Handle(GEOM_Object)> theShapes,
124                      const Standard_Integer         theShapeType);
125
126   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
127     GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
128                       const Standard_Integer     theShapeType,
129                       const Handle(GEOM_Object)& theAx1,
130                       const GEOMAlgo_State       theState);
131
132   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
133     GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
134                                   const Standard_Integer     theShapeType,
135                                   const Handle(GEOM_Object)& theAx1,
136                                   const Handle(GEOM_Object)& thePnt,
137                                   const GEOMAlgo_State       theState);
138
139
140   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
141     GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
142                          const Standard_Integer     theShapeType,
143                          const Handle(GEOM_Object)& theAxis,
144                          const Standard_Real        theRadius,
145                          const GEOMAlgo_State       theState);
146
147   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
148     GetShapesOnCylinderWithLocation (const Handle(GEOM_Object)& theShape,
149                                      const Standard_Integer     theShapeType,
150                                      const Handle(GEOM_Object)& theAxis,
151                                      const Handle(GEOM_Object)& thePnt,
152                                      const Standard_Real        theRadius,
153                                      const GEOMAlgo_State       theState);
154
155   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
156     GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
157                        const Standard_Integer     theShapeType,
158                        const Handle(GEOM_Object)& theCenter,
159                        const Standard_Real        theRadius,
160                        const GEOMAlgo_State       theState);
161
162   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
163     GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
164                          const Standard_Integer     theShapeType,
165                          const Handle(GEOM_Object)& theAx1,
166                          const GEOMAlgo_State       theState);
167
168   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
169     GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
170                                      const Standard_Integer     theShapeType,
171                                      const Handle(GEOM_Object)& theAx1,
172                                      const Handle(GEOM_Object)& thePnt,
173                                      const GEOMAlgo_State       theState);
174
175   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
176     GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
177                             const Standard_Integer     theShapeType,
178                             const Handle(GEOM_Object)& theAxis,
179                             const Standard_Real        theRadius,
180                             const GEOMAlgo_State       theState);
181
182   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
183     GetShapesOnCylinderWithLocationIDs (const Handle(GEOM_Object)& theShape,
184                                         const Standard_Integer     theShapeType,
185                                         const Handle(GEOM_Object)& theAxis,
186                                         const Handle(GEOM_Object)& thePnt,
187                                         const Standard_Real        theRadius,
188                                         const GEOMAlgo_State       theState);
189
190   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
191     GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
192                           const Standard_Integer     theShapeType,
193                           const Handle(GEOM_Object)& theCenter,
194                           const Standard_Real        theRadius,
195                           const GEOMAlgo_State       theState);
196
197   /*!
198    * \brief Find subshapes complying with given status about quadrangle
199     * \param theShape - the shape to explore
200     * \param theShapeType - type of subshape of theShape
201     * \param theTopLeftPoint - top left quadrangle corner
202     * \param theTopRigthPoint - top right quadrangle corner
203     * \param theBottomLeftPoint - bottom left quadrangle corner
204     * \param theBottomRigthPoint - bottom right quadrangle corner
205     * \param theState - required state
206     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
207    */
208   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
209     GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
210                            const Standard_Integer     theShapeType,
211                            const Handle(GEOM_Object)& theTopLeftPoint,
212                            const Handle(GEOM_Object)& theTopRigthPoint,
213                            const Handle(GEOM_Object)& theBottomLeftPoint,
214                            const Handle(GEOM_Object)& theBottomRigthPoint,
215                            const GEOMAlgo_State       theState);
216
217   /*!
218    * \brief Find IDs of subshapes complying with given status about quadrangle
219     * \param theShape - the shape to explore
220     * \param theShapeType - type of subshape of theShape
221     * \param theTopLeftPoint - top left quadrangle corner
222     * \param theTopRigthPoint - top right quadrangle corner
223     * \param theBottomLeftPoint - bottom left quadrangle corner
224     * \param theBottomRigthPoint - bottom right quadrangle corner
225     * \param theState - required state
226     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
227    */
228   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
229     GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
230                               const Standard_Integer     theShapeType,
231                               const Handle(GEOM_Object)& theTopLeftPoint,
232                               const Handle(GEOM_Object)& theTopRigthPoint,
233                               const Handle(GEOM_Object)& theBottomLeftPoint,
234                               const Handle(GEOM_Object)& theBottomRigthPoint,
235                               const GEOMAlgo_State       theState);
236
237   Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object)    theShape,
238                                                               const Standard_Integer theShapeType,
239                                                               Handle(GEOM_Object)    theAxis,
240                                                               const Standard_Real    theRadius);
241
242   Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object)    theShape,
243                                                             const Standard_Integer theShapeType,
244                                                             Handle(GEOM_Object)    theCenter,
245                                                             const Standard_Real    theRadius);
246
247   void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
248
249   Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
250                                                   Handle(GEOM_Object) theShapeWhat);
251
252   Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
253                                                            Handle(GEOM_Object) theShapeWhat);
254
255   /*!
256    * \brief Searches a shape equal to theWhat in the context of theWhere
257    * \param theShapeWhere - a context shap
258    * \param theShapeWhat - a sample shape
259    * \retval Handle(GEOM_Object) - found shape
260    */
261   Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
262                                               const Handle(GEOM_Object)& theShapeWhat);
263
264   /*!
265    * \brief Find IDs of subshapes complying with given status about surface
266     * \param theBox - the box to check state of subshapes against
267     * \param theShape - the shape to explore
268     * \param theShapeType - type of subshape of theShape
269     * \param theState - required state
270     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
271    */
272   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
273                               GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
274                                                 const Handle(GEOM_Object)& theShape,
275                                                 const Standard_Integer theShapeType,
276                                                 GEOMAlgo_State theState);
277
278   /*!
279    * \brief Find subshapes complying with given status about surface
280    * \param theBox - the box to check state of subshapes against
281    * \param theShape - the shape to explore
282    * \param theShapeType - type of subshape of theShape
283    * \param theState - required state
284    * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
285    */
286   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
287                              GetShapesOnBox(const Handle(GEOM_Object)& theBox,
288                                             const Handle(GEOM_Object)& theShape,
289                                             const Standard_Integer theShapeType,
290                                             GEOMAlgo_State theState);
291
292   /*!
293    * \brief Find IDs of subshapes complying with given status about surface
294    * \param theCheckShape - the shape to check state of subshapes against
295    * \param theShape - the shape to explore
296    * \param theShapeType - type of subshape of theShape
297    * \param theState - required state
298    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
299    */
300   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
301                    GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape,
302                                        const Handle(GEOM_Object)& theShape,
303                                        const Standard_Integer theShapeType,
304                                        GEOMAlgo_State theState);
305
306   /*!
307    * \brief Find subshapes complying with given status about surface
308    * \param theCheckShape - the shape to check state of subshapes against
309    * \param theShape - the shape to explore
310    * \param theShapeType - type of subshape of theShape
311    * \param theState - required state
312    * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
313    */
314   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
315                       GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape,
316                                        const Handle(GEOM_Object)& theShape,
317                                        const Standard_Integer theShapeType,
318                                        GEOMAlgo_State theState);
319   Standard_EXPORT Handle(GEOM_Object)
320             GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape,
321                                        const Handle(GEOM_Object)& theShape,
322                                        const Standard_Integer theShapeType,
323                                        GEOMAlgo_State theState);
324
325  public:
326   /*!
327    * \brief Sort shapes in the list by their coordinates.
328    * \param SL The list of shapes to sort.
329    */
330   Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL,
331                                           const Standard_Boolean isOldSorting = Standard_True);
332
333   /*!
334    * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND.
335    *
336    * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is.
337    *
338    * \param theCompsolid The compsolid to be converted.
339    * \retval TopoDS_Shape Returns the resulting compound.
340    */
341   Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
342
343   /*!
344    * \brief Build a triangulation on \a theShape if it is absent.
345    * \param theShape The shape to check/build triangulation on.
346    * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation.
347    */
348   Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
349
350  private:
351   Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)>      theShapes,
352                                  const Standard_Integer         theObjectType,
353                                  const Standard_Integer         theFunctionType,
354                                  const TCollection_AsciiString& theMethodName);
355
356 // ----------------------------------------------------
357 // methods common for all GetShapesOnXXX() functions
358 // ----------------------------------------------------
359
360   /*!
361    * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
362    * \param theShapeType - the shape type to check
363    * \retval bool  - result of the check
364    */
365   bool checkTypeShapesOn(const Standard_Integer theShapeType);
366
367   /*!
368    * \brief Creates Geom_Plane
369    * \param theAx1 - edge defining plane normal
370    * \retval Handle(Geom_Surface) - resulting surface
371    */
372   Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
373
374   /*!
375    * \brief Creates Geom_CylindricalSurface
376    * \param theAx1 - edge defining cylinder axis
377    * \param theRadius - cylinder radius
378    * \retval Handle(Geom_Surface) - resulting surface
379    */
380   Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
381                                     const Standard_Real theRadius);
382
383   /*!
384    * \brief Find IDs of subshapes complying with given status about surface
385    * \param theSurface - the surface to check state of subshapes against
386    * \param theShape - the shape to explore
387    * \param theShapeType - type of subshape of theShape
388    * \param theState - required state
389    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
390    */
391   Handle(TColStd_HSequenceOfInteger)
392     getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
393                           const TopoDS_Shape&         theShape,
394                           TopAbs_ShapeEnum            theShapeType,
395                           GEOMAlgo_State              theState);
396
397   /*!
398    * \brief Find subshapes complying with given status about surface
399    * \param theSurface - the surface to check state of subshapes against
400    * \param theShape - the shape to explore
401    * \param theShapeType - type of subshape of theShape
402    * \param theState - required state
403    * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
404    * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
405    */
406   Handle(TColStd_HSequenceOfTransient)
407     getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
408                        const Handle(GEOM_Object)&  theShape,
409                        TopAbs_ShapeEnum            theShapeType,
410                        GEOMAlgo_State              theState,
411                        TCollection_AsciiString &   theShapeEntries);
412
413   /*!
414    * \brief Find IDs of subshapes complying with given status about quadrangle
415    * \param theShape - the shape to explore
416    * \param theShapeType - type of subshape of theShape
417    * \param theTopLeftPoint - top left quadrangle corner
418    * \param theTopRigthPoint - top right quadrangle corner
419    * \param theBottomLeftPoint - bottom left quadrangle corner
420    * \param theBottomRigthPoint - bottom right quadrangle corner
421    * \param theState - required state
422    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
423    */
424   Handle(TColStd_HSequenceOfInteger)
425     getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
426                               const Standard_Integer     theShapeType,
427                               const Handle(GEOM_Object)& theTopLeftPoint,
428                               const Handle(GEOM_Object)& theTopRigthPoint,
429                               const Handle(GEOM_Object)& theBottomLeftPoint,
430                               const Handle(GEOM_Object)& theBottomRigthPoint,
431                               const GEOMAlgo_State       theState);
432
433   /*!
434    * \brief Find IDs of subshapes complying with given status about surface
435    * \param theBox - the box to check state of subshapes against
436    * \param theShape - the shape to explore
437    * \param theShapeType - type of subshape of theShape
438    * \param theState - required state
439    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
440    */
441   Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
442                                                        const Handle(GEOM_Object)& theShape,
443                                                        const Standard_Integer theShapeType,
444                                                        GEOMAlgo_State theState);
445
446   /*!
447    * \brief Find IDs of subshapes complying with given status about surface
448    * \param theCheckShape - the shape to check state of subshapes against
449    * \param theShape - the shape to explore
450    * \param theShapeType - type of subshape of theShape
451    * \param theState - required state
452    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
453    */
454   Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs
455                                       (const Handle(GEOM_Object)& theCheckShape,
456                                        const Handle(GEOM_Object)& theShape,
457                                        const Standard_Integer theShapeType,
458                                        GEOMAlgo_State theState);
459
460   /*!
461    * \brief Find shape objects and their entries by their ids
462    * \param theShape - the main shape
463    * \param theShapeIDs - theShapeIDs - incoming shape ids
464    * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
465    * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
466    */
467   Handle(TColStd_HSequenceOfTransient)
468     getObjectsShapesOn(const Handle(GEOM_Object)&                theShape,
469                        const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
470                        TCollection_AsciiString &                 theShapeEntries);
471
472   /*!
473    * \brief Select the object created last
474    * \param theObj1 - Object 1
475    * \param theObj2 - Object 2
476    * \retval Handle(GEOM_Object) - selected object
477    */
478   static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
479                                             const Handle(GEOM_Object)& theObj2);
480 };
481
482 #endif