16#include "TGLIncludes.h"
50 virtual void Draw()
const = 0;
66 void Draw()
const override;
82 void Draw()
const override;
96 void Draw()
const override;
110 void Draw()
const override;
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;
190 for (
Int_t i = 0,
e = (
fLOD + 1) * 2; i <
e; ++i) {
205 fNorm[j + 1].Negate();
229 fNorm[ind + 1] = norm;
230 fNorm[ind + 2] = norm;
231 fNorm[ind + 3] = norm;
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);
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);
286 for (
Int_t i = 0,
e = (
fLOD + 1) * 2; i <
e; ++i) {
301 fNorm[j + 1].Negate();
320 glEnableClientState(GL_VERTEX_ARRAY);
321 glEnableClientState(GL_NORMAL_ARRAY);
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);
357 Int_t botShift = topShift + 2 * (
fLOD + 1);
363 for (
Int_t i = 0,
e = (
fLOD + 1) * 2, j = 0; i <
e; ++i) {
389 glEnableClientState(GL_VERTEX_ARRAY);
390 glEnableClientState(GL_NORMAL_ARRAY);
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);
425 fMesh[topShift] = vTop;
431 fMesh[botShift] = vBot;
438 for (
Int_t e = (
fLOD + 1) * 2, j = 0; i <
e; ++i) {
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;
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);
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);
534 switch (buffer.
Type())
537 case TBuffer3DTypes::kTube:
550 const TBuffer3DTubeSeg * segBuffer = dynamic_cast<const TBuffer3DTubeSeg *>(&buffer);
552 Error(
"TGLCylinder::TGLCylinder",
"cannot cast TBuffer3D");
556 fPhi1 = segBuffer->fPhiMin;
557 fPhi2 = segBuffer->fPhiMax;
565 Error(
"TGLCylinder::TGLCylinder",
"cannot cast TBuffer3D");
569 for (
UInt_t i =0; i < 3; i++) {
593 if (lod >= 100) off = 0;
594 else if (lod < 10) off = lod / 2;
595 else off = lod / 10 + 4;
613 lod = 10 *
static_cast<Int_t>(quant);
618 lod = 2 *
static_cast<Int_t>(quant);
620 return static_cast<Short_t>(lod);
629 Info(
"TGLCylinder::DirectDraw",
"this %zd (class %s) LOD %d",
630 (
size_t)
this,
IsA()->GetName(), rnrCtx.
ShapeLOD());
638 std::vector<TGLMesh *> meshParts;
651 for (
UInt_t i = 0; i < meshParts.size(); ++i) meshParts[i]->
Draw();
654 for (
UInt_t i = 0; i < meshParts.size(); ++i) {
656 meshParts[i] =
nullptr;
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
short Short_t
Signed Short integer 2 bytes (short).
double Double_t
Double 8 bytes.
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
TGLVector3 gHighNormalDefault(0., 0., 1.)
TGLVector3 gLowNormalDefault(0., 0., -1.)
Cut tube segment description class - see TBuffer3DTypes for producer classes.
Double_t fLowPlaneNorm[3]
Double_t fHighPlaneNorm[3]
Complete tube description class - see TBuffer3DTypes for producer classes.
TGLVertex3 fMesh[(TGLRnrCtx::kLODHigh+1) *4+2]
TGLVector3 fNorm[(TGLRnrCtx::kLODHigh+1) *4+2]
TCylinderMesh(UInt_t LOD, Double_t r1, Double_t r2, Double_t dz, const TGLVector3 &l=gLowNormalDefault, const TGLVector3 &h=gHighNormalDefault)
constructor
void Draw() const override
draw cylinder mesh
TGLVector3 fNorm[(TGLRnrCtx::kLODHigh+1) *4+10]
TGLVertex3 fMesh[(TGLRnrCtx::kLODHigh+1) *4+10]
TCylinderSegMesh(UInt_t LOD, Double_t r1, Double_t r2, Double_t dz, Double_t phi1, Double_t phi2, const TGLVector3 &l=gLowNormalDefault, const TGLVector3 &h=gHighNormalDefault)
One quad mesh and two fans.
void Draw() const override
Cylinder segment is drawn as one quad strip and two triangle fans.
TGLVector3 fHighPlaneNorm
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Debug tracing.
TGLCylinder(const TBuffer3DTube &buffer)
Copy out relevant parts of buffer - we create and delete mesh parts on demand in DirectDraw() and the...
TClass * IsA() const override
~TGLCylinder() override
destructor
Short_t QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const override
Factor in scene/viewer LOD and quantize.
UInt_t DLOffset(Short_t lod) const override
Return display-list offset for given LOD.
TGLLogicalShape(const TGLLogicalShape &)=delete
Int_t fDLSize
! display-list size for different LODs
const TGLVertex3 & MakeVertex(Double_t x, Double_t y, Double_t z) const
make vertex
virtual void Draw() const =0
TGLMesh(UInt_t LOD, Double_t r1, Double_t r2, Double_t r3, Double_t r4, Double_t dz, const TGLVector3 &l=gLowNormalDefault, const TGLVector3 &h=gHighNormalDefault)
Double_t GetZcoord(Double_t x, Double_t y, Double_t z) const
get Z coordinate
void GetNormal(const TGLVertex3 &vertex, TGLVector3 &normal) const
get normal
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
3 component (x/y/z) vector class.
3 component (x/y/z) vertex class.
TGLVertex3 fMesh[(TGLRnrCtx::kLODHigh+1) *8]
TubeMesh(UInt_t LOD, Double_t r1, Double_t r2, Double_t r3, Double_t r4, Double_t dz, const TGLVector3 &l=gLowNormalDefault, const TGLVector3 &h=gHighNormalDefault)
constructor
TGLVector3 fNorm[(TGLRnrCtx::kLODHigh+1) *8]
void Draw() const override
Tube is drawn as four quad strips.
TGLVertex3 fMesh[(TGLRnrCtx::kLODHigh+1) *8+8]
TGLVector3 fNorm[(TGLRnrCtx::kLODHigh+1) *8+8]
TubeSegMesh(UInt_t LOD, Double_t r1, Double_t r2, Double_t r3, Double_t r4, Double_t dz, Double_t phi1, Double_t phi2, const TGLVector3 &l=gLowNormalDefault, const TGLVector3 &h=gHighNormalDefault)
void Draw() const override
Tube segment is drawn as three quad strips.
T * Normal2Plane(const T v1[3], const T v2[3], const T v3[3], T normal[3])
Calculates a normal vector of a plane.
constexpr Double_t DegToRad()
Conversion from degree to radian: .
Double_t Sqrt(Double_t x)
Returns the square root of x.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
constexpr Double_t TwoPi()