1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #ifndef _GEOMAlgo_Tools3D_HeaderFile
23 #define _GEOMAlgo_Tools3D_HeaderFile
25 #include <Basics_OCCTVersion.hxx>
27 #ifndef _Standard_HeaderFile
28 #include <Standard.hxx>
30 #ifndef _Standard_Macro_HeaderFile
31 #include <Standard_Macro.hxx>
34 #ifndef _Standard_Boolean_HeaderFile
35 #include <Standard_Boolean.hxx>
37 #if OCC_VERSION_LARGE > 0x06050200
38 #ifndef _Handle_IntTools_Context_HeaderFile
39 #include <Handle_IntTools_Context.hxx>
42 #ifndef _Standard_Integer_HeaderFile
43 #include <Standard_Integer.hxx>
45 #ifndef _TopAbs_ShapeEnum_HeaderFile
46 #include <TopAbs_ShapeEnum.hxx>
48 #ifndef _TopAbs_State_HeaderFile
49 #include <TopAbs_State.hxx>
51 #ifndef _Standard_Real_HeaderFile
52 #include <Standard_Real.hxx>
56 class IntTools_Context;
59 class TopTools_ListOfShape;
60 class TopTools_IndexedMapOfShape;
65 class TopTools_IndexedDataMapOfShapeListOfShape;
66 class NMTTools_ListOfCoupleOfShape;
69 //! Auxiliary tools for Algorithms <br>
70 class GEOMAlgo_Tools3D {
74 void* operator new(size_t,void* anAddress)
78 void* operator new(size_t size)
80 return Standard::Allocate(size);
82 void operator delete(void *anAddress)
84 if (anAddress) Standard::Free((Standard_Address&)anAddress);
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);
95 IntTools_Context& theContext);
98 //! Returns True if normal direction of the face <br>
99 //! theShape is not the same as for the face <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);
107 IntTools_Context& theContext);
110 //! Returns True if tangent direction of the edge <br>
111 //! theEdge is not the same as for the edge <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);
119 IntTools_Context& theContext);
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);
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);
133 //! Makes empty shape theShape of the type theType <br>
134 Standard_EXPORT static void MakeContainer (const TopAbs_ShapeEnum theType, TopoDS_Shape& theShape);
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);
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);
155 IntTools_Context& theContext);
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);
169 IntTools_Context& theContext);
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);
183 IntTools_Context& theContext);
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);
197 IntTools_Context& theContext);
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);
213 IntTools_Context& theContext);
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);
227 IntTools_Context& theContext);
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);
240 IntTools_Context& theContext);
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);
255 IntTools_Context& theContext);
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);
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);
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);
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,
297 // other Inline functions and methods (like "C++: function call" methods)