Generate Primitives, required.
72 {
73
75
76
77 SoState *state =
action->getState();
78 if (!state)
79 return;
80
81
82
83 SbBool useTexFunction=
84 (SoTextureCoordinateElement::getType(state) ==
85 SoTextureCoordinateElement::FUNCTION);
86
87
88
89
90 const SoTextureCoordinateElement *tce = NULL;
91 SbVec4f texCoord;
92 if (useTexFunction) {
93 tce = SoTextureCoordinateElement::getInstance(state);
94 } else {
95 texCoord[2] = 0.0;
96 texCoord[3] = 1.0;
97 }
98 SbVec3f point, normal;
99
101
102#define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
103 point.setValue((float)(x),(float)(y),(float)(z)); \
104 normal.setValue((float)(nx),(float)(ny),(float)(nz)); \
105 if (useTexFunction) { \
106 texCoord=tce->get(point,normal); \
107 } else { \
108 texCoord[0]=(float)(s); \
109 texCoord[1]=(float)(t); \
110 } \
111 pv.setPoint(point); \
112 pv.setNormal(normal); \
113 pv.setTextureCoords(texCoord); \
114 shapeVertex(&pv);
115
117
119 return;
120 }
121
122 int nSeg =
fRmin.getNum()-1;
123 if (nSeg<1) {
124 return;
125 }
126
127 for (
int p=0;
p<nSeg;
p++) {
128
131
134
135 double zMin =
fDz[
p];
136 double zMax=
fDz[
p+1];
137
139
143 double cosPhi0 =
cos(phi0);
144 double sinPhi0 =
sin(phi0);
145 double cosPhi1 =
cos(phi1);
146 double sinPhi1 =
sin(phi1);
149
151 double sinPhi;
152 double cosPhi;
153
154
155
156
157 if (1)
158 {
159 double dR =rMax2-rMax1;
160 double dZ =zMax-zMin;
161 double cosTheta = -dR/sqrt(dR*dR+dZ*dZ);
162 double sinTheta = dZ/sqrt(dR*dR+dZ*dZ);
163
164 beginShape(action,TRIANGLE_STRIP);
165 sinPhi=sinPhi0;
166 cosPhi=cosPhi0;
167 for (i = 0;
i<=NPHI;
i++) {
168 GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,sinTheta*cosPhi,sinTheta*sinPhi,cosTheta);
169 GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,sinTheta*cosPhi,sinTheta*sinPhi,cosTheta);
170 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
171 }
172 endShape();
173 }
174 if (1)
175
176
177
178 {
179 beginShape(action,TRIANGLE_STRIP);
180 sinPhi=sinPhi0;
181 cosPhi=cosPhi0;
182
183 double dR =rMin2-rMin1;
184 double dZ =zMax-zMin;
185 double cosTheta = -dR/sqrt(dR*dR+dZ*dZ);
186 double sinTheta = dZ/sqrt(dR*dR+dZ*dZ);
187
188 for (i = 0;
i<=NPHI;
i++) {
189 GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,-cosPhi*sinTheta,-sinPhi*sinTheta,-cosTheta);
190 GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,1.0,1.0,-cosPhi*sinTheta,-sinPhi*sinTheta,-cosTheta);
191 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
192 }
193
194 endShape();
195 }
196
197 if (1) {
199
200
201
202 beginShape(action,TRIANGLE_STRIP);
203 sinPhi=sinPhi0;
204 cosPhi=cosPhi0;
205 GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,sinPhi,-cosPhi,0);
206 GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,sinPhi,-cosPhi,0);
207 GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,1.0,0.0,sinPhi,-cosPhi,0);
208 GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,1.0,sinPhi,-cosPhi,0);
209 endShape();
210
211
212
213 beginShape(action,TRIANGLE_STRIP);
214 sinPhi=sinPhi1;
215 cosPhi=cosPhi1;
216 GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi, zMax,0.0,0.0,-sinPhi,+cosPhi,0);
217 GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi, zMin,1.0,1.0,-sinPhi,+cosPhi,0);
218 GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi, zMax,1.0,0.0,-sinPhi,+cosPhi,0);
219 GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi, zMin,0.0,1.0,-sinPhi,+cosPhi,0);
220 endShape();
221 }
222 }
223 if (p==(nSeg-1)) {
224
225
226
227 beginShape(action,TRIANGLE_STRIP);
228 sinPhi=sinPhi0;
229 cosPhi=cosPhi0;
230 for (i = 0;
i<=NPHI;
i++) {
231 GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,0,0,1);
232 GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,1.0,1.0,0,0,1);
233 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
234 }
235 endShape();
236 }
237 if (p==0) {
238
239
240
241 beginShape(action,TRIANGLE_STRIP);
242 sinPhi=sinPhi0;
243 cosPhi=cosPhi0;
244 for (i = 0;
i<=NPHI;
i++) {
245 GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,0.0,0,0,-1);
246 GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,0,0,-1);
247 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
248 }
249 endShape();
250 }
251 }
252
253 if (state&&state->isElementEnabled(SoGLCacheContextElement::getClassStackIndex())) {
254
255 SoGLCacheContextElement::shouldAutoCache(state, SoGLCacheContextElement::DO_AUTO_CACHE);
256#if ((COIN_MAJOR_VERSION>=3)||((COIN_MAJOR_VERSION==2)&&(COIN_MINOR_VERSION>=5)))
257 SoGLCacheContextElement::incNumShapes(state);
258#endif
259 }
260}
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
#define GEN_VERTEX(pv, x, y, z, s, t, nx, ny, nz)
static int nphiDivisions(const float &dphi, const float &complexity, int OverrideNPhi=0)
void inc(double &sinPhi, double &cosPhi, double sinDeltaPhi, double cosDeltaPhi) const
help with trigonometry. increments sines an cosines by an angle.