summaryrefslogtreecommitdiff
path: root/src/HLRBRep/HLRBRep_BSurfaceTool.cxx
blob: 26ff291ae68737d2bd71c9abe25dc8b0c23e2d6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//-- File       : HLRBRep_BSurfaceTool.cxx 
//-- Created    : Wed Jui 7 18:00:00 1993
//-- Author     : Laurent BUCHARD
//--              <lbr@nonox>
//-- Copyright:	 Matra Datavision 1993

#include <HLRBRep_BSurfaceTool.ixx>
#include <BRepAdaptor_Surface.hxx>

//=======================================================================
//function : NbSamplesU
//purpose  : 
//=======================================================================

Standard_Integer
HLRBRep_BSurfaceTool::NbSamplesU(const BRepAdaptor_Surface& S)
{ 
  Standard_Integer nbs;
  GeomAbs_SurfaceType typS = S.GetType();
  switch(typS) { 
  case GeomAbs_Plane:
    {
      nbs = 2;
    }
    break;
  case GeomAbs_BezierSurface: 
    {
      nbs =  3 + S.NbUPoles();
    }
    break;
  case GeomAbs_BSplineSurface: 
    {
      nbs = S.NbUKnots();
      nbs*= S.UDegree();
      if(nbs < 2) nbs=2;
      
    }
    break;
  case GeomAbs_Torus: 
    {
      nbs = 20;
    }
    break;
  case GeomAbs_Cylinder:
  case GeomAbs_Cone:
  case GeomAbs_Sphere:
  case GeomAbs_SurfaceOfRevolution:
  case GeomAbs_SurfaceOfExtrusion:
    {
      nbs = 10;
    }
    break;
    
  default: 
    {
      nbs = 10;
    }
    break;
  }
  return(nbs);
}

//=======================================================================
//function : NbSamplesV
//purpose  : 
//=======================================================================

Standard_Integer
HLRBRep_BSurfaceTool::NbSamplesV(const BRepAdaptor_Surface& S)
{ 
  Standard_Integer nbs;
  GeomAbs_SurfaceType typS = S.GetType();
  switch(typS) { 
  case GeomAbs_Plane:
    {
      nbs = 2;
    }
    break;
  case GeomAbs_BezierSurface: 
    {
      nbs =  3 + S.NbVPoles();
    }
    break;
  case GeomAbs_BSplineSurface: 
    {
      nbs = S.NbVKnots();
      nbs*= S.VDegree();
      if(nbs < 2) nbs=2;
      
    }
    break;
  case GeomAbs_Cylinder:
  case GeomAbs_Cone:
  case GeomAbs_Sphere:
  case GeomAbs_Torus:
  case GeomAbs_SurfaceOfRevolution:
  case GeomAbs_SurfaceOfExtrusion:
    {
      nbs = 15;
    }
    break;
    
  default: 
    {
      nbs = 10;
    }
    break;
  }
  return(nbs);
}

//=======================================================================
//function : NbSamplesU
//purpose  : 
//=======================================================================

Standard_Integer
HLRBRep_BSurfaceTool::NbSamplesU(const BRepAdaptor_Surface& S,
				 const Standard_Real u1,
				 const Standard_Real u2)
{ 
  Standard_Integer nbs = NbSamplesU(S);
  Standard_Integer n = nbs;
  if(nbs>10) { 
    Standard_Real uf = FirstUParameter(S);
    Standard_Real ul = LastUParameter(S);
    n*= (Standard_Integer)((u2-u1)/(uf-ul));
    if(n>nbs) n = nbs;
    if(n<5)   n = 5;
  }
  return(n);
}

//=======================================================================
//function : NbSamplesV
//purpose  : 
//=======================================================================

Standard_Integer
HLRBRep_BSurfaceTool::NbSamplesV(const BRepAdaptor_Surface& S,
				 const Standard_Real v1,
				 const Standard_Real v2)
{ 
  Standard_Integer nbs = NbSamplesV(S);
  Standard_Integer n = nbs;
  if(nbs>10) { 
    Standard_Real vf = FirstVParameter(S);
    Standard_Real vl = LastVParameter(S);
    n*= (Standard_Integer)((v2-v1)/(vf-vl));
    if(n>nbs) n = nbs;
    if(n<5)   n = 5;
  }
  return(n);
}