NOTE: We don't implement raw tesselation of sphere - hence this will not appear in viewers which don't support directly (non-OpenGL) Shows that viewers can at least deal gracefully with these cases
Our abstract base shape class.
#include <vector>
{
public:
~Shape() override {};
protected:
};
fX(
x), fY(
y), fZ(z), fColor(color)
{}
class Sphere : public Shape
{
public:
~Sphere() override {};
private:
};
fRadius(radius)
{}
{
}
Double_t halfLength[3] = { fRadius, fRadius, fRadius };
}
}
}
}
return buffer;
}
class Box : public Shape
{
public:
~Box() override {};
private:
};
fDX(dX), fDY(dY), fDZ(dZ)
{}
{
}
Double_t halfLength[3] = { fDX, fDY, fDZ };
}
}
buffer.
fPnts[ 0] = fX - fDX; buffer.
fPnts[ 1] = fY - fDY; buffer.
fPnts[ 2] = fZ - fDZ;
buffer.
fPnts[ 3] = fX + fDX; buffer.
fPnts[ 4] = fY - fDY; buffer.
fPnts[ 5] = fZ - fDZ;
buffer.
fPnts[ 6] = fX + fDX; buffer.
fPnts[ 7] = fY + fDY; buffer.
fPnts[ 8] = fZ - fDZ;
buffer.
fPnts[ 9] = fX - fDX; buffer.
fPnts[10] = fY + fDY; buffer.
fPnts[11] = fZ - fDZ;
buffer.
fPnts[12] = fX - fDX; buffer.
fPnts[13] = fY - fDY; buffer.
fPnts[14] = fZ + fDZ;
buffer.
fPnts[15] = fX + fDX; buffer.
fPnts[16] = fY - fDY; buffer.
fPnts[17] = fZ + fDZ;
buffer.
fPnts[18] = fX + fDX; buffer.
fPnts[19] = fY + fDY; buffer.
fPnts[20] = fZ + fDZ;
buffer.
fPnts[21] = fX - fDX; buffer.
fPnts[22] = fY + fDY; buffer.
fPnts[23] = fZ + fDZ;
}
return buffer;
}
class SBPyramid : public Shape
{
public:
~SBPyramid() override {};
private:
};
fDX(dX), fDY(dY), fDZ(dZ)
{}
{
}
Double_t halfLength[3] = { fDX, fDY, fDZ/2.0 };
Double_t origin[3] = { fX , fY, fZ + halfLength[2]};
}
}
buffer.
fPnts[ 0] = fX - fDX; buffer.
fPnts[ 1] = fY - fDY; buffer.
fPnts[ 2] = fZ;
buffer.
fPnts[ 3] = fX + fDX; buffer.
fPnts[ 4] = fY - fDY; buffer.
fPnts[ 5] = fZ;
buffer.
fPnts[ 6] = fX + fDX; buffer.
fPnts[ 7] = fY + fDY; buffer.
fPnts[ 8] = fZ;
buffer.
fPnts[ 9] = fX - fDX; buffer.
fPnts[10] = fY + fDY; buffer.
fPnts[11] = fZ;
buffer.
fPnts[12] = fX; buffer.
fPnts[13] = fY ; buffer.
fPnts[14] = fZ + fDZ;
}
return buffer;
}
{
public:
MyGeom();
~MyGeom() override;
private:
std::vector<Shape *> fShapes;
};
MyGeom::MyGeom()
{
Shape * aShape;
aShape =
new Sphere(
kYellow, 80.0, 60.0, 120.0, 10.0);
fShapes.push_back(aShape);
aShape =
new Box(
kRed, 0.0, 0.0, 0.0, 20.0, 20.0, 20.0);
fShapes.push_back(aShape);
aShape =
new Box(
kBlue, 50.0, 100.0, 200.0, 5.0, 10.0, 15.0);
fShapes.push_back(aShape);
aShape =
new SBPyramid(
kGreen, 20.0, 25.0, 45.0, 30.0, 30.0, 90.0);
fShapes.push_back(aShape);
}
MyGeom::~MyGeom()
{
}
{
}
{
std::vector<Shape *>::const_iterator ShapeIt = fShapes.begin();
Shape * shape;
while (ShapeIt != fShapes.end()) {
shape = *ShapeIt;
TBuffer3D & buffer = shape->GetBuffer3D(reqSections);
shape->GetBuffer3D(reqSections);
}
ShapeIt++;
}
}
void viewer3DLocal()
{
printf("\n\nviewer3DLocal: This frame demonstates local frame use of 3D viewer architecture.\n");
printf("Creates sphere, two boxes and a square based pyramid, described in local frame.\n");
printf("We do not implement raw tesselation of sphere - hence will not appear in viewers\n");
printf("which do not support in natively (non-GL viewer).\n\n");
MyGeom * myGeom = new MyGeom;
myGeom->Draw("ogl");
}
#define ClassDefOverride(name, id)
Use this attribute class when an object should have 3D capabilities.
Sphere description class - see TBuffer3DTypes for producer classes Supports hollow and cut spheres.
Generic 3D primitive description class.
void SetLocalMasterIdentity()
Set kRaw tessellation section of buffer with supplied sizes.
Double_t fLocalMaster[16]
void ClearSectionsValid()
Clear any sections marked valid.
void SetSectionsValid(UInt_t mask)
void SetAABoundingBox(const Double_t origin[3], const Double_t halfLengths[3])
Set fBBVertex in kBoundingBox section to a axis aligned (local) BB using supplied origin and box half...
Bool_t SetRawSizes(UInt_t reqPnts, UInt_t reqPntsCapacity, UInt_t reqSegs, UInt_t reqSegsCapacity, UInt_t reqPols, UInt_t reqPolsCapacity)
Set kRaw tessellation section of buffer with supplied sizes.
Mother of all ROOT objects.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
Abstract 3D shapes viewer.
virtual Int_t AddObject(const TBuffer3D &buffer, Bool_t *addChildren=nullptr)=0