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