0024624: Lost word in license statement in source files
[occt.git] / src / Adaptor3d / Adaptor3d_HSurfaceTool.cxx
CommitLineData
b311480e 1// Created by: Laurent BUCHARD
2// Copyright (c) 1993-1999 Matra Datavision
973c2be1 3// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
16#include <Adaptor3d_HSurfaceTool.ixx>
17
18Standard_Integer Adaptor3d_HSurfaceTool::NbSamplesU(const Handle(Adaptor3d_HSurface)& S)
19{
20 switch (S->GetType())
21 {
22 case GeomAbs_Plane: return 2;
23 case GeomAbs_BezierSurface: return (3 + S->NbUPoles());
24 case GeomAbs_BSplineSurface:
25 {
26 const Standard_Integer nbs = S->NbUKnots() * S->UDegree();
27 return (nbs < 2 ? 2 : nbs);
28 }
29 case GeomAbs_Torus: return 20;
566f8441 30 default:
31 break;
7fd59977 32 }
33 return 10;
34}
35
36Standard_Integer Adaptor3d_HSurfaceTool::NbSamplesV(const Handle(Adaptor3d_HSurface)& S)
37{
38 switch (S->GetType())
39 {
40 case GeomAbs_Plane: return 2;
41 case GeomAbs_BezierSurface: return (3 + S->NbVPoles());
42 case GeomAbs_BSplineSurface:
43 {
44 const Standard_Integer nbs = S->NbVKnots() * S->VDegree();
45 return (nbs < 2 ? 2 : nbs);
46 }
47 case GeomAbs_Cylinder:
48 case GeomAbs_Cone:
49 case GeomAbs_Sphere:
50 case GeomAbs_Torus:
51 case GeomAbs_SurfaceOfRevolution:
52 case GeomAbs_SurfaceOfExtrusion: return 15;
566f8441 53 default:
54 break;
7fd59977 55 }
56 return 10;
57}
58
59Standard_Integer Adaptor3d_HSurfaceTool::NbSamplesU(const Handle(Adaptor3d_HSurface)& S,
60 const Standard_Real u1,
61 const Standard_Real u2)
62{
63 const Standard_Integer nbs = NbSamplesU(S);
64 Standard_Integer n = nbs;
65 if(nbs>10)
66 {
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;
71 if (n<5) n = 5;
72 }
73 return n;
74}
75
76Standard_Integer Adaptor3d_HSurfaceTool::NbSamplesV(const Handle(Adaptor3d_HSurface)& S,
77 const Standard_Real v1,
78 const Standard_Real v2)
79{
80 const Standard_Integer nbs = NbSamplesV(S);
81 Standard_Integer n = nbs;
82 if(nbs>10)
83 {
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;
88 if (n<5) n = 5;
89 }
90 return n;
91}