24 void DrawMesh(GLenum
type,
const std::vector<V> &vs,
const std::vector<V> &ns,
25 const std::vector<UInt_t> &fTS)
27 glEnableClientState(GL_VERTEX_ARRAY);
28 glEnableClientState(GL_NORMAL_ARRAY);
29 glVertexPointer(3, type, 0, &vs[0]);
30 glNormalPointer(type, 0, &ns[0]);
31 glDrawElements(GL_TRIANGLES, fTS.size(), GL_UNSIGNED_INT, &fTS[0]);
32 glDisableClientState(GL_NORMAL_ARRAY);
33 glDisableClientState(GL_VERTEX_ARRAY);
39 void DrawMesh(
const std::vector<Float_t> &vs,
const std::vector<Float_t> &ns,
40 const std::vector<UInt_t> &ts)
48 void DrawMesh(
const std::vector<Double_t> &vs,
const std::vector<Double_t> &ns,
49 const std::vector<UInt_t> &ts)
58 void DrawMesh(GLenum
type,
const std::vector<V> &vs,
const std::vector<UInt_t> &fTS)
60 glEnableClientState(GL_VERTEX_ARRAY);
61 glVertexPointer(3, type, 0, &vs[0]);
62 glDrawElements(GL_TRIANGLES, fTS.size(), GL_UNSIGNED_INT, &fTS[0]);
63 glDisableClientState(GL_VERTEX_ARRAY);
69 void DrawMesh(
const std::vector<Float_t> &vs,
const std::vector<UInt_t> &ts)
77 void DrawMesh(
const std::vector<Double_t> &vs,
const std::vector<UInt_t> &ts)
86 template<
class V,
class GLN,
class GLV>
87 void DrawMesh(GLN normal3, GLV vertex3,
const std::vector<V> &vs,
88 const std::vector<V> &ns,
const std::vector<UInt_t> &fTS,
91 glBegin(GL_TRIANGLES);
93 for (
UInt_t i = 0, e = fTS.size() / 3; i < e; ++i) {
94 const UInt_t * t = &fTS[i * 3];
102 normal3(&ns[t[0] * 3]);
103 vertex3(&vs[t[0] * 3]);
105 normal3(&ns[t[1] * 3]);
106 vertex3(&vs[t[1] * 3]);
108 normal3(&ns[t[2] * 3]);
109 vertex3(&vs[t[2] * 3]);
118 void DrawMesh(
const std::vector<Float_t> &vs,
const std::vector<Float_t> &ns,
121 DrawMesh(&glNormal3fv, &glVertex3fv, vs, ns, ts, box);
127 void DrawMesh(
const std::vector<Double_t> &vs,
const std::vector<Double_t> &ns,
130 DrawMesh(&glNormal3dv, &glVertex3dv, vs, ns, ts, box);
137 template<
class V,
class GLV>
138 void DrawMesh(GLV vertex3,
const std::vector<V> &vs,
const std::vector<UInt_t> &fTS,
141 glBegin(GL_TRIANGLES);
143 for (
UInt_t i = 0, e = fTS.size() / 3; i < e; ++i) {
144 const UInt_t * t = &fTS[i * 3];
145 if (box.
IsInCut(&vs[t[0] * 3]))
147 if (box.
IsInCut(&vs[t[1] * 3]))
149 if (box.
IsInCut(&vs[t[2] * 3]))
152 vertex3(&vs[t[0] * 3]);
153 vertex3(&vs[t[1] * 3]);
154 vertex3(&vs[t[2] * 3]);
165 DrawMesh(&glVertex3fv, vs, ts, box);
173 DrawMesh(&glVertex3dv, vs, ts, box);
184 rfColor[0] = (x > 0. ? x : 0.) + (y < 0. ? -0.5 * y : 0.) + (z < 0. ? -0.5 * z : 0.);
185 rfColor[1] = (y > 0. ? y : 0.) + (z < 0. ? -0.5 * z : 0.) + (x < 0. ? -0.5 * x : 0.);
186 rfColor[2] = (z > 0. ? z : 0.) + (x < 0. ? -0.5 * x : 0.) + (y < 0. ? -0.5 * y : 0.);
192 void DrawMapleMesh(
const std::vector<Double_t> &vs,
const std::vector<Double_t> &ns,
193 const std::vector<UInt_t> &fTS)
195 Double_t color[] = {0., 0., 0., 0.15};
197 glBegin(GL_TRIANGLES);
199 for (
UInt_t i = 0, e = fTS.size() / 3; i < e; ++i) {
200 const UInt_t *t = &fTS[i * 3];
205 glVertex3dv(&vs[t[0] * 3]);
210 glVertex3dv(&vs[t[1] * 3]);
215 glVertex3dv(&vs[t[2] * 3]);
224 void DrawMapleMesh(
const std::vector<Double_t> &vs,
const std::vector<Double_t> &ns,
227 Double_t color[] = {0., 0., 0., 0.15};
229 glBegin(GL_TRIANGLES);
231 for (
UInt_t i = 0, e = fTS.size() / 3; i < e; ++i) {
232 const UInt_t *t = &fTS[i * 3];
233 if (box.
IsInCut(&vs[t[0] * 3]))
235 if (box.
IsInCut(&vs[t[1] * 3]))
237 if (box.
IsInCut(&vs[t[2] * 3]))
243 glVertex3dv(&vs[t[0] * 3]);
248 glVertex3dv(&vs[t[1] * 3]);
253 glVertex3dv(&vs[t[2] * 3]);
void NormalToColor(Double_t *rfColor, const Double_t *n)
NormalToColor generates a color from a given normal.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
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.
Bool_t IsInCut(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax) const
Check, if box defined by xmin/xmax etc. is in cut.
Used by plot-painters to determine the area of the plot that is cut away.
void DrawMesh(const std::vector< Float_t > &vs, const std::vector< Float_t > &ns, const std::vector< UInt_t > &ts)
Call function-template.