Integration of OCCT 6.5.0 from SVN
[occt.git] / src / HLRBRep / HLRBRep_SurfaceTool.cxx
1 //-- File       : HLRBRep_SurfaceTool.gxx 
2 //-- Created    : Wed Jui 7 18:00:00 1c93
3 //-- Author     : Laurent BUCHARD
4 //--              <lbr@nonox>
5 //-- Copyright:  Matra Datavision 1993
6
7 #include <HLRBRep_SurfaceTool.ixx>
8 #include <BRepAdaptor_Surface.hxx>
9
10 Standard_Integer  HLRBRep_SurfaceTool::NbSamplesU(const Standard_Address S) { 
11   Standard_Integer nbs;
12   GeomAbs_SurfaceType typS = ((BRepAdaptor_Surface *)S)->GetType();
13   switch(typS) { 
14   case GeomAbs_Plane:
15     {
16       nbs = 2;
17     }
18     break;
19   case GeomAbs_BezierSurface: 
20     {
21       nbs =  3 + ((BRepAdaptor_Surface *)S)->NbUPoles();
22     }
23     break;
24   case GeomAbs_BSplineSurface: 
25     {
26       nbs = ((BRepAdaptor_Surface *)S)->NbUKnots();
27       nbs*= ((BRepAdaptor_Surface *)S)->UDegree();
28       if(nbs < 2) nbs=2;
29       
30     }
31     break;
32   case GeomAbs_Torus: 
33     {
34       nbs = 20;
35     }
36     break;
37   case GeomAbs_Cylinder:
38   case GeomAbs_Cone:
39   case GeomAbs_Sphere:
40   case GeomAbs_SurfaceOfRevolution:
41   case GeomAbs_SurfaceOfExtrusion:
42     {
43       nbs = 10;
44     }
45     break;
46     
47   default: 
48     {
49       nbs = 10;
50     }
51     break;
52   }
53   return(nbs);
54 }
55
56 Standard_Integer  HLRBRep_SurfaceTool::NbSamplesV(const Standard_Address S) { 
57   Standard_Integer nbs;
58   GeomAbs_SurfaceType typS = ((BRepAdaptor_Surface *)S)->GetType();
59   switch(typS) { 
60   case GeomAbs_Plane:
61     {
62       nbs = 2;
63     }
64     break;
65   case GeomAbs_BezierSurface: 
66     {
67       nbs =  3 + ((BRepAdaptor_Surface *)S)->NbVPoles();
68     }
69     break;
70   case GeomAbs_BSplineSurface: 
71     {
72       nbs = ((BRepAdaptor_Surface *)S)->NbVKnots();
73       nbs*= ((BRepAdaptor_Surface *)S)->VDegree();
74       if(nbs < 2) nbs=2;
75       
76     }
77     break;
78   case GeomAbs_Cylinder:
79   case GeomAbs_Cone:
80   case GeomAbs_Sphere:
81   case GeomAbs_Torus:
82   case GeomAbs_SurfaceOfRevolution:
83   case GeomAbs_SurfaceOfExtrusion:
84     {
85       nbs = 15;
86     }
87     break;
88     
89   default: 
90     {
91       nbs = 10;
92     }
93     break;
94   }
95   return(nbs);
96 }
97
98 Standard_Integer  HLRBRep_SurfaceTool::NbSamplesU(const Standard_Address S,
99                                                       const Standard_Real u1,
100                                                       const Standard_Real u2) { 
101   Standard_Integer nbs = NbSamplesU(S);
102   Standard_Integer n = nbs;
103   if(nbs>10) { 
104     Standard_Real uf = FirstUParameter(S);
105     Standard_Real ul = LastUParameter(S);
106     n*= (Standard_Integer)((u2-u1)/(uf-ul));
107     if(n>nbs) n = nbs;
108     if(n<5)   n = 5;
109   }
110   return(n);
111 }
112
113 Standard_Integer  HLRBRep_SurfaceTool::NbSamplesV(const Standard_Address S,
114                                                       const Standard_Real v1,
115                                                       const Standard_Real v2) { 
116   Standard_Integer nbs = NbSamplesV(S);
117   Standard_Integer n = nbs;
118   if(nbs>10) { 
119     Standard_Real vf = FirstVParameter(S);
120     Standard_Real vl = LastVParameter(S);
121     n*= (Standard_Integer)((v2-v1)/(vf-vl));
122     if(n>nbs) n = nbs;
123     if(n<5)   n = 5;
124   }
125   return(n);
126 }
127