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