1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _BOPTools_AlgoTools3D_HeaderFile
16 #define _BOPTools_AlgoTools3D_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
22 #include <Standard_Real.hxx>
23 #include <Standard_Integer.hxx>
24 #include <Standard_Boolean.hxx>
31 class IntTools_Context;
37 //! The class contains handy static functions
38 //! dealing with the topology
39 //! This is the copy of BOPTools_AlgoTools3D.cdl file
40 class BOPTools_AlgoTools3D
48 //! Make the edge <aSp> seam edge for the face <aF>
49 Standard_EXPORT static void DoSplitSEAMOnFace (const TopoDS_Edge& aSp,
50 const TopoDS_Face& aF);
52 //! Computes normal to the face <aF> for the point on the edge <aE>
53 //! at parameter <aT>.<br>
54 //! <theContext> - storage for caching the geometrical tools
55 Standard_EXPORT static void GetNormalToFaceOnEdge (const TopoDS_Edge& aE,
56 const TopoDS_Face& aF,
57 const Standard_Real aT,
59 const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
62 //! Computes normal to the face <aF> for the point on the edge <aE>
63 //! at arbitrary intermediate parameter.<br>
64 //! <theContext> - storage for caching the geometrical tools
65 Standard_EXPORT static void GetNormalToFaceOnEdge (const TopoDS_Edge& aE,
66 const TopoDS_Face& aF,
68 const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
71 //! Returns 1 if scalar product aNF1* aNF2>0.<br>
72 //! Returns 0 if directions aNF1 aNF2 coincide<br>
73 //! Returns -1 if scalar product aNF1* aNF2<0.
74 Standard_EXPORT static Standard_Integer SenseFlag (const gp_Dir& aNF1,
77 //! Compute normal <aD> to surface <aS> in point (U,V)
78 //! Returns TRUE if directions aD1U, aD1V coincide
79 Standard_EXPORT static Standard_Boolean GetNormalToSurface (const Handle(Geom_Surface)& aS,
80 const Standard_Real U,
81 const Standard_Real V,
84 //! Computes normal to the face <aF> for the 3D-point that
85 //! belongs to the edge <aE> at parameter <aT>.<br>
87 //! aPx - the 3D-point where the normal computed<br>
88 //! aD - the normal;<br>
90 //! The normal is computed not exactly in the point on the
91 //! edge, but in point that is near to the edge towards to
92 //! the face material (so, we'll have approx. normal);<br>
93 //! The point is computed using PointNearEdge function,
94 //! with the shifting value BOPTools_AlgoTools3D::MinStepIn2d(),
95 //! from the edge, but if this value is too big,
96 //! the point will be computed using Hatcher (PointInFace function).<br>
97 //! Returns TRUE in case of success.
98 Standard_EXPORT static Standard_Boolean GetApproxNormalToFaceOnEdge (const TopoDS_Edge& aE,
99 const TopoDS_Face& aF,
100 const Standard_Real aT,
103 const Handle(IntTools_Context)& theContext);
105 //! Computes normal to the face <aF> for the 3D-point that
106 //! belongs to the edge <aE> at parameter <aT>.<br>
108 //! aPx - the 3D-point where the normal computed<br>
109 //! aD - the normal;<br>
111 //! The normal is computed not exactly in the point on the
112 //! edge, but in point that is near to the edge towards to
113 //! the face material (so, we'll have approx. normal);<br>
114 //! The point is computed using PointNearEdge function
115 //! with the shifting value <aDt2D> from the edge;<br>
116 //! No checks on this value will be done.<br>
117 //! Returns TRUE in case of success.
118 Standard_EXPORT static Standard_Boolean GetApproxNormalToFaceOnEdge (const TopoDS_Edge& theE,
119 const TopoDS_Face& theF,
120 const Standard_Real aT,
123 const Standard_Real aDt2D);
125 //! Computes normal to the face <aF> for the 3D-point that
126 //! belongs to the edge <aE> at parameter <aT>.<br>
128 //! aPx - the 3D-point where the normal computed<br>
129 //! aD - the normal;<br>
131 //! The normal is computed not exactly in the point on the
132 //! edge, but in point that is near to the edge towards to
133 //! the face material (so, we'll have approx. normal);<br>
134 //! The point is computed using PointNearEdge function
135 //! with the shifting value <aDt2D> from the edge,
136 //! but if this value is too big the point will be
137 //! computed using Hatcher (PointInFace function).<br>
138 //! Returns TRUE in case of success.
139 Standard_EXPORT static Standard_Boolean GetApproxNormalToFaceOnEdge (const TopoDS_Edge& theE,
140 const TopoDS_Face& theF,
141 const Standard_Real aT,
142 const Standard_Real aDt2D,
145 const Handle(IntTools_Context)& theContext);
147 //! Compute the point <aPx>, (<aP2D>) that is near to
148 //! the edge <aE> at parameter <aT> towards to the
149 //! material of the face <aF>. The value of shifting in
150 //! 2D is <aDt2D><br>
151 //! If the value of shifting is too big the point
152 //! will be computed using Hatcher (PointInFace function).<br>
153 //! Returns error status:<br>
154 //! 0 - in case of success;<br>
155 //! 1 - <aE> does not have 2d curve on the face <aF>;<br>
156 //! 2 - the computed point is out of the face.
157 Standard_EXPORT static Standard_Integer PointNearEdge (const TopoDS_Edge& aE,
158 const TopoDS_Face& aF,
159 const Standard_Real aT,
160 const Standard_Real aDt2D,
163 const Handle(IntTools_Context)& theContext);
165 //! Compute the point <aPx>, (<aP2D>) that is near to
166 //! the edge <aE> at parameter <aT> towards to the
167 //! material of the face <aF>. The value of shifting in
168 //! 2D is <aDt2D>. No checks on this value will be done.<br>
169 //! Returns error status:<br>
170 //! 0 - in case of success;<br>
171 //! 1 - <aE> does not have 2d curve on the face <aF>.
172 Standard_EXPORT static Standard_Integer PointNearEdge (const TopoDS_Edge& aE,
173 const TopoDS_Face& aF,
174 const Standard_Real aT,
175 const Standard_Real aDt2D,
179 //! Computes the point <aPx>, (<aP2D>) that is near to
180 //! the edge <aE> at parameter <aT> towards to the
181 //! material of the face <aF>. The value of shifting in
182 //! 2D is dt2D=BOPTools_AlgoTools3D::MinStepIn2d()<br>
183 //! If the value of shifting is too big the point will be computed
184 //! using Hatcher (PointInFace function).<br>
185 //! Returns error status:<br>
186 //! 0 - in case of success;<br>
187 //! 1 - <aE> does not have 2d curve on the face <aF>;<br>
188 //! 2 - the computed point is out of the face.
189 Standard_EXPORT static Standard_Integer PointNearEdge (const TopoDS_Edge& aE,
190 const TopoDS_Face& aF,
191 const Standard_Real aT,
194 const Handle(IntTools_Context)& theContext);
197 //! Compute the point <aPx>, (<aP2D>) that is near to
198 //! the edge <aE> at arbitrary parameter towards to the
199 //! material of the face <aF>. The value of shifting in
200 //! 2D is dt2D=BOPTools_AlgoTools3D::MinStepIn2d().<br>
201 //! If the value of shifting is too big the point will be computed
202 //! using Hatcher (PointInFace function).<br>
203 //! Returns error status:<br>
204 //! 0 - in case of success;<br>
205 //! 1 - <aE> does not have 2d curve on the face <aF>;<br>
206 //! 2 - the computed point is out of the face.
207 Standard_EXPORT static Standard_Integer PointNearEdge (const TopoDS_Edge& aE,
208 const TopoDS_Face& aF,
211 const Handle(IntTools_Context)& theContext);
214 //! Returns simple step value that is used in 2D-computations
216 Standard_EXPORT static Standard_Real MinStepIn2d();
219 //! Returns TRUE if the shape <aS> does not contain
220 //! geometry information (e.g. empty compound)
221 Standard_EXPORT static Standard_Boolean IsEmptyShape (const TopoDS_Shape& aS);
224 //! Get the edge <aER> from the face <aF> that is the same as
226 Standard_EXPORT static void OrientEdgeOnFace (const TopoDS_Edge& aE, const TopoDS_Face& aF, TopoDS_Edge& aER);
228 //! Computes arbitrary point <theP> inside the face <theF>.<br>
229 //! <theP2D> - 2D representation of <theP>
230 //! on the surface of <theF><br>
231 //! Returns 0 in case of success.
232 Standard_EXPORT static Standard_Integer PointInFace (const TopoDS_Face& theF,
235 const Handle(IntTools_Context)& theContext);
237 //! Computes a point <theP> inside the face <theF>
238 //! using starting point taken by the parameter <theT>
239 //! from the 2d curve of the edge <theE> on the face <theF>
240 //! in the direction perpendicular to the tangent vector
241 //! of the 2d curve of the edge.<br>
242 //! The point will be distanced on <theDt2D> from the 2d curve.
243 //! <theP2D> - 2D representation of <theP>
244 //! on the surface of <theF><br>
245 //! Returns 0 in case of success.
246 Standard_EXPORT static Standard_Integer PointInFace (const TopoDS_Face& theF,
247 const TopoDS_Edge& theE,
248 const Standard_Real theT,
249 const Standard_Real theDt2D,
252 const Handle(IntTools_Context)& theContext);
254 //! Computes a point <theP> inside the face <theF>
255 //! using the line <theL> so that 2D point
256 //! <theP2D>, 2D representation of <theP>
257 //! on the surface of <theF>, lies on that line.<br>
258 //! Returns 0 in case of success.
259 Standard_EXPORT static Standard_Integer PointInFace (const TopoDS_Face& theF,
260 const Handle(Geom2d_Curve)& theL,
263 const Handle(IntTools_Context)& theContext,
264 const Standard_Real theDt2D = 0.0);
273 #endif // _BOPTools_AlgoTools3D_HeaderFile