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 | ||
42cf5bc1 | 20 | #include <Adaptor3d_Surface.hxx> |
c22b52d6 | 21 | #include <BSplSLib_Cache.hxx> |
42cf5bc1 | 22 | #include <GeomAbs_Shape.hxx> |
6b84c3f7 | 23 | #include <GeomEvaluator_Surface.hxx> |
c22b52d6 | 24 | #include <Geom_Surface.hxx> |
25 | #include <Standard_NullObject.hxx> | |
26 | #include <TColStd_Array1OfReal.hxx> | |
42cf5bc1 | 27 | |
c22b52d6 | 28 | DEFINE_STANDARD_HANDLE(GeomAdaptor_Surface, Adaptor3d_Surface) |
42cf5bc1 | 29 | |
30 | //! An interface between the services provided by any | |
31 | //! surface from the package Geom and those required | |
32 | //! of the surface by algorithms which use it. | |
33 | //! Creation of the loaded surface the surface is C1 by piece | |
34e4e9f2 BB |
34 | //! |
35 | //! Polynomial coefficients of BSpline surfaces used for their evaluation are | |
36 | //! cached for better performance. Therefore these evaluations are not | |
37 | //! thread-safe and parallel evaluations need to be prevented. | |
42cf5bc1 | 38 | class GeomAdaptor_Surface : public Adaptor3d_Surface |
39 | { | |
c22b52d6 | 40 | DEFINE_STANDARD_RTTIEXT(GeomAdaptor_Surface, Adaptor3d_Surface) |
42cf5bc1 | 41 | public: |
42 | ||
c22b52d6 | 43 | GeomAdaptor_Surface() |
44 | : myUFirst(0.), myULast(0.), | |
45 | myVFirst(0.), myVLast (0.), | |
46 | myTolU(0.), myTolV(0.), | |
47 | mySurfaceType (GeomAbs_OtherSurface) {} | |
48 | ||
49 | GeomAdaptor_Surface(const Handle(Geom_Surface)& theSurf) | |
50 | : myTolU(0.), myTolV(0.) | |
51 | { | |
52 | Load (theSurf); | |
53 | } | |
54 | ||
55 | //! Standard_ConstructionError is raised if UFirst>ULast or VFirst>VLast | |
56 | GeomAdaptor_Surface (const Handle(Geom_Surface)& theSurf, | |
57 | const Standard_Real theUFirst, const Standard_Real theULast, | |
58 | const Standard_Real theVFirst, const Standard_Real theVLast, | |
59 | const Standard_Real theTolU = 0.0, const Standard_Real theTolV = 0.0) | |
60 | { | |
61 | Load (theSurf, theUFirst, theULast, theVFirst, theVLast, theTolU, theTolV); | |
62 | } | |
63 | ||
872a7e3a | 64 | //! Shallow copy of adaptor |
65 | Standard_EXPORT virtual Handle(Adaptor3d_Surface) ShallowCopy() const Standard_OVERRIDE; | |
66 | ||
c22b52d6 | 67 | void Load (const Handle(Geom_Surface)& theSurf) |
68 | { | |
69 | if (theSurf.IsNull()) { throw Standard_NullObject("GeomAdaptor_Surface::Load"); } | |
70 | ||
71 | Standard_Real aU1, aU2, aV1, aV2; | |
72 | theSurf->Bounds (aU1, aU2, aV1, aV2); | |
73 | load (theSurf, aU1, aU2, aV1, aV2); | |
74 | } | |
75 | ||
76 | //! Standard_ConstructionError is raised if theUFirst>theULast or theVFirst>theVLast | |
77 | void Load (const Handle(Geom_Surface)& theSurf, | |
78 | const Standard_Real theUFirst, const Standard_Real theULast, | |
79 | const Standard_Real theVFirst, const Standard_Real theVLast, | |
80 | const Standard_Real theTolU = 0.0, const Standard_Real theTolV = 0.0) | |
81 | { | |
82 | if (theSurf.IsNull()) { throw Standard_NullObject("GeomAdaptor_Surface::Load"); } | |
83 | if (theUFirst > theULast || theVFirst > theVLast) { throw Standard_ConstructionError("GeomAdaptor_Surface::Load"); } | |
84 | ||
85 | load (theSurf, theUFirst, theULast, theVFirst, theVLast, theTolU, theTolV); | |
86 | } | |
87 | ||
88 | const Handle(Geom_Surface)& Surface() const { return mySurface; } | |
89 | ||
90 | virtual Standard_Real FirstUParameter() const Standard_OVERRIDE { return myUFirst; } | |
91 | ||
92 | virtual Standard_Real LastUParameter() const Standard_OVERRIDE { return myULast; } | |
93 | ||
94 | virtual Standard_Real FirstVParameter() const Standard_OVERRIDE { return myVFirst; } | |
95 | ||
96 | virtual Standard_Real LastVParameter() const Standard_OVERRIDE { return myVLast; } | |
42cf5bc1 | 97 | |
42cf5bc1 | 98 | Standard_EXPORT GeomAbs_Shape UContinuity() const Standard_OVERRIDE; |
99 | ||
100 | Standard_EXPORT GeomAbs_Shape VContinuity() const Standard_OVERRIDE; | |
101 | ||
102 | //! Returns the number of U intervals for continuity | |
103 | //! <S>. May be one if UContinuity(me) >= <S> | |
104 | Standard_EXPORT Standard_Integer NbUIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE; | |
105 | ||
106 | //! Returns the number of V intervals for continuity | |
107 | //! <S>. May be one if VContinuity(me) >= <S> | |
108 | Standard_EXPORT Standard_Integer NbVIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE; | |
109 | ||
110 | //! Returns the intervals with the requested continuity | |
111 | //! in the U direction. | |
112 | Standard_EXPORT void UIntervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE; | |
113 | ||
114 | //! Returns the intervals with the requested continuity | |
115 | //! in the V direction. | |
116 | Standard_EXPORT void VIntervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE; | |
117 | ||
118 | //! Returns a surface trimmed in the U direction | |
119 | //! equivalent of <me> between | |
120 | //! parameters <First> and <Last>. <Tol> is used to | |
121 | //! test for 3d points confusion. | |
122 | //! If <First> >= <Last> | |
c22b52d6 | 123 | Standard_EXPORT Handle(Adaptor3d_Surface) UTrim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE; |
42cf5bc1 | 124 | |
125 | //! Returns a surface trimmed in the V direction between | |
126 | //! parameters <First> and <Last>. <Tol> is used to | |
127 | //! test for 3d points confusion. | |
128 | //! If <First> >= <Last> | |
c22b52d6 | 129 | Standard_EXPORT Handle(Adaptor3d_Surface) VTrim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE; |
42cf5bc1 | 130 | |
131 | Standard_EXPORT Standard_Boolean IsUClosed() const Standard_OVERRIDE; | |
132 | ||
133 | Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE; | |
134 | ||
135 | Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; | |
136 | ||
137 | Standard_EXPORT Standard_Real UPeriod() const Standard_OVERRIDE; | |
138 | ||
139 | Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; | |
140 | ||
141 | Standard_EXPORT Standard_Real VPeriod() const Standard_OVERRIDE; | |
142 | ||
143 | //! Computes the point of parameters U,V on the surface. | |
144 | Standard_EXPORT gp_Pnt Value (const Standard_Real U, const Standard_Real V) const Standard_OVERRIDE; | |
145 | ||
146 | //! Computes the point of parameters U,V on the surface. | |
147 | Standard_EXPORT void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const Standard_OVERRIDE; | |
148 | ||
149 | //! Computes the point and the first derivatives on | |
150 | //! the surface. | |
151 | //! | |
152 | //! Warning : On the specific case of BSplineSurface: | |
153 | //! if the surface is cut in interval of continuity at least C1, | |
154 | //! the derivatives are computed on the current interval. | |
155 | //! else the derivatives are computed on the basis surface. | |
156 | Standard_EXPORT void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const Standard_OVERRIDE; | |
157 | ||
158 | //! Computes the point, the first and second | |
159 | //! derivatives on the surface. | |
160 | //! | |
161 | //! Warning : On the specific case of BSplineSurface: | |
162 | //! if the surface is cut in interval of continuity at least C2, | |
163 | //! the derivatives are computed on the current interval. | |
164 | //! else the derivatives are computed on the basis surface. | |
165 | 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; | |
166 | ||
167 | //! Computes the point, the first, second and third | |
168 | //! derivatives on the surface. | |
169 | //! | |
170 | //! Warning : On the specific case of BSplineSurface: | |
171 | //! if the surface is cut in interval of continuity at least C3, | |
172 | //! the derivatives are computed on the current interval. | |
173 | //! else the derivatives are computed on the basis surface. | |
174 | 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; | |
175 | ||
176 | //! Computes the derivative of order Nu in the | |
177 | //! direction U and Nv in the direction V at the point P(U, V). | |
178 | //! | |
179 | //! Warning : On the specific case of BSplineSurface: | |
180 | //! if the surface is cut in interval of continuity CN, | |
181 | //! the derivatives are computed on the current interval. | |
182 | //! else the derivatives are computed on the basis surface. | |
183 | //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0. | |
184 | Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv) const Standard_OVERRIDE; | |
185 | ||
186 | //! Returns the parametric U resolution corresponding | |
187 | //! to the real space resolution <R3d>. | |
188 | Standard_EXPORT Standard_Real UResolution (const Standard_Real R3d) const Standard_OVERRIDE; | |
189 | ||
190 | //! Returns the parametric V resolution corresponding | |
191 | //! to the real space resolution <R3d>. | |
192 | Standard_EXPORT Standard_Real VResolution (const Standard_Real R3d) const Standard_OVERRIDE; | |
193 | ||
194 | //! Returns the type of the surface : Plane, Cylinder, | |
195 | //! Cone, Sphere, Torus, BezierSurface, | |
196 | //! BSplineSurface, SurfaceOfRevolution, | |
197 | //! SurfaceOfExtrusion, OtherSurface | |
c22b52d6 | 198 | virtual GeomAbs_SurfaceType GetType() const Standard_OVERRIDE { return mySurfaceType; } |
199 | ||
42cf5bc1 | 200 | Standard_EXPORT gp_Pln Plane() const Standard_OVERRIDE; |
201 | ||
202 | Standard_EXPORT gp_Cylinder Cylinder() const Standard_OVERRIDE; | |
203 | ||
204 | Standard_EXPORT gp_Cone Cone() const Standard_OVERRIDE; | |
205 | ||
206 | Standard_EXPORT gp_Sphere Sphere() const Standard_OVERRIDE; | |
207 | ||
208 | Standard_EXPORT gp_Torus Torus() const Standard_OVERRIDE; | |
209 | ||
210 | Standard_EXPORT Standard_Integer UDegree() const Standard_OVERRIDE; | |
211 | ||
212 | Standard_EXPORT Standard_Integer NbUPoles() const Standard_OVERRIDE; | |
213 | ||
214 | Standard_EXPORT Standard_Integer VDegree() const Standard_OVERRIDE; | |
215 | ||
216 | Standard_EXPORT Standard_Integer NbVPoles() const Standard_OVERRIDE; | |
217 | ||
218 | Standard_EXPORT Standard_Integer NbUKnots() const Standard_OVERRIDE; | |
219 | ||
220 | Standard_EXPORT Standard_Integer NbVKnots() const Standard_OVERRIDE; | |
221 | ||
222 | Standard_EXPORT Standard_Boolean IsURational() const Standard_OVERRIDE; | |
223 | ||
224 | Standard_EXPORT Standard_Boolean IsVRational() const Standard_OVERRIDE; | |
225 | ||
226 | //! This will NOT make a copy of the | |
227 | //! Bezier Surface : If you want to modify | |
228 | //! the Surface please make a copy yourself | |
229 | //! Also it will NOT trim the surface to | |
230 | //! myU/VFirst/Last. | |
231 | Standard_EXPORT Handle(Geom_BezierSurface) Bezier() const Standard_OVERRIDE; | |
232 | ||
233 | //! This will NOT make a copy of the | |
234 | //! BSpline Surface : If you want to modify | |
235 | //! the Surface please make a copy yourself | |
236 | //! Also it will NOT trim the surface to | |
237 | //! myU/VFirst/Last. | |
238 | Standard_EXPORT Handle(Geom_BSplineSurface) BSpline() const Standard_OVERRIDE; | |
239 | ||
240 | Standard_EXPORT gp_Ax1 AxeOfRevolution() const Standard_OVERRIDE; | |
241 | ||
242 | Standard_EXPORT gp_Dir Direction() const Standard_OVERRIDE; | |
243 | ||
c22b52d6 | 244 | Standard_EXPORT Handle(Adaptor3d_Curve) BasisCurve() const Standard_OVERRIDE; |
42cf5bc1 | 245 | |
c22b52d6 | 246 | Standard_EXPORT Handle(Adaptor3d_Surface) BasisSurface() const Standard_OVERRIDE; |
42cf5bc1 | 247 | |
248 | Standard_EXPORT Standard_Real OffsetValue() const Standard_OVERRIDE; | |
249 | ||
42cf5bc1 | 250 | private: |
251 | ||
42cf5bc1 | 252 | 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; |
253 | ||
254 | 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; | |
255 | ||
256 | 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); | |
257 | ||
258 | //! Rebuilds B-spline cache | |
259 | //! \param theU first parameter to identify the span for caching | |
260 | //! \param theV second parameter to identify the span for caching | |
261 | Standard_EXPORT void RebuildCache (const Standard_Real theU, const Standard_Real theV) const; | |
262 | ||
872a7e3a | 263 | protected: |
42cf5bc1 | 264 | |
265 | Handle(Geom_Surface) mySurface; | |
42cf5bc1 | 266 | Standard_Real myUFirst; |
267 | Standard_Real myULast; | |
268 | Standard_Real myVFirst; | |
269 | Standard_Real myVLast; | |
270 | Standard_Real myTolU; | |
271 | Standard_Real myTolV; | |
3b25c0e8 IC |
272 | |
273 | Handle(Geom_BSplineSurface) myBSplineSurface; ///< B-spline representation to prevent downcasts | |
81093856 | 274 | mutable Handle(BSplSLib_Cache) mySurfaceCache; ///< Cached data for B-spline or Bezier surface |
42cf5bc1 | 275 | |
6b84c3f7 | 276 | GeomAbs_SurfaceType mySurfaceType; |
277 | Handle(GeomEvaluator_Surface) myNestedEvaluator; ///< Calculates values of nested complex surfaces (offset surface, surface of extrusion or revolution) | |
42cf5bc1 | 278 | }; |
279 | ||
42cf5bc1 | 280 | #endif // _GeomAdaptor_Surface_HeaderFile |