Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveRenderData.cxx
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
13#include <ROOT/REveUtil.hxx>
14
15#include <cstdio>
16#include <cstring>
17
18using namespace ROOT::Experimental;
19
20/////////////////////////////////////////////////////////////////////////////////////////
21/// Constructor
22
23REveRenderData::REveRenderData(const std::string &func, int size_vert, int size_norm, int size_idx) :
24 fRnrFunc(func)
25{
26 Reserve(size_vert, size_norm, size_idx);
27}
28
29/////////////////////////////////////////////////////////////////////////////////////////
30/// Reserve place for render data
31
32void REveRenderData::Reserve(int size_vert, int size_norm, int size_idx)
33{
34 if (size_vert > 0)
35 fVertexBuffer.reserve(size_vert);
36 if (size_norm > 0)
37 fNormalBuffer.reserve(size_norm);
38 if (size_idx > 0)
39 fIndexBuffer.reserve(size_idx);
40}
41
42/////////////////////////////////////////////////////////////////////////////////////////
43/// Write render data to binary buffer
44
45int REveRenderData::Write(char *msg, int maxlen)
46{
47 static const REveException eh("REveRenderData::Write ");
48
49 int off{0};
50
51 auto append = [&](void *buf, int len) {
52 if (off + len > maxlen)
53 throw eh + "output buffer does not have enough memory";
54 memcpy(msg + off, buf, len);
55 off += len;
56 };
57
58 if (!fMatrix.empty())
59 append(&fMatrix[0], fMatrix.size() * sizeof(float));
60
61 if (!fVertexBuffer.empty())
62 append(&fVertexBuffer[0], fVertexBuffer.size() * sizeof(float));
63
64 if (!fNormalBuffer.empty())
65 append(&fNormalBuffer[0], fNormalBuffer.size() * sizeof(float));
66
67 if (!fIndexBuffer.empty())
68 append(&fIndexBuffer[0], fIndexBuffer.size() * sizeof(int));
69
70 return off;
71}
72
73/////////////////////////////////////////////////////////////////////////////////////////
74/// Set transformation matrix
75
76void REveRenderData::SetMatrix(const double *arr)
77{
78 fMatrix.reserve(16);
79 for (int i = 0; i < 16; ++i) {
80 fMatrix.push_back(arr[i]);
81 }
82}
REveException Exception-type thrown by Eve classes.
Definition REveTypes.hxx:41
void Reserve(int size_vert=0, int size_norm=0, int size_idx=0)
Reserve place for render data.
int Write(char *msg, int maxlen)
Write render data to binary buffer.
void SetMatrix(const double *arr)
Set transformation matrix.