// $Header$ #include "TriangleSet.h" #include #include #include #include #include #include using namespace Reve; ClassImp(TriangleSet) TriangleSet::TriangleSet(Int_t nv, Int_t nt, Bool_t norms, Bool_t cols) : RenderElement(fColor), TNamed("TriangleSet", 0), fNVerts (nv), fNTrings (nt), fColor (2) { fVerts = new Float_t[3*fNVerts]; fTrings = new Int_t [3*fNTrings]; fTringNorms = (norms) ? new Float_t[3*fNTrings] : 0; fTringCols = (cols) ? new UChar_t[3*fNTrings] : 0; } TriangleSet::~TriangleSet() { delete [] fVerts; delete [] fTrings; delete [] fTringNorms; delete [] fTringCols; } /**************************************************************************/ void TriangleSet::GenerateTriangleNormals() { if (fTringNorms == 0) fTringNorms = new Float_t[3*fNTrings]; TVector3 e1, e2, n; Float_t *N = fTringNorms; Int_t *T = fTrings; for(Int_t t=0; tModified(); gPad->Update(); } /**************************************************************************/ void TriangleSet::ComputeBBox() { if (fNVerts <= 0) { BBoxZero(); return; } BBoxInit(); Float_t* v = fVerts; for (Int_t i=0; iGetViewer3D()->AddObject(buffer); if (reqSections == TBuffer3D::kNone) { return; } Error("TriangleSet::Paint", "only direct OpenGL rendering supported."); } /**************************************************************************/ #include TriangleSet* TriangleSet::ReadTrivialFile(const char* file) { FILE* f = fopen(file, "r"); if (f == 0) { ::Error("TriangleSet::ReadTrivialFile", Form("file '%s' not found.", file)); return 0; } Int_t nv, nt; fscanf(f, "%d %d", &nv, &nt); TriangleSet* ts = new TriangleSet(nv, nt); Float_t *V = ts->Vertex(0); for (Int_t i=0; iTriangle(0); for (Int_t i=0; i