Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveTriangleSet.h
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TEveTriangleSet
13 #define ROOT_TEveTriangleSet
14 
15 #include "TEveElement.h"
16 #include "TNamed.h"
17 #include "TAttBBox.h"
18 #include "TAtt3D.h"
19 
20 #include "TEveTrans.h"
21 
22 class TGeoMatrix;
23 
24 class TEveTriangleSet : public TEveElementList,
25  public TAtt3D,
26  public TAttBBox
27 {
28  friend class TEveTriangleSetEditor;
29  friend class TEveTriangleSetGL;
30 
31  TEveTriangleSet(const TEveTriangleSet&); // Not implemented
32  TEveTriangleSet& operator=(const TEveTriangleSet&); // Not implemented
33 
34 protected:
35  // Vertex data
36  Int_t fNVerts;
37  Float_t* fVerts; //[3*fNVerts]
38 
39  // Triangle data
40  Int_t fNTrings;
41  Int_t* fTrings; //[3*fNTrings]
42  Float_t* fTringNorms; //[3*fNTrings]
43  UChar_t* fTringCols; //[3*fNTrings]
44 
45 public:
46  TEveTriangleSet(Int_t nv, Int_t nt, Bool_t norms=kFALSE, Bool_t cols=kFALSE);
47  ~TEveTriangleSet();
48 
49  virtual Bool_t CanEditMainTransparency() const { return kTRUE; }
50 
51  Int_t GetNVerts() const { return fNVerts; }
52  Int_t GetNTrings() const { return fNTrings; }
53 
54  Float_t* Vertex(Int_t i) { return &(fVerts[3*i]); }
55  Int_t* Triangle(Int_t i) { return &(fTrings[3*i]); }
56  Float_t* TriangleNormal(Int_t i) { return &(fTringNorms[3*i]); }
57  UChar_t* TriangleColor(Int_t i) { return &(fTringCols[3*i]); }
58 
59  void SetVertex(Int_t i, Float_t x, Float_t y, Float_t z)
60  { Float_t* v = Vertex(i); v[0] = x; v[1] = y; v[2] = z; }
61  void SetTriangle(Int_t i, Int_t v0, Int_t v1, Int_t v2)
62  { Int_t* t = Triangle(i); t[0] = v0; t[1] = v1; t[2] = v2; }
63  void SetTriangleColor(Int_t i, UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
64  { UChar_t* c = TriangleColor(i); c[0] = r; c[1] = g; c[2] = b; c[3] = a; }
65 
66  void GenerateTriangleNormals();
67  void GenerateRandomColors();
68  void GenerateZNormalColors(Float_t fac=20, Int_t min=-20, Int_t max=20,
69  Bool_t interp=kFALSE, Bool_t wrap=kFALSE);
70 
71  virtual void ComputeBBox();
72  virtual void Paint(Option_t* option="");
73 
74  void SetTransparency(Char_t tr) { SetMainTransparency(tr); } // *MENU*
75 
76  static TEveTriangleSet* ReadTrivialFile(const char* file);
77 
78  ClassDef(TEveTriangleSet, 0); // Generic mesh or soup of triangles with per-triangle normals and colors.
79 };
80 
81 #endif