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 
lvr2::floatArr
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
lvr2::FloatChannelPtr
FloatChannel::Ptr FloatChannelPtr
Definition: Channel.hpp:89
lvr2::PointBuffer::getColorArray
ucharArr getColorArray(size_t &w)
Definition: PointBuffer.cpp:97
lvr2::Channel::Optional
boost::optional< Channel< T > > Optional
Definition: Channel.hpp:45
lvr2::PointBuffer::PointBuffer
PointBuffer()
Definition: PointBuffer.cpp:36
lvr2::UCharChannelPtr
UCharChannel::Ptr UCharChannelPtr
Definition: Channel.hpp:97
lvr2::PointBuffer::hasNormals
bool hasNormals() const
True, if buffer has normals.
Definition: PointBuffer.cpp:116
lvr2::PointBuffer::setColorArray
void setColorArray(ucharArr colors, size_t n, size_t width=3)
Definition: PointBuffer.cpp:69
lvr2::PointBuffer
A class to handle point information with an arbitrarily large number of attribute channels....
Definition: PointBuffer.hpp:51
lvr2::PointBuffer::clone
PointBuffer clone() const
Makes a clone.
Definition: PointBuffer.cpp:136
lvr2::PointBuffer::getNormalArray
floatArr getNormalArray()
Definition: PointBuffer.cpp:86
lvr2::PointBuffer::setNormalArray
void setNormalArray(floatArr normals, size_t n)
Definition: PointBuffer.cpp:64
PointBuffer.hpp
lvr2::PointBuffer::getPointArray
floatArr getPointArray()
Returns the internal point array.
Definition: PointBuffer.cpp:75
lvr2::BaseBuffer
ChannelManager class Store and access AttributeChannels. It expands the MultiChannelMap with downwoar...
Definition: BaseBuffer.hpp:54
lvr2::Channel::dataPtr
const DataPtr dataPtr() const
lvr2::BaseBuffer::addUCharChannel
void addUCharChannel(UCharChannelPtr data, const std::string &name)
Adds an uchar channel pointer to the map.
Definition: BaseBuffer.hpp:169
scripts.create_png.colors
colors
Definition: create_png.py:41
lvr2::PointBuffer::setPointArray
void setPointArray(floatArr points, size_t n)
Definition: PointBuffer.cpp:58
lvr2::PointBuffer::numPoints
size_t numPoints() const
Returns the number of points in the buffer.
Definition: PointBuffer.cpp:121
lvr2::Channel
Definition: Channel.hpp:42
lvr2::PointBuffer::hasColors
bool hasColors() const
True, if buffer contains colors.
Definition: PointBuffer.cpp:111
lvr2::FloatChannel
Channel< float > FloatChannel
Definition: Channel.hpp:87
lvr2::ucharArr
boost::shared_array< unsigned char > ucharArr
Definition: DataStruct.hpp:137
lvr2
Definition: BaseBufferManipulators.hpp:39
Timestamp.hpp
lvr2::BaseBuffer::addFloatChannel
void addFloatChannel(FloatChannelPtr data, const std::string &name)
Adds a float channel pointer to the map.
Definition: BaseBuffer.hpp:159
lvr2::Channel::width
size_t width() const
lvr2::UCharChannel
Channel< unsigned char > UCharChannel
Definition: Channel.hpp:95
lvr2::Channel::numElements
size_t numElements() const


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 Wed Mar 2 2022 00:37:24