Class CPointCloud
Defined in File CPointCloud.h
Inheritance Relationships
Base Types
public mrpt::viz::CVisualObject(Class CVisualObject)public mrpt::viz::VisualObjectParams_Points(Class VisualObjectParams_Points)public mrpt::viz::PLY_Importer(Class PLY_Importer)public mrpt::viz::PLY_Exporter(Class PLY_Exporter)
Class Documentation
-
class CPointCloud : public virtual mrpt::viz::CVisualObject, public mrpt::viz::VisualObjectParams_Points, public mrpt::viz::PLY_Importer, public mrpt::viz::PLY_Exporter
A cloud of points, all with the same color or each depending on its value along a particular coordinate axis. This class is just an OpenGL representation of a point cloud. For operating with maps of points, see mrpt::maps::CPointsMap and derived classes.
To load from a points-map, CPointCloud::loadFromPointsMap().
This class uses smart optimizations while rendering to efficiently draw clouds of millions of points, using octrees.

See also
opengl::CPlanarLaserScan, mrpt::viz::Scene, mrpt::viz::CPointCloudColoured, mrpt::maps::CPointsMap
PLY Import virtual methods to implement in base classes
-
virtual void PLY_import_set_vertex_count(size_t N) override
In a base class, reserve memory to prepare subsequent calls to PLY_import_set_vertex
-
inline void PLY_import_set_vertex_timestamp([[maybe_unused]] size_t idx, [[maybe_unused]] const double unixTimestamp) override
-
inline void PLY_import_set_face_count([[maybe_unused]] size_t N) override
In a base class, reserve memory to prepare subsequent calls to PLY_import_set_face
-
virtual void PLY_import_set_vertex(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.
- Parameters:
pt_color – Will be nullptr if the loaded file does not provide color info.
PLY Export virtual methods to implement in base classes
-
virtual size_t PLY_export_get_vertex_count() const override
In a base class, return the number of vertices
-
inline virtual size_t PLY_export_get_face_count() const override
In a base class, return the number of faces
-
virtual void PLY_export_get_vertex(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.
- Parameters:
pt_color – Will be nullptr if the loaded file does not provide color info.
Read/Write of the list of points to render
-
inline size_t size() const
-
inline size_t size_unprotected() const
Like size(), but without locking the data mutex (internal usage)
-
inline void resize(size_t N)
Set the number of points (with contents undefined)
-
inline void reserve(size_t N)
Like STL std::vector’s reserve
-
template<typename T>
inline void setAllPoints(const std::vector<T> &x, const std::vector<T> &y, const std::vector<T> &z) Set the list of (X,Y,Z) point coordinates, all at once, from three vectors with their coordinates
-
void setAllPoints(const std::vector<mrpt::math::TPoint3D> &pts)
-
inline void setAllPointsFast(std::vector<mrpt::math::TPoint3Df> &pts)
Set the list of (X,Y,Z) point coordinates, DESTROYING the contents of the input vectors (via swap)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
-
inline const std::vector<mrpt::math::TPoint3Df> &getArrayPoints() const
Get a const reference to the internal array of points
-
void clear()
Empty the list of points.
-
inline bool empty() const
-
void insertPoint(float x, float y, float z)
Adds a new point to the cloud
-
inline void insertPoint(const mrpt::math::TPoint3Df &p)
-
inline void insertPoint(const mrpt::math::TPoint3D &p)
-
inline const mrpt::math::TPoint3Df &operator[](size_t i) const
Read access to each individual point (checks for “i” in the valid range only in Debug).
-
inline const mrpt::math::TPoint3Df &getPoint3Df(size_t i) const
NOTE: This method is intentionally not protected by the shared_mutex, since it’s called in the inner loops of the octree, which acquires the lock once.
-
void setPoint(size_t i, const float x, const float y, const float z)
Write an individual point (checks for “i” in the valid range only in Debug).
-
inline void setPoint_fast(size_t i, const float x, const float y, const float z)
Write an individual point (without checking validity of the index).
-
template<class POINTSMAP>
void loadFromPointsMap(const POINTSMAP *themap) Load the points from any other point map class supported by the adapter mrpt::viz::PointCloudAdapter.
-
template<class LISTOFPOINTS>
inline void loadFromPointsList(LISTOFPOINTS &pointsList) Load the points from a list of mrpt::math::TPoint3D
Modify the appearance of the rendered points
-
inline void enableColorFromX(bool v = true)
-
inline void enableColorFromY(bool v = true)
-
inline void enableColorFromZ(bool v = true)
-
void setGradientColors(const mrpt::img::TColorf &colorMin, const mrpt::img::TColorf &colorMax)
Sets the colors used as extremes when colorFromDepth is enabled.
Public Functions
-
CPointCloud()
Constructor
-
~CPointCloud() override = default
Private, virtual destructor: only can be deleted from smart pointers
-
virtual void toYAMLMap(mrpt::containers::yaml &propertiesMap) const override
Used from Scene::asYAML().
Note
(New in MRPT 2.4.2)
Protected Types
Protected Functions
-
void markAllPointsAsNew()
Do needed internal work if all points are new (octree rebuilt,…)
-
virtual auto internalBoundingBoxLocal() const -> mrpt::math::TBoundingBoxf override
Must be implemented by derived classes to provide the updated bounding box in the object local frame of coordinates. This will be called only once after each time the derived class reports to notifyChange() that the object geometry changed.
See also
getBoundingBox(), getBoundingBoxLocal(), getBoundingBoxLocalf()
Protected Attributes
-
Axis m_colorFromDepth = CPointCloud::colNone
-
std::vector<mrpt::math::TPoint3Df> &m_points = VisualObjectParams_Points::m_vertex_buffer_data
Actually, an alias for the base class shader container of points. Kept to have an easy to use name.
-
virtual void PLY_import_set_vertex_count(size_t N) override