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 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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Adaptor3d_HCurve.hxx>
19 #include <Adaptor3d_HSurface.hxx>
20 #include <BRep_Tool.hxx>
21 #include <BRepAdaptor_Surface.hxx>
22 #include <BRepTools.hxx>
23 #include <Geom_BezierSurface.hxx>
24 #include <Geom_BSplineSurface.hxx>
25 #include <Geom_Surface.hxx>
26 #include <GeomAdaptor_HCurve.hxx>
27 #include <GeomAdaptor_HSurface.hxx>
28 #include <GeomAdaptor_Surface.hxx>
30 #include <gp_Cone.hxx>
31 #include <gp_Cylinder.hxx>
35 #include <gp_Sphere.hxx>
36 #include <gp_Torus.hxx>
37 #include <gp_Trsf.hxx>
39 #include <Standard_DomainError.hxx>
40 #include <Standard_NoSuchObject.hxx>
41 #include <Standard_OutOfRange.hxx>
42 #include <TopoDS_Face.hxx>
44 //=======================================================================
45 //function : BRepAdaptor_Surface
47 //=======================================================================
48 BRepAdaptor_Surface::BRepAdaptor_Surface()
53 //=======================================================================
54 //function : BRepAdaptor_Surface
56 //=======================================================================
58 BRepAdaptor_Surface::BRepAdaptor_Surface(const TopoDS_Face& F,
59 const Standard_Boolean R)
65 //=======================================================================
66 //function : Initialize
68 //=======================================================================
70 void BRepAdaptor_Surface::Initialize(const TopoDS_Face& F,
71 const Standard_Boolean Restriction)
76 Standard_Real umin,umax,vmin,vmax;
77 BRepTools::UVBounds(F,umin,umax,vmin,vmax);
78 mySurf.Load(BRep_Tool::Surface(F,L),umin,umax,vmin,vmax);
81 mySurf.Load(BRep_Tool::Surface(F,L));
82 myTrsf = L.Transformation();
86 //=======================================================================
89 //=======================================================================
91 const GeomAdaptor_Surface& BRepAdaptor_Surface::Surface() const
97 //=======================================================================
98 //function : ChangeSurface
100 //=======================================================================
102 GeomAdaptor_Surface& BRepAdaptor_Surface::ChangeSurface()
108 //=======================================================================
111 //=======================================================================
113 const gp_Trsf& BRepAdaptor_Surface::Trsf() const
119 //=======================================================================
122 //=======================================================================
124 const TopoDS_Face& BRepAdaptor_Surface::Face() const
129 //=======================================================================
130 //function : Tolerance
132 //=======================================================================
134 Standard_Real BRepAdaptor_Surface::Tolerance() const
136 return BRep_Tool::Tolerance(myFace);
140 //=======================================================================
141 //function : UIntervals
143 //=======================================================================
145 void BRepAdaptor_Surface::UIntervals(TColStd_Array1OfReal& T,
146 const GeomAbs_Shape S) const
148 mySurf.UIntervals(T,S);
152 //=======================================================================
153 //function : VIntervals
155 //=======================================================================
157 void BRepAdaptor_Surface::VIntervals(TColStd_Array1OfReal& T,
158 const GeomAbs_Shape S) const
160 mySurf.VIntervals(T,S);
164 //=======================================================================
167 //=======================================================================
169 Handle(Adaptor3d_HSurface) BRepAdaptor_Surface::UTrim
170 (const Standard_Real First,
171 const Standard_Real Last ,
172 const Standard_Real Tol ) const
174 Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
175 HS->ChangeSurface().Load
176 (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
177 return HS->UTrim(First,Last,Tol);
181 //=======================================================================
184 //=======================================================================
186 Handle(Adaptor3d_HSurface) BRepAdaptor_Surface::VTrim
187 (const Standard_Real First,
188 const Standard_Real Last,
189 const Standard_Real Tol) const
191 Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
192 HS->ChangeSurface().Load
193 (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
194 return HS->VTrim(First,Last,Tol);
198 //=======================================================================
201 //=======================================================================
203 gp_Pnt BRepAdaptor_Surface::Value(const Standard_Real U,
204 const Standard_Real V) const
206 return mySurf.Value(U,V).Transformed(myTrsf);
209 //=======================================================================
212 //=======================================================================
214 void BRepAdaptor_Surface::D0(const Standard_Real U,
215 const Standard_Real V,
222 //=======================================================================
225 //=======================================================================
227 void BRepAdaptor_Surface::D1(const Standard_Real U,
228 const Standard_Real V,
233 mySurf.D1(U,V,P,D1U,D1V);
235 D1U.Transform(myTrsf);
236 D1V.Transform(myTrsf);
240 //=======================================================================
243 //=======================================================================
245 void BRepAdaptor_Surface::D2(const Standard_Real U,
246 const Standard_Real V,
247 gp_Pnt& P, gp_Vec& D1U,
253 mySurf.D2(U,V,P,D1U,D1V,D2U,D2V,D2UV);
255 D1U.Transform(myTrsf);
256 D1V.Transform(myTrsf);
257 D2U.Transform(myTrsf);
258 D2V.Transform(myTrsf);
259 D2UV.Transform(myTrsf);
262 //=======================================================================
265 //=======================================================================
267 void BRepAdaptor_Surface::D3(const Standard_Real U,
268 const Standard_Real V,
270 gp_Vec& D1U, gp_Vec& D1V,
271 gp_Vec& D2U, gp_Vec& D2V,
273 gp_Vec& D3U, gp_Vec& D3V,
274 gp_Vec& D3UUV, gp_Vec& D3UVV)const
276 mySurf.D3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV);
278 D1U.Transform(myTrsf);
279 D1V.Transform(myTrsf);
280 D2U.Transform(myTrsf);
281 D2V.Transform(myTrsf);
282 D2UV.Transform(myTrsf);
283 D3U.Transform(myTrsf);
284 D3V.Transform(myTrsf);
285 D3UUV.Transform(myTrsf);
286 D3UVV.Transform(myTrsf);
290 //=======================================================================
293 //=======================================================================
295 gp_Vec BRepAdaptor_Surface::DN(const Standard_Real U,
296 const Standard_Real V,
297 const Standard_Integer Nu,
298 const Standard_Integer Nv) const
300 return mySurf.DN(U,V,Nu,Nv).Transformed(myTrsf);
303 //=======================================================================
306 //=======================================================================
308 gp_Pln BRepAdaptor_Surface::Plane()const
310 return mySurf.Plane().Transformed(myTrsf);
314 //=======================================================================
315 //function : Cylinder
317 //=======================================================================
319 gp_Cylinder BRepAdaptor_Surface::Cylinder()const
321 return mySurf.Cylinder().Transformed(myTrsf);
325 //=======================================================================
328 //=======================================================================
330 gp_Sphere BRepAdaptor_Surface::Sphere()const
332 return mySurf.Sphere().Transformed(myTrsf);
336 //=======================================================================
339 //=======================================================================
341 gp_Cone BRepAdaptor_Surface::Cone()const
343 return mySurf.Cone().Transformed(myTrsf);
346 //=======================================================================
349 //=======================================================================
351 gp_Torus BRepAdaptor_Surface::Torus()const
353 return mySurf.Torus().Transformed(myTrsf);
356 //=======================================================================
359 //=======================================================================
361 Handle(Geom_BezierSurface) BRepAdaptor_Surface::Bezier() const
363 return Handle(Geom_BezierSurface)::DownCast
364 (mySurf.Bezier()->Transformed(myTrsf));
368 //=======================================================================
371 //=======================================================================
373 Handle(Geom_BSplineSurface) BRepAdaptor_Surface::BSpline() const
375 return Handle(Geom_BSplineSurface)::DownCast
376 (mySurf.BSpline()->Transformed(myTrsf));
380 //=======================================================================
381 //function : AxeOfRevolution
383 //=======================================================================
385 gp_Ax1 BRepAdaptor_Surface::AxeOfRevolution() const
387 return mySurf.AxeOfRevolution().Transformed(myTrsf);
391 //=======================================================================
392 //function : Direction
394 //=======================================================================
396 gp_Dir BRepAdaptor_Surface::Direction() const
398 return mySurf.Direction().Transformed(myTrsf);
402 //=======================================================================
403 //function : BasisCurve
405 //=======================================================================
407 Handle(Adaptor3d_HCurve) BRepAdaptor_Surface::BasisCurve() const
409 Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
410 HS->ChangeSurface().Load
411 (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
413 return HS->BasisCurve();
417 //=======================================================================
418 //function : BasisSurface
420 //=======================================================================
422 Handle(Adaptor3d_HSurface) BRepAdaptor_Surface::BasisSurface() const
424 Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
425 HS->ChangeSurface().Load
426 (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
427 return HS->BasisSurface();
431 //=======================================================================
432 //function : OffsetValue
434 //=======================================================================
436 Standard_Real BRepAdaptor_Surface::OffsetValue() const
438 return mySurf.OffsetValue();