1 // Created on: 2000-11-16
2 // Created by: Peter KURNEV
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _IntTools_Tools_HeaderFile
17 #define _IntTools_Tools_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
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>
28 #include <Precision.hxx>
34 class IntTools_CommonPrt;
48 //! The class contains handy static functions
49 //! dealing with the geometry and topology.
58 //! Computes distance between vertex V1 and vertex V2,
59 //! if the distance is less than sum of vertex tolerances
61 //! otherwise returns negative value
62 Standard_EXPORT static Standard_Integer ComputeVV (const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
65 //! Returns True if wire aW contains edges
66 //! with INTERNAL orientation
67 Standard_EXPORT static Standard_Boolean HasInternalEdge (const TopoDS_Wire& aW);
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);
74 Standard_EXPORT static TopAbs_State ClassifyPointByFace (const TopoDS_Face& aF, const gp_Pnt2d& P);
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);
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);
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);
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);
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);
111 //! Returns some value between aFirst and aLast
112 Standard_EXPORT static Standard_Real IntermediatePoint (const Standard_Real aFirst, const Standard_Real aLast);
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);
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);
126 //! Returns True if D1 and D2 coincide
127 Standard_EXPORT static Standard_Boolean IsDirsCoinside (const gp_Dir& D1, const gp_Dir& D2);
130 //! Returns True if D1 and D2 coincide with given tolerance
131 Standard_EXPORT static Standard_Boolean IsDirsCoinside (const gp_Dir& D1, const gp_Dir& D2, const Standard_Real aTol);
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);
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);
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,
151 Standard_EXPORT static Standard_Boolean IsOnPave (const Standard_Real theT, const IntTools_Range& theRange, const Standard_Real theTol);
153 Standard_EXPORT static void VertexParameters (const IntTools_CommonPrt& theCP, Standard_Real& theT1, Standard_Real& theT2);
155 Standard_EXPORT static void VertexParameter (const IntTools_CommonPrt& theCP, Standard_Real& theT);
157 Standard_EXPORT static Standard_Boolean IsOnPave1 (const Standard_Real theT, const IntTools_Range& theRange, const Standard_Real theTol);
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);
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);
165 //! Computes the max distance between points
166 //! taken from 3D and 2D curves by the same parameter
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());
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);
206 #endif // _IntTools_Tools_HeaderFile