class mrpt::viz::CPointCloud

Overview

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.

mrpt::viz::CPointCloud

See also:

opengl::CPlanarLaserScan, mrpt::viz::Scene, mrpt::viz::CPointCloudColoured, mrpt::maps::CPointsMap

#include <mrpt/viz/CPointCloud.h>

class CPointCloud:
    public mrpt::viz::CVisualObject,
    public mrpt::viz::VisualObjectParams_Points,
    public mrpt::viz::PLY_Importer,
    public mrpt::viz::PLY_Exporter
{
public:
    // typedefs

    typedef std::shared_ptr<mrpt::viz ::CPointCloud> Ptr;
    typedef std::shared_ptr<const mrpt::viz ::CPointCloud> ConstPtr;
    typedef std::unique_ptr<mrpt::viz ::CPointCloud> UniquePtr;
    typedef std::unique_ptr<const mrpt::viz ::CPointCloud> ConstUniquePtr;

    // fields

    static constexpr const char* className = "mrpt::viz" "::" "CPointCloud";

    // construction

    CPointCloud();

    // methods

    static constexpr auto getClassName();
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    static std::shared_ptr<CObject> CreateObject();

    template <typename... Args>
    static Ptr Create(Args&&... args);

    template <typename Alloc, typename... Args>
    static Ptr CreateAlloc(
        const Alloc& alloc,
        Args&&... args
        );

    template <typename... Args>
    static UniquePtr CreateUnique(Args&&... args);

    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual mrpt::rtti::CObject* clone() const;
    size_t size() const;
    size_t size_unprotected() const;
    void resize(size_t N);
    void reserve(size_t N);

    template <typename T>
    void setAllPoints(
        const std::vector<T>& x,
        const std::vector<T>& y,
        const std::vector<T>& z
        );

    void setAllPoints(const std::vector<mrpt::math::TPoint3D>& pts);
    void setAllPointsFast(std::vector<mrpt::math::TPoint3Df>& pts);
    const std::vector<mrpt::math::TPoint3Df>& getArrayPoints() const;
    void clear();
    bool empty() const;
    void insertPoint(float x, float y, float z);
    void insertPoint(const mrpt::math::TPoint3Df& p);
    void insertPoint(const mrpt::math::TPoint3D& p);
    const mrpt::math::TPoint3Df& operator [] (size_t i) const;
    const mrpt::math::TPoint3Df& getPoint3Df(size_t i) const;
    void setPoint(size_t i, const float x, const float y, const float z);
    void setPoint_fast(size_t i, const float x, const float y, const float z);

    template <class POINTSMAP>
    void loadFromPointsMap(const POINTSMAP* themap);

    template <class LISTOFPOINTS>
    void loadFromPointsList(LISTOFPOINTS& pointsList);

    void enableColorFromX(bool v = true);
    void enableColorFromY(bool v = true);
    void enableColorFromZ(bool v = true);
    void setGradientColors(const mrpt::img::TColorf& colorMin, const mrpt::img::TColorf& colorMax);
    virtual void toYAMLMap(mrpt::containers::yaml& propertiesMap) const;
};

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<CObject> Ptr;
    typedef std::shared_ptr<const CObject> ConstPtr;
    typedef std::shared_ptr<CSerializable> Ptr;
    typedef std::shared_ptr<const CSerializable> ConstPtr;

    // structs

    struct PoseAndScale;
    struct State;

    // methods

    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    const auto& shaderPointsVertexPointBuffer() const;
    const auto& shaderPointsVertexColorBuffer() const;
    auto& shaderPointsBuffersMutex() const;
    float getPointSize() const;
    bool isEnabledVariablePointSize() const;
    float getVariablePointSize_k() const;
    float getVariablePointSize_DepthScale() const;

Typedefs

typedef std::shared_ptr<mrpt::viz ::CPointCloud> Ptr

A type for the associated smart pointer.

Construction

CPointCloud()

Constructor.

Methods

virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const

Returns information about the class of an object in runtime.

virtual mrpt::rtti::CObject* clone() const

Returns a deep copy (clone) of the object, indepently of its class.

size_t size_unprotected() const

Like size(), but without locking the data mutex (internal usage)

void resize(size_t N)

Set the number of points (with contents undefined)

void reserve(size_t N)

Like STL std::vector’s reserve.

template <typename T>
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 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.

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.

void insertPoint(float x, float y, float z)

Adds a new point to the cloud.

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).

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).

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>
void loadFromPointsList(LISTOFPOINTS& pointsList)

Load the points from a list of mrpt::math::TPoint3D.

void setGradientColors(const mrpt::img::TColorf& colorMin, const mrpt::img::TColorf& colorMax)

Sets the colors used as extremes when colorFromDepth is enabled.

virtual void toYAMLMap(mrpt::containers::yaml& propertiesMap) const

Used from Scene::asYAML().

(New in MRPT 2.4.2)