-// $Header$
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/* $Id$ */
+
#include "TriangleSet.h"
+#include "RGBAPalette.h"
+#include <TMath.h>
#include <TVector3.h>
#include <TRandom3.h>
#include <TVirtualPad.h>
#include <TVirtualViewer3D.h>
#include <TBuffer3D.h>
#include <TBuffer3DTypes.h>
-#include <TGeoMatrix.h>
using namespace Reve;
+//______________________________________________________________________
+// TriangleSet
+//
+// Made from a list of vertices and a list of triangles (triplets of
+// vertex indices).
+//
+// If input is composed from triangles with direct vertex coordinates
+// one should consider finding all occurences of the same vertex
+// and specifying it only once.
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)
+ fNVerts (nv), fVerts(0),
+ fNTrings (nt), fTrings(0), fTringNorms(0), fTringCols(0),
+ fColor (2),
+ fHMTrans ()
{
fVerts = new Float_t[3*fNVerts];
fTrings = new Int_t [3*fNTrings];
}
}
+void TriangleSet::GenerateZNormalColors(Float_t fac, Int_t min, Int_t max,
+ Bool_t interp, Bool_t wrap)
+{
+ if (fTringCols == 0) fTringCols = new UChar_t[3*fNTrings];
+ if (fTringNorms == 0) GenerateTriangleNormals();
+
+ RGBAPalette pal(min, max, interp, wrap);
+ UChar_t *C = fTringCols;
+ Float_t *N = fTringNorms;
+ for(Int_t t=0; t<fNTrings; ++t, C+=3, N+=3)
+ {
+ Int_t v = TMath::Nint(fac * N[2]);
+ pal.ColorFromValue(v, C, kFALSE);
+ }
+ gPad->Modified(); gPad->Update();
+}
+
/**************************************************************************/
void TriangleSet::ComputeBBox()
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);