Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
REveRenderData.hxx
Go to the documentation of this file.
1 // @(#)root/eve7:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007, 2018
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2019, 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 ROOT7_REveRenderData
13 #define ROOT7_REveRenderData
14 
15 #include <ROOT/REveVector.hxx>
16 
17 #include <string>
18 #include <vector>
19 
20 namespace ROOT {
21 namespace Experimental {
22 
23 class REveRenderData
24 {
25 private:
26  std::string fRnrFunc;
27  std::vector<float> fVertexBuffer;
28  std::vector<float> fNormalBuffer;
29  std::vector<int> fIndexBuffer;
30  std::vector<float> fMatrix;
31 
32 public:
33  // If Primitive_e is changed, change also definition in EveElements.js.
34 
35  enum Primitive_e { GL_POINTS = 0, GL_LINES, GL_LINE_LOOP, GL_LINE_STRIP, GL_TRIANGLES };
36 
37  REveRenderData() = default;
38  REveRenderData(const std::string &func, int size_vert = 0, int size_norm = 0, int size_idx = 0);
39 
40  void Reserve(int size_vert = 0, int size_norm = 0, int size_idx = 0);
41 
42  void PushV(float x) { fVertexBuffer.emplace_back(x); }
43 
44  void PushV(float x, float y, float z)
45  {
46  PushV(x);
47  PushV(y);
48  PushV(z);
49  }
50 
51  void PushV(const REveVectorF &v)
52  {
53  PushV(v.fX);
54  PushV(v.fY);
55  PushV(v.fZ);
56  }
57 
58  void PushV(float *v, int len) { fVertexBuffer.insert(fVertexBuffer.end(), v, v + len); }
59 
60  void PushN(float x) { fNormalBuffer.emplace_back(x); }
61 
62  void PushN(float x, float y, float z)
63  {
64  PushN(x);
65  PushN(y);
66  PushN(z);
67  }
68 
69  void PushN(const REveVectorF &v)
70  {
71  PushN(v.fX);
72  PushN(v.fY);
73  PushN(v.fZ);
74  }
75 
76  void PushI(int i) { fIndexBuffer.emplace_back(i); }
77 
78  void PushI(int i, int j, int k)
79  {
80  PushI(i);
81  PushI(j);
82  PushI(k);
83  }
84 
85  void PushI(int *v, int len) { fIndexBuffer.insert(fIndexBuffer.end(), v, v + len); }
86 
87  void PushI(std::vector<int> &v) { fIndexBuffer.insert(fIndexBuffer.end(), v.begin(), v.end()); }
88 
89  void SetMatrix(const double *arr);
90 
91  const std::string GetRnrFunc() const { return fRnrFunc; }
92 
93  int SizeV() const { return fVertexBuffer.size(); }
94  int SizeN() const { return fNormalBuffer.size(); }
95  int SizeI() const { return fIndexBuffer.size(); }
96  int SizeT() const { return fMatrix.size(); }
97 
98  int GetBinarySize() { return (SizeV() + SizeN() + SizeT()) * sizeof(float) + SizeI() * sizeof(int); }
99 
100  int Write(char *msg, int maxlen);
101 };
102 
103 } // namespace Experimental
104 } // namespace ROOT
105 
106 #endif