1 // Created on: 1993-02-19
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and / or modify it
9 // under the terms of the GNU Lesser General Public 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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRepAdaptor_Surface.ixx>
18 #include <BRep_Tool.hxx>
19 #include <BRepTools.hxx>
20 #include <GeomAdaptor_HSurface.hxx>
21 #include <GeomAdaptor_HCurve.hxx>
23 //=======================================================================
24 //function : BRepAdaptor_Surface
26 //=======================================================================
28 BRepAdaptor_Surface::BRepAdaptor_Surface()
33 //=======================================================================
34 //function : BRepAdaptor_Surface
36 //=======================================================================
38 BRepAdaptor_Surface::BRepAdaptor_Surface(const TopoDS_Face& F,
39 const Standard_Boolean R)
45 //=======================================================================
46 //function : Initialize
48 //=======================================================================
50 void BRepAdaptor_Surface::Initialize(const TopoDS_Face& F,
51 const Standard_Boolean Restriction)
56 Standard_Real umin,umax,vmin,vmax;
57 BRepTools::UVBounds(F,umin,umax,vmin,vmax);
58 mySurf.Load(BRep_Tool::Surface(F,L),umin,umax,vmin,vmax);
61 mySurf.Load(BRep_Tool::Surface(F,L));
62 myTrsf = L.Transformation();
66 //=======================================================================
69 //=======================================================================
71 const GeomAdaptor_Surface& BRepAdaptor_Surface::Surface() const
77 //=======================================================================
78 //function : ChangeSurface
80 //=======================================================================
82 GeomAdaptor_Surface& BRepAdaptor_Surface::ChangeSurface()
88 //=======================================================================
91 //=======================================================================
93 const gp_Trsf& BRepAdaptor_Surface::Trsf() const
99 //=======================================================================
102 //=======================================================================
104 const TopoDS_Face& BRepAdaptor_Surface::Face() const
109 //=======================================================================
110 //function : Tolerance
112 //=======================================================================
114 Standard_Real BRepAdaptor_Surface::Tolerance() const
116 return BRep_Tool::Tolerance(myFace);
120 //=======================================================================
121 //function : UIntervals
123 //=======================================================================
125 void BRepAdaptor_Surface::UIntervals(TColStd_Array1OfReal& T,
126 const GeomAbs_Shape S) const
128 mySurf.UIntervals(T,S);
132 //=======================================================================
133 //function : VIntervals
135 //=======================================================================
137 void BRepAdaptor_Surface::VIntervals(TColStd_Array1OfReal& T,
138 const GeomAbs_Shape S) const
140 mySurf.VIntervals(T,S);
144 //=======================================================================
147 //=======================================================================
149 Handle(Adaptor3d_HSurface) BRepAdaptor_Surface::UTrim
150 (const Standard_Real First,
151 const Standard_Real Last ,
152 const Standard_Real Tol ) const
154 Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
155 HS->ChangeSurface().Load
156 (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
157 return HS->UTrim(First,Last,Tol);
161 //=======================================================================
164 //=======================================================================
166 Handle(Adaptor3d_HSurface) BRepAdaptor_Surface::VTrim
167 (const Standard_Real First,
168 const Standard_Real Last,
169 const Standard_Real Tol) const
171 Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
172 HS->ChangeSurface().Load
173 (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
174 return HS->VTrim(First,Last,Tol);
178 //=======================================================================
181 //=======================================================================
183 gp_Pnt BRepAdaptor_Surface::Value(const Standard_Real U,
184 const Standard_Real V) const
186 return mySurf.Value(U,V).Transformed(myTrsf);
189 //=======================================================================
192 //=======================================================================
194 void BRepAdaptor_Surface::D0(const Standard_Real U,
195 const Standard_Real V,
202 //=======================================================================
205 //=======================================================================
207 void BRepAdaptor_Surface::D1(const Standard_Real U,
208 const Standard_Real V,
213 mySurf.D1(U,V,P,D1U,D1V);
215 D1U.Transform(myTrsf);
216 D1V.Transform(myTrsf);
220 //=======================================================================
223 //=======================================================================
225 void BRepAdaptor_Surface::D2(const Standard_Real U,
226 const Standard_Real V,
227 gp_Pnt& P, gp_Vec& D1U,
233 mySurf.D2(U,V,P,D1U,D1V,D2U,D2V,D2UV);
235 D1U.Transform(myTrsf);
236 D1V.Transform(myTrsf);
237 D2U.Transform(myTrsf);
238 D2V.Transform(myTrsf);
239 D2UV.Transform(myTrsf);
242 //=======================================================================
245 //=======================================================================
247 void BRepAdaptor_Surface::D3(const Standard_Real U,
248 const Standard_Real V,
250 gp_Vec& D1U, gp_Vec& D1V,
251 gp_Vec& D2U, gp_Vec& D2V,
253 gp_Vec& D3U, gp_Vec& D3V,
254 gp_Vec& D3UUV, gp_Vec& D3UVV)const
256 mySurf.D3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV);
258 D1U.Transform(myTrsf);
259 D1V.Transform(myTrsf);
260 D2U.Transform(myTrsf);
261 D2V.Transform(myTrsf);
262 D2UV.Transform(myTrsf);
263 D3U.Transform(myTrsf);
264 D3V.Transform(myTrsf);
265 D3UUV.Transform(myTrsf);
266 D3UVV.Transform(myTrsf);
270 //=======================================================================
273 //=======================================================================
275 gp_Vec BRepAdaptor_Surface::DN(const Standard_Real U,
276 const Standard_Real V,
277 const Standard_Integer Nu,
278 const Standard_Integer Nv) const
280 return mySurf.DN(U,V,Nu,Nv).Transformed(myTrsf);
283 //=======================================================================
286 //=======================================================================
288 gp_Pln BRepAdaptor_Surface::Plane()const
290 return mySurf.Plane().Transformed(myTrsf);
294 //=======================================================================
295 //function : Cylinder
297 //=======================================================================
299 gp_Cylinder BRepAdaptor_Surface::Cylinder()const
301 return mySurf.Cylinder().Transformed(myTrsf);
305 //=======================================================================
308 //=======================================================================
310 gp_Sphere BRepAdaptor_Surface::Sphere()const
312 return mySurf.Sphere().Transformed(myTrsf);
316 //=======================================================================
319 //=======================================================================
321 gp_Cone BRepAdaptor_Surface::Cone()const
323 return mySurf.Cone().Transformed(myTrsf);
326 //=======================================================================
329 //=======================================================================
331 gp_Torus BRepAdaptor_Surface::Torus()const
333 return mySurf.Torus().Transformed(myTrsf);
336 //=======================================================================
339 //=======================================================================
341 Handle(Geom_BezierSurface) BRepAdaptor_Surface::Bezier() const
343 return Handle(Geom_BezierSurface)::DownCast
344 (mySurf.Bezier()->Transformed(myTrsf));
348 //=======================================================================
351 //=======================================================================
353 Handle(Geom_BSplineSurface) BRepAdaptor_Surface::BSpline() const
355 return Handle(Geom_BSplineSurface)::DownCast
356 (mySurf.BSpline()->Transformed(myTrsf));
360 //=======================================================================
361 //function : AxeOfRevolution
363 //=======================================================================
365 gp_Ax1 BRepAdaptor_Surface::AxeOfRevolution() const
367 return mySurf.AxeOfRevolution().Transformed(myTrsf);
371 //=======================================================================
372 //function : Direction
374 //=======================================================================
376 gp_Dir BRepAdaptor_Surface::Direction() const
378 return mySurf.Direction().Transformed(myTrsf);
382 //=======================================================================
383 //function : BasisCurve
385 //=======================================================================
387 Handle(Adaptor3d_HCurve) BRepAdaptor_Surface::BasisCurve() const
389 Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
390 HS->ChangeSurface().Load
391 (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
393 return HS->BasisCurve();
397 //=======================================================================
398 //function : BasisSurface
400 //=======================================================================
402 Handle(Adaptor3d_HSurface) BRepAdaptor_Surface::BasisSurface() const
404 Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
405 HS->ChangeSurface().Load
406 (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
407 return HS->BasisSurface();
411 //=======================================================================
412 //function : OffsetValue
414 //=======================================================================
416 Standard_Real BRepAdaptor_Surface::OffsetValue() const
418 return mySurf.OffsetValue();