6#ifndef YARP_SIG_POINTCLOUD_H
7#define YARP_SIG_POINTCLOUD_H
23 static_assert(std::is_same<T, DataXY>::value ||
24 std::is_same<T, DataXYZ>::value ||
25 std::is_same<T, DataNormal>::value ||
26 std::is_same<T, DataXYZRGBA>::value ||
27 std::is_same<T, DataXYZI>::value ||
28 std::is_same<T, DataInterestPointXYZ>::value ||
29 std::is_same<T, DataXYZNormal>::value ||
30 std::is_same<T, DataXYZNormalRGBA>::value,
"yarp::sig::PointCloud<T>: T chosen is not supported");
77 m_storage.resize(
width);
82 return m_storage.getMemoryBlock();
107 return m_storage.size();
118 return m_storage[u + v *
width()];
129 return m_storage[u + v *
width()];
174 size_t nr_points = m_storage.size();
175 m_storage.resize(nr_points + rhs.
size());
176 for (
size_t i = nr_points; i < m_storage.size(); ++i) {
177 m_storage[i] = rhs.m_storage[i - nr_points];
208 m_storage.push_back(pt);
254 if (std::is_same<T, T1>::value) {
267 bool ok = connection.
expectBlock((
char*)&_header,
sizeof(_header));
273 std::memset((
void*)m_storage.data(), 0, m_storage.size() *
sizeof(T));
280 return m_storage.read(connection);
283 T* tmp = m_storage.data();
294 for (
size_t i = 0; i < m_storage.size(); i++) {
295 for (
size_t j = 0; j < recipe.size(); j++) {
299 connection.
expectBlock((
char*)&tmp[i] + offset, sizeToRead);
314 return m_storage.write(writer);
321 for (
size_t r = 0; r < this->
width(); r++) {
322 for (
size_t c = 0; c < this->
height(); c++) {
325 if (r < this->
width() - 1)
332 for (
size_t i = 0; i < this->
size(); i++) {
351 for (
size_t i = 0; i < this->
size(); i++) {
381 for (
size_t i = 0; i < this->
size(); i++) {
390 return BottleTagMap<T>();
398 if (std::is_same<T, DataXY>::value) {
403 if (std::is_same<T, DataXYZ>::value) {
408 if (std::is_same<T, DataNormal>::value) {
413 if (std::is_same<T, DataXYZRGBA>::value) {
418 if (std::is_same<T, DataXYZI>::value) {
423 if (std::is_same<T, DataInterestPointXYZ>::value) {
428 if (std::is_same<T, DataXYZNormal>::value) {
433 if (std::is_same<T, DataXYZNormalRGBA>::value) {
#define BOTTLE_TAG_FLOAT64
int BottleTagMap< yarp::sig::DataXYZ >()
int BottleTagMap< yarp::sig::DataXYZRGBA >()
int BottleTagMap< yarp::sig::DataXYZNormalRGBA >()
int BottleTagMap< yarp::sig::DataXYZNormal >()
int BottleTagMap< yarp::sig::DataNormal >()
int BottleTagMap< yarp::sig::DataXYZI >()
int BottleTagMap< yarp::sig::DataXY >()
int BottleTagMap< yarp::sig::DataInterestPointXYZ >()
contains the definition of a Vector type
A simple collection of objects that can be described and transmitted in a portable way.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
bool isNull() const override
Checks if the object is invalid.
An interface for reading from a network connection.
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
An interface for writing to a network connection.
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data to the network connection.
An abstraction for a block of bytes, with optional responsibility for allocating/destroying that bloc...
const Bytes & bytes() const
bool allocateOnNeed(size_t neededLen, size_t allocateLen)
virtual std::int32_t asInt32() const
Get 32-bit integer value.
The PointCloudBase class.
yarp::sig::PointCloudNetworkHeader header
virtual std::vector< int > getComposition(int type_composite) const
virtual size_t width() const
virtual bool isDense() const
virtual void copyFromRawData(const char *dst, const char *source, std::vector< int > &recipe)
virtual bool isOrganized() const
virtual int getPointType() const
virtual size_t height() const
virtual size_t pointType2Size(int type) const
virtual size_t getOffset(int type_composite, int type_basic) const
const char * getRawData() const override
Get the pointer to the data.
const PointCloud< T > & operator=(const PointCloud< T1 > &alt)
Assignment operator.
virtual void fromExternalPC(const char *source, int type, size_t width, size_t height, bool isDense=true)
Copy the content of an external PointCloud.
const T & operator()(size_t i) const
Obtain the point given by the index (const version).
const PointCloud< T > operator+(const PointCloud< T > &rhs)
Concatenate a point cloud to another cloud.
bool fromBottle(const yarp::os::Bottle &bt)
Populate the PointCloud from a yarp::os::Bottle.
T & operator()(size_t u, size_t v)
Obtain the point given by the (column, row) coordinates.
T & operator()(size_t i)
Obtain the point given by the index.
void push_back(const T &pt)
Insert a new point in the cloud, at the end of the container.
virtual std::string toString(int precision=-1, int width=-1) const
PointCloud()
PointCloud, default constructor.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
const T & operator()(size_t u, size_t v) const
Obtain the point given by the (column, row) coordinates (const version).
PointCloud(const PointCloud< T1 > &alt)
PointCloud, copy constructor.
yarp::os::Bottle toBottle() const
Generate a yarp::os::Bottle filled with the PointCloud data.
int getBottleTag() const override
virtual void resize(size_t width)
Resize the PointCloud.
PointCloud< T > & operator+=(const PointCloud< T > &rhs)
Concatenate a point cloud to the current cloud.
virtual void clear()
Clear the data.
bool write(yarp::os::ConnectionWriter &writer) const override
Write this object to a network connection.
virtual void resize(size_t width, size_t height)
Resize the PointCloud.
size_t dataSizeBytes() const override
Get the size of the data in terms of number of bytes.
void copy(const PointCloud< T1 > &alt)
Copy operator.
size_t wireSizeBytes() const override
Get the size of the data + the header in terms of number of bytes.
size_t size() const override
@ PCL_POINT_XYZ_NORMAL_RGBA