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
8 // under the terms of the GNU Lesser General Public 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.
16 #include <Adaptor3d_HSurfaceTool.ixx>
18 Standard_Integer Adaptor3d_HSurfaceTool::NbSamplesU(const Handle(Adaptor3d_HSurface)& S)
22 case GeomAbs_Plane: return 2;
23 case GeomAbs_BezierSurface: return (3 + S->NbUPoles());
24 case GeomAbs_BSplineSurface:
26 const Standard_Integer nbs = S->NbUKnots() * S->UDegree();
27 return (nbs < 2 ? 2 : nbs);
29 case GeomAbs_Torus: return 20;
36 Standard_Integer Adaptor3d_HSurfaceTool::NbSamplesV(const Handle(Adaptor3d_HSurface)& S)
40 case GeomAbs_Plane: return 2;
41 case GeomAbs_BezierSurface: return (3 + S->NbVPoles());
42 case GeomAbs_BSplineSurface:
44 const Standard_Integer nbs = S->NbVKnots() * S->VDegree();
45 return (nbs < 2 ? 2 : nbs);
47 case GeomAbs_Cylinder:
51 case GeomAbs_SurfaceOfRevolution:
52 case GeomAbs_SurfaceOfExtrusion: return 15;
59 Standard_Integer Adaptor3d_HSurfaceTool::NbSamplesU(const Handle(Adaptor3d_HSurface)& S,
60 const Standard_Real u1,
61 const Standard_Real u2)
63 const Standard_Integer nbs = NbSamplesU(S);
64 Standard_Integer n = nbs;
67 const Standard_Real uf = FirstUParameter(S);
68 const Standard_Real ul = LastUParameter(S);
69 n *= (Standard_Integer)((u2-u1)/(ul-uf));
70 if (n>nbs || n>50) n = nbs;
76 Standard_Integer Adaptor3d_HSurfaceTool::NbSamplesV(const Handle(Adaptor3d_HSurface)& S,
77 const Standard_Real v1,
78 const Standard_Real v2)
80 const Standard_Integer nbs = NbSamplesV(S);
81 Standard_Integer n = nbs;
84 const Standard_Real vf = FirstVParameter(S);
85 const Standard_Real vl = LastVParameter(S);
86 n *= (Standard_Integer)((v2-v1)/(vl-vf));
87 if (n>nbs || n>50) n = nbs;