Commit | Line | Data |
---|---|---|
42cf5bc1 | 1 | // Created on: 1993-05-14 |
2 | // Created by: Bruno DUMORTIER | |
3 | // Copyright (c) 1993-1999 Matra Datavision | |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS | |
5 | // | |
6 | // This file is part of Open CASCADE Technology software library. | |
7 | // | |
8 | // This library is free software; you can redistribute it and/or modify it under | |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
10 | // by the Free Software Foundation, with special exception defined in the file | |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
12 | // distribution for complete text of the license and disclaimer of any warranty. | |
13 | // | |
14 | // Alternatively, this file may be used under the terms of Open CASCADE | |
15 | // commercial license or contractual agreement. | |
16 | ||
17 | #ifndef _GeomAdaptor_Surface_HeaderFile | |
18 | #define _GeomAdaptor_Surface_HeaderFile | |
19 | ||
20 | #include <Standard.hxx> | |
21 | #include <Standard_DefineAlloc.hxx> | |
22 | #include <Standard_Handle.hxx> | |
23 | ||
24 | #include <GeomAbs_SurfaceType.hxx> | |
25 | #include <Standard_Real.hxx> | |
26 | #include <BSplSLib_Cache.hxx> | |
27 | #include <Adaptor3d_Surface.hxx> | |
28 | #include <GeomAbs_Shape.hxx> | |
29 | #include <Standard_Integer.hxx> | |
30 | #include <TColStd_Array1OfReal.hxx> | |
31 | #include <Standard_Boolean.hxx> | |
6b84c3f7 | 32 | #include <GeomEvaluator_Surface.hxx> |
42cf5bc1 | 33 | class Geom_Surface; |
34 | class Standard_NoSuchObject; | |
35 | class Standard_OutOfRange; | |
36 | class Standard_ConstructionError; | |
37 | class Standard_DomainError; | |
38 | class Adaptor3d_HSurface; | |
39 | class gp_Pnt; | |
40 | class gp_Vec; | |
41 | class gp_Pln; | |
42 | class gp_Cylinder; | |
43 | class gp_Cone; | |
44 | class gp_Sphere; | |
45 | class gp_Torus; | |
46 | class Geom_BezierSurface; | |
47 | class Geom_BSplineSurface; | |
48 | class gp_Ax1; | |
49 | class gp_Dir; | |
50 | class Adaptor3d_HCurve; | |
51 | ||
52 | ||
53 | //! An interface between the services provided by any | |
54 | //! surface from the package Geom and those required | |
55 | //! of the surface by algorithms which use it. | |
56 | //! Creation of the loaded surface the surface is C1 by piece | |
34e4e9f2 BB |
57 | //! |
58 | //! Polynomial coefficients of BSpline surfaces used for their evaluation are | |
59 | //! cached for better performance. Therefore these evaluations are not | |
60 | //! thread-safe and parallel evaluations need to be prevented. | |
42cf5bc1 | 61 | class GeomAdaptor_Surface : public Adaptor3d_Surface |
62 | { | |
63 | public: | |
64 | ||
65 | DEFINE_STANDARD_ALLOC | |
66 | ||
67 | ||
68 | GeomAdaptor_Surface(); | |
69 | ||
70 | GeomAdaptor_Surface(const Handle(Geom_Surface)& S); | |
71 | ||
72 | //! ConstructionError is raised if UFirst>ULast or VFirst>VLast | |
73 | GeomAdaptor_Surface(const Handle(Geom_Surface)& S, const Standard_Real UFirst, const Standard_Real ULast, const Standard_Real VFirst, const Standard_Real VLast, const Standard_Real TolU = 0.0, const Standard_Real TolV = 0.0); | |
74 | ||
75 | void Load (const Handle(Geom_Surface)& S); | |
76 | ||
77 | //! ConstructionError is raised if UFirst>ULast or VFirst>VLast | |
78 | void Load (const Handle(Geom_Surface)& S, const Standard_Real UFirst, const Standard_Real ULast, const Standard_Real VFirst, const Standard_Real VLast, const Standard_Real TolU = 0.0, const Standard_Real TolV = 0.0); | |
79 | ||
80 | const Handle(Geom_Surface)& Surface() const; | |
81 | ||
82 | Standard_Real FirstUParameter() const Standard_OVERRIDE; | |
83 | ||
84 | Standard_Real LastUParameter() const Standard_OVERRIDE; | |
85 | ||
86 | Standard_Real FirstVParameter() const Standard_OVERRIDE; | |
87 | ||
88 | Standard_Real LastVParameter() const Standard_OVERRIDE; | |
89 | ||
90 | Standard_EXPORT GeomAbs_Shape UContinuity() const Standard_OVERRIDE; | |
91 | ||
92 | Standard_EXPORT GeomAbs_Shape VContinuity() const Standard_OVERRIDE; | |
93 | ||
94 | //! Returns the number of U intervals for continuity | |
95 | //! <S>. May be one if UContinuity(me) >= <S> | |
96 | Standard_EXPORT Standard_Integer NbUIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE; | |
97 | ||
98 | //! Returns the number of V intervals for continuity | |
99 | //! <S>. May be one if VContinuity(me) >= <S> | |
100 | Standard_EXPORT Standard_Integer NbVIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE; | |
101 | ||
102 | //! Returns the intervals with the requested continuity | |
103 | //! in the U direction. | |
104 | Standard_EXPORT void UIntervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE; | |
105 | ||
106 | //! Returns the intervals with the requested continuity | |
107 | //! in the V direction. | |
108 | Standard_EXPORT void VIntervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE; | |
109 | ||
110 | //! Returns a surface trimmed in the U direction | |
111 | //! equivalent of <me> between | |
112 | //! parameters <First> and <Last>. <Tol> is used to | |
113 | //! test for 3d points confusion. | |
114 | //! If <First> >= <Last> | |
115 | Standard_EXPORT Handle(Adaptor3d_HSurface) UTrim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE; | |
116 | ||
117 | //! Returns a surface trimmed in the V direction between | |
118 | //! parameters <First> and <Last>. <Tol> is used to | |
119 | //! test for 3d points confusion. | |
120 | //! If <First> >= <Last> | |
121 | Standard_EXPORT Handle(Adaptor3d_HSurface) VTrim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE; | |
122 | ||
123 | Standard_EXPORT Standard_Boolean IsUClosed() const Standard_OVERRIDE; | |
124 | ||
125 | Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE; | |
126 | ||
127 | Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; | |
128 | ||
129 | Standard_EXPORT Standard_Real UPeriod() const Standard_OVERRIDE; | |
130 | ||
131 | Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; | |
132 | ||
133 | Standard_EXPORT Standard_Real VPeriod() const Standard_OVERRIDE; | |
134 | ||
135 | //! Computes the point of parameters U,V on the surface. | |
136 | Standard_EXPORT gp_Pnt Value (const Standard_Real U, const Standard_Real V) const Standard_OVERRIDE; | |
137 | ||
138 | //! Computes the point of parameters U,V on the surface. | |
139 | Standard_EXPORT void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const Standard_OVERRIDE; | |
140 | ||
141 | //! Computes the point and the first derivatives on | |
142 | //! the surface. | |
143 | //! | |
144 | //! Warning : On the specific case of BSplineSurface: | |
145 | //! if the surface is cut in interval of continuity at least C1, | |
146 | //! the derivatives are computed on the current interval. | |
147 | //! else the derivatives are computed on the basis surface. | |
148 | Standard_EXPORT void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const Standard_OVERRIDE; | |
149 | ||
150 | //! Computes the point, the first and second | |
151 | //! derivatives on the surface. | |
152 | //! | |
153 | //! Warning : On the specific case of BSplineSurface: | |
154 | //! if the surface is cut in interval of continuity at least C2, | |
155 | //! the derivatives are computed on the current interval. | |
156 | //! else the derivatives are computed on the basis surface. | |
157 | Standard_EXPORT void D2 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const Standard_OVERRIDE; | |
158 | ||
159 | //! Computes the point, the first, second and third | |
160 | //! derivatives on the surface. | |
161 | //! | |
162 | //! Warning : On the specific case of BSplineSurface: | |
163 | //! if the surface is cut in interval of continuity at least C3, | |
164 | //! the derivatives are computed on the current interval. | |
165 | //! else the derivatives are computed on the basis surface. | |
166 | Standard_EXPORT void D3 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const Standard_OVERRIDE; | |
167 | ||
168 | //! Computes the derivative of order Nu in the | |
169 | //! direction U and Nv in the direction V at the point P(U, V). | |
170 | //! | |
171 | //! Warning : On the specific case of BSplineSurface: | |
172 | //! if the surface is cut in interval of continuity CN, | |
173 | //! the derivatives are computed on the current interval. | |
174 | //! else the derivatives are computed on the basis surface. | |
175 | //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0. | |
176 | Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv) const Standard_OVERRIDE; | |
177 | ||
178 | //! Returns the parametric U resolution corresponding | |
179 | //! to the real space resolution <R3d>. | |
180 | Standard_EXPORT Standard_Real UResolution (const Standard_Real R3d) const Standard_OVERRIDE; | |
181 | ||
182 | //! Returns the parametric V resolution corresponding | |
183 | //! to the real space resolution <R3d>. | |
184 | Standard_EXPORT Standard_Real VResolution (const Standard_Real R3d) const Standard_OVERRIDE; | |
185 | ||
186 | //! Returns the type of the surface : Plane, Cylinder, | |
187 | //! Cone, Sphere, Torus, BezierSurface, | |
188 | //! BSplineSurface, SurfaceOfRevolution, | |
189 | //! SurfaceOfExtrusion, OtherSurface | |
190 | GeomAbs_SurfaceType GetType() const Standard_OVERRIDE; | |
191 | ||
192 | Standard_EXPORT gp_Pln Plane() const Standard_OVERRIDE; | |
193 | ||
194 | Standard_EXPORT gp_Cylinder Cylinder() const Standard_OVERRIDE; | |
195 | ||
196 | Standard_EXPORT gp_Cone Cone() const Standard_OVERRIDE; | |
197 | ||
198 | Standard_EXPORT gp_Sphere Sphere() const Standard_OVERRIDE; | |
199 | ||
200 | Standard_EXPORT gp_Torus Torus() const Standard_OVERRIDE; | |
201 | ||
202 | Standard_EXPORT Standard_Integer UDegree() const Standard_OVERRIDE; | |
203 | ||
204 | Standard_EXPORT Standard_Integer NbUPoles() const Standard_OVERRIDE; | |
205 | ||
206 | Standard_EXPORT Standard_Integer VDegree() const Standard_OVERRIDE; | |
207 | ||
208 | Standard_EXPORT Standard_Integer NbVPoles() const Standard_OVERRIDE; | |
209 | ||
210 | Standard_EXPORT Standard_Integer NbUKnots() const Standard_OVERRIDE; | |
211 | ||
212 | Standard_EXPORT Standard_Integer NbVKnots() const Standard_OVERRIDE; | |
213 | ||
214 | Standard_EXPORT Standard_Boolean IsURational() const Standard_OVERRIDE; | |
215 | ||
216 | Standard_EXPORT Standard_Boolean IsVRational() const Standard_OVERRIDE; | |
217 | ||
218 | //! This will NOT make a copy of the | |
219 | //! Bezier Surface : If you want to modify | |
220 | //! the Surface please make a copy yourself | |
221 | //! Also it will NOT trim the surface to | |
222 | //! myU/VFirst/Last. | |
223 | Standard_EXPORT Handle(Geom_BezierSurface) Bezier() const Standard_OVERRIDE; | |
224 | ||
225 | //! This will NOT make a copy of the | |
226 | //! BSpline Surface : If you want to modify | |
227 | //! the Surface please make a copy yourself | |
228 | //! Also it will NOT trim the surface to | |
229 | //! myU/VFirst/Last. | |
230 | Standard_EXPORT Handle(Geom_BSplineSurface) BSpline() const Standard_OVERRIDE; | |
231 | ||
232 | Standard_EXPORT gp_Ax1 AxeOfRevolution() const Standard_OVERRIDE; | |
233 | ||
234 | Standard_EXPORT gp_Dir Direction() const Standard_OVERRIDE; | |
235 | ||
236 | Standard_EXPORT Handle(Adaptor3d_HCurve) BasisCurve() const Standard_OVERRIDE; | |
237 | ||
238 | Standard_EXPORT Handle(Adaptor3d_HSurface) BasisSurface() const Standard_OVERRIDE; | |
239 | ||
240 | Standard_EXPORT Standard_Real OffsetValue() const Standard_OVERRIDE; | |
241 | ||
242 | ||
243 | ||
244 | ||
245 | protected: | |
246 | ||
247 | ||
248 | ||
249 | ||
250 | ||
251 | private: | |
252 | ||
253 | ||
254 | Standard_EXPORT void Span (const Standard_Integer Side, const Standard_Integer Ideb, const Standard_Integer Ifin, Standard_Integer& OutIdeb, Standard_Integer& OutIfin, const Standard_Integer FKIndx, const Standard_Integer LKIndx) const; | |
255 | ||
256 | Standard_EXPORT Standard_Boolean IfUVBound (const Standard_Real U, const Standard_Real V, Standard_Integer& Ideb, Standard_Integer& Ifin, Standard_Integer& IVdeb, Standard_Integer& IVfin, const Standard_Integer USide, const Standard_Integer VSide) const; | |
257 | ||
258 | Standard_EXPORT void load (const Handle(Geom_Surface)& S, const Standard_Real UFirst, const Standard_Real ULast, const Standard_Real VFirst, const Standard_Real VLast, const Standard_Real TolU = 0.0, const Standard_Real TolV = 0.0); | |
259 | ||
260 | //! Rebuilds B-spline cache | |
261 | //! \param theU first parameter to identify the span for caching | |
262 | //! \param theV second parameter to identify the span for caching | |
263 | Standard_EXPORT void RebuildCache (const Standard_Real theU, const Standard_Real theV) const; | |
264 | ||
265 | ||
266 | Handle(Geom_Surface) mySurface; | |
42cf5bc1 | 267 | Standard_Real myUFirst; |
268 | Standard_Real myULast; | |
269 | Standard_Real myVFirst; | |
270 | Standard_Real myVLast; | |
271 | Standard_Real myTolU; | |
272 | Standard_Real myTolV; | |
3b25c0e8 IC |
273 | |
274 | Handle(Geom_BSplineSurface) myBSplineSurface; ///< B-spline representation to prevent downcasts | |
d660a72a | 275 | Handle(BSplSLib_Cache) mySurfaceCache; ///< Cached data for B-spline or Bezier surface |
42cf5bc1 | 276 | |
6b84c3f7 | 277 | protected: |
278 | GeomAbs_SurfaceType mySurfaceType; | |
279 | Handle(GeomEvaluator_Surface) myNestedEvaluator; ///< Calculates values of nested complex surfaces (offset surface, surface of extrusion or revolution) | |
42cf5bc1 | 280 | }; |
281 | ||
282 | ||
283 | #include <GeomAdaptor_Surface.lxx> | |
284 | ||
285 | ||
286 | ||
287 | ||
288 | ||
289 | #endif // _GeomAdaptor_Surface_HeaderFile |