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