Logo ROOT  
Reference Guide
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 
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
ROOT::Experimental::REveRenderData::SizeT
int SizeT() const
Definition: REveRenderData.hxx:114
ROOT::Experimental::REveRenderData::GL_TRIANGLES
@ GL_TRIANGLES
Definition: REveRenderData.hxx:53
ROOT::Experimental::REveRenderData::SizeV
int SizeV() const
Definition: REveRenderData.hxx:111
ROOT::Experimental::REveRenderData::GL_LINE_STRIP
@ GL_LINE_STRIP
Definition: REveRenderData.hxx:53
ROOT::Experimental::REveRenderData::PushI
void PushI(int i)
Definition: REveRenderData.hxx:94
ROOT::Experimental::REveRenderData::PushV
void PushV(float x)
Definition: REveRenderData.hxx:60
ROOT::Experimental::REveRenderData::Primitive_e
Primitive_e
Definition: REveRenderData.hxx:53
x
Double_t x[n]
Definition: legend1.C:17
ROOT::Experimental::REveRenderData::GetRnrFunc
const std::string GetRnrFunc() const
Definition: REveRenderData.hxx:109
ROOT::Experimental::REveVectorT< Float_t >
v
@ v
Definition: rootcling_impl.cxx:3635
ROOT::Experimental::REveRenderData::fIndexBuffer
std::vector< int > fIndexBuffer
Definition: REveRenderData.hxx:47
ROOT::Experimental::REveRenderData::REveRenderData
REveRenderData()=default
ROOT::Experimental::REveRenderData::Write
int Write(char *msg, int maxlen)
Write render data to binary buffer.
Definition: REveRenderData.cxx:45
ROOT::Experimental::REveRenderData::fRnrFunc
std::string fRnrFunc
Definition: REveRenderData.hxx:44
ROOT::Experimental::REveRenderData::GL_LINES
@ GL_LINES
Definition: REveRenderData.hxx:53
ROOT::Experimental::REveRenderData::GL_LINE_LOOP
@ GL_LINE_LOOP
Definition: REveRenderData.hxx:53
ROOT::Experimental::REveRenderData::fNormalBuffer
std::vector< float > fNormalBuffer
Definition: REveRenderData.hxx:46
y
Double_t y[n]
Definition: legend1.C:17
ROOT::Experimental::REveRenderData::SizeN
int SizeN() const
Definition: REveRenderData.hxx:112
ROOT::Experimental::REveRenderData::fVertexBuffer
std::vector< float > fVertexBuffer
Definition: REveRenderData.hxx:45
ROOT::Experimental::REveRenderData::SetMatrix
void SetMatrix(const double *arr)
Set transformation matrix.
Definition: REveRenderData.cxx:76
ROOT::Experimental::REveRenderData::PushN
void PushN(float x)
Definition: REveRenderData.hxx:78
ROOT::Experimental::REveRenderData::GL_POINTS
@ GL_POINTS
Definition: REveRenderData.hxx:53
REveVector.hxx
ROOT::Experimental::REveRenderData::GetBinarySize
int GetBinarySize()
Definition: REveRenderData.hxx:116
ROOT::Experimental::REveRenderData::SizeI
int SizeI() const
Definition: REveRenderData.hxx:113
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Experimental::REveRenderData::fMatrix
std::vector< float > fMatrix
Definition: REveRenderData.hxx:48
int
ROOT::Experimental::REveRenderData::Reserve
void Reserve(int size_vert=0, int size_norm=0, int size_idx=0)
Reserve place for render data.
Definition: REveRenderData.cxx:32