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)
 
   42    DrawMesh(GL_FLOAT, vs, ns, ts);
 
   48 void DrawMesh(
const std::vector<Double_t> &vs, 
const std::vector<Double_t> &ns,
 
   49               const std::vector<UInt_t> &ts)
 
   51    DrawMesh(GL_DOUBLE, vs, ns, 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)
 
   71    DrawMesh(GL_FLOAT, vs, ts);
 
   77 void DrawMesh(
const std::vector<Double_t> &vs, 
const std::vector<UInt_t> &ts)
 
   79    DrawMesh(GL_DOUBLE, vs, 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];
 
   95       if (box.IsInCut(&vs[t[0] * 3]))
 
   97       if (box.IsInCut(&vs[t[1] * 3]))
 
   99       if (box.IsInCut(&vs[t[2] * 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,
 
  119               const std::vector<UInt_t> &ts, 
const TGLBoxCut &box)
 
  121    DrawMesh(&glNormal3fv, &glVertex3fv, vs,  ns, ts, box);
 
  127 void DrawMesh(
const std::vector<Double_t> &vs, 
const std::vector<Double_t> &ns,
 
  128               const std::vector<UInt_t> &ts, 
const TGLBoxCut &box)
 
  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,
 
  139               const TGLBoxCut &box)
 
  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]);
 
  163 void DrawMesh(
const std::vector<Float_t> &vs, 
const std::vector<UInt_t> &ts, 
const TGLBoxCut &box)
 
  165    DrawMesh(&glVertex3fv, vs, ts, box);
 
  171 void DrawMesh(
const std::vector<Double_t> &vs, 
const std::vector<UInt_t> &ts, 
const TGLBoxCut &box)
 
  173    DrawMesh(&glVertex3dv, vs, ts, box);
 
  179 void NormalToColor(Double_t *rfColor, 
const Double_t *n)
 
  181    const Double_t x = n[0];
 
  182    const Double_t y = n[1];
 
  183    const Double_t z = n[2];
 
  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];
 
  201       const Double_t * n = &ns[t[0] * 3];
 
  203       NormalToColor(color, n);
 
  205       glVertex3dv(&vs[t[0] * 3]);
 
  208       NormalToColor(color, n);
 
  210       glVertex3dv(&vs[t[1] * 3]);
 
  213       NormalToColor(color, n);
 
  215       glVertex3dv(&vs[t[2] * 3]);
 
  224 void DrawMapleMesh(
const std::vector<Double_t> &vs, 
const std::vector<Double_t> &ns,
 
  225                    const std::vector<UInt_t> &fTS, 
const TGLBoxCut & box)
 
  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]))
 
  239       const Double_t * n = &ns[t[0] * 3];
 
  241       NormalToColor(color, n);
 
  243       glVertex3dv(&vs[t[0] * 3]);
 
  246       NormalToColor(color, n);
 
  248       glVertex3dv(&vs[t[1] * 3]);
 
  251       NormalToColor(color, n);
 
  253       glVertex3dv(&vs[t[2] * 3]);