]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMImpl/GEOMImpl_IShapesOperations.hxx
Salome HOME
NPAL15298: KindOfShape(). A tool by PKV.
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IShapesOperations.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20
21 #ifndef _GEOMImpl_IShapesOperations_HXX_
22 #define _GEOMImpl_IShapesOperations_HXX_
23
24 #include "GEOM_IOperations.hxx"
25
26 #include "GEOMAlgo_State.hxx"
27
28 #include <TopTools_ListOfShape.hxx>
29 #include <TColStd_HSequenceOfTransient.hxx>
30 #include <TColStd_HSequenceOfInteger.hxx>
31
32 #include <list>
33 #include <Handle_Geom_Surface.hxx>
34
35 class GEOM_Engine;
36 class Handle(GEOM_Object);
37 class Handle(TColStd_HArray1OfInteger);
38
39 class GEOMImpl_IShapesOperations : public GEOM_IOperations {
40  public:
41   Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
42   Standard_EXPORT ~GEOMImpl_IShapesOperations();
43
44   Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
45                                 Handle(GEOM_Object) thePoint2);
46
47   Standard_EXPORT Handle(GEOM_Object) MakeWire (list<Handle(GEOM_Object)> theEdgesAndWires);
48
49   Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
50
51   Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (list<Handle(GEOM_Object)> theWires,
52                                      const bool isPlanarWanted);
53
54   Standard_EXPORT Handle(GEOM_Object) MakeShell (list<Handle(GEOM_Object)> theShapes);
55
56   Standard_EXPORT Handle(GEOM_Object) MakeSolidShell (Handle(GEOM_Object) theShell);
57
58   Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (list<Handle(GEOM_Object)> theShells);
59
60   Standard_EXPORT Handle(GEOM_Object) MakeCompound (list<Handle(GEOM_Object)> theShapes);
61
62   Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
63                                      const Standard_Real theTolerance);
64
65   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode (Handle(GEOM_Object)    theShape,
66                                                     const Standard_Integer theShapeType,
67                                                     const Standard_Boolean isSorted);
68
69   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs (Handle(GEOM_Object)    theShape,
70                                                      const Standard_Integer theShapeType,
71                                                      const Standard_Boolean isSorted);
72
73   Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object)    theMainShape,
74                                                    const Standard_Integer theID);
75
76   Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
77                                                      Handle(GEOM_Object) theSubShape);
78
79   Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
80                                                      Handle(GEOM_Object) theSubShape);
81
82   Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
83
84   Standard_EXPORT Standard_Integer NumberOfFaces (Handle(GEOM_Object) theShape);
85   Standard_EXPORT Standard_Integer NumberOfEdges (Handle(GEOM_Object) theShape);
86
87   Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
88
89   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
90
91   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetSharedShapes (Handle(GEOM_Object)    theShape1,
92                                                         Handle(GEOM_Object)    theShape2,
93                                                         const Standard_Integer theShapeType);
94
95   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
96                                                          const Standard_Integer     theShapeType,
97                                                          const Handle(GEOM_Object)& theAx1,
98                                                          const GEOMAlgo_State       theState);
99
100   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
101     GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
102                                   const Standard_Integer     theShapeType,
103                                   const Handle(GEOM_Object)& theAx1,
104                                   const Handle(GEOM_Object)& thePnt,
105                                   const GEOMAlgo_State       theState);
106
107
108   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
109                                                             const Standard_Integer     theShapeType,
110                                                             const Handle(GEOM_Object)& theAxis,
111                                                             const Standard_Real        theRadius,
112                                                             const GEOMAlgo_State       theState);
113
114   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
115                                                           const Standard_Integer     theShapeType,
116                                                           const Handle(GEOM_Object)& theCenter,
117                                                           const Standard_Real        theRadius,
118                                                           const GEOMAlgo_State       theState);
119
120   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
121                                                           const Standard_Integer     theShapeType,
122                                                           const Handle(GEOM_Object)& theAx1,
123                                                           const GEOMAlgo_State       theState);
124
125   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
126     GetShapesOnPlaneWithLocationIDs (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);
131
132   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
133                                                              const Standard_Integer     theShapeType,
134                                                              const Handle(GEOM_Object)& theAxis,
135                                                              const Standard_Real        theRadius,
136                                                              const GEOMAlgo_State       theState);
137
138   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnSphereIDs (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);
143
144   /*!
145    * \brief Find subshapes complying with given status about quadrangle
146     * \param theShape - the shape to explore
147     * \param theShapeType - type of subshape of theShape
148     * \param theTopLeftPoint - top left quadrangle corner
149     * \param theTopRigthPoint - top right quadrangle corner
150     * \param theBottomLeftPoint - bottom left quadrangle corner
151     * \param theBottomRigthPoint - bottom right quadrangle corner
152     * \param theState - required state
153     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
154    */
155   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
156     GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
157                            const Standard_Integer     theShapeType,
158                            const Handle(GEOM_Object)& theTopLeftPoint,
159                            const Handle(GEOM_Object)& theTopRigthPoint,
160                            const Handle(GEOM_Object)& theBottomLeftPoint,
161                            const Handle(GEOM_Object)& theBottomRigthPoint,
162                            const GEOMAlgo_State       theState);
163
164   /*!
165    * \brief Find IDs of subshapes complying with given status about quadrangle
166     * \param theShape - the shape to explore
167     * \param theShapeType - type of subshape of theShape
168     * \param theTopLeftPoint - top left quadrangle corner
169     * \param theTopRigthPoint - top right quadrangle corner
170     * \param theBottomLeftPoint - bottom left quadrangle corner
171     * \param theBottomRigthPoint - bottom right quadrangle corner
172     * \param theState - required state
173     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
174    */
175   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
176     GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
177                               const Standard_Integer     theShapeType,
178                               const Handle(GEOM_Object)& theTopLeftPoint,
179                               const Handle(GEOM_Object)& theTopRigthPoint,
180                               const Handle(GEOM_Object)& theBottomLeftPoint,
181                               const Handle(GEOM_Object)& theBottomRigthPoint,
182                               const GEOMAlgo_State       theState);
183
184   Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object)    theShape,
185                                               const Standard_Integer theShapeType,
186                                               Handle(GEOM_Object)    theAxis,
187                                               const Standard_Real    theRadius);
188
189   Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object)    theShape,
190                                             const Standard_Integer theShapeType,
191                                             Handle(GEOM_Object)    theCenter,
192                                             const Standard_Real    theRadius);
193
194   Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
195                                                   Handle(GEOM_Object) theShapeWhat);
196
197   Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
198
199   /*!
200    * \brief Searches a shape equal to theWhat in the context of theWhere
201    * \param theShapeWhere - a context shap
202    * \param theShapeWhat - a sample shape
203    * \retval Handle(GEOM_Object) - found shape
204    */
205   Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
206                                               const Handle(GEOM_Object)& theShapeWhat);
207
208   /*!
209    * \brief Find IDs of subshapes complying with given status about surface
210     * \param theBox - the box to check state of subshapes against
211     * \param theShape - the shape to explore
212     * \param theShapeType - type of subshape of theShape
213     * \param theState - required state
214     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
215    */
216   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
217                               GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
218                                                 const Handle(GEOM_Object)& theShape,
219                                                 const Standard_Integer theShapeType,
220                                                 GEOMAlgo_State theState);
221
222   /*!
223    * \brief Find subshapes complying with given status about surface
224    * \param theBox - the box to check state of subshapes against
225    * \param theShape - the shape to explore
226    * \param theShapeType - type of subshape of theShape
227    * \param theState - required state
228    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
229    */
230   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
231                                 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
232                                                const Handle(GEOM_Object)& theShape,
233                                                const Standard_Integer theShapeType,
234                                                GEOMAlgo_State theState);
235
236  private:
237   Handle(GEOM_Object) MakeShape (list<Handle(GEOM_Object)>      theShapes,
238                                  const Standard_Integer         theObjectType,
239                                  const Standard_Integer         theFunctionType,
240                                  const TCollection_AsciiString& theMethodName);
241
242 // ----------------------------------------------------
243   // methods common for all GetShapesOnXXX() functions
244 // ----------------------------------------------------
245
246   bool CheckTriangulation (const TopoDS_Shape& aShape);
247
248   /*!
249    * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
250     * \param theShapeType - the shape type to check
251     * \retval bool  - result of the check
252    */
253   bool checkTypeShapesOn(const Standard_Integer theShapeType);
254
255   /*!
256    * \brief Creates Geom_Plane
257     * \param theAx1 - edge defining plane normal
258     * \retval Handle(Geom_Surface) - resulting surface
259    */
260   Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
261
262   /*!
263    * \brief Creates Geom_CylindricalSurface
264     * \param theAx1 - edge defining cylinder axis
265     * \param theRadius - cylinder radius
266     * \retval Handle(Geom_Surface) - resulting surface
267    */
268   Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
269                                     const Standard_Real theRadius);
270
271   /*!
272    * \brief Find IDs of subshapes complying with given status about surface
273     * \param theSurface - the surface 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_HSequenceOfInteger) - IDs of found subshapes
278    */
279   Handle(TColStd_HSequenceOfInteger)
280     getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
281                           const TopoDS_Shape&         theShape,
282                           TopAbs_ShapeEnum            theShapeType,
283                           GEOMAlgo_State              theState);
284
285   /*!
286    * \brief Find subshapes complying with given status about surface
287     * \param theSurface - the surface 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     * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
292     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
293    */
294   Handle(TColStd_HSequenceOfTransient)
295     getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
296                        const Handle(GEOM_Object)&  theShape,
297                        TopAbs_ShapeEnum            theShapeType,
298                        GEOMAlgo_State              theState,
299                        TCollection_AsciiString &   theShapeEntries);
300
301   /*!
302    * \brief Find IDs of subshapes complying with given status about quadrangle
303     * \param theShape - the shape to explore
304     * \param theShapeType - type of subshape of theShape
305     * \param theTopLeftPoint - top left quadrangle corner
306     * \param theTopRigthPoint - top right quadrangle corner
307     * \param theBottomLeftPoint - bottom left quadrangle corner
308     * \param theBottomRigthPoint - bottom right quadrangle corner
309     * \param theState - required state
310     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
311    */
312   Handle(TColStd_HSequenceOfInteger)
313     getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
314                               const Standard_Integer     theShapeType,
315                               const Handle(GEOM_Object)& theTopLeftPoint,
316                               const Handle(GEOM_Object)& theTopRigthPoint,
317                               const Handle(GEOM_Object)& theBottomLeftPoint,
318                               const Handle(GEOM_Object)& theBottomRigthPoint,
319                               const GEOMAlgo_State       theState);
320
321   /*!
322    * \brief Find IDs of subshapes complying with given status about surface
323     * \param theBox - the box 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_HSequenceOfInteger) - IDs of found subshapes
328    */
329   Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
330                                                        const Handle(GEOM_Object)& theShape,
331                                                        const Standard_Integer theShapeType,
332                                                        GEOMAlgo_State theState);
333
334   /*!
335    * \brief Find shape objects and their entries by their ids
336     * \param theShape - the main shape
337     * \param theShapeIDs - theShapeIDs - incoming shape ids
338     * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
339     * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
340    */
341   Handle(TColStd_HSequenceOfTransient)
342     getObjectsShapesOn(const Handle(GEOM_Object)&                theShape,
343                        const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
344                        TCollection_AsciiString &                 theShapeEntries);
345
346   /*!
347    * \brief Select the object created last
348     * \param theObj1 - Object 1
349     * \param theObj2 - Object 2
350     * \retval Handle(GEOM_Object) - selected object
351    */
352   static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
353                                             const Handle(GEOM_Object)& theObj2);
354 };
355
356 #endif