#include "TEvePolygonSetProjectedGL.h"
#include "TEvePolygonSetProjected.h"
#include "TEveVSDStructs.h"
#include "TGLRnrCtx.h"
#include "TGLIncludes.h"
ClassImp(TEvePolygonSetProjectedGL);
TEvePolygonSetProjectedGL::TEvePolygonSetProjectedGL() : TGLObject()
{
fMultiColor = kTRUE;
}
Bool_t TEvePolygonSetProjectedGL::SetModel(TObject* obj, const Option_t* )
{
return SetModelCheckClass(obj, TEvePolygonSetProjected::Class());
}
void TEvePolygonSetProjectedGL::SetBBox()
{
SetAxisAlignedBBox(((TEvePolygonSetProjected*)fExternalObj)->AssertBBox());
}
void TEvePolygonSetProjectedGL::DirectDraw(TGLRnrCtx & ) const
{
TEvePolygonSetProjected& refPS = * (TEvePolygonSetProjected*) fExternalObj;
if (refPS.fPols.size() == 0) return;
fMultiColor = (refPS.fFillColor != refPS.fLineColor);
glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT | GL_POLYGON_BIT);
glDisable(GL_LIGHTING);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDisable(GL_CULL_FACE);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.,1.);
GLUtesselator *tessObj = TGLUtil::GetDrawTesselator3fv();
TEveVector* pnts = refPS.fPnts;
for (TEvePolygonSetProjected::vpPolygon_ci i = refPS.fPols.begin();
i != refPS.fPols.end(); ++i)
{
Int_t vi;
Int_t pntsN = (*i).fNPnts;
if (pntsN < 4)
{
glBegin(GL_POLYGON);
for (Int_t k = 0; k < pntsN; ++k)
{
vi = (*i).fPnts[k];
glVertex3fv(pnts[vi].Arr());
}
glEnd();
}
else
{
gluBeginPolygon(tessObj);
gluNextContour(tessObj, (GLenum)GLU_UNKNOWN);
glNormal3f(0., 0., 1.);
Double_t coords[3];
coords[2] = 0.;
for (Int_t k = 0; k < pntsN; ++k)
{
vi = (*i).fPnts[k];
coords[0] = pnts[vi].fX;
coords[1] = pnts[vi].fY;
gluTessVertex(tessObj, coords, pnts[vi].Arr());
}
gluEndPolygon(tessObj);
}
}
glDisable(GL_POLYGON_OFFSET_FILL);
TGLUtil::Color(refPS.fLineColor);
glEnable(GL_LINE_SMOOTH);
glLineWidth(refPS.fLineWidth);
Int_t vi;
for (TEvePolygonSetProjected::vpPolygon_ci i = refPS.fPols.begin();
i != refPS.fPols.end(); ++i)
{
glBegin(GL_LINE_LOOP);
for(Int_t k = 0; k < (*i).fNPnts; ++k)
{
vi = (*i).fPnts[k];
glVertex3fv(refPS.fPnts[vi].Arr());
}
glEnd();
}
glPopAttrib();
}
Last change: Wed Nov 12 13:46:19 2008
Last generated: 2008-11-12 13:46
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.