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 _IntTools_Context_HeaderFile
16 #define _IntTools_Context_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_Type.hxx>
21 #include <BOPCol_BaseAllocator.hxx>
22 #include <BOPCol_DataMapOfShapeAddress.hxx>
23 #include <BOPCol_DataMapOfTransientAddress.hxx>
24 #include <Standard_Integer.hxx>
25 #include <Standard_Real.hxx>
26 #include <MMgt_TShared.hxx>
27 #include <TopAbs_State.hxx>
28 #include <Standard_Boolean.hxx>
29 class IntTools_FClass2d;
31 class GeomAPI_ProjectPointOnSurf;
32 class GeomAPI_ProjectPointOnCurve;
35 class IntTools_SurfaceRangeLocalizeData;
36 class BRepClass3d_SolidClassifier;
38 class Geom2dHatch_Hatcher;
47 class IntTools_Context;
48 DEFINE_STANDARD_HANDLE(IntTools_Context, MMgt_TShared)
51 //! The intersection Context contains geometrical
52 //! and topological toolkit (classifiers, projectors, etc).
53 //! The intersection Context is for caching the tools
54 //! to increase the performance.
55 class IntTools_Context : public MMgt_TShared
61 Standard_EXPORT IntTools_Context();
62 Standard_EXPORT virtual ~IntTools_Context();
64 Standard_EXPORT IntTools_Context(const BOPCol_BaseAllocator& theAllocator);
67 //! Returns a reference to point classifier
69 Standard_EXPORT IntTools_FClass2d& FClass2d (const TopoDS_Face& aF);
72 //! Returns a reference to point projector
74 Standard_EXPORT GeomAPI_ProjectPointOnSurf& ProjPS (const TopoDS_Face& aF);
77 //! Returns a reference to point projector
79 Standard_EXPORT GeomAPI_ProjectPointOnCurve& ProjPC (const TopoDS_Edge& aE);
82 //! Returns a reference to point projector
84 Standard_EXPORT GeomAPI_ProjectPointOnCurve& ProjPT (const Handle(Geom_Curve)& aC);
87 //! Returns a reference to surface localization data
89 Standard_EXPORT IntTools_SurfaceRangeLocalizeData& SurfaceData (const TopoDS_Face& aF);
92 //! Returns a reference to solid classifier
94 Standard_EXPORT BRepClass3d_SolidClassifier& SolidClassifier (const TopoDS_Solid& aSolid);
97 //! Returns a reference to 2D hatcher
99 Standard_EXPORT Geom2dHatch_Hatcher& Hatcher (const TopoDS_Face& aF);
102 //! Computes parameter of the Point theP on
104 //! Returns zero if the distance between point
105 //! and edge is less than sum of tolerance value of edge and theTopP,
106 //! otherwise and for following conditions returns
108 //! 1. the edge is degenerated (-1)
109 //! 2. the edge does not contain 3d curve and pcurves (-2)
110 //! 3. projection algorithm failed (-3)
111 Standard_EXPORT Standard_Integer ComputePE (const gp_Pnt& theP, const Standard_Real theTolP, const TopoDS_Edge& theE, Standard_Real& theT);
114 //! Computes parameter of the vertex aV on
116 //! Returns zero if the distance between vertex
117 //! and edge is less than sum of tolerances,
118 //! otherwise and for following conditions returns
120 //! 1. the edge is degenerated (-1)
121 //! 2. the edge does not contain 3d curve and pcurves (-2)
122 //! 3. projection algorithm failed (-3)
123 Standard_EXPORT Standard_Integer ComputeVE (const TopoDS_Vertex& aV, const TopoDS_Edge& aE, Standard_Real& aT);
126 //! Computes UV parameters of the vertex aV on face aF
127 //! Returns zero if the distance between vertex and face is
128 //! less than or equal the sum of tolerances and the projection
129 //! point lays inside boundaries of the face.
130 //! For following conditions returns negative value
131 //! 1. projection algorithm failed (-1)
132 //! 2. distance is more than sum of tolerances (-2)
133 //! 3. projection point out or on the boundaries of face (-3)
134 Standard_EXPORT Standard_Integer ComputeVF (const TopoDS_Vertex& aV, const TopoDS_Face& aF, Standard_Real& U, Standard_Real& V);
137 //! Returns the state of the point aP2D
138 //! relative to face aF
139 Standard_EXPORT TopAbs_State StatePointFace (const TopoDS_Face& aF, const gp_Pnt2d& aP2D);
142 //! Returns true if the point aP2D is
143 //! inside the boundaries of the face aF,
144 //! otherwise returns false
145 Standard_EXPORT Standard_Boolean IsPointInFace (const TopoDS_Face& aF, const gp_Pnt2d& aP2D);
148 //! Returns true if the point aP2D is
149 //! inside the boundaries of the face aF,
150 //! otherwise returns false
151 Standard_EXPORT Standard_Boolean IsPointInFace (const gp_Pnt& aP3D, const TopoDS_Face& aF, const Standard_Real aTol);
154 //! Returns true if the point aP2D is
155 //! inside or on the boundaries of aF
156 Standard_EXPORT Standard_Boolean IsPointInOnFace (const TopoDS_Face& aF, const gp_Pnt2d& aP2D);
159 //! Returns true if the distance between point aP3D
160 //! and face aF is less or equal to tolerance aTol
161 //! and projection point is inside or on the boundaries
163 Standard_EXPORT Standard_Boolean IsValidPointForFace (const gp_Pnt& aP3D, const TopoDS_Face& aF, const Standard_Real aTol);
166 //! Returns true if IsValidPointForFace returns true
167 //! for both face aF1 and aF2
168 Standard_EXPORT Standard_Boolean IsValidPointForFaces (const gp_Pnt& aP3D, const TopoDS_Face& aF1, const TopoDS_Face& aF2, const Standard_Real aTol);
171 //! Returns true if IsValidPointForFace returns true
172 //! for some 3d point that lay on the curve aIC bounded by
173 //! parameters aT1 and aT2
174 Standard_EXPORT Standard_Boolean IsValidBlockForFace (const Standard_Real aT1, const Standard_Real aT2, const IntTools_Curve& aIC, const TopoDS_Face& aF, const Standard_Real aTol);
177 //! Returns true if IsValidBlockForFace returns true
178 //! for both faces aF1 and aF2
179 Standard_EXPORT Standard_Boolean IsValidBlockForFaces (const Standard_Real aT1, const Standard_Real aT2, const IntTools_Curve& aIC, const TopoDS_Face& aF1, const TopoDS_Face& aF2, const Standard_Real aTol);
182 //! Computes parameter of the vertex aV on
184 //! Returns true if the distance between vertex and
185 //! curve is less than sum of tolerance of aV and aTolC,
186 //! otherwise or if projection algorithm failed
187 //! returns false (in this case aT isn't significant)
188 Standard_EXPORT Standard_Boolean IsVertexOnLine (const TopoDS_Vertex& aV, const IntTools_Curve& aIC, const Standard_Real aTolC, Standard_Real& aT);
191 //! Computes parameter of the vertex aV on
193 //! Returns true if the distance between vertex and
194 //! curve is less than sum of tolerance of aV and aTolC,
195 //! otherwise or if projection algorithm failed
196 //! returns false (in this case aT isn't significant)
197 Standard_EXPORT Standard_Boolean IsVertexOnLine (const TopoDS_Vertex& aV, const Standard_Real aTolV, const IntTools_Curve& aIC, const Standard_Real aTolC, Standard_Real& aT);
200 //! Computes parameter of the point aP on
202 //! Returns false if projection algorithm failed
203 //! other wiese returns true.
204 Standard_EXPORT Standard_Boolean ProjectPointOnEdge (const gp_Pnt& aP, const TopoDS_Edge& aE, Standard_Real& aT);
206 Standard_EXPORT Bnd_Box& BndBox (const TopoDS_Shape& theS);
208 //! Returns true if the solid <theFace> has
210 Standard_EXPORT Standard_Boolean IsInfiniteFace (const TopoDS_Face& theFace);
212 //! Sets tolerance to be used for projection of point on surface.
213 //! Clears map of already cached projectors in order to maintain
214 //! correct value for all projectors
215 Standard_EXPORT void SetPOnSProjectionTolerance (const Standard_Real theValue);
220 DEFINE_STANDARD_RTTIEXT(IntTools_Context,MMgt_TShared)
225 BOPCol_BaseAllocator myAllocator;
226 BOPCol_DataMapOfShapeAddress myFClass2dMap;
227 BOPCol_DataMapOfShapeAddress myProjPSMap;
228 BOPCol_DataMapOfShapeAddress myProjPCMap;
229 BOPCol_DataMapOfShapeAddress mySClassMap;
230 BOPCol_DataMapOfTransientAddress myProjPTMap;
231 BOPCol_DataMapOfShapeAddress myHatcherMap;
232 BOPCol_DataMapOfShapeAddress myProjSDataMap;
233 BOPCol_DataMapOfShapeAddress myBndBoxDataMap;
234 Standard_Integer myCreateFlag;
235 Standard_Real myPOnSTolerance;
241 //! Clears map of already cached projectors.
242 Standard_EXPORT void clearCachedPOnSProjectors();
254 #endif // _IntTools_Context_HeaderFile