Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGLIsoMesh.h
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Timur Pocheptsov 06/01/2009
3
4/*************************************************************************
5 * Copyright (C) 1995-2009, 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_TGLIsoMesh
13#define ROOT_TGLIsoMesh
14
15#include <vector>
16
17#include "RtypesCore.h"
18#include "TAxis.h"
19
20class TGLBoxCut;
21
22namespace Rgl {
23namespace Mc {
24
25/*
26TIsoMesh - set of vertices, per-vertex normals, "triangles".
27Each "triangle" is a triplet of indices, pointing into vertices
28and normals arrays. For example, triangle t = {1, 4, 6}
29has vertices &fVerts[1 * 3], &fVerts[4 * 3], &fVerts[6 * 3];
30and normals &fNorms[1 * 3], &fNorms[4 * 3], &fNorms[6 * 3]
31"V" parameter should be Float_t or Double_t (or some
32integral type?).
33
34Prefix "T" in a class name only for code-style checker.
35*/
36
37template<class V>
38class TIsoMesh {
39public:
40 UInt_t AddVertex(const V *v)
41 {
42 const UInt_t index = UInt_t(fVerts.size() / 3);
43 fVerts.push_back(v[0]);
44 fVerts.push_back(v[1]);
45 fVerts.push_back(v[2]);
46
47 return index;
48 }
49
50 void AddNormal(const V *n)
51 {
52 fNorms.push_back(n[0]);
53 fNorms.push_back(n[1]);
54 fNorms.push_back(n[2]);
55 }
56
58 {
59 const UInt_t index = UInt_t(fTris.size() / 3);
60 fTris.push_back(t[0]);
61 fTris.push_back(t[1]);
62 fTris.push_back(t[2]);
63
64 return index;
65 }
66
67 void Swap(TIsoMesh &rhs)
68 {
69 std::swap(fVerts, rhs.fVerts);
70 std::swap(fNorms, rhs.fNorms);
71 std::swap(fTris, rhs.fTris);
72 }
73
74 void ClearMesh()
75 {
76 fVerts.clear();
77 fNorms.clear();
78 fTris.clear();
79 }
80
81 std::vector<V> fVerts;
82 std::vector<V> fNorms;
83 std::vector<UInt_t> fTris;
84};
85
86/*
87TGridGeometry describes ranges and cell steps (scales are
88already in steps and ranges).
89*/
90template<class V>
92public:
96 };
97
99 fMinY(0), fStepY(0),
100 fMinZ(0), fStepZ(0),
101 fXScaleInverted(1.),
102 fYScaleInverted(1.),
104 {
105 //Default constructor.
106 }
107
108 TGridGeometry(const TAxis *x, const TAxis *y, const TAxis *z,
109 Double_t xs = 1., Double_t ys = 1., Double_t zs = 1.,
111 : fMinX(0), fStepX(0),
112 fMinY(0), fStepY(0),
113 fMinZ(0), fStepZ(0),
114 fXScaleInverted(1.),
115 fYScaleInverted(1.),
117 {
118 //Define geometry using TAxis.
119 if (pos == kBinCenter) {
120 fMinX = V(x->GetBinCenter(x->GetFirst()));
121 fStepX = V((x->GetBinCenter(x->GetLast()) - fMinX) / (x->GetNbins() - 1));
122 fMinY = V(y->GetBinCenter(y->GetFirst()));
123 fStepY = V((y->GetBinCenter(y->GetLast()) - fMinY) / (y->GetNbins() - 1));
124 fMinZ = V(z->GetBinCenter(z->GetFirst()));
125 fStepZ = V((z->GetBinCenter(z->GetLast()) - fMinZ) / (z->GetNbins() - 1));
126
127 fMinX *= xs, fStepX *= xs;
128 fMinY *= ys, fStepY *= ys;
129 fMinZ *= zs, fStepZ *= zs;
130 } else if (pos == kBinEdge) {
131 fMinX = V(x->GetBinLowEdge(x->GetFirst()));
132 fStepX = V((x->GetBinUpEdge(x->GetLast()) - fMinX) / (x->GetNbins()));
133 fMinY = V(y->GetBinLowEdge(y->GetFirst()));
134 fStepY = V((y->GetBinUpEdge(y->GetLast()) - fMinY) / (y->GetNbins()));
135 fMinZ = V(z->GetBinLowEdge(z->GetFirst()));
136 fStepZ = V((z->GetBinUpEdge(z->GetLast()) - fMinZ) / (z->GetNbins()));
137
138 fMinX *= xs, fStepX *= xs;
139 fMinY *= ys, fStepY *= ys;
140 fMinZ *= zs, fStepZ *= zs;
141 }
142
143 fXScaleInverted = 1. / xs;
144 fYScaleInverted = 1. / ys;
145 fZScaleInverted = 1. / zs;
146 }
147
150
153
156
160};
161
162}//namespace Mc
163
164//Auxilary functions to draw an iso mesh in different modes.
165void DrawMesh(const std::vector<Float_t> &vs, const std::vector<Float_t> &ns,
166 const std::vector<UInt_t> &ts);
167void DrawMesh(const std::vector<Double_t> &vs, const std::vector<Double_t> &ns,
168 const std::vector<UInt_t> &ts);
169
170void DrawMesh(const std::vector<Float_t> &vs, const std::vector<UInt_t> &fTS);
171void DrawMesh(const std::vector<Double_t> &vs, const std::vector<UInt_t> &fTS);
172
173void DrawMesh(const std::vector<Float_t> &vs, const std::vector<Float_t> &ns,
174 const std::vector<UInt_t> &ts, const TGLBoxCut &box);
175void DrawMesh(const std::vector<Double_t> &vs, const std::vector<Double_t> &ns,
176 const std::vector<UInt_t> &ts, const TGLBoxCut &box);
177
178void DrawMesh(const std::vector<Float_t> &vs, const std::vector<UInt_t> &ts,
179 const TGLBoxCut &box);
180void DrawMesh(const std::vector<Double_t> &vs, const std::vector<UInt_t> &ts,
181 const TGLBoxCut &box);
182
183void DrawMesh(const std::vector<Double_t> &vs, const std::vector<UInt_t> &ts,
184 const TGLBoxCut &box);
185void DrawMesh(const std::vector<Float_t> &vs, const std::vector<UInt_t> &ts,
186 const TGLBoxCut &box);
187
188void DrawMapleMesh(const std::vector<Double_t> &vs, const std::vector<Double_t> &ns,
189 const std::vector<UInt_t> &ts);
190void DrawMapleMesh(const std::vector<Double_t> &vs, const std::vector<Double_t> &ns,
191 const std::vector<UInt_t> &ts, const TGLBoxCut & box);
192
193}//namespace Rgl
194
195#endif
unsigned int UInt_t
Definition RtypesCore.h:46
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
TGridGeometry(const TAxis *x, const TAxis *y, const TAxis *z, Double_t xs=1., Double_t ys=1., Double_t zs=1., EVertexPosition pos=kBinCenter)
Definition TGLIsoMesh.h:108
void Swap(TIsoMesh &rhs)
Definition TGLIsoMesh.h:67
void AddNormal(const V *n)
Definition TGLIsoMesh.h:50
UInt_t AddVertex(const V *v)
Definition TGLIsoMesh.h:40
UInt_t AddTriangle(const UInt_t *t)
Definition TGLIsoMesh.h:57
std::vector< V > fVerts
Definition TGLIsoMesh.h:81
std::vector< V > fNorms
Definition TGLIsoMesh.h:82
std::vector< UInt_t > fTris
Definition TGLIsoMesh.h:83
Class to manage histogram axis.
Definition TAxis.h:31
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Definition TAxis.cxx:478
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition TAxis.cxx:518
Int_t GetLast() const
Return last bin on the axis i.e.
Definition TAxis.cxx:469
Int_t GetNbins() const
Definition TAxis.h:125
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition TAxis.cxx:528
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition TAxis.cxx:458
Used by plot-painters to determine the area of the plot that is cut away.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
void DrawMapleMesh(const std::vector< Double_t > &vs, const std::vector< Double_t > &ns, const std::vector< UInt_t > &ts)
Colored mesh with lighting disabled.
void DrawMesh(const std::vector< Float_t > &vs, const std::vector< Float_t > &ns, const std::vector< UInt_t > &ts)
Call function-template.