1 // Created by: Laurent BUCHARD
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <Adaptor3d_HCurve.hxx>
18 #include <Adaptor3d_HSurface.hxx>
19 #include <Adaptor3d_HSurfaceTool.hxx>
20 #include <Geom_BezierSurface.hxx>
21 #include <Geom_BSplineSurface.hxx>
24 #include <Standard_NoSuchObject.hxx>
25 #include <Standard_OutOfRange.hxx>
27 Standard_Integer Adaptor3d_HSurfaceTool::NbSamplesU(const Handle(Adaptor3d_HSurface)& S)
31 case GeomAbs_Plane: return 2;
32 case GeomAbs_BezierSurface: return (3 + S->NbUPoles());
33 case GeomAbs_BSplineSurface:
35 const Standard_Integer nbs = S->NbUKnots() * S->UDegree();
36 return (nbs < 2 ? 2 : nbs);
38 case GeomAbs_Torus: return 20;
45 Standard_Integer Adaptor3d_HSurfaceTool::NbSamplesV(const Handle(Adaptor3d_HSurface)& S)
49 case GeomAbs_Plane: return 2;
50 case GeomAbs_BezierSurface: return (3 + S->NbVPoles());
51 case GeomAbs_BSplineSurface:
53 const Standard_Integer nbs = S->NbVKnots() * S->VDegree();
54 return (nbs < 2 ? 2 : nbs);
56 case GeomAbs_Cylinder:
60 case GeomAbs_SurfaceOfRevolution:
61 case GeomAbs_SurfaceOfExtrusion: return 15;
68 Standard_Integer Adaptor3d_HSurfaceTool::NbSamplesU(const Handle(Adaptor3d_HSurface)& S,
69 const Standard_Real u1,
70 const Standard_Real u2)
72 const Standard_Integer nbs = NbSamplesU(S);
73 Standard_Integer n = nbs;
76 const Standard_Real uf = FirstUParameter(S);
77 const Standard_Real ul = LastUParameter(S);
78 n *= (Standard_Integer)((u2-u1)/(ul-uf));
79 if (n>nbs || n>50) n = nbs;
85 Standard_Integer Adaptor3d_HSurfaceTool::NbSamplesV(const Handle(Adaptor3d_HSurface)& S,
86 const Standard_Real v1,
87 const Standard_Real v2)
89 const Standard_Integer nbs = NbSamplesV(S);
90 Standard_Integer n = nbs;
93 const Standard_Real vf = FirstVParameter(S);
94 const Standard_Real vl = LastVParameter(S);
95 n *= (Standard_Integer)((v2-v1)/(vl-vf));
96 if (n>nbs || n>50) n = nbs;