35 Double_t fRmin1, fRmax1, fRmin2, fRmax2;
49 virtual ~TGLMesh() { }
50 virtual void Draw()
const = 0;
55 class TubeSegMesh :
public TGLMesh {
71 class TubeMesh :
public TGLMesh
86 class TCylinderMesh :
public TGLMesh {
100 class TCylinderSegMesh :
public TGLMesh
116 fRmin1(r1), fRmax1(r2), fRmin2(r3), fRmax2(r4),
117 fDz(dz), fNlow(l), fNhigh(h)
132 Double_t z = (fRmax1 - fRmax2) / (2 * fDz);
151 if (z < 0) newz = -fDz - (x * fNlow[0] + y * fNlow[1]) / fNlow[2];
152 else newz = fDz - (x * fNhigh[0] + y * fNhigh[1]) / fNhigh[2];
165 vert[2] = GetZcoord(x, y, z);
175 :TGLMesh(LOD, r1, r2, r3, r4, dz, l, h), fMesh(), fNorm()
179 const Double_t delta = (phi2 - phi1) / LOD;
185 const Int_t topShift = (fLOD + 1) * 4 + 8;
186 const Int_t botShift = (fLOD + 1) * 6 + 8;
187 Int_t j = 4 * (fLOD + 1) + 2;
190 for (
Int_t i = 0,
e = (fLOD + 1) * 2; i <
e; ++i) {
192 fMesh[i] = MakeVertex(fRmax2 * c, fRmax2 * s, fDz);
193 fMesh[j] = MakeVertex(fRmin2 * c, fRmin2 * s, fDz);
194 fMesh[i + topShift] = MakeVertex(fRmin2 * c, fRmin2 * s, fDz);
195 fMesh[i + botShift] = MakeVertex(fRmax1 * c, fRmax1 * s, - fDz);
196 GetNormal(fMesh[j], fNorm[j]);
200 fMesh[i] = MakeVertex(fRmax1 * c, fRmax1 * s, - fDz);
201 fMesh[j + 1] = MakeVertex(fRmin1 * c, fRmin1 * s, -fDz);
202 fMesh[i + topShift] = MakeVertex(fRmax2 * c, fRmax2 * s, fDz);
203 fMesh[i + botShift] = MakeVertex(fRmin1 * c, fRmin1 * s, - fDz);
204 GetNormal(fMesh[j + 1], fNorm[j + 1]);
205 fNorm[j + 1].Negate();
213 GetNormal(fMesh[i], fNorm[i]);
214 fNorm[i + topShift] = fNhigh;
215 fNorm[i + botShift] = fNlow;
219 Int_t ind = 2 * (fLOD + 1);
222 fMesh[ind] = fMesh[ind - 2];
223 fMesh[ind + 1] = fMesh[ind - 1];
224 fMesh[ind + 2] = fMesh[ind + 4];
225 fMesh[ind + 3] = fMesh[ind + 5];
229 fNorm[ind + 1] = norm;
230 fNorm[ind + 2] = norm;
231 fNorm[ind + 3] = norm;
234 fMesh[ind] = fMesh[ind - 2];
235 fMesh[ind + 1] = fMesh[ind - 1];
236 fMesh[ind + 2] = fMesh[0];
237 fMesh[ind + 3] = fMesh[1];
241 fNorm[ind + 1] = norm;
242 fNorm[ind + 2] = norm;
243 fNorm[ind + 3] = norm;
252 glEnableClientState(GL_VERTEX_ARRAY);
253 glEnableClientState(GL_NORMAL_ARRAY);
255 glVertexPointer(3, GL_DOUBLE,
sizeof(
TGLVertex3), fMesh[0].CArr());
256 glNormalPointer(GL_DOUBLE,
sizeof(
TGLVector3), fNorm[0].CArr());
258 glDrawArrays(GL_QUAD_STRIP, 0, 4 * (fLOD + 1) + 8);
260 glDrawArrays(GL_QUAD_STRIP, 4 * (fLOD + 1) + 8, 2 * (fLOD + 1));
261 glDrawArrays(GL_QUAD_STRIP, 6 * (fLOD + 1) + 8, 2 * (fLOD + 1));
263 glDisableClientState(GL_VERTEX_ARRAY);
264 glDisableClientState(GL_NORMAL_ARRAY);
272 :TGLMesh(LOD, r1, r2, r3, r4, z, l, h), fMesh(), fNorm()
281 const Int_t topShift = (fLOD + 1) * 4;
282 const Int_t botShift = (fLOD + 1) * 6;
283 Int_t j = 4 * (fLOD + 1) - 2;
286 for (
Int_t i = 0, e = (fLOD + 1) * 2; i <
e; ++i) {
288 fMesh[i] = MakeVertex(fRmax2 * c, fRmax2 * s, fDz);
289 fMesh[j] = MakeVertex(fRmin2 * c, fRmin2 * s, fDz);
290 fMesh[i + topShift] = MakeVertex(fRmin2 * c, fRmin2 * s, fDz);
291 fMesh[i + botShift] = MakeVertex(fRmax1 * c, fRmax1 * s, - fDz);
292 GetNormal(fMesh[j], fNorm[j]);
296 fMesh[i] = MakeVertex(fRmax1 * c, fRmax1 * s, - fDz);
297 fMesh[j + 1] = MakeVertex(fRmin1 * c, fRmin1 * s, -fDz);
298 fMesh[i + topShift] = MakeVertex(fRmax2 * c, fRmax2 * s, fDz);
299 fMesh[i + botShift] = MakeVertex(fRmin1 * c, fRmin1 * s, - fDz);
300 GetNormal(fMesh[j + 1], fNorm[j + 1]);
301 fNorm[j + 1].Negate();
309 GetNormal(fMesh[i], fNorm[i]);
310 fNorm[i + topShift] = fNhigh;
311 fNorm[i + botShift] = fNlow;
320 glEnableClientState(GL_VERTEX_ARRAY);
321 glEnableClientState(GL_NORMAL_ARRAY);
323 glVertexPointer(3, GL_DOUBLE,
sizeof(
TGLVertex3), fMesh[0].CArr());
324 glNormalPointer(GL_DOUBLE,
sizeof(
TGLVector3), fNorm[0].CArr());
326 glDrawArrays(GL_QUAD_STRIP, 0, 2 * (fLOD + 1));
327 glDrawArrays(GL_QUAD_STRIP, 2 * (fLOD + 1), 2 * (fLOD + 1));
329 glDrawArrays(GL_QUAD_STRIP, 4 * (fLOD + 1), 2 * (fLOD + 1));
330 glDrawArrays(GL_QUAD_STRIP, 6 * (fLOD + 1), 2 * (fLOD + 1));
332 glDisableClientState(GL_VERTEX_ARRAY);
333 glDisableClientState(GL_NORMAL_ARRAY);
341 :TGLMesh(LOD, 0., r1, 0., r2, dz, l, h), fMesh(), fNorm()
351 Int_t topShift = (fLOD + 1) * 2;
352 fMesh[topShift][0] = fMesh[topShift][1] = 0., fMesh[topShift][2] = fDz;
353 fNorm[topShift] = fNhigh;
357 Int_t botShift = topShift + 2 * (fLOD + 1);
358 fMesh[botShift][0] = fMesh[botShift][1] = 0., fMesh[botShift][2] = -fDz;
359 fNorm[botShift] = fNlow;
363 for (
Int_t i = 0, e = (fLOD + 1) * 2, j = 0; i <
e; ++i) {
365 fMesh[i] = MakeVertex(fRmax2 * c, fRmax2 * s, fDz);
366 fMesh[j + topShift] = MakeVertex(fRmin2 * c, fRmin2 * s, fDz);
367 fMesh[j + botShift] = MakeVertex(fRmax1 * c, fRmax1 * s, - fDz);
370 fMesh[i] = MakeVertex(fRmax1 * c, fRmax1 * s, - fDz);
378 GetNormal(fMesh[i], fNorm[i]);
379 fNorm[i + topShift] = fNhigh;
380 fNorm[i + botShift] = fNlow;
389 glEnableClientState(GL_VERTEX_ARRAY);
390 glEnableClientState(GL_NORMAL_ARRAY);
392 glVertexPointer(3, GL_DOUBLE,
sizeof(
TGLVertex3), fMesh[0].CArr());
393 glNormalPointer(GL_DOUBLE,
sizeof(
TGLVector3), fNorm[0].CArr());
396 glDrawArrays(GL_QUAD_STRIP, 0, 2 * (fLOD + 1));
398 glDrawArrays(GL_TRIANGLE_FAN, 2 * (fLOD + 1), fLOD + 2);
399 glDrawArrays(GL_TRIANGLE_FAN, 3 * (fLOD + 1) + 1, fLOD + 2);
401 glDisableClientState(GL_VERTEX_ARRAY);
402 glDisableClientState(GL_NORMAL_ARRAY);
411 :TGLMesh(LOD, 0., r1, 0., r2, dz, l, h), fMesh(), fNorm()
413 Double_t delta = (phi2 - phi1) / fLOD;
424 Int_t topShift = (fLOD + 1) * 2 + 8;
425 fMesh[topShift] = vTop;
426 fNorm[topShift] = fNhigh;
430 Int_t botShift = topShift + fLOD + 1;
431 fMesh[botShift] = vBot;
432 fNorm[botShift] = fNlow;
438 for (
Int_t e = (fLOD + 1) * 2, j = 0; i <
e; ++i) {
440 fMesh[i] = MakeVertex(fRmax2 * c, fRmax2 * s, fDz);
441 fMesh[j + topShift] = MakeVertex(fRmax2 * c, fRmax2 * s, fDz);
442 fMesh[j + botShift] = MakeVertex(fRmax1 * c, fRmax1 * s, - fDz);
444 fNorm[j + topShift] = fNhigh;
445 fNorm[j + botShift] = fNlow;
447 fMesh[i] = MakeVertex(fRmax1 * c, fRmax1 * s, - fDz);
455 GetNormal(fMesh[i], fNorm[i]);
459 Int_t ind = 2 * (fLOD + 1);
462 fMesh[ind] = fMesh[ind - 2];
463 fMesh[ind + 1] = fMesh[ind - 1];
464 fMesh[ind + 2] = vTop;
465 fMesh[ind + 3] = vBot;
469 fNorm[ind + 1] = norm;
470 fNorm[ind + 2] = norm;
471 fNorm[ind + 3] = norm;
475 fMesh[ind + 1] = vBot;
476 fMesh[ind + 2] = fMesh[0];
477 fMesh[ind + 3] = fMesh[1];
481 fNorm[ind + 1] = norm;
482 fNorm[ind + 2] = norm;
483 fNorm[ind + 3] = norm;
493 glEnableClientState(GL_VERTEX_ARRAY);
494 glEnableClientState(GL_NORMAL_ARRAY);
496 glVertexPointer(3, GL_DOUBLE,
sizeof(
TGLVertex3), fMesh[0].CArr());
497 glNormalPointer(GL_DOUBLE,
sizeof(
TGLVector3), fNorm[0].CArr());
499 glDrawArrays(GL_QUAD_STRIP, 0, 2 * (fLOD + 1) + 8);
501 glDrawArrays(GL_TRIANGLE_FAN, 2 * (fLOD + 1) + 8, fLOD + 2);
504 glDisableClientState(GL_VERTEX_ARRAY);
505 glDisableClientState(GL_NORMAL_ARRAY);
535 switch (buffer.
Type())
553 Error(
"TGLCylinder::TGLCylinder",
"cannot cast TBuffer3D");
566 Error(
"TGLCylinder::TGLCylinder",
"cannot cast TBuffer3D");
570 for (
UInt_t i =0; i < 3; i++) {
594 if (lod >= 100) off = 0;
595 else if (lod < 10) off = lod / 2;
596 else off = lod / 10 + 4;
614 lod = 10 *
static_cast<Int_t>(quant);
619 lod = 2 *
static_cast<Int_t>(quant);
621 return static_cast<Short_t>(lod);
630 Info(
"TGLCylinder::DirectDraw",
"this %ld (class %s) LOD %d",
639 std::vector<TGLMesh *> meshParts;
652 for (
UInt_t i = 0; i < meshParts.size(); ++i) meshParts[i]->
Draw();
655 for (
UInt_t i = 0; i < meshParts.size(); ++i) {
Complete tube description class - see TBuffer3DTypes for producer classes.
TGLVector3 gLowNormalDefault(0., 0., -1.)
std::string GetName(const std::string &scope_name)
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Double_t fHighPlaneNorm[3]
Tube segment description class - see TBuffer3DTypes for producer classes.
constexpr Double_t TwoPi()
Implements a native ROOT-GL cylinder that can be rendered at different levels of detail.
Int_t fDLSize
display-list id base
virtual UInt_t DLOffset(Short_t lod) const
Return display-list offset for given LOD.
Cut tube segment description class - see TBuffer3DTypes for producer classes.
T * Normal2Plane(const T v1[3], const T v2[3], const T v3[3], T normal[3])
Calculate a normal vector of a plane.
TGLCylinder(const TBuffer3DTube &buffer)
Copy out relevant parts of buffer - we create and delete mesh parts on demand in DirectDraw() and the...
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Debug tracing.
3 component (x/y/z) vertex class.
constexpr Double_t DegToRad()
Conversion from degree to radian: .
void Info(const char *location, const char *msgfmt,...)
TGLVector3 gHighNormalDefault(0., 0., 1.)
TGLVector3 fHighPlaneNorm
3 component (x/y/z) vector class.
void Error(const char *location, const char *msgfmt,...)
virtual Short_t QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const
Factor in scene/viewer LOD and quantize.
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
Double_t fLowPlaneNorm[3]
static constexpr double s
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
you should not use this method at all Int_t Int_t z
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw the GL drawable, using draw flags.
Double_t Sqrt(Double_t x)