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)
75 const Handle(Geom_Surface)& aSurface = BRep_Tool::Surface(F, L);
76 if (aSurface.IsNull())
80 Standard_Real umin,umax,vmin,vmax;
81 BRepTools::UVBounds(F,umin,umax,vmin,vmax);
82 mySurf.Load(aSurface,umin,umax,vmin,vmax);
85 mySurf.Load(aSurface);
86 myTrsf = L.Transformation();
90 //=======================================================================
93 //=======================================================================
95 const GeomAdaptor_Surface& BRepAdaptor_Surface::Surface() const
101 //=======================================================================
102 //function : ChangeSurface
104 //=======================================================================
106 GeomAdaptor_Surface& BRepAdaptor_Surface::ChangeSurface()
112 //=======================================================================
115 //=======================================================================
117 const gp_Trsf& BRepAdaptor_Surface::Trsf() const
123 //=======================================================================
126 //=======================================================================
128 const TopoDS_Face& BRepAdaptor_Surface::Face() const
133 //=======================================================================
134 //function : Tolerance
136 //=======================================================================
138 Standard_Real BRepAdaptor_Surface::Tolerance() const
140 return BRep_Tool::Tolerance(myFace);
144 //=======================================================================
145 //function : UIntervals
147 //=======================================================================
149 void BRepAdaptor_Surface::UIntervals(TColStd_Array1OfReal& T,
150 const GeomAbs_Shape S) const
152 mySurf.UIntervals(T,S);
156 //=======================================================================
157 //function : VIntervals
159 //=======================================================================
161 void BRepAdaptor_Surface::VIntervals(TColStd_Array1OfReal& T,
162 const GeomAbs_Shape S) const
164 mySurf.VIntervals(T,S);
168 //=======================================================================
171 //=======================================================================
173 Handle(Adaptor3d_HSurface) BRepAdaptor_Surface::UTrim
174 (const Standard_Real First,
175 const Standard_Real Last ,
176 const Standard_Real Tol ) const
178 Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
179 HS->ChangeSurface().Load
180 (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
181 return HS->UTrim(First,Last,Tol);
185 //=======================================================================
188 //=======================================================================
190 Handle(Adaptor3d_HSurface) BRepAdaptor_Surface::VTrim
191 (const Standard_Real First,
192 const Standard_Real Last,
193 const Standard_Real Tol) const
195 Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
196 HS->ChangeSurface().Load
197 (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
198 return HS->VTrim(First,Last,Tol);
202 //=======================================================================
205 //=======================================================================
207 gp_Pnt BRepAdaptor_Surface::Value(const Standard_Real U,
208 const Standard_Real V) const
210 return mySurf.Value(U,V).Transformed(myTrsf);
213 //=======================================================================
216 //=======================================================================
218 void BRepAdaptor_Surface::D0(const Standard_Real U,
219 const Standard_Real V,
226 //=======================================================================
229 //=======================================================================
231 void BRepAdaptor_Surface::D1(const Standard_Real U,
232 const Standard_Real V,
237 mySurf.D1(U,V,P,D1U,D1V);
239 D1U.Transform(myTrsf);
240 D1V.Transform(myTrsf);
244 //=======================================================================
247 //=======================================================================
249 void BRepAdaptor_Surface::D2(const Standard_Real U,
250 const Standard_Real V,
251 gp_Pnt& P, gp_Vec& D1U,
257 mySurf.D2(U,V,P,D1U,D1V,D2U,D2V,D2UV);
259 D1U.Transform(myTrsf);
260 D1V.Transform(myTrsf);
261 D2U.Transform(myTrsf);
262 D2V.Transform(myTrsf);
263 D2UV.Transform(myTrsf);
266 //=======================================================================
269 //=======================================================================
271 void BRepAdaptor_Surface::D3(const Standard_Real U,
272 const Standard_Real V,
274 gp_Vec& D1U, gp_Vec& D1V,
275 gp_Vec& D2U, gp_Vec& D2V,
277 gp_Vec& D3U, gp_Vec& D3V,
278 gp_Vec& D3UUV, gp_Vec& D3UVV)const
280 mySurf.D3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV);
282 D1U.Transform(myTrsf);
283 D1V.Transform(myTrsf);
284 D2U.Transform(myTrsf);
285 D2V.Transform(myTrsf);
286 D2UV.Transform(myTrsf);
287 D3U.Transform(myTrsf);
288 D3V.Transform(myTrsf);
289 D3UUV.Transform(myTrsf);
290 D3UVV.Transform(myTrsf);
294 //=======================================================================
297 //=======================================================================
299 gp_Vec BRepAdaptor_Surface::DN(const Standard_Real U,
300 const Standard_Real V,
301 const Standard_Integer Nu,
302 const Standard_Integer Nv) const
304 return mySurf.DN(U,V,Nu,Nv).Transformed(myTrsf);
307 //=======================================================================
310 //=======================================================================
312 gp_Pln BRepAdaptor_Surface::Plane()const
314 return mySurf.Plane().Transformed(myTrsf);
318 //=======================================================================
319 //function : Cylinder
321 //=======================================================================
323 gp_Cylinder BRepAdaptor_Surface::Cylinder()const
325 return mySurf.Cylinder().Transformed(myTrsf);
329 //=======================================================================
332 //=======================================================================
334 gp_Sphere BRepAdaptor_Surface::Sphere()const
336 return mySurf.Sphere().Transformed(myTrsf);
340 //=======================================================================
343 //=======================================================================
345 gp_Cone BRepAdaptor_Surface::Cone()const
347 return mySurf.Cone().Transformed(myTrsf);
350 //=======================================================================
353 //=======================================================================
355 gp_Torus BRepAdaptor_Surface::Torus()const
357 return mySurf.Torus().Transformed(myTrsf);
360 //=======================================================================
363 //=======================================================================
365 Handle(Geom_BezierSurface) BRepAdaptor_Surface::Bezier() const
367 return Handle(Geom_BezierSurface)::DownCast
368 (mySurf.Bezier()->Transformed(myTrsf));
372 //=======================================================================
375 //=======================================================================
377 Handle(Geom_BSplineSurface) BRepAdaptor_Surface::BSpline() const
379 return Handle(Geom_BSplineSurface)::DownCast
380 (mySurf.BSpline()->Transformed(myTrsf));
384 //=======================================================================
385 //function : AxeOfRevolution
387 //=======================================================================
389 gp_Ax1 BRepAdaptor_Surface::AxeOfRevolution() const
391 return mySurf.AxeOfRevolution().Transformed(myTrsf);
395 //=======================================================================
396 //function : Direction
398 //=======================================================================
400 gp_Dir BRepAdaptor_Surface::Direction() const
402 return mySurf.Direction().Transformed(myTrsf);
406 //=======================================================================
407 //function : BasisCurve
409 //=======================================================================
411 Handle(Adaptor3d_HCurve) BRepAdaptor_Surface::BasisCurve() const
413 Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
414 HS->ChangeSurface().Load
415 (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
417 return HS->BasisCurve();
421 //=======================================================================
422 //function : BasisSurface
424 //=======================================================================
426 Handle(Adaptor3d_HSurface) BRepAdaptor_Surface::BasisSurface() const
428 Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface();
429 HS->ChangeSurface().Load
430 (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
431 return HS->BasisSurface();
435 //=======================================================================
436 //function : OffsetValue
438 //=======================================================================
440 Standard_Real BRepAdaptor_Surface::OffsetValue() const
442 return mySurf.OffsetValue();