Generate Primitives, required.
69 {
70
72
73
74 SoState *state =
action->getState();
75 if (!state)
76 return;
77
78
79
80 SbBool useTexFunction=
81 (SoTextureCoordinateElement::getType(state) ==
82 SoTextureCoordinateElement::FUNCTION);
83
84
85
86
87 const SoTextureCoordinateElement *tce = NULL;
88 SbVec4f texCoord;
89 if (useTexFunction) {
90 tce = SoTextureCoordinateElement::getInstance(state);
91 } else {
92 texCoord[2] = 0.0;
93 texCoord[3] = 1.0;
94 }
95 SbVec3f point, normal;
96
98
99#define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
100 point.setValue((float)(x),(float)(y),(float)(z)); \
101 normal.setValue((float)(nx),(float)(ny),(float)(nz)); \
102 if (useTexFunction) { \
103 texCoord=tce->get(point,normal); \
104 } else { \
105 texCoord[0]=(float)(s); \
106 texCoord[1]=(float)(t); \
107 } \
108 pv.setPoint(point); \
109 pv.setNormal(normal); \
110 pv.setTextureCoords(texCoord); \
111 shapeVertex(&pv);
112
114
116
120 double rMax1 =
fRmax1.getValue();
121 double rMin1 =
fRmin1.getValue();
122 double rMax2 =
fRmax2.getValue();
123 double rMin2 =
fRmin2.getValue();
124 double zMax =
fDz.getValue();
125 double zMin = -zMax;
126 double cosPhi0 =
cos(phi0);
127 double sinPhi0 =
sin(phi0);
128 double cosPhi1 =
cos(phi1);
129 double sinPhi1 =
sin(phi1);
132
133
134
136 double sinPhi=sinPhi0;
137 double cosPhi=cosPhi0;
138
139 {
140 double dR =rMax2-rMax1;
141 double dZ =zMax-zMin;
142 double cosTheta = -dR/sqrt(dR*dR+dZ*dZ);
143 double sinTheta = dZ/sqrt(dR*dR+dZ*dZ);
144
145 beginShape(action,TRIANGLE_STRIP);
146 for (i = 0;
i<=NPHI;
i++) {
147 GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,sinTheta*cosPhi,sinTheta*sinPhi,cosTheta);
148 GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,sinTheta*cosPhi,sinTheta*sinPhi,cosTheta);
149 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
150 }
151 endShape();
152 }
153
154
155
156
157 sinPhi=sinPhi0;
158 cosPhi=cosPhi0;
159
160 {
161 double dR =rMin2-rMin1;
162 double dZ =zMax-zMin;
163 double cosTheta = -dR/sqrt(dR*dR+dZ*dZ);
164 double sinTheta = dZ/sqrt(dR*dR+dZ*dZ);
165 beginShape(action,TRIANGLE_STRIP);
166 for (i = 0;
i<=NPHI;
i++) {
167 GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,-sinTheta*cosPhi,-sinTheta*sinPhi,-cosTheta);
168 GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,1.0,1.0,-sinTheta*cosPhi,-sinTheta*sinPhi,-cosTheta);
169 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
170 }
171 endShape();
172 }
174
175
176
177 beginShape(action,TRIANGLE_STRIP);
178 sinPhi=sinPhi0;
179 cosPhi=cosPhi0;
180 GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,sinPhi,-cosPhi,0);
181 GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,sinPhi,-cosPhi,0);
182 GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,1.0,0.0,sinPhi,-cosPhi,0);
183 GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,1.0,sinPhi,-cosPhi,0);
184 endShape();
185
186
187
188 beginShape(action,TRIANGLE_STRIP);
189 sinPhi=sinPhi1;
190 cosPhi=cosPhi1;
191 GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi, zMax,0.0,0.0,-sinPhi,+cosPhi,0);
192 GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi, zMin,1.0,1.0,-sinPhi,+cosPhi,0);
193 GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi, zMax,1.0,0.0,-sinPhi,+cosPhi,0);
194 GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi, zMin,0.0,1.0,-sinPhi,+cosPhi,0);
195 endShape();
196 }
197
198
199
200
201 beginShape(action,TRIANGLE_STRIP);
202 sinPhi=sinPhi0;
203 cosPhi=cosPhi0;
204 for (i = 0;
i<=NPHI;
i++) {
205 GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,0,0,1);
206 GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,1.0,1.0,0,0,1);
207 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
208 }
209 endShape();
210
211
212
213 beginShape(action,TRIANGLE_STRIP);
214 sinPhi=sinPhi0;
215 cosPhi=cosPhi0;
216 for (i = 0;
i<=NPHI;
i++) {
217 GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,0.0,0,0,-1);
218 GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,0,0,-1);
219 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
220 }
221 endShape();
222
223 if (state&&state->isElementEnabled(SoGLCacheContextElement::getClassStackIndex())) {
224
225 SoGLCacheContextElement::shouldAutoCache(state, SoGLCacheContextElement::DO_AUTO_CACHE);
226#if ((COIN_MAJOR_VERSION>=3)||((COIN_MAJOR_VERSION==2)&&(COIN_MINOR_VERSION>=5)))
227 SoGLCacheContextElement::incNumShapes(state);
228#endif
229 }
230}
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.