0026431: Can't cut a sphere from a cylinder
[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
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>
29class IntTools_FClass2d;
30class TopoDS_Face;
31class GeomAPI_ProjectPointOnSurf;
32class GeomAPI_ProjectPointOnCurve;
33class TopoDS_Edge;
34class Geom_Curve;
35class IntTools_SurfaceRangeLocalizeData;
36class BRepClass3d_SolidClassifier;
37class TopoDS_Solid;
38class Geom2dHatch_Hatcher;
39class gp_Pnt;
40class TopoDS_Vertex;
41class gp_Pnt2d;
42class IntTools_Curve;
43class Bnd_Box;
44class TopoDS_Shape;
45
46
47class IntTools_Context;
48DEFINE_STANDARD_HANDLE(IntTools_Context, MMgt_TShared)
49
50
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.
55class IntTools_Context : public MMgt_TShared
56{
57
58public:
59
60
61 Standard_EXPORT IntTools_Context();
62Standard_EXPORT virtual ~IntTools_Context();
63
64 Standard_EXPORT IntTools_Context(const BOPCol_BaseAllocator& theAllocator);
65
66
67 //! Returns a reference to point classifier
68 //! for given face
69 Standard_EXPORT IntTools_FClass2d& FClass2d (const TopoDS_Face& aF);
70
71
72 //! Returns a reference to point projector
73 //! for given face
74 Standard_EXPORT GeomAPI_ProjectPointOnSurf& ProjPS (const TopoDS_Face& aF);
75
76
77 //! Returns a reference to point projector
78 //! for given edge
79 Standard_EXPORT GeomAPI_ProjectPointOnCurve& ProjPC (const TopoDS_Edge& aE);
80
81
82 //! Returns a reference to point projector
83 //! for given curve
84 Standard_EXPORT GeomAPI_ProjectPointOnCurve& ProjPT (const Handle(Geom_Curve)& aC);
85
86
87 //! Returns a reference to surface localization data
88 //! for given face
89 Standard_EXPORT IntTools_SurfaceRangeLocalizeData& SurfaceData (const TopoDS_Face& aF);
90
91
92 //! Returns a reference to solid classifier
93 //! for given solid
94 Standard_EXPORT BRepClass3d_SolidClassifier& SolidClassifier (const TopoDS_Solid& aSolid);
95
96
97 //! Returns a reference to 2D hatcher
98 //! for given face
99 Standard_EXPORT Geom2dHatch_Hatcher& Hatcher (const TopoDS_Face& aF);
100
101
102 //! Computes parameter of the Point theP on
103 //! the edge aE.
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
107 //! negative value
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);
112
113
114 //! Computes parameter of the vertex aV on
115 //! the edge aE.
116 //! Returns zero if the distance between vertex
117 //! and edge is less than sum of tolerances,
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)
123 Standard_EXPORT Standard_Integer ComputeVE (const TopoDS_Vertex& aV, const TopoDS_Edge& aE, Standard_Real& aT);
124
125
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);
135
136
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);
140
141
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);
146
147
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);
152
153
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);
157
158
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
162 //! of the face aF
163 Standard_EXPORT Standard_Boolean IsValidPointForFace (const gp_Pnt& aP3D, const TopoDS_Face& aF, const Standard_Real aTol);
164
165
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);
169
170
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);
175
176
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);
180
181
182 //! Computes parameter of the vertex aV on
183 //! the curve aIC.
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);
189
190
191 //! Computes parameter of the vertex aV on
192 //! the curve aIC.
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);
198
199
200 //! Computes parameter of the point aP on
201 //! the edge aE.
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);
205
206 Standard_EXPORT Bnd_Box& BndBox (const TopoDS_Shape& theS);
207
208 //! Returns true if the solid <theFace> has
209 //! infinite bounds
210 Standard_EXPORT Standard_Boolean IsInfiniteFace (const TopoDS_Face& theFace);
211
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);
216
217
218
219
220 DEFINE_STANDARD_RTTI(IntTools_Context,MMgt_TShared)
221
222protected:
223
224
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;
236
237
238private:
239
240
241 //! Clears map of already cached projectors.
242 Standard_EXPORT void clearCachedPOnSProjectors();
243
244
245
246};
247
248
249
250
251
252
253
254#endif // _IntTools_Context_HeaderFile