1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
\r
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
\r
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
\r
6 // This library is free software; you can redistribute it and/or
\r
7 // modify it under the terms of the GNU Lesser General Public
\r
8 // License as published by the Free Software Foundation; either
\r
9 // version 2.1 of the License.
\r
11 // This library is distributed in the hope that it will be useful,
\r
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
14 // Lesser General Public License for more details.
\r
16 // You should have received a copy of the GNU Lesser General Public
\r
17 // License along with this library; if not, write to the Free Software
\r
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
\r
22 // File : GEOMAlgo_Tools3D.hxx
\r
24 // Author : Peter KURNEV
\r
26 #ifndef _GEOMAlgo_Tools3D_HeaderFile
\r
27 #define _GEOMAlgo_Tools3D_HeaderFile
\r
29 #include <Standard.hxx>
\r
30 #include <Standard_Macro.hxx>
\r
31 #include <Standard_Boolean.hxx>
\r
32 #include <Handle_IntTools_Context.hxx>
\r
33 #include <Standard_Integer.hxx>
\r
34 #include <TopAbs_ShapeEnum.hxx>
\r
35 #include <TopAbs_State.hxx>
\r
36 #include <Standard_Real.hxx>
\r
37 #include <NMTTools_ListOfCoupleOfShape.hxx>
\r
38 #include <TopoDS_Shape.hxx>
\r
39 #include <IntTools_Context.hxx>
\r
40 #include <TopoDS_Face.hxx>
\r
41 #include <TopoDS_Edge.hxx>
\r
42 #include <TopTools_ListOfShape.hxx>
\r
43 #include <TopTools_IndexedMapOfShape.hxx>
\r
44 #include <TopoDS_Solid.hxx>
\r
45 #include <gp_Pnt.hxx>
\r
46 #include <TopoDS_Vertex.hxx>
\r
47 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
\r
48 #include <gp_Pnt2d.hxx>
\r
51 //! Auxiliary tools for Algorithms <br>
\r
52 //=======================================================================
\r
53 //class : GEOMAlgo_Tools3D
\r
55 //=======================================================================
\r
56 class GEOMAlgo_Tools3D {
\r
58 //! Returns True if the shape theSplit has opposite <br>
\r
59 //! direction than theShape <br>
\r
60 //! theContext - cashed geometrical tools <br>
\r
62 static Standard_Boolean IsSplitToReverse(const TopoDS_Shape& theSplit,
\r
63 const TopoDS_Shape& theShape,
\r
64 const Handle(IntTools_Context)& theContext) ;
\r
66 //! Returns True if normal direction of the face <br>
\r
67 //! theShape is not the same as for the face <br>
\r
69 //! theContext - cashed geometrical tools <br>
\r
71 static Standard_Boolean IsSplitToReverse(const TopoDS_Face& theSplit,
\r
72 const TopoDS_Face& theShape,
\r
73 const Handle(IntTools_Context)& theContext) ;
\r
75 //! Returns True if tangent direction of the edge <br>
\r
76 //! theEdge is not the same as for the edge <br>
\r
78 //! theContext - cashed geometrical tools <br>
\r
80 static Standard_Boolean IsSplitToReverse(const TopoDS_Edge& theEdge,
\r
81 const TopoDS_Edge& theSplit,
\r
82 const Handle(IntTools_Context)& theContext) ;
\r
84 //! For the couple of faces theF1, theF2 <br>
\r
85 //! computes sense value <br>
\r
86 //! Returns 0 if the faces are not sensible <br>
\r
87 //! Returns 1 if the faces have same sense <br>
\r
88 //! Returns 2 if the faces have opposite sense <br>
\r
90 static Standard_Integer Sense(const TopoDS_Face& theF1,
\r
91 const TopoDS_Face& theF2) ;
\r
93 //! Makes new face theF2 from surface and wires <br>
\r
94 //! of the face theF1 <br>
\r
96 static void CopyFace(const TopoDS_Face& theF1,
\r
97 TopoDS_Face& theF2) ;
\r
99 //! Makes empty shape theShape of the type theType <br>
\r
101 static void MakeContainer(const TopAbs_ShapeEnum theType,
\r
102 TopoDS_Shape& theShape) ;
\r
104 //! For the list of faces theLS build block <br>
\r
105 //! theLSCB in terms of connexity by edges <br>
\r
106 //! theMapAvoid - set of edges to avoid for <br>
\r
107 //! the treatment <br>
\r
109 static void MakeConnexityBlock(const TopTools_ListOfShape& theLS,
\r
110 const TopTools_IndexedMapOfShape& theMapAvoid,
\r
111 TopTools_ListOfShape& theLSCB) ;
\r
113 //! Computes the 3-D state of the shape theShape <br>
\r
114 //! toward solid theSolid. <br>
\r
115 //! theTol - value of precision of computation <br>
\r
116 //! theContext- cahed geometrical tools <br>
\r
117 //! Returns 3-D state. <br>
\r
119 static TopAbs_State ComputeStateByOnePoint(const TopoDS_Shape& theShape,
\r
120 const TopoDS_Solid& theSolid,
\r
121 const Standard_Real theTol,
\r
122 const Handle(IntTools_Context)& theContext) ;
\r
124 //! Computes the 3-D state of the point thePoint <br>
\r
125 //! toward solid theSolid. <br>
\r
126 //! theTol - value of precision of computation <br>
\r
127 //! theContext- cahed geometrical tools <br>
\r
128 //! Returns 3-D state. <br>
\r
130 static TopAbs_State ComputeState(const gp_Pnt& thePoint,
\r
131 const TopoDS_Solid& theSolid,
\r
132 const Standard_Real theTol,
\r
133 const Handle(IntTools_Context)& theContext) ;
\r
135 //! Computes the 3-D state of the vertex theVertex <br>
\r
136 //! toward solid theSolid. <br>
\r
137 //! theTol - value of precision of computation <br>
\r
138 //! theContext- cahed geometrical tools <br>
\r
139 //! Returns 3-D state. <br>
\r
141 static TopAbs_State ComputeState(const TopoDS_Vertex& theVertex,
\r
142 const TopoDS_Solid& theSolid,
\r
143 const Standard_Real theTol,
\r
144 const Handle(IntTools_Context)& theContext) ;
\r
146 //! Computes the 3-D state of the edge theEdge <br>
\r
147 //! toward solid theSolid. <br>
\r
148 //! theTol - value of precision of computation <br>
\r
149 //! theContext- cahed geometrical tools <br>
\r
150 //! Returns 3-D state. <br>
\r
152 static TopAbs_State ComputeState(const TopoDS_Edge& theEdge,
\r
153 const TopoDS_Solid& theSolid,
\r
154 const Standard_Real theTol,
\r
155 const Handle(IntTools_Context)& theContext) ;
\r
157 //! Computes the 3-D state of the face theFace <br>
\r
158 //! toward solid theSolid. <br>
\r
159 //! theTol - value of precision of computation <br>
\r
160 //! theBounds - set of edges of theFace to avoid <br>
\r
161 //! theContext- cahed geometrical tools <br>
\r
162 //! Returns 3-D state. <br>
\r
164 static TopAbs_State ComputeState(const TopoDS_Face& theFace,
\r
165 const TopoDS_Solid& theSolid,
\r
166 const Standard_Real theTol,
\r
167 const TopTools_IndexedMapOfShape& theBounds,
\r
168 const Handle(IntTools_Context)& theContext) ;
\r
170 //! Returns True if the face theFace is inside of the <br>
\r
171 //! couple of faces theFace1, theFace2. <br>
\r
172 //! The faces theFace, theFace1, theFace2 must <br>
\r
173 //! share the edge theEdge <br>
\r
175 static Standard_Boolean IsInternalFace(const TopoDS_Face& theFace,
\r
176 const TopoDS_Edge& theEdge,
\r
177 const TopoDS_Face& theFace1,
\r
178 const TopoDS_Face& theFace2,
\r
179 const Handle(IntTools_Context)& theContext) ;
\r
181 //! Returns True if the face theFace is inside of the <br>
\r
182 //! appropriate couple of faces (from the set theLF) . <br>
\r
183 //! The faces of the set theLF and theFace must <br>
\r
184 //! share the edge theEdge <br>
\r
186 static Standard_Boolean IsInternalFace(const TopoDS_Face& theFace,
\r
187 const TopoDS_Edge& theEdge,
\r
188 const TopTools_ListOfShape& theLF,
\r
189 const Handle(IntTools_Context)& theContext) ;
\r
191 //! Returns True if the face theFace is inside the <br>
\r
192 //! solid theSolid. <br>
\r
193 //! theMEF - Map Edge/Faces for theSolid <br>
\r
194 //! theTol - value of precision of computation <br>
\r
195 //! theContext- cahed geometrical tools <br>
\r
197 static Standard_Boolean IsInternalFace(const TopoDS_Face& theFace,
\r
198 const TopoDS_Solid& theSolid,
\r
199 const TopTools_IndexedDataMapOfShapeListOfShape& theMEF,
\r
200 const Standard_Real theTol,
\r
201 const Handle(IntTools_Context)& theContext) ;
\r
203 //! For the face theFace and its edge theEdge <br>
\r
204 //! finds the face suitable to produce shell. <br>
\r
205 //! theLCEF - set of faces to search. All faces <br>
\r
206 //! from theLCEF must share edge theEdge <br>
\r
208 static void GetFaceOff(const TopoDS_Edge& theEdge,
\r
209 const TopoDS_Face& theFace,
\r
210 const NMTTools_ListOfCoupleOfShape& theLCEF,
\r
211 TopoDS_Face& theFaceOff) ;
\r
213 //! For the face theFace gets the edge theEdgeOnF <br>
\r
214 //! that is the same as theEdge <br>
\r
215 //! Returns True if such edge exists <br>
\r
216 //! Returns False if there is no such edge <br>
\r
218 static Standard_Boolean GetEdgeOnFace(const TopoDS_Edge& theEdge,
\r
219 const TopoDS_Face& theFace,
\r
220 TopoDS_Edge& theEdgeOnF) ;
\r
222 //! Returns True if the face theFace contains <br>
\r
223 //! the edge theEdge but with opposite orientation. <br>
\r
224 //! If the method returns True theEdgeOff is the <br>
\r
225 //! edge founded <br>
\r
227 static Standard_Boolean GetEdgeOff(const TopoDS_Edge& theEdge,
\r
228 const TopoDS_Face& theFace,
\r
229 TopoDS_Edge& theEdgeOff) ;
\r
231 //! Computes a point <theP> inside the face <theF>. <br>
\r
232 //! <theP2D> - 2D representation of <theP> <br>
\r
233 //! on the surface of <theF> <br>
\r
234 //! Returns 0 in case of success. <br>
\r
236 static Standard_Integer PntInFace(const TopoDS_Face& theF,
\r
238 gp_Pnt2d& theP2D) ;
\r