]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Reve/TriangleSet.h
New files: arbitrary triangulated surface.
[u/mrichter/AliRoot.git] / EVE / Reve / TriangleSet.h
CommitLineData
6196c437 1// $Header$
2
3#ifndef REVE_TriangleSet_H
4#define REVE_TriangleSet_H
5
6#include "RenderElement.h"
7#include <TNamed.h>
8#include <TAttBBox.h>
9
10#include "ZTrans.h"
11
12class TGeoMatrix;
13
14namespace Reve {
15
16class TriangleSet : public RenderElement,
17 public TNamed,
18 public TAttBBox
19{
20 friend class TriangleSetEditor;
21 friend class TriangleSetGL;
22
23protected:
24
25 // Vertex data
26 Int_t fNVerts;
27 Float_t* fVerts; //[3*fNVerts]
28
29 // Triangle data
30 Int_t fNTrings;
31 Int_t* fTrings; //[3*fNTrings]
32 Float_t* fTringNorms; //[3*fNTrings]
33 UChar_t* fTringCols; //[3*fNTrings]
34
35 // --------------------------------------------------------------
36
37 Color_t fColor;
38 ZTrans fHMTrans;
39
40public:
41
42 TriangleSet(Int_t nv, Int_t nt, Bool_t norms=false, Bool_t cols=false);
43 ~TriangleSet();
44
45 virtual Bool_t CanEditMainColor() { return kTRUE; }
46
47 Float_t* Vertex(Int_t i) { return &(fVerts[3*i]); }
48 Int_t* Triangle(Int_t i) { return &(fTrings[3*i]); }
49 Float_t* TriangleNormal(Int_t i) { return &(fTringNorms[3*i]); }
50 UChar_t* TriangleColor(Int_t i) { return &(fTringCols[3*i]); }
51
52 void SetVertex(Int_t i, Float_t x, Float_t y, Float_t z)
53 { Float_t* v = Vertex(i); v[0] = x; v[1] = y; v[2] = z; }
54 void SetTriangle(Int_t i, Int_t v0, Int_t v1, Int_t v2)
55 { Int_t* t = Triangle(i); t[0] = v0; t[1] = v1; t[2] = v2; }
56 void SetTriangleColor(Int_t i, UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
57 { UChar_t* c = TriangleColor(i); c[0] = r; c[1] = g; c[2] = b; c[3] = a; }
58
59 void GenerateTriangleNormals();
60 void GenerateRandomColors();
61
62 virtual void ComputeBBox();
63 virtual void Paint(Option_t* = "");
64
65 Color_t GetColor() const { return fColor; }
66 void SetColor(Color_t c) { fColor = c; }
67
68 ZTrans& RefHMTrans() { return fHMTrans; }
69 void SetTransMatrix(Double_t* carr) { fHMTrans.SetFrom(carr); }
70 void SetTransMatrix(const TGeoMatrix& mat) { fHMTrans.SetFrom(mat); }
71
72 static TriangleSet* ReadTrivialFile(const char* file);
73
74 ClassDef(TriangleSet, 0)
75}; // endclass TriangleSet
76
77}
78
79#endif