]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/Reve/TriangleSet.cxx
Dealing with two different loaders for simulation and reconstruction if necessary...
[u/mrichter/AliRoot.git] / EVE / Reve / TriangleSet.cxx
index 49d38d5f75663237e776a8ad015ce015adc527f1..16aef602694b98b74f29a97842bb551e69292952 100644 (file)
@@ -1,26 +1,53 @@
-// $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];
@@ -73,6 +100,23 @@ void TriangleSet::GenerateRandomColors()
     }
 }
 
+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()
@@ -115,6 +159,10 @@ void TriangleSet::Paint(Option_t* )
 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);