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>
33 class IntTools_CommonPrt;
47 //! The class contains handy static functions
48 //! dealing with the geometry and topology.
57 //! Computes distance between vertex V1 and vertex V2,
58 //! if the distance is less than sum of vertex tolerances
60 //! otherwise returns negative value
61 Standard_EXPORT static Standard_Integer ComputeVV (const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
64 //! Returns True if wire aW contains edges
65 //! with INTERNAL orientation
66 Standard_EXPORT static Standard_Boolean HasInternalEdge (const TopoDS_Wire& aW);
69 //! Build a face based on surface of given face aF
70 //! and bounded by wire aW
71 Standard_EXPORT static void MakeFaceFromWireAndFace (const TopoDS_Wire& aW, const TopoDS_Face& aF, TopoDS_Face& aFNew);
73 Standard_EXPORT static TopAbs_State ClassifyPointByFace (const TopoDS_Face& aF, const gp_Pnt2d& P);
76 //! Computes square distance between a point on the edge E
77 //! corresponded to parameter t and vertices of edge E.
78 //! Returns True if this distance is less than square
79 //! tolerance of vertex, otherwise returns false.
80 Standard_EXPORT static Standard_Boolean IsVertex (const TopoDS_Edge& E, const Standard_Real t);
83 //! Returns True if square distance between vertex V
84 //! and a point on the edge E corresponded to parameter t
85 //! is less than square tolerance of V
86 Standard_EXPORT static Standard_Boolean IsVertex (const TopoDS_Edge& E, const TopoDS_Vertex& V, const Standard_Real t);
89 //! Returns True if IsVertx for middle parameter of fist range
90 //! and first edge returns True
91 //! and if IsVertex for middle parameter of second range and
92 //! second range returns True,
93 //! otherwise returns False
94 Standard_EXPORT static Standard_Boolean IsVertex (const IntTools_CommonPrt& aCmnPrt);
97 //! Gets boundary of parameters of E1 and E2.
98 //! Computes 3d points on each corresponded to average parameters.
99 //! Returns True if distance between computed points is less than
100 //! sum of edge tolerance, otherwise returns False.
101 Standard_EXPORT static Standard_Boolean IsMiddlePointsEqual (const TopoDS_Edge& E1, const TopoDS_Edge& E2);
104 //! Returns True if the distance between point aP and
105 //! vertex aV is less or equal to sum of aTolPV and
106 //! vertex tolerance, otherwise returns False
107 Standard_EXPORT static Standard_Boolean IsVertex (const gp_Pnt& aP, const Standard_Real aTolPV, const TopoDS_Vertex& aV);
110 //! Returns some value between aFirst and aLast
111 Standard_EXPORT static Standard_Real IntermediatePoint (const Standard_Real aFirst, const Standard_Real aLast);
114 //! Split aC by average parameter if aC is closed in 3D.
115 //! Returns positive value if splitting has been done,
116 //! otherwise returns zero.
117 Standard_EXPORT static Standard_Integer SplitCurve (const IntTools_Curve& aC, IntTools_SequenceOfCurves& aS);
120 //! Puts curves from aSIn to aSOut except those curves that
121 //! are coincide with first curve from aSIn.
122 Standard_EXPORT static void RejectLines (const IntTools_SequenceOfCurves& aSIn, IntTools_SequenceOfCurves& aSOut);
125 //! Returns True if D1 and D2 coinside
126 Standard_EXPORT static Standard_Boolean IsDirsCoinside (const gp_Dir& D1, const gp_Dir& D2);
129 //! Returns True if D1 and D2 coinside with given tolerance
130 Standard_EXPORT static Standard_Boolean IsDirsCoinside (const gp_Dir& D1, const gp_Dir& D2, const Standard_Real aTol);
133 //! Returns True if aC is BoundedCurve from Geom and
134 //! the distance between first point
135 //! of the curve aC and last point
136 //! is less than 1.e-12
137 Standard_EXPORT static Standard_Boolean IsClosed (const Handle(Geom_Curve)& aC);
140 //! Returns adaptive tolerance for given aTolBase
141 //! if aC is trimmed curve and basis curve is parabola,
142 //! otherwise returns value of aTolBase
143 Standard_EXPORT static Standard_Real CurveTolerance (const Handle(Geom_Curve)& aC, const Standard_Real aTolBase);
145 Standard_EXPORT static Standard_Boolean CheckCurve (const Handle(Geom_Curve)& theC, const Standard_Real theTol, Bnd_Box& theBox);
147 Standard_EXPORT static Standard_Boolean IsOnPave (const Standard_Real theT, const IntTools_Range& theRange, const Standard_Real theTol);
149 Standard_EXPORT static void VertexParameters (const IntTools_CommonPrt& theCP, Standard_Real& theT1, Standard_Real& theT2);
151 Standard_EXPORT static void VertexParameter (const IntTools_CommonPrt& theCP, Standard_Real& theT);
153 Standard_EXPORT static Standard_Boolean IsOnPave1 (const Standard_Real theT, const IntTools_Range& theRange, const Standard_Real theTol);
155 //! Checks if the range <theR> interfere with the range <theRRef>
156 Standard_EXPORT static Standard_Boolean IsInRange (const IntTools_Range& theRRef, const IntTools_Range& theR, const Standard_Real theTol);
158 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);
161 //! Computes the max distance between points
162 //! taken from 3D and 2D curves by the same parameter
163 Standard_EXPORT static Standard_Boolean ComputeTolerance (const Handle(Geom_Curve)& theCurve3D, const Handle(Geom2d_Curve)& theCurve2D, const Handle(Geom_Surface)& theSurf, const Standard_Real theFirst, const Standard_Real theLast, Standard_Real& theMaxDist, Standard_Real& theMaxPar);
188 #endif // _IntTools_Tools_HeaderFile