Our abstract base shape class.
#include <vector>
{
public:
~Shape() {};
protected:
};
fX(x), fY(y), fZ(z), fColor(color)
{}
class Box : public Shape
{
public:
~Box() {};
private:
};
Shape(color,x,y,z),
fDX(dX), fDY(dY), fDZ(dZ)
{}
{
if (reqSections & TBuffer3D::kCore) {
}
if (reqSections & TBuffer3D::kBoundingBox) {
Double_t halfLength[3] = { fDX, fDY, fDZ };
}
if (reqSections & TBuffer3D::kRawSizes) {
}
if (reqSections & TBuffer3D::kRaw) {
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() {};
private:
};
Shape(color,x,y,z),
fDX(dX), fDY(dY), fDZ(dZ)
{}
{
if (reqSections & TBuffer3D::kCore) {
}
if (reqSections & TBuffer3D::kBoundingBox) {
Double_t halfLength[3] = { fDX, fDY, fDZ/2.0 };
Double_t origin[3] = { fX , fY, fZ + halfLength[2]};
}
if (reqSections & TBuffer3D::kRawSizes) {
}
if (reqSections & TBuffer3D::kRaw) {
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();
private:
std::vector<Shape *> fShapes;
};
MyGeom::MyGeom()
{
Shape * 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()
{
}
{
gPad->GetViewer3D(option);
}
{
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 viewer3DMaster()
{
printf("\n\nviewer3DMaster: This frame demonstates master frame use of 3D viewer architecture.\n");
printf("Creates two boxes and a square based pyramid, described in master frame.\n\n");
MyGeom * myGeom = new MyGeom;
myGeom->Draw("ogl");
}