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 _IntTools_Context_HeaderFile |
16 | #define _IntTools_Context_HeaderFile |
17 | |
18 | #include <Standard.hxx> |
19 | #include <Standard_Type.hxx> |
20 | |
1155d05a |
21 | #include <NCollection_BaseAllocator.hxx> |
22 | #include <NCollection_DataMap.hxx> |
23 | #include <TopTools_ShapeMapHasher.hxx> |
42cf5bc1 |
24 | #include <Standard_Integer.hxx> |
25 | #include <Standard_Real.hxx> |
0d0481c7 |
26 | #include <Precision.hxx> |
25e59720 |
27 | #include <Standard_Transient.hxx> |
42cf5bc1 |
28 | #include <TopAbs_State.hxx> |
29 | #include <Standard_Boolean.hxx> |
51db0179 |
30 | #include <BRepAdaptor_Surface.hxx> |
1155d05a |
31 | #include <TColStd_MapTransientHasher.hxx> |
42cf5bc1 |
32 | class IntTools_FClass2d; |
33 | class TopoDS_Face; |
34 | class GeomAPI_ProjectPointOnSurf; |
35 | class GeomAPI_ProjectPointOnCurve; |
36 | class TopoDS_Edge; |
37 | class Geom_Curve; |
38 | class IntTools_SurfaceRangeLocalizeData; |
39 | class BRepClass3d_SolidClassifier; |
40 | class TopoDS_Solid; |
41 | class Geom2dHatch_Hatcher; |
42 | class gp_Pnt; |
43 | class TopoDS_Vertex; |
44 | class gp_Pnt2d; |
45 | class IntTools_Curve; |
46 | class Bnd_Box; |
47 | class TopoDS_Shape; |
48 | |
42cf5bc1 |
49 | //! The intersection Context contains geometrical |
50 | //! and topological toolkit (classifiers, projectors, etc). |
51 | //! The intersection Context is for caching the tools |
52 | //! to increase the performance. |
51db0179 |
53 | class IntTools_Context : public Standard_Transient |
42cf5bc1 |
54 | { |
42cf5bc1 |
55 | public: |
56 | |
57 | |
58 | Standard_EXPORT IntTools_Context(); |
59 | Standard_EXPORT virtual ~IntTools_Context(); |
60 | |
1155d05a |
61 | Standard_EXPORT IntTools_Context(const Handle(NCollection_BaseAllocator)& theAllocator); |
42cf5bc1 |
62 | |
63 | |
64 | //! Returns a reference to point classifier |
65 | //! for given face |
66 | Standard_EXPORT IntTools_FClass2d& FClass2d (const TopoDS_Face& aF); |
67 | |
68 | |
69 | //! Returns a reference to point projector |
70 | //! for given face |
71 | Standard_EXPORT GeomAPI_ProjectPointOnSurf& ProjPS (const TopoDS_Face& aF); |
72 | |
73 | |
74 | //! Returns a reference to point projector |
75 | //! for given edge |
76 | Standard_EXPORT GeomAPI_ProjectPointOnCurve& ProjPC (const TopoDS_Edge& aE); |
77 | |
78 | |
79 | //! Returns a reference to point projector |
80 | //! for given curve |
81 | Standard_EXPORT GeomAPI_ProjectPointOnCurve& ProjPT (const Handle(Geom_Curve)& aC); |
82 | |
83 | |
84 | //! Returns a reference to surface localization data |
85 | //! for given face |
86 | Standard_EXPORT IntTools_SurfaceRangeLocalizeData& SurfaceData (const TopoDS_Face& aF); |
87 | |
88 | |
89 | //! Returns a reference to solid classifier |
90 | //! for given solid |
91 | Standard_EXPORT BRepClass3d_SolidClassifier& SolidClassifier (const TopoDS_Solid& aSolid); |
92 | |
93 | |
94 | //! Returns a reference to 2D hatcher |
95 | //! for given face |
96 | Standard_EXPORT Geom2dHatch_Hatcher& Hatcher (const TopoDS_Face& aF); |
97 | |
51db0179 |
98 | //! Returns a reference to surface adaptor for given face |
99 | Standard_EXPORT BRepAdaptor_Surface& SurfaceAdaptor (const TopoDS_Face& theFace); |
100 | |
101 | //! Computes the boundaries of the face using surface adaptor |
102 | Standard_EXPORT void UVBounds (const TopoDS_Face& theFace, |
103 | Standard_Real& UMin, |
104 | Standard_Real& UMax, |
105 | Standard_Real& VMin, |
106 | Standard_Real& VMax); |
42cf5bc1 |
107 | |
108 | //! Computes parameter of the Point theP on |
109 | //! the edge aE. |
110 | //! Returns zero if the distance between point |
111 | //! and edge is less than sum of tolerance value of edge and theTopP, |
112 | //! otherwise and for following conditions returns |
113 | //! negative value |
114 | //! 1. the edge is degenerated (-1) |
115 | //! 2. the edge does not contain 3d curve and pcurves (-2) |
116 | //! 3. projection algorithm failed (-3) |
05cf4d98 |
117 | Standard_EXPORT Standard_Integer ComputePE (const gp_Pnt& theP, const Standard_Real theTolP, |
118 | const TopoDS_Edge& theE, Standard_Real& theT, |
119 | Standard_Real& theDist); |
0d0481c7 |
120 | |
42cf5bc1 |
121 | |
122 | //! Computes parameter of the vertex aV on |
0d0481c7 |
123 | //! the edge aE and correct tolerance value for |
124 | //! the vertex on the edge. |
42cf5bc1 |
125 | //! Returns zero if the distance between vertex |
0d0481c7 |
126 | //! and edge is less than sum of tolerances and the fuzzy value, |
42cf5bc1 |
127 | //! otherwise and for following conditions returns |
3510db62 |
128 | //! negative value: <br> |
129 | //! 1. the edge is degenerated (-1) <br> |
130 | //! 2. the edge does not contain 3d curve and pcurves (-2) <br> |
42cf5bc1 |
131 | //! 3. projection algorithm failed (-3) |
0d0481c7 |
132 | Standard_EXPORT Standard_Integer ComputeVE (const TopoDS_Vertex& theV, |
133 | const TopoDS_Edge& theE, |
134 | Standard_Real& theT, |
135 | Standard_Real& theTol, |
136 | const Standard_Real theFuzz = Precision::Confusion()); |
3510db62 |
137 | |
42cf5bc1 |
138 | |
139 | //! Computes UV parameters of the vertex aV on face aF |
0d0481c7 |
140 | //! and correct tolerance value for the vertex on the face. |
42cf5bc1 |
141 | //! Returns zero if the distance between vertex and face is |
0d0481c7 |
142 | //! less than or equal the sum of tolerances and the fuzzy value |
143 | //! and the projection point lays inside boundaries of the face. |
3510db62 |
144 | //! For following conditions returns negative value <br> |
145 | //! 1. projection algorithm failed (-1) <br> |
146 | //! 2. distance is more than sum of tolerances (-2) <br> |
42cf5bc1 |
147 | //! 3. projection point out or on the boundaries of face (-3) |
0d0481c7 |
148 | Standard_EXPORT Standard_Integer ComputeVF (const TopoDS_Vertex& theVertex, |
149 | const TopoDS_Face& theFace, |
150 | Standard_Real& theU, |
151 | Standard_Real& theV, |
152 | Standard_Real& theTol, |
153 | const Standard_Real theFuzz = Precision::Confusion()); |
3510db62 |
154 | |
42cf5bc1 |
155 | |
156 | //! Returns the state of the point aP2D |
157 | //! relative to face aF |
158 | Standard_EXPORT TopAbs_State StatePointFace (const TopoDS_Face& aF, const gp_Pnt2d& aP2D); |
159 | |
160 | |
161 | //! Returns true if the point aP2D is |
162 | //! inside the boundaries of the face aF, |
163 | //! otherwise returns false |
164 | Standard_EXPORT Standard_Boolean IsPointInFace (const TopoDS_Face& aF, const gp_Pnt2d& aP2D); |
165 | |
166 | |
167 | //! Returns true if the point aP2D is |
168 | //! inside the boundaries of the face aF, |
169 | //! otherwise returns false |
170 | Standard_EXPORT Standard_Boolean IsPointInFace (const gp_Pnt& aP3D, const TopoDS_Face& aF, const Standard_Real aTol); |
171 | |
172 | |
173 | //! Returns true if the point aP2D is |
174 | //! inside or on the boundaries of aF |
175 | Standard_EXPORT Standard_Boolean IsPointInOnFace (const TopoDS_Face& aF, const gp_Pnt2d& aP2D); |
176 | |
177 | |
178 | //! Returns true if the distance between point aP3D |
179 | //! and face aF is less or equal to tolerance aTol |
180 | //! and projection point is inside or on the boundaries |
181 | //! of the face aF |
182 | Standard_EXPORT Standard_Boolean IsValidPointForFace (const gp_Pnt& aP3D, const TopoDS_Face& aF, const Standard_Real aTol); |
183 | |
184 | |
185 | //! Returns true if IsValidPointForFace returns true |
186 | //! for both face aF1 and aF2 |
187 | Standard_EXPORT Standard_Boolean IsValidPointForFaces (const gp_Pnt& aP3D, const TopoDS_Face& aF1, const TopoDS_Face& aF2, const Standard_Real aTol); |
188 | |
189 | |
190 | //! Returns true if IsValidPointForFace returns true |
191 | //! for some 3d point that lay on the curve aIC bounded by |
192 | //! parameters aT1 and aT2 |
193 | 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); |
194 | |
195 | |
196 | //! Returns true if IsValidBlockForFace returns true |
197 | //! for both faces aF1 and aF2 |
198 | 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); |
199 | |
200 | |
201 | //! Computes parameter of the vertex aV on |
202 | //! the curve aIC. |
203 | //! Returns true if the distance between vertex and |
204 | //! curve is less than sum of tolerance of aV and aTolC, |
205 | //! otherwise or if projection algorithm failed |
206 | //! returns false (in this case aT isn't significant) |
207 | Standard_EXPORT Standard_Boolean IsVertexOnLine (const TopoDS_Vertex& aV, const IntTools_Curve& aIC, const Standard_Real aTolC, Standard_Real& aT); |
208 | |
209 | |
210 | //! Computes parameter of the vertex aV on |
211 | //! the curve aIC. |
212 | //! Returns true if the distance between vertex and |
213 | //! curve is less than sum of tolerance of aV and aTolC, |
214 | //! otherwise or if projection algorithm failed |
215 | //! returns false (in this case aT isn't significant) |
216 | Standard_EXPORT Standard_Boolean IsVertexOnLine (const TopoDS_Vertex& aV, const Standard_Real aTolV, const IntTools_Curve& aIC, const Standard_Real aTolC, Standard_Real& aT); |
217 | |
218 | |
219 | //! Computes parameter of the point aP on |
220 | //! the edge aE. |
221 | //! Returns false if projection algorithm failed |
222 | //! other wiese returns true. |
223 | Standard_EXPORT Standard_Boolean ProjectPointOnEdge (const gp_Pnt& aP, const TopoDS_Edge& aE, Standard_Real& aT); |
224 | |
225 | Standard_EXPORT Bnd_Box& BndBox (const TopoDS_Shape& theS); |
226 | |
227 | //! Returns true if the solid <theFace> has |
228 | //! infinite bounds |
229 | Standard_EXPORT Standard_Boolean IsInfiniteFace (const TopoDS_Face& theFace); |
230 | |
231 | //! Sets tolerance to be used for projection of point on surface. |
232 | //! Clears map of already cached projectors in order to maintain |
233 | //! correct value for all projectors |
234 | Standard_EXPORT void SetPOnSProjectionTolerance (const Standard_Real theValue); |
235 | |
236 | |
237 | |
51db0179 |
238 | DEFINE_STANDARD_RTTIEXT(IntTools_Context,Standard_Transient) |
42cf5bc1 |
239 | |
240 | protected: |
241 | |
1155d05a |
242 | typedef NCollection_DataMap<TopoDS_Shape, |
243 | Standard_Address, |
244 | TopTools_ShapeMapHasher> DataMapOfShapeAddress; |
245 | typedef NCollection_DataMap<Handle(Standard_Transient), |
246 | Standard_Address, |
247 | TColStd_MapTransientHasher> DataMapOfTransientAddress; |
248 | |
249 | Handle(NCollection_BaseAllocator) myAllocator; |
250 | DataMapOfShapeAddress myFClass2dMap; |
251 | DataMapOfShapeAddress myProjPSMap; |
252 | DataMapOfShapeAddress myProjPCMap; |
253 | DataMapOfShapeAddress mySClassMap; |
254 | DataMapOfTransientAddress myProjPTMap; |
255 | DataMapOfShapeAddress myHatcherMap; |
256 | DataMapOfShapeAddress myProjSDataMap; |
257 | DataMapOfShapeAddress myBndBoxDataMap; |
258 | DataMapOfShapeAddress mySurfAdaptorMap; |
42cf5bc1 |
259 | Standard_Integer myCreateFlag; |
260 | Standard_Real myPOnSTolerance; |
261 | |
262 | |
263 | private: |
264 | |
265 | |
266 | //! Clears map of already cached projectors. |
267 | Standard_EXPORT void clearCachedPOnSProjectors(); |
268 | |
42cf5bc1 |
269 | }; |
270 | |
51db0179 |
271 | DEFINE_STANDARD_HANDLE(IntTools_Context, Standard_Transient) |
272 | |
42cf5bc1 |
273 | #endif // _IntTools_Context_HeaderFile |