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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
//File Convert_ConeToBSplineSurface.cxx
//JCV 16/10/91
#include <Convert_ConeToBSplineSurface.ixx>
#include <gp.hxx>
#include <gp_Trsf.hxx>
static const Standard_Integer TheUDegree = 2;
static const Standard_Integer TheVDegree = 1;
static const Standard_Integer TheNbUKnots = 5;
static const Standard_Integer TheNbVKnots = 2;
static const Standard_Integer TheNbUPoles = 9;
static const Standard_Integer TheNbVPoles = 2;
static void ComputePoles( const Standard_Real R,
const Standard_Real A,
const Standard_Real U1,
const Standard_Real U2,
const Standard_Real V1,
const Standard_Real V2,
TColgp_Array2OfPnt& Poles)
{
Standard_Real deltaU = U2 - U1;
Standard_Integer i;
// Nombre de spans : ouverture maximale = 150 degres ( = PI / 1.2 rds)
Standard_Integer
nbUSpans = (Standard_Integer)IntegerPart( 1.2 * deltaU / PI) + 1;
Standard_Real AlfaU = deltaU / ( nbUSpans * 2);
Standard_Real x[TheNbVPoles];
Standard_Real z[TheNbVPoles];
x[0] = R + V1 * Sin(A);
z[0] = V1 * Cos(A);
x[1] = R + V2 * Sin(A);
z[1] = V2 * Cos(A);
Standard_Real UStart = U1;
Poles(1,1) = gp_Pnt(x[0]*Cos(UStart),x[0]*Sin(UStart),z[0]);
Poles(1,2) = gp_Pnt(x[1]*Cos(UStart),x[1]*Sin(UStart),z[1]);
for ( i = 1; i <= nbUSpans; i++) {
Poles( 2*i, 1) = gp_Pnt( x[0] * Cos(UStart+AlfaU) / Cos(AlfaU),
x[0] * Sin(UStart+AlfaU) / Cos(AlfaU),
z[0] );
Poles( 2*i, 2) = gp_Pnt( x[1] * Cos(UStart+AlfaU) / Cos(AlfaU),
x[1] * Sin(UStart+AlfaU) / Cos(AlfaU),
z[1] );
Poles(2*i+1,1) = gp_Pnt( x[0] * Cos(UStart+2*AlfaU),
x[0] * Sin(UStart+2*AlfaU),
z[0] );
Poles(2*i+1,2) = gp_Pnt( x[1] * Cos(UStart+2*AlfaU),
x[1] * Sin(UStart+2*AlfaU),
z[1] );
UStart += 2*AlfaU;
}
}
//=======================================================================
//function : Convert_ConeToBSplineSurface
//purpose :
//=======================================================================
Convert_ConeToBSplineSurface::Convert_ConeToBSplineSurface
(const gp_Cone& C ,
const Standard_Real U1,
const Standard_Real U2,
const Standard_Real V1,
const Standard_Real V2 )
: Convert_ElementarySurfaceToBSplineSurface (TheNbUPoles, TheNbVPoles,
TheNbUKnots, TheNbVKnots,
TheUDegree , TheVDegree )
{
Standard_Real deltaU = U2 - U1;
Standard_DomainError_Raise_if( (Abs(V2-V1) <= Abs(Epsilon(V1))) ||
(deltaU > 2*PI) ||
(deltaU < 0. ),
"Convert_ConeToBSplineSurface");
isuperiodic = Standard_False;
isvperiodic = Standard_False;
Standard_Integer i,j;
// construction du cone dans le repere de reference xOy.
// Nombre de spans : ouverture maximale = 150 degres ( = PI / 1.2 rds)
Standard_Integer
nbUSpans = (Standard_Integer)IntegerPart( 1.2 * deltaU / PI) + 1;
Standard_Real AlfaU = deltaU / ( nbUSpans * 2);
nbUPoles = 2 * nbUSpans + 1;
nbUKnots = nbUSpans + 1;
nbVPoles = 2;
nbVKnots = 2;
Standard_Real R = C.RefRadius();
Standard_Real A = C.SemiAngle();
ComputePoles( R, A, U1, U2, V1, V2, poles);
for ( i = 1; i<= nbUKnots; i++) {
uknots(i) = U1 + (i-1) * 2 * AlfaU;
umults(i) = 2;
}
umults(1)++; umults(nbUKnots)++;
vknots(1) = V1; vmults(1) = 2;
vknots(2) = V2; vmults(2) = 2;
// On replace la bspline dans le repere de la sphere.
// et on calcule les poids de la bspline.
Standard_Real W1;
gp_Trsf Trsf;
Trsf.SetTransformation( C.Position(), gp::XOY());
for ( i = 1; i <= nbUPoles; i++) {
if ( i % 2 == 0) W1 = Cos(AlfaU);
else W1 = 1.;
for ( j = 1; j <= nbVPoles; j++) {
weights( i, j) = W1;
poles( i, j).Transform( Trsf);
}
}
}
//=======================================================================
//function : Convert_ConeToBSplineSurface
//purpose :
//=======================================================================
Convert_ConeToBSplineSurface::Convert_ConeToBSplineSurface
(const gp_Cone& C ,
const Standard_Real V1,
const Standard_Real V2 )
: Convert_ElementarySurfaceToBSplineSurface (TheNbUPoles, TheNbVPoles,
TheNbUKnots, TheNbVKnots,
TheUDegree, TheVDegree)
{
Standard_DomainError_Raise_if( Abs(V2-V1) <= Abs(Epsilon(V1)),
"Convert_ConeToBSplineSurface");
Standard_Integer i,j;
isuperiodic = Standard_True;
isvperiodic = Standard_False;
// construction du cone dans le repere de reference xOy.
Standard_Real R = C.RefRadius();
Standard_Real A = C.SemiAngle();
ComputePoles( R, A, 0., 2.*PI, V1, V2, poles);
nbUPoles = 6;
nbUKnots = 4;
nbVPoles = 2;
nbVKnots = 2;
for ( i = 1; i <= nbUKnots; i++) {
uknots(i) = ( i-1) * 2. * PI /3.;
umults(i) = 2;
}
vknots(1) = V1; vmults(1) = 2;
vknots(2) = V2; vmults(2) = 2;
// On replace la bspline dans le repere du cone.
// et on calcule les poids de la bspline.
Standard_Real W;
gp_Trsf Trsf;
Trsf.SetTransformation( C.Position(), gp::XOY());
for ( i = 1; i <= nbUPoles; i++) {
if ( i % 2 == 0) W = 0.5; // = Cos(pi /3)
else W = 1.;
for ( j = 1; j <= nbVPoles; j++) {
weights( i, j) = W;
poles( i, j).Transform( Trsf);
}
}
}
|