42cf5bc1 |
1 | // Created on: 2000-11-16 |
2 | // Created by: Peter KURNEV |
3 | // Copyright (c) 2000-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _IntTools_Tools_HeaderFile |
17 | #define _IntTools_Tools_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_DefineAlloc.hxx> |
21 | #include <Standard_Handle.hxx> |
22 | |
23 | #include <Standard_Integer.hxx> |
24 | #include <Standard_Boolean.hxx> |
25 | #include <TopAbs_State.hxx> |
26 | #include <Standard_Real.hxx> |
27 | #include <IntTools_SequenceOfCurves.hxx> |
6ca1c746 |
28 | #include <Precision.hxx> |
42cf5bc1 |
29 | class TopoDS_Vertex; |
30 | class TopoDS_Wire; |
31 | class TopoDS_Face; |
32 | class gp_Pnt2d; |
33 | class TopoDS_Edge; |
34 | class IntTools_CommonPrt; |
35 | class gp_Pnt; |
36 | class IntTools_Curve; |
37 | class gp_Dir; |
38 | class Geom_Curve; |
39 | class Bnd_Box; |
40 | class IntTools_Range; |
41 | class gp_Lin; |
42 | class gp_Pln; |
43 | class Geom2d_Curve; |
44 | class Geom_Surface; |
45 | |
46 | |
47 | |
48 | //! The class contains handy static functions |
49 | //! dealing with the geometry and topology. |
50 | class IntTools_Tools |
51 | { |
52 | public: |
53 | |
54 | DEFINE_STANDARD_ALLOC |
55 | |
56 | |
57 | |
58 | //! Computes distance between vertex V1 and vertex V2, |
59 | //! if the distance is less than sum of vertex tolerances |
60 | //! returns zero, |
61 | //! otherwise returns negative value |
62 | Standard_EXPORT static Standard_Integer ComputeVV (const TopoDS_Vertex& V1, const TopoDS_Vertex& V2); |
63 | |
64 | |
65 | //! Returns True if wire aW contains edges |
66 | //! with INTERNAL orientation |
67 | Standard_EXPORT static Standard_Boolean HasInternalEdge (const TopoDS_Wire& aW); |
68 | |
69 | |
70 | //! Build a face based on surface of given face aF |
71 | //! and bounded by wire aW |
72 | Standard_EXPORT static void MakeFaceFromWireAndFace (const TopoDS_Wire& aW, const TopoDS_Face& aF, TopoDS_Face& aFNew); |
73 | |
74 | Standard_EXPORT static TopAbs_State ClassifyPointByFace (const TopoDS_Face& aF, const gp_Pnt2d& P); |
75 | |
76 | |
77 | //! Computes square distance between a point on the edge E |
78 | //! corresponded to parameter t and vertices of edge E. |
79 | //! Returns True if this distance is less than square |
80 | //! tolerance of vertex, otherwise returns false. |
81 | Standard_EXPORT static Standard_Boolean IsVertex (const TopoDS_Edge& E, const Standard_Real t); |
82 | |
83 | |
84 | //! Returns True if square distance between vertex V |
85 | //! and a point on the edge E corresponded to parameter t |
86 | //! is less than square tolerance of V |
87 | Standard_EXPORT static Standard_Boolean IsVertex (const TopoDS_Edge& E, const TopoDS_Vertex& V, const Standard_Real t); |
88 | |
89 | |
90 | //! Returns True if IsVertx for middle parameter of fist range |
91 | //! and first edge returns True |
92 | //! and if IsVertex for middle parameter of second range and |
93 | //! second range returns True, |
94 | //! otherwise returns False |
95 | Standard_EXPORT static Standard_Boolean IsVertex (const IntTools_CommonPrt& aCmnPrt); |
96 | |
97 | |
98 | //! Gets boundary of parameters of E1 and E2. |
99 | //! Computes 3d points on each corresponded to average parameters. |
100 | //! Returns True if distance between computed points is less than |
101 | //! sum of edge tolerance, otherwise returns False. |
102 | Standard_EXPORT static Standard_Boolean IsMiddlePointsEqual (const TopoDS_Edge& E1, const TopoDS_Edge& E2); |
103 | |
104 | |
105 | //! Returns True if the distance between point aP and |
106 | //! vertex aV is less or equal to sum of aTolPV and |
107 | //! vertex tolerance, otherwise returns False |
108 | Standard_EXPORT static Standard_Boolean IsVertex (const gp_Pnt& aP, const Standard_Real aTolPV, const TopoDS_Vertex& aV); |
109 | |
110 | |
111 | //! Returns some value between aFirst and aLast |
112 | Standard_EXPORT static Standard_Real IntermediatePoint (const Standard_Real aFirst, const Standard_Real aLast); |
113 | |
114 | |
115 | //! Split aC by average parameter if aC is closed in 3D. |
116 | //! Returns positive value if splitting has been done, |
117 | //! otherwise returns zero. |
118 | Standard_EXPORT static Standard_Integer SplitCurve (const IntTools_Curve& aC, IntTools_SequenceOfCurves& aS); |
119 | |
120 | |
121 | //! Puts curves from aSIn to aSOut except those curves that |
122 | //! are coincide with first curve from aSIn. |
123 | Standard_EXPORT static void RejectLines (const IntTools_SequenceOfCurves& aSIn, IntTools_SequenceOfCurves& aSOut); |
124 | |
125 | |
126 | //! Returns True if D1 and D2 coinside |
127 | Standard_EXPORT static Standard_Boolean IsDirsCoinside (const gp_Dir& D1, const gp_Dir& D2); |
128 | |
129 | |
130 | //! Returns True if D1 and D2 coinside with given tolerance |
131 | Standard_EXPORT static Standard_Boolean IsDirsCoinside (const gp_Dir& D1, const gp_Dir& D2, const Standard_Real aTol); |
132 | |
133 | |
134 | //! Returns True if aC is BoundedCurve from Geom and |
135 | //! the distance between first point |
136 | //! of the curve aC and last point |
137 | //! is less than 1.e-12 |
138 | Standard_EXPORT static Standard_Boolean IsClosed (const Handle(Geom_Curve)& aC); |
139 | |
140 | |
141 | //! Returns adaptive tolerance for given aTolBase |
142 | //! if aC is trimmed curve and basis curve is parabola, |
143 | //! otherwise returns value of aTolBase |
144 | Standard_EXPORT static Standard_Real CurveTolerance (const Handle(Geom_Curve)& aC, const Standard_Real aTolBase); |
5652dc62 |
145 | |
146 | //! Checks if the curve is not covered by the default tolerance (confusion).<br> |
147 | //! Builds bounding box for the curve and stores it into <theBox>. |
148 | Standard_EXPORT static Standard_Boolean CheckCurve(const IntTools_Curve& theCurve, |
149 | Bnd_Box& theBox); |
42cf5bc1 |
150 | |
151 | Standard_EXPORT static Standard_Boolean IsOnPave (const Standard_Real theT, const IntTools_Range& theRange, const Standard_Real theTol); |
152 | |
153 | Standard_EXPORT static void VertexParameters (const IntTools_CommonPrt& theCP, Standard_Real& theT1, Standard_Real& theT2); |
154 | |
155 | Standard_EXPORT static void VertexParameter (const IntTools_CommonPrt& theCP, Standard_Real& theT); |
156 | |
157 | Standard_EXPORT static Standard_Boolean IsOnPave1 (const Standard_Real theT, const IntTools_Range& theRange, const Standard_Real theTol); |
158 | |
159 | //! Checks if the range <theR> interfere with the range <theRRef> |
160 | Standard_EXPORT static Standard_Boolean IsInRange (const IntTools_Range& theRRef, const IntTools_Range& theR, const Standard_Real theTol); |
161 | |
162 | Standard_EXPORT static Standard_Integer SegPln (const gp_Lin& theLin, const Standard_Real theTLin1, const Standard_Real theTLin2, const Standard_Real theTolLin, const gp_Pln& thePln, const Standard_Real theTolPln, gp_Pnt& theP, Standard_Real& theT, Standard_Real& theTolP, Standard_Real& theTmin, Standard_Real& theTmax); |
163 | |
164 | |
165 | //! Computes the max distance between points |
166 | //! taken from 3D and 2D curves by the same parameter |
6ca1c746 |
167 | Standard_EXPORT static |
168 | Standard_Boolean ComputeTolerance(const Handle(Geom_Curve)& theCurve3D, |
169 | const Handle(Geom2d_Curve)& theCurve2D, |
170 | const Handle(Geom_Surface)& theSurf, |
171 | const Standard_Real theFirst, |
172 | const Standard_Real theLast, |
173 | Standard_Real& theMaxDist, |
174 | Standard_Real& theMaxPar, |
175 | const Standard_Real theTolRange = |
176 | Precision::PConfusion()); |
42cf5bc1 |
177 | |
178 | |
3510db62 |
179 | //! Computes the correct Intersection range for |
180 | //! Line/Line, Line/Plane and Plane/Plane intersections |
181 | Standard_EXPORT static Standard_Real ComputeIntRange(const Standard_Real theTol1, |
182 | const Standard_Real theTol2, |
183 | const Standard_Real theAngle); |
42cf5bc1 |
184 | |
185 | |
186 | protected: |
187 | |
188 | |
189 | |
190 | |
191 | |
192 | private: |
193 | |
194 | |
195 | |
196 | |
197 | |
198 | }; |
199 | |
200 | |
201 | |
202 | |
203 | |
204 | |
205 | |
206 | #endif // _IntTools_Tools_HeaderFile |