42cf5bc1 |
1 | // Created by: Peter KURNEV |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
3 | // |
4 | // This file is part of Open CASCADE Technology software library. |
5 | // |
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. |
11 | // |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
14 | |
15 | #ifndef _BOPTools_AlgoTools3D_HeaderFile |
16 | #define _BOPTools_AlgoTools3D_HeaderFile |
17 | |
18 | #include <Standard.hxx> |
19 | #include <Standard_DefineAlloc.hxx> |
20 | #include <Standard_Handle.hxx> |
21 | |
22 | #include <Standard_Real.hxx> |
23 | #include <Standard_Integer.hxx> |
24 | #include <Standard_Boolean.hxx> |
25 | class TopoDS_Edge; |
26 | class TopoDS_Face; |
27 | class gp_Dir; |
28 | class Geom_Surface; |
18c06690 |
29 | class Geom2d_Curve; |
42cf5bc1 |
30 | class gp_Pnt; |
31 | class IntTools_Context; |
32 | class gp_Pnt2d; |
33 | class TopoDS_Shape; |
34 | |
35 | |
36 | |
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 |
41 | { |
42 | public: |
43 | |
44 | DEFINE_STANDARD_ALLOC |
45 | |
46 | |
47 | |
48 | //! Make the edge <aSp> seam edge for the face <aF> |
18c06690 |
49 | Standard_EXPORT static void DoSplitSEAMOnFace (const TopoDS_Edge& aSp, |
50 | const TopoDS_Face& aF); |
42cf5bc1 |
51 | |
52 | //! Computes normal to the face <aF> for the point on the edge <aE> |
51db0179 |
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, |
58 | gp_Dir& aD, |
59 | const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); |
42cf5bc1 |
60 | |
61 | |
62 | //! Computes normal to the face <aF> for the point on the edge <aE> |
51db0179 |
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, |
67 | gp_Dir& aD, |
68 | const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); |
42cf5bc1 |
69 | |
70 | |
18c06690 |
71 | //! Returns 1 if scalar product aNF1* aNF2>0.<br> |
72 | //! Returns 0 if directions aNF1 aNF2 coincide<br> |
42cf5bc1 |
73 | //! Returns -1 if scalar product aNF1* aNF2<0. |
18c06690 |
74 | Standard_EXPORT static Standard_Integer SenseFlag (const gp_Dir& aNF1, |
75 | const gp_Dir& aNF2); |
42cf5bc1 |
76 | |
77 | //! Compute normal <aD> to surface <aS> in point (U,V) |
18c06690 |
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, |
82 | gp_Dir& aD); |
42cf5bc1 |
83 | |
84 | //! Computes normal to the face <aF> for the 3D-point that |
18c06690 |
85 | //! belongs to the edge <aE> at parameter <aT>.<br> |
86 | //! Output:<br> |
87 | //! aPx - the 3D-point where the normal computed<br> |
88 | //! aD - the normal;<br> |
89 | //! Warning:<br> |
42cf5bc1 |
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 |
18c06690 |
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, |
101 | gp_Pnt& aPx, |
102 | gp_Dir& aD, |
80d55adf |
103 | const Handle(IntTools_Context)& theContext); |
42cf5bc1 |
104 | |
18c06690 |
105 | //! Computes normal to the face <aF> for the 3D-point that |
106 | //! belongs to the edge <aE> at parameter <aT>.<br> |
107 | //! Output:<br> |
108 | //! aPx - the 3D-point where the normal computed<br> |
109 | //! aD - the normal;<br> |
110 | //! Warning:<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, |
121 | gp_Pnt& aP, |
122 | gp_Dir& aDNF, |
123 | const Standard_Real aDt2D); |
42cf5bc1 |
124 | |
18c06690 |
125 | //! Computes normal to the face <aF> for the 3D-point that |
126 | //! belongs to the edge <aE> at parameter <aT>.<br> |
127 | //! Output:<br> |
128 | //! aPx - the 3D-point where the normal computed<br> |
129 | //! aD - the normal;<br> |
130 | //! Warning:<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, |
143 | gp_Pnt& aP, |
144 | gp_Dir& aDNF, |
80d55adf |
145 | const Handle(IntTools_Context)& theContext); |
42cf5bc1 |
146 | |
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 |
18c06690 |
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, |
161 | gp_Pnt2d& aP2D, |
162 | gp_Pnt& aPx, |
80d55adf |
163 | const Handle(IntTools_Context)& theContext); |
18c06690 |
164 | |
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, |
176 | gp_Pnt2d& aP2D, |
177 | gp_Pnt& aPx); |
42cf5bc1 |
178 | |
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 |
18c06690 |
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, |
192 | gp_Pnt2d& aP2D, |
193 | gp_Pnt& aPx, |
80d55adf |
194 | const Handle(IntTools_Context)& theContext); |
42cf5bc1 |
195 | |
196 | |
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 |
18c06690 |
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, |
209 | gp_Pnt2d& aP2D, |
210 | gp_Pnt& aPx, |
80d55adf |
211 | const Handle(IntTools_Context)& theContext); |
42cf5bc1 |
212 | |
213 | |
214 | //! Returns simple step value that is used in 2D-computations |
215 | //! = 1.e-5 |
216 | Standard_EXPORT static Standard_Real MinStepIn2d(); |
217 | |
218 | |
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); |
222 | |
223 | |
224 | //! Get the edge <aER> from the face <aF> that is the same as |
225 | //! the edge <aE> |
226 | Standard_EXPORT static void OrientEdgeOnFace (const TopoDS_Edge& aE, const TopoDS_Face& aF, TopoDS_Edge& aER); |
227 | |
18c06690 |
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, |
233 | gp_Pnt& theP, |
234 | gp_Pnt2d& theP2D, |
80d55adf |
235 | const Handle(IntTools_Context)& theContext); |
18c06690 |
236 | |
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, |
250 | gp_Pnt& theP, |
251 | gp_Pnt2d& theP2D, |
80d55adf |
252 | const Handle(IntTools_Context)& theContext); |
18c06690 |
253 | |
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, |
261 | gp_Pnt& theP, |
262 | gp_Pnt2d& theP2D, |
80d55adf |
263 | const Handle(IntTools_Context)& theContext, |
18c06690 |
264 | const Standard_Real theDt2D = 0.0); |
42cf5bc1 |
265 | |
266 | |
267 | protected: |
268 | |
42cf5bc1 |
269 | private: |
270 | |
42cf5bc1 |
271 | }; |
272 | |
42cf5bc1 |
273 | #endif // _BOPTools_AlgoTools3D_HeaderFile |