|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
9 #ifndef YARP_SIG_POINTCLOUD_H
10 #define YARP_SIG_POINTCLOUD_H
28 static_assert(std::is_same<T, DataXY>::value ||
29 std::is_same<T, DataXYZ>::value ||
30 std::is_same<T, DataNormal>::value ||
31 std::is_same<T, DataXYZRGBA>::value ||
32 std::is_same<T, DataXYZI>::value ||
33 std::is_same<T, DataInterestPointXYZ>::value ||
34 std::is_same<T, DataXYZNormal>::value ||
35 std::is_same<T, DataXYZNormalRGBA>::value,
"yarp::sig::PointCloud<T>: T chosen is not supported");
82 m_storage.resize(
width);
87 return m_storage.getMemoryBlock();
112 return m_storage.size();
123 return m_storage[u + v *
width()];
134 return m_storage[u + v *
width()];
179 size_t nr_points = m_storage.size();
180 m_storage.resize(nr_points + rhs.
size());
181 for (
size_t i = nr_points; i < m_storage.size(); ++i) {
182 m_storage[i] = rhs.m_storage[i - nr_points];
213 m_storage.push_back(pt);
259 if (std::is_same<T, T1>::value) {
272 bool ok = connection.
expectBlock((
char*)&_header,
sizeof(_header));
277 m_storage.resize(_header.height * _header.width);
278 std::memset((
void*)m_storage.data(), 0, m_storage.size() *
sizeof(T));
285 return m_storage.read(connection);
288 T* tmp = m_storage.data();
299 for (
size_t i = 0; i < m_storage.size(); i++) {
300 for (
size_t j = 0; j < recipe.size(); j++) {
304 connection.
expectBlock((
char*)&tmp[i] + offset, sizeToRead);
319 return m_storage.write(writer);
326 for (
size_t r = 0; r < this->
width(); r++) {
327 for (
size_t c = 0; c < this->
height(); c++) {
330 if (r < this->
width() - 1)
337 for (
size_t i = 0; i < this->
size(); i++) {
356 for (
size_t i = 0; i < this->
size(); i++) {
386 for (
size_t i = 0; i < this->
size(); i++) {
395 return BottleTagMap<T>();
403 if (std::is_same<T, DataXY>::value) {
408 if (std::is_same<T, DataXYZ>::value) {
413 if (std::is_same<T, DataNormal>::value) {
418 if (std::is_same<T, DataXYZRGBA>::value) {
423 if (std::is_same<T, DataXYZI>::value) {
428 if (std::is_same<T, DataInterestPointXYZ>::value) {
433 if (std::is_same<T, DataXYZNormal>::value) {
438 if (std::is_same<T, DataXYZNormalRGBA>::value) {
464 inline int BottleTagMap<yarp::sig::DataXY>()
470 inline int BottleTagMap<yarp::sig::DataXYZ>()
476 inline int BottleTagMap<yarp::sig::DataNormal>()
482 inline int BottleTagMap<yarp::sig::DataXYZRGBA>()
488 inline int BottleTagMap<yarp::sig::DataXYZI>()
494 inline int BottleTagMap<yarp::sig::DataInterestPointXYZ>()
500 inline int BottleTagMap<yarp::sig::DataXYZNormal>()
506 inline int BottleTagMap<yarp::sig::DataXYZNormalRGBA>()
512 #endif // YARP_SIG_POINTCLOUD_H
virtual void fromExternalPC(const char *source, int type, size_t width, size_t height, bool isDense=true)
Copy the content of an external PointCloud.
A simple collection of objects that can be described and transmitted in a portable way.
virtual std::vector< int > getComposition(int type_composite) const
virtual int getPointType() const
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data to the network connection.
size_type size() const
Gets the number of elements in the bottle.
contains the definition of a Vector type
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
size_t wireSizeBytes() const override
Get the size of the data + the header in terms of number of bytes.
const T & operator()(size_t u, size_t v) const
Obtain the point given by the (column, row) coordinates (const version).
virtual bool isDense() const
size_t size() const override
void copy(const PointCloud< T1 > &alt)
Copy operator.
yarp::os::Bottle toBottle() const
Generate a yarp::os::Bottle filled with the PointCloud data.
size_t dataSizeBytes() const override
Get the size of the data in terms of number of bytes.
@ PCL_POINT_XYZ_NORMAL_RGBA
PointCloud< T > & operator+=(const PointCloud< T > &rhs)
Concatenate a point cloud to the current cloud.
bool fromBottle(const yarp::os::Bottle &bt)
Populate the PointCloud from a yarp::os::Bottle.
const char * getRawData() const override
Get the pointer to the data.
bool allocateOnNeed(size_t neededLen, size_t allocateLen)
virtual void resize(size_t width, size_t height)
Resize the PointCloud.
const Bytes & bytes() const
virtual std::string toString(int precision=-1, int width=-1) const
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
An abstraction for a block of bytes, with optional responsibility for allocating/destroying that bloc...
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
The PointCloudBase class.
An interface for writing to a network connection.
PointCloud(const PointCloud< T1 > &alt)
PointCloud, copy constructor.
T & operator()(size_t u, size_t v)
Obtain the point given by the (column, row) coordinates.
void push_back(const T &pt)
Insert a new point in the cloud, at the end of the container.
yarp::sig::PointCloudNetworkHeader header
const PointCloud< T > & operator=(const PointCloud< T1 > &alt)
Assignment operator.
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
const PointCloud< T > operator+(const PointCloud< T > &rhs)
Concatenate a point cloud to another cloud.
virtual void copyFromRawData(const char *dst, const char *source, std::vector< int > &recipe)
bool write(yarp::os::ConnectionWriter &writer) const override
Write this object to a network connection.
virtual size_t pointType2Size(int type) const
bool isNull() const override
Checks if the object is invalid.
virtual void resize(size_t width)
Resize the PointCloud.
An interface for reading from a network connection.
#define BOTTLE_TAG_FLOAT64
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual size_t getOffset(int type_composite, int type_basic) const
virtual void clear()
Clear the data.
const T & operator()(size_t i) const
Obtain the point given by the index (const version).
virtual size_t height() const
The main, catch-all namespace for YARP.
virtual bool isOrganized() const
virtual size_t width() const
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
PointCloud()
PointCloud, default constructor.
T & operator()(size_t i)
Obtain the point given by the index.
int getBottleTag() const override