50 void reserve(
size_t newLength)
override;
51 void resize(
size_t newLength)
override;
52 void setSize(
size_t newLength)
override;
64 const size_t index, std::vector<float>& point_data)
const override 67 point_data[0] =
m_x[index];
68 point_data[1] =
m_y[index];
69 point_data[2] =
m_z[index];
79 const size_t index,
const std::vector<float>& point_data)
override 81 ASSERT_(point_data.size() == 4);
82 m_x[index] = point_data[0];
83 m_y[index] = point_data[1];
84 m_z[index] = point_data[2];
110 const CPointsMap& anotherMap,
const size_t nPreviousPoints)
override;
113 template <
class Derived>
115 template <
class Derived>
134 size_t index,
float x,
float y,
float z,
float R_intensity,
135 float G_ignored,
float B_ignored)
override;
140 float x,
float y,
float z,
float R_intensity,
float G_ignored,
141 float B_ignored)
override;
157 size_t index,
float& x,
float& y,
float& z,
float& R_intensity,
158 float& G_intensity,
float& B_intensity)
const override;
183 #if defined(PCL_LINEAR_VERSION) 184 inline bool savePCDFile(
185 const std::string& filename,
bool save_as_binary)
const 187 pcl::PointCloud<pcl::PointXYZI> cloud;
189 const size_t nThis = this->
size();
194 cloud.is_dense =
false;
195 cloud.points.resize(cloud.width * cloud.height);
197 for (
size_t i = 0; i < nThis; ++i)
199 cloud.points[i].x =
m_x[i];
200 cloud.points[i].y =
m_y[i];
201 cloud.points[i].z =
m_z[i];
205 return 0 == pcl::io::savePCDFile(filename, cloud, save_as_binary);
219 template <
class POINTCLOUD>
222 const size_t N = cloud.points.size();
225 for (
size_t i = 0; i < N; ++i)
227 const auto& pt = cloud.points[i];
237 template <
class POINTCLOUD>
240 const size_t nThis = this->
size();
243 for (
size_t i = 0; i < nThis; ++i)
280 #include <mrpt/opengl/pointcloud_adapters.h> 296 static constexpr
bool HAS_RGB =
true;
298 static constexpr
bool HAS_RGBf =
true;
300 static constexpr
bool HAS_RGBu8 =
false;
308 inline size_t size()
const {
return m_obj.
size(); }
314 template <
typename T>
327 template <
typename T>
329 const size_t idx, T& x, T& y, T& z,
float& r,
float& g,
float& b,
338 const float r,
const float g,
const float b,
339 [[maybe_unused]]
const float a)
345 template <
typename T>
347 const size_t idx, T& x, T& y, T& z, uint8_t& r, uint8_t& g,
350 float I, Gignrd, Bignrd;
351 m_obj.
getPoint(idx, x, y, z, I, Gignrd, Bignrd);
357 const uint8_t r,
const uint8_t g,
const uint8_t b)
359 m_obj.
setPointRGB(idx, x, y, z, r / 255.f, g / 255.f, b / 255.f);
364 const size_t idx,
float& r,
float& g,
float& b)
const 370 const size_t idx,
const float r,
const float g,
const float b)
377 const size_t idx, uint8_t& r, uint8_t& g, uint8_t& b)
const 384 const size_t idx,
const uint8_t r,
const uint8_t g,
const uint8_t b)
void clear()
Erase all the contents of the map.
void setPointRGB(size_t index, float x, float y, float z, float R_intensity, float G_ignored, float B_ignored) override
Changes a given point from map.
PointCloudAdapter(const mrpt::maps::CPointsMapXYZI &obj)
Constructor (accept a const ref for convenience)
void getPoint(size_t index, float &x, float &y, float &z) const
Access to a given point from map, as a 2D point.
void getPointXYZ(const size_t idx, T &x, T &y, T &z) const
Get XYZ coordinates of i'th point.
void getPointFast(size_t index, float &x, float &y, float &z) const
Just like getPoint() but without checking out-of-bound index and without returning the point weight...
void PLY_export_get_vertex(const size_t idx, mrpt::math::TPoint3Df &pt, bool &pt_has_color, mrpt::img::TColorf &pt_color) const override
In a base class, will be called after PLY_export_get_vertex_count() once for each exported point...
void setSize(size_t newLength) override
Resizes all point buffers so they can hold the given number of points, erasing all previous contents ...
CPointsMap & operator=(const CPointsMap &o)
size_t size() const
Get number of points.
bool loadXYZI_from_text_file(const std::string &file)
Loads from a text file, each line having "X Y Z I", I in [0,1].
void PLY_import_set_vertex(const size_t idx, const mrpt::math::TPoint3Df &pt, const mrpt::img::TColorf *pt_color=nullptr) override
In a base class, will be called after PLY_import_set_vertex_count() once for each loaded point...
CPointsMapXYZI(const CPointsMap &o)
bool hasColorPoints() const override
Returns true if the point map has a color field for each point.
void setPointAllFieldsFast(const size_t index, const std::vector< float > &point_data) override
Set all the data fields for one point as a vector: [X Y Z I] Unlike setPointAllFields(), this method does not check for index out of bounds.
mrpt::aligned_std_vector< float > m_intensity
The intensity/reflectance data.
void setPointXYZ(const size_t idx, const coords_t x, const coords_t y, const coords_t z)
Set XYZ coordinates of i'th point.
#define MAP_DEFINITION_START(_CLASS_NAME_)
Add a MAP_DEFINITION_START() ...
void setFromPCLPointCloudXYZI(const POINTCLOUD &cloud)
Save the point cloud as a PCL PCD file, in either ASCII or binary format.
void setDimensions(size_t, size_t)
Does nothing as of now.
void resize(const size_t N)
Set number of points (to uninitialized values)
A range or depth 3D scan measurement, as from a time-of-flight range camera or a structured-light dep...
void getPointXYZ_RGBAf(const size_t idx, T &x, T &y, T &z, float &r, float &g, float &b, float &a) const
Get XYZ_RGBf coordinates of i'th point.
void getPCLPointCloudXYZI(POINTCLOUD &cloud) const
Like CPointsMap::getPCLPointCloud() but for PointCloud<PointXYZI>
void setPointIntensity(size_t index, float intensity)
Changes the intensity of a given point from the map.
std::vector< T, mrpt::aligned_allocator_cpp11< T > > aligned_std_vector
void internal_clear() override
Clear the map, erasing all the points.
void setPointRGBf(const size_t idx, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i'th point.
bool loadFromKittiVelodyneFile(const std::string &filename)
Loads from a Kitti dataset Velodyne scan binary file.
void addFrom_classSpecific(const CPointsMap &anotherMap, const size_t nPreviousPoints) override
Auxiliary method called from within addFrom() automatically, to finish the copying of class-specific ...
#define ASSERT_(f)
Defines an assertion mechanism.
With this struct options are provided to the observation insertion process.
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors...
void setPointXYZ_RGBu8(const size_t idx, const coords_t x, const coords_t y, const coords_t z, const uint8_t r, const uint8_t g, const uint8_t b)
Set XYZ_RGBu8 coordinates of i'th point.
void impl_copyFrom(const CPointsMap &obj) override
Virtual assignment operator, copies as much common data (XYZ, color,...) as possible from the source ...
void PLY_import_set_vertex_count(const size_t N) override
In a base class, reserve memory to prepare subsequent calls to PLY_import_set_vertex.
An adapter to different kinds of point cloud object.
void resize(size_t newLength) override
Resizes all point buffers so they can hold the given number of points: newly created points are set t...
float getPointIntensity_fast(size_t index) const
Like getPointColor but without checking for out-of-index erors.
void getPointRGB(size_t index, float &x, float &y, float &z, float &R_intensity, float &G_intensity, float &B_intensity) const override
Retrieves a point and its color (colors range is [0,1])
mrpt::maps::CPointsMapXYZI & m_obj
void getPointXYZ_RGBu8(const size_t idx, T &x, T &y, T &z, uint8_t &r, uint8_t &g, uint8_t &b) const
Get XYZ_RGBu8 coordinates of i'th point.
void getPCLPointCloud(POINTCLOUD &cloud) const
Use to convert this MRPT point cloud object into a PCL point cloud object (PointCloud<PointXYZ>).
void setPointFast(size_t index, float x, float y, float z)
Changes the coordinates of the given point (0-based index), without checking for out-of-bounds and wi...
void loadFromRangeScan(const mrpt::obs::CObservation2DRangeScan &rangeScan, const mrpt::poses::CPose3D *robotPose=nullptr) override
See CPointsMap::loadFromRangeScan()
void setPointRGBu8(const size_t idx, const uint8_t r, const uint8_t g, const uint8_t b)
Set RGBu8 coordinates of i'th point.
void insertPointRGB(float x, float y, float z, float R_intensity, float G_ignored, float B_ignored) override
Adds a new point given its coordinates and color (colors range is [0,1])
A map of 3D points with reflectance/intensity (float).
CPointsMapXYZI & operator=(const CPointsMapXYZI &o)
mrpt::aligned_std_vector< float > m_z
float getPointIntensity(size_t index) const
Retrieves a point intensity (range [0,1])
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
void mark_as_modified() const
Users normally don't need to call this.
mrpt::aligned_std_vector< float > m_y
bool saveToKittiVelodyneFile(const std::string &filename) const
void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr &outObj) const override
Override of the default 3D scene builder to account for the individual points' color.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Options used when evaluating "computeObservationLikelihood" in the derived classes.
An RGBA color - floats in the range [0,1].
void getPointRGBf(const size_t idx, float &r, float &g, float &b) const
Get RGBf color of i'th point.
float coords_t
The type of each point XYZ coordinates.
CPointsMapXYZI & operator=(const CPointsMap &o)
void getPointRGBu8(const size_t idx, uint8_t &r, uint8_t &g, uint8_t &b) const
Get RGBu8 color of i'th point.
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
void getPointAllFieldsFast(const size_t index, std::vector< float > &point_data) const override
Get all the data fields for one point as a vector: [X Y Z I] Unlike getPointAllFields(), this method does not check for index out of bounds.
void insertPointFast(float x, float y, float z=0) override
The virtual method for insertPoint() without calling mark_as_modified()
CPointsMapXYZI(const CPointsMapXYZI &o)
mrpt::aligned_std_vector< float > m_x
The point coordinates.
#define MAP_DEFINITION_END(_CLASS_NAME_)
size_t size() const
Save the point cloud as a PCL PCD file, in either ASCII or binary format.
void setPointColor_fast(size_t index, float R, float G, float B)
Like setPointColor but without checking for out-of-index erors.
bool saveXYZI_to_text_file(const std::string &file) const
Save to a text file.
void setPointXYZ_RGBAf(const size_t idx, const coords_t x, const coords_t y, const coords_t z, const float r, const float g, const float b, [[maybe_unused]] const float a)
Set XYZ_RGBf coordinates of i'th point.
void reserve(size_t newLength) override
Reserves memory for a given number of points: the size of the map does not change, it only reserves the memory.