PointBuffer.cpp
Go to the documentation of this file.
1 
28 #include "lvr2/io/PointBuffer.hpp"
29 #include "lvr2/io/Timestamp.hpp"
30 
31 #include <iostream>
32 
33 namespace lvr2
34 {
35 
37 :base()
38 {
39 
40 }
41 
43 {
44  // Generate channel object pointer and add it
45  // to channel map
46  FloatChannelPtr point_data(new FloatChannel(n, 3, points));
47  this->addFloatChannel(point_data, "points");
48 
49 }
50 
51 PointBuffer::PointBuffer(floatArr points, floatArr normals, size_t n) : PointBuffer(points, n)
52 {
53  // Add normal data
54  FloatChannelPtr normal_data(new FloatChannel(n, 3, points));
55  this->addFloatChannel(normal_data, "normals");
56 }
57 
58 void PointBuffer::setPointArray(floatArr points, size_t n)
59 {
60  FloatChannelPtr pts(new FloatChannel(n, 3, points));
61  this->addFloatChannel(pts, "points");
62 }
63 
64 void PointBuffer::setNormalArray(floatArr normals, size_t n)
65 {
66  FloatChannelPtr nmls(new FloatChannel(n, 3, normals));
67  this->addFloatChannel(nmls, "normals");
68 }
69 void PointBuffer::setColorArray(ucharArr colors, size_t n, size_t width)
70 {
71  UCharChannelPtr cls(new UCharChannel(n, width, colors));
72  this->addUCharChannel(cls, "colors");
73 }
74 
76 {
77  typename Channel<float>::Optional opt = getChannel<float>("points");
78  if(opt)
79  {
80  return opt->dataPtr();
81  }
82 
83  return floatArr();
84 }
85 
87 {
88  typename Channel<float>::Optional opt = getChannel<float>("normals");
89  if(opt)
90  {
91  return opt->dataPtr();
92  }
93 
94  return floatArr();
95 }
96 
98 {
99  w = 0;
100  typename Channel<unsigned char>::Optional opt = getChannel<unsigned char>("colors");
101  if(opt)
102  {
103  w = opt->width();
104  return opt->dataPtr();
105  }
106 
107  return ucharArr();
108 }
109 
110 
112 {
113  return hasChannel<unsigned char>("colors");
114 }
115 
117 {
118  return hasChannel<float>("normals");
119 }
120 
122 {
123  const typename Channel<float>::Optional opt = getChannel<float>("points");
124  if(opt)
125  {
126  return opt->numElements();
127  }
128  else
129  {
130  return 0;
131  }
132 
133 }
134 
135 
137 {
138  PointBuffer pb;
139 
140  for(const auto& elem : *this)
141  {
142  pb.insert({elem.first, elem.second.clone()});
143  }
144 
145  return pb;
146 
147 }
148 
149 
150 
151 }
152 
153 
A class to handle point information with an arbitrarily large number of attribute channels...
Definition: PointBuffer.hpp:51
bool hasNormals() const
True, if buffer has normals.
void setNormalArray(floatArr normals, size_t n)
Definition: PointBuffer.cpp:64
size_t width() const
floatArr getNormalArray()
Definition: PointBuffer.cpp:86
bool hasColors() const
True, if buffer contains colors.
const DataPtr dataPtr() const
boost::shared_array< unsigned char > ucharArr
Definition: DataStruct.hpp:137
void addFloatChannel(FloatChannelPtr data, const std::string &name)
Adds a float channel pointer to the map.
Definition: BaseBuffer.hpp:159
Channel< float > FloatChannel
Definition: Channel.hpp:87
ucharArr getColorArray(size_t &w)
Definition: PointBuffer.cpp:97
void setPointArray(floatArr points, size_t n)
Definition: PointBuffer.cpp:58
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
void addUCharChannel(UCharChannelPtr data, const std::string &name)
Adds an uchar channel pointer to the map.
Definition: BaseBuffer.hpp:169
size_t numPoints() const
Returns the number of points in the buffer.
Channel< unsigned char > UCharChannel
Definition: Channel.hpp:95
boost::optional< Channel< T > > Optional
Definition: Channel.hpp:45
floatArr getPointArray()
Returns the internal point array.
Definition: PointBuffer.cpp:75
UCharChannel::Ptr UCharChannelPtr
Definition: Channel.hpp:97
PointBuffer clone() const
Makes a clone.
void setColorArray(ucharArr colors, size_t n, size_t width=3)
Definition: PointBuffer.cpp:69
FloatChannel::Ptr FloatChannelPtr
Definition: Channel.hpp:89
size_t numElements() const
ChannelManager class Store and access AttributeChannels. It expands the MultiChannelMap with downwoar...
Definition: BaseBuffer.hpp:54


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:08