]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMAlgo/GEOMAlgo_Tools3D.hxx
Salome HOME
0021434: Boolean operations generate a shape with big vertex tolerance.
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_Tools3D.hxx
1 // Copyright (C) 2007-2011  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 #ifndef _GEOMAlgo_Tools3D_HeaderFile
23 #define _GEOMAlgo_Tools3D_HeaderFile
24
25 #include <Basics_OCCTVersion.hxx>
26
27 #ifndef _Standard_HeaderFile
28 #include <Standard.hxx>
29 #endif
30 #ifndef _Standard_Macro_HeaderFile
31 #include <Standard_Macro.hxx>
32 #endif
33
34 #ifndef _Standard_Boolean_HeaderFile
35 #include <Standard_Boolean.hxx>
36 #endif
37 #if OCC_VERSION_LARGE > 0x06050200
38 #ifndef _Handle_IntTools_Context_HeaderFile
39 #include <Handle_IntTools_Context.hxx>
40 #endif
41 #endif
42 #ifndef _Standard_Integer_HeaderFile
43 #include <Standard_Integer.hxx>
44 #endif
45 #ifndef _TopAbs_ShapeEnum_HeaderFile
46 #include <TopAbs_ShapeEnum.hxx>
47 #endif
48 #ifndef _TopAbs_State_HeaderFile
49 #include <TopAbs_State.hxx>
50 #endif
51 #ifndef _Standard_Real_HeaderFile
52 #include <Standard_Real.hxx>
53 #endif
54
55 class TopoDS_Shape;
56 class IntTools_Context;
57 class TopoDS_Face;
58 class TopoDS_Edge;
59 class TopTools_ListOfShape;
60 class TopTools_IndexedMapOfShape;
61 class TopoDS_Solid;
62 class gp_Pnt;
63 class gp_Pnt2d;
64 class TopoDS_Vertex;
65 class TopTools_IndexedDataMapOfShapeListOfShape;
66 class NMTTools_ListOfCoupleOfShape;
67
68
69 //!  Auxiliary tools for Algorithms <br>
70 class GEOMAlgo_Tools3D  {
71
72 public:
73
74   void* operator new(size_t,void* anAddress)
75   {
76     return anAddress;
77   }
78   void* operator new(size_t size)
79   {
80     return Standard::Allocate(size);
81   }
82   void  operator delete(void *anAddress)
83   {
84     if (anAddress) Standard::Free((Standard_Address&)anAddress);
85   }
86
87   //! Returns True if the shape theSplit has opposite <br>
88   //!          direction than theShape <br>
89   //!          theContext - cashed geometrical tools <br>
90   Standard_EXPORT static Standard_Boolean IsSplitToReverse (const TopoDS_Shape& theSplit,
91                                                             const TopoDS_Shape& theShape,
92 #if OCC_VERSION_LARGE > 0x06050200
93                                                             const Handle(IntTools_Context)& theContext);
94 #else
95                                                             IntTools_Context& theContext);
96 #endif
97
98   //! Returns True if normal direction of the face <br>
99   //!          theShape is not the same as for the face <br>
100   //!          theSplit <br>
101   //!          theContext - cashed geometrical tools <br>
102   Standard_EXPORT static Standard_Boolean IsSplitToReverse (const TopoDS_Face& theSplit,
103                                                             const TopoDS_Face& theShape,
104 #if OCC_VERSION_LARGE > 0x06050200
105                                                             const Handle(IntTools_Context)& theContext);
106 #else
107                                                             IntTools_Context& theContext);
108 #endif
109
110   //! Returns True if tangent direction of the edge <br>
111   //!          theEdge is not the same as for the edge <br>
112   //!          theSplit <br>
113   //!          theContext - cashed geometrical tools <br>
114   Standard_EXPORT static Standard_Boolean IsSplitToReverse (const TopoDS_Edge& theEdge,
115                                                             const TopoDS_Edge& theSplit,
116 #if OCC_VERSION_LARGE > 0x06050200
117                                                             const Handle(IntTools_Context)& theContext);
118 #else
119                                                             IntTools_Context& theContext);
120 #endif
121
122   //! For the couple of faces theF1, theF2 <br>
123   //!          computes sense value <br>
124   //!          Returns 0 if the faces are not sensible <br>
125   //!          Returns 1 if the faces have same sense <br>
126   //!          Returns 2 if the faces have opposite sense <br>
127   Standard_EXPORT static Standard_Integer Sense (const TopoDS_Face& theF1, const TopoDS_Face& theF2);
128
129   //! Makes new face theF2 from surface and wires <br>
130   //!          of the face theF1 <br>
131   Standard_EXPORT static void CopyFace (const TopoDS_Face& theF1, TopoDS_Face& theF2);
132
133   //! Makes empty shape theShape of the type theType <br>
134   Standard_EXPORT static void MakeContainer (const TopAbs_ShapeEnum theType, TopoDS_Shape& theShape);
135
136   //! For the list of faces theLS build block <br>
137   //!          theLSCB in terms of connexity by edges <br>
138   //!          theMapAvoid - set of edges to avoid for <br>
139   //!          the treatment <br>
140   Standard_EXPORT static void MakeConnexityBlock (const TopTools_ListOfShape& theLS,
141                                                   const TopTools_IndexedMapOfShape& theMapAvoid,
142                                                   TopTools_ListOfShape& theLSCB);
143
144   //! Computes the 3-D state of the shape theShape <br>
145   //!          toward solid theSolid. <br>
146   //!          theTol - value of precision of computation <br>
147   //!          theContext- cahed geometrical tools <br>
148   //!          Returns 3-D state. <br>
149   Standard_EXPORT static TopAbs_State ComputeStateByOnePoint (const TopoDS_Shape& theShape,
150                                                               const TopoDS_Solid& theSolid,
151                                                               const Standard_Real theTol,
152 #if OCC_VERSION_LARGE > 0x06050200
153                                                               const Handle(IntTools_Context)& theContext);
154 #else
155                                                               IntTools_Context& theContext);
156 #endif
157
158   //! Computes the 3-D state of the point thePoint <br>
159   //!          toward solid theSolid. <br>
160   //!          theTol - value of precision of computation <br>
161   //!          theContext- cahed geometrical tools <br>
162   //!          Returns 3-D state. <br>
163   Standard_EXPORT static TopAbs_State ComputeState (const gp_Pnt& thePoint,
164                                                     const TopoDS_Solid& theSolid,
165                                                     const Standard_Real theTol,
166 #if OCC_VERSION_LARGE > 0x06050200
167                                                     const Handle(IntTools_Context)& theContext);
168 #else
169                                                     IntTools_Context& theContext);
170 #endif
171
172   //! Computes the 3-D state of the vertex theVertex <br>
173   //!          toward solid theSolid. <br>
174   //!          theTol - value of precision of computation <br>
175   //!          theContext- cahed geometrical tools <br>
176   //!          Returns 3-D state. <br>
177   Standard_EXPORT static TopAbs_State ComputeState (const TopoDS_Vertex& theVertex,
178                                                     const TopoDS_Solid& theSolid,
179                                                     const Standard_Real theTol,
180 #if OCC_VERSION_LARGE > 0x06050200
181                                                     const Handle(IntTools_Context)& theContext);
182 #else
183                                                     IntTools_Context& theContext);
184 #endif
185
186   //! Computes the 3-D state of the edge theEdge <br>
187   //!          toward solid theSolid. <br>
188   //!          theTol - value of precision of computation <br>
189   //!          theContext- cahed geometrical tools <br>
190   //!          Returns 3-D state. <br>
191   Standard_EXPORT static TopAbs_State ComputeState (const TopoDS_Edge& theEdge,
192                                                     const TopoDS_Solid& theSolid,
193                                                     const Standard_Real theTol,
194 #if OCC_VERSION_LARGE > 0x06050200
195                                                     const Handle(IntTools_Context)& theContext);
196 #else
197                                                     IntTools_Context& theContext);
198 #endif
199
200   //! Computes the 3-D state of the face theFace <br>
201   //!          toward solid theSolid. <br>
202   //!          theTol - value of precision of computation <br>
203   //!          theBounds - set of edges of theFace to avoid <br>
204   //!          theContext- cahed geometrical tools <br>
205   //!          Returns 3-D state. <br>
206   Standard_EXPORT static TopAbs_State ComputeState (const TopoDS_Face& theFace,
207                                                     const TopoDS_Solid& theSolid,
208                                                     const Standard_Real theTol,
209                                                     const TopTools_IndexedMapOfShape& theBounds,
210 #if OCC_VERSION_LARGE > 0x06050200
211                                                     const Handle(IntTools_Context)& theContext);
212 #else
213                                                     IntTools_Context& theContext);
214 #endif
215
216   //! Returns True if the face theFace is inside of the <br>
217   //!          couple of faces theFace1, theFace2. <br>
218   //!          The faces theFace, theFace1, theFace2  must <br>
219   //!          share the edge theEdge <br>
220   Standard_EXPORT static Standard_Boolean IsInternalFace (const TopoDS_Face& theFace,
221                                                           const TopoDS_Edge& theEdge,
222                                                           const TopoDS_Face& theFace1,
223                                                           const TopoDS_Face& theFace2,
224 #if OCC_VERSION_LARGE > 0x06050200
225                                                           const Handle(IntTools_Context)& theContext);
226 #else
227                                                           IntTools_Context& theContext);
228 #endif
229
230   //! Returns True if the face theFace is inside of the <br>
231   //!          appropriate couple of faces (from the set theLF)    . <br>
232   //!          The faces of the set theLF and theFace  must <br>
233   //!          share the edge theEdge <br>
234   Standard_EXPORT static Standard_Boolean IsInternalFace (const TopoDS_Face& theFace,
235                                                           const TopoDS_Edge& theEdge,
236                                                           const TopTools_ListOfShape& theLF,
237 #if OCC_VERSION_LARGE > 0x06050200
238                                                           const Handle(IntTools_Context)& theContext);
239 #else
240                                                           IntTools_Context& theContext);
241 #endif
242
243   //! Returns True if the face theFace is inside the <br>
244   //!          solid theSolid. <br>
245   //!          theMEF - Map Edge/Faces for theSolid <br>
246   //!          theTol - value of precision of computation <br>
247   //!          theContext- cahed geometrical tools <br>
248   Standard_EXPORT static Standard_Boolean IsInternalFace (const TopoDS_Face& theFace,
249                                                           const TopoDS_Solid& theSolid,
250                                                           const TopTools_IndexedDataMapOfShapeListOfShape& theMEF,
251                                                           const Standard_Real theTol,
252 #if OCC_VERSION_LARGE > 0x06050200
253                                                           const Handle(IntTools_Context)& theContext);
254 #else
255                                                           IntTools_Context& theContext);
256 #endif
257
258   //!  For the face theFace and its edge theEdge <br>
259   //!           finds the face suitable to produce shell. <br>
260   //!           theLCEF - set of faces to search. All faces <br>
261   //!           from theLCEF must share edge theEdge <br>
262   Standard_EXPORT static void GetFaceOff (const TopoDS_Edge& theEdge,
263                                           const TopoDS_Face& theFace,
264                                           const NMTTools_ListOfCoupleOfShape& theLCEF,
265                                           TopoDS_Face& theFaceOff);
266
267   //! For the face theFace gets the edge theEdgeOnF <br>
268   //!          that is the same as theEdge <br>
269   //!          Returns True if such edge exists <br>
270   //!          Returns False if there is no such edge <br>
271   Standard_EXPORT static Standard_Boolean GetEdgeOnFace (const TopoDS_Edge& theEdge,
272                                                          const TopoDS_Face& theFace,
273                                                          TopoDS_Edge& theEdgeOnF);
274
275   //! Returns True if the face theFace contains <br>
276   //!          the edge theEdge but with opposite orientation. <br>
277   //!          If the method  returns True theEdgeOff is the <br>
278   //!          edge founded <br>
279   Standard_EXPORT static Standard_Boolean GetEdgeOff (const TopoDS_Edge& theEdge,
280                                                       const TopoDS_Face& theFace,
281                                                       TopoDS_Edge& theEdgeOff);
282
283   //! Computes a point <theP> inside the face <theF>. <br>
284   //!          <theP2D> -  2D  representation of <theP> <br>
285   //!          on the surface of <theF> <br>
286   //!          Returns 0 in case of success. <br>
287   Standard_EXPORT static Standard_Integer PntInFace (const TopoDS_Face& theF,
288                                                      gp_Pnt& theP,
289                                                      gp_Pnt2d& theP2D);
290
291 protected:
292
293 private:
294
295 };
296
297 // other Inline functions and methods (like "C++: function call" methods)
298
299 #endif