0032951: Coding - get rid of unused headers [GeomConvert to IGESBasic]
[occt.git] / src / HLRBRep / HLRBRep_SurfaceTool.cxx
1 // Created by: Laurent BUCHARD
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <HLRBRep_SurfaceTool.hxx>
17
18 #include <BRepAdaptor_Surface.hxx>
19
20 Standard_Integer  HLRBRep_SurfaceTool::NbSamplesU(const Standard_Address S) { 
21   Standard_Integer nbs;
22   GeomAbs_SurfaceType typS = ((BRepAdaptor_Surface *)S)->GetType();
23   switch(typS) { 
24   case GeomAbs_Plane:
25     {
26       nbs = 2;
27     }
28     break;
29   case GeomAbs_BezierSurface: 
30     {
31       nbs =  3 + ((BRepAdaptor_Surface *)S)->NbUPoles();
32     }
33     break;
34   case GeomAbs_BSplineSurface: 
35     {
36       nbs = ((BRepAdaptor_Surface *)S)->NbUKnots();
37       nbs*= ((BRepAdaptor_Surface *)S)->UDegree();
38       if(nbs < 2) nbs=2;
39       
40     }
41     break;
42   case GeomAbs_Torus: 
43     {
44       nbs = 20;
45     }
46     break;
47   case GeomAbs_Cylinder:
48   case GeomAbs_Cone:
49   case GeomAbs_Sphere:
50   case GeomAbs_SurfaceOfRevolution:
51   case GeomAbs_SurfaceOfExtrusion:
52     {
53       nbs = 10;
54     }
55     break;
56     
57   default: 
58     {
59       nbs = 10;
60     }
61     break;
62   }
63   return(nbs);
64 }
65
66 Standard_Integer  HLRBRep_SurfaceTool::NbSamplesV(const Standard_Address S) { 
67   Standard_Integer nbs;
68   GeomAbs_SurfaceType typS = ((BRepAdaptor_Surface *)S)->GetType();
69   switch(typS) { 
70   case GeomAbs_Plane:
71     {
72       nbs = 2;
73     }
74     break;
75   case GeomAbs_BezierSurface: 
76     {
77       nbs =  3 + ((BRepAdaptor_Surface *)S)->NbVPoles();
78     }
79     break;
80   case GeomAbs_BSplineSurface: 
81     {
82       nbs = ((BRepAdaptor_Surface *)S)->NbVKnots();
83       nbs*= ((BRepAdaptor_Surface *)S)->VDegree();
84       if(nbs < 2) nbs=2;
85       
86     }
87     break;
88   case GeomAbs_Cylinder:
89   case GeomAbs_Cone:
90   case GeomAbs_Sphere:
91   case GeomAbs_Torus:
92   case GeomAbs_SurfaceOfRevolution:
93   case GeomAbs_SurfaceOfExtrusion:
94     {
95       nbs = 15;
96     }
97     break;
98     
99   default: 
100     {
101       nbs = 10;
102     }
103     break;
104   }
105   return(nbs);
106 }
107
108 Standard_Integer  HLRBRep_SurfaceTool::NbSamplesU(const Standard_Address S,
109                                                       const Standard_Real u1,
110                                                       const Standard_Real u2) { 
111   Standard_Integer nbs = NbSamplesU(S);
112   Standard_Integer n = nbs;
113   if(nbs>10) { 
114     Standard_Real uf = FirstUParameter(S);
115     Standard_Real ul = LastUParameter(S);
116     n*= (Standard_Integer)((u2-u1)/(uf-ul));
117     if(n>nbs) n = nbs;
118     if(n<5)   n = 5;
119   }
120   return(n);
121 }
122
123 Standard_Integer  HLRBRep_SurfaceTool::NbSamplesV(const Standard_Address S,
124                                                       const Standard_Real v1,
125                                                       const Standard_Real v2) { 
126   Standard_Integer nbs = NbSamplesV(S);
127   Standard_Integer n = nbs;
128   if(nbs>10) { 
129     Standard_Real vf = FirstVParameter(S);
130     Standard_Real vl = LastVParameter(S);
131     n*= (Standard_Integer)((v2-v1)/(vf-vl));
132     if(n>nbs) n = nbs;
133     if(n<5)   n = 5;
134   }
135   return(n);
136 }