Salome HOME
Add new command GetShapesOnBox.
[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) GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
101                                                                      const Standard_Integer     theShapeType,
102                                                                      const Handle(GEOM_Object)& theAx1,
103                                                                      const Handle(GEOM_Object)& thePnt,
104                                                                      const GEOMAlgo_State       theState);
105
106
107   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
108                                                             const Standard_Integer     theShapeType,
109                                                             const Handle(GEOM_Object)& theAxis,
110                                                             const Standard_Real        theRadius,
111                                                             const GEOMAlgo_State       theState);
112
113   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
114                                                           const Standard_Integer     theShapeType,
115                                                           const Handle(GEOM_Object)& theCenter,
116                                                           const Standard_Real        theRadius,
117                                                           const GEOMAlgo_State       theState);
118
119   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
120                                                           const Standard_Integer     theShapeType,
121                                                           const Handle(GEOM_Object)& theAx1,
122                                                           const GEOMAlgo_State       theState);
123
124   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
125                                                       const Standard_Integer     theShapeType,
126                                                           const Handle(GEOM_Object)& theAx1,
127                                                           const Handle(GEOM_Object)& thePnt,
128                                                           const GEOMAlgo_State       theState);
129
130   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
131                                                              const Standard_Integer     theShapeType,
132                                                              const Handle(GEOM_Object)& theAxis,
133                                                              const Standard_Real        theRadius,
134                                                              const GEOMAlgo_State       theState);
135
136   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
137                                                            const Standard_Integer     theShapeType,
138                                                            const Handle(GEOM_Object)& theCenter,
139                                                            const Standard_Real        theRadius,
140                                                            const GEOMAlgo_State       theState);
141
142   /*!
143    * \brief Find subshapes complying with given status about quadrangle
144     * \param theShape - the shape to explore
145     * \param theShapeType - type of subshape of theShape
146     * \param theTopLeftPoint - top left quadrangle corner
147     * \param theTopRigthPoint - top right quadrangle corner
148     * \param theBottomLeftPoint - bottom left quadrangle corner
149     * \param theBottomRigthPoint - bottom right quadrangle corner
150     * \param theState - required state
151     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
152    */
153   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
154     GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
155                            const Standard_Integer     theShapeType,
156                            const Handle(GEOM_Object)& theTopLeftPoint,
157                            const Handle(GEOM_Object)& theTopRigthPoint,
158                            const Handle(GEOM_Object)& theBottomLeftPoint,
159                            const Handle(GEOM_Object)& theBottomRigthPoint,
160                            const GEOMAlgo_State       theState);
161
162   /*!
163    * \brief Find IDs of subshapes complying with given status about quadrangle
164     * \param theShape - the shape to explore
165     * \param theShapeType - type of subshape of theShape
166     * \param theTopLeftPoint - top left quadrangle corner
167     * \param theTopRigthPoint - top right quadrangle corner
168     * \param theBottomLeftPoint - bottom left quadrangle corner
169     * \param theBottomRigthPoint - bottom right quadrangle corner
170     * \param theState - required state
171     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
172    */
173   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
174     GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
175                               const Standard_Integer     theShapeType,
176                               const Handle(GEOM_Object)& theTopLeftPoint,
177                               const Handle(GEOM_Object)& theTopRigthPoint,
178                               const Handle(GEOM_Object)& theBottomLeftPoint,
179                               const Handle(GEOM_Object)& theBottomRigthPoint,
180                               const GEOMAlgo_State       theState);
181
182   Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object)    theShape,
183                                               const Standard_Integer theShapeType,
184                                               Handle(GEOM_Object)    theAxis,
185                                               const Standard_Real    theRadius);
186
187   Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object)    theShape,
188                                             const Standard_Integer theShapeType,
189                                             Handle(GEOM_Object)    theCenter,
190                                             const Standard_Real    theRadius);
191
192   Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
193                                   Handle(GEOM_Object) theShapeWhat);
194
195   Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
196
197   /*!
198    * \brief Searches a shape equal to theWhat in the context of theWhere
199    * \param theShapeWhere - a context shap
200    * \param theShapeWhat - a sample shape 
201    * \retval Handle(GEOM_Object) - found shape
202    */
203   Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere, 
204                                               const Handle(GEOM_Object)& theShapeWhat);
205
206   /*!
207    * \brief Find IDs of subshapes complying with given status about surface
208     * \param theBox - the box to check state of subshapes against
209     * \param theShape - the shape to explore
210     * \param theShapeType - type of subshape of theShape
211     * \param theState - required state
212     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
213    */
214   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
215   GEOMImpl_IShapesOperations::GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
216                                                 const Handle(GEOM_Object)& theShape,
217                                                 const Standard_Integer theShapeType,
218                                                 GEOMAlgo_State theState);
219
220   /*!
221    * \brief Find subshapes complying with given status about surface
222    * \param theBox - the box to check state of subshapes against
223    * \param theShape - the shape to explore
224    * \param theShapeType - type of subshape of theShape
225    * \param theState - required state
226    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
227    */
228   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
229     GEOMImpl_IShapesOperations::GetShapesOnBox(const Handle(GEOM_Object)& theBox,
230                                                const Handle(GEOM_Object)& theShape,
231                                                const Standard_Integer theShapeType,
232                                                GEOMAlgo_State theState);
233
234
235  private:
236   Handle(GEOM_Object) MakeShape (list<Handle(GEOM_Object)>      theShapes,
237                                  const Standard_Integer         theObjectType,
238                                  const Standard_Integer         theFunctionType,
239                                  const TCollection_AsciiString& theMethodName);
240
241 // ----------------------------------------------------
242   // methods common for all GetShapesOnXXX() functions
243 // ----------------------------------------------------
244
245   bool CheckTriangulation (const TopoDS_Shape& aShape);
246
247   /*!
248    * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
249     * \param theShapeType - the shape type to check
250     * \retval bool  - result of the check
251    */
252   bool checkTypeShapesOn(const Standard_Integer theShapeType);
253
254   /*!
255    * \brief Creates Geom_Plane
256     * \param theAx1 - edge defining plane normal
257     * \retval Handle(Geom_Surface) - resulting surface
258    */
259   Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
260
261   /*!
262    * \brief Creates Geom_CylindricalSurface
263     * \param theAx1 - edge defining cylinder axis
264     * \param theRadius - cylinder radius
265     * \retval Handle(Geom_Surface) - resulting surface
266    */
267   Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
268                                     const Standard_Real theRadius);
269
270   /*!
271    * \brief Find IDs of subshapes complying with given status about surface
272     * \param theSurface - the surface to check state of subshapes against
273     * \param theShape - the shape to explore
274     * \param theShapeType - type of subshape of theShape
275     * \param theState - required state
276     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
277    */
278   Handle(TColStd_HSequenceOfInteger)
279     getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
280                           const TopoDS_Shape&         theShape,
281                           TopAbs_ShapeEnum            theShapeType,
282                           GEOMAlgo_State              theState);
283
284   /*!
285    * \brief Find subshapes complying with given status about surface
286     * \param theSurface - the surface to check state of subshapes against
287     * \param theShape - the shape to explore
288     * \param theShapeType - type of subshape of theShape
289     * \param theState - required state
290     * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
291     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
292    */
293   Handle(TColStd_HSequenceOfTransient)
294     getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
295                        const Handle(GEOM_Object)&  theShape,
296                        TopAbs_ShapeEnum            theShapeType,
297                        GEOMAlgo_State              theState,
298                        TCollection_AsciiString &   theShapeEntries
299                        );
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)
330   GEOMImpl_IShapesOperations::getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
331                                                 const Handle(GEOM_Object)& theShape,
332                                                 const Standard_Integer theShapeType,
333                                                 GEOMAlgo_State theState);
334
335   /*!
336    * \brief Find shape objects and their entries by their ids
337     * \param theShape - the main shape
338     * \param theShapeIDs - theShapeIDs - incoming shape ids
339     * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
340     * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
341    */
342   Handle(TColStd_HSequenceOfTransient)
343     getObjectsShapesOn(const Handle(GEOM_Object)&                theShape,
344                        const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
345                        TCollection_AsciiString &                 theShapeEntries);
346
347   /*!
348    * \brief Select the object created last
349     * \param theObj1 - Object 1
350     * \param theObj2 - Object 2
351     * \retval Handle(GEOM_Object) - selected object
352    */
353   static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
354                                             const Handle(GEOM_Object)& theObj2);
355 };
356
357 #endif