class mrpt::viz::CPointCloudColoured

Python API: mrpt.viz.CPointCloudColoured

Overview

A cloud of points, each one with an individual color (R,G,B,A).

To load from a points-map, CPointCloudColoured::loadFromPointsMap().

mrpt::viz::CPointCloudColoured

See also:

opengl::Scene, opengl::CPointCloud

#include <mrpt/viz/CPointCloudColoured.h>

class CPointCloudColoured:
    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 ::CPointCloudColoured> Ptr;
    typedef std::shared_ptr<const mrpt::viz ::CPointCloudColoured> ConstPtr;
    typedef std::unique_ptr<mrpt::viz ::CPointCloudColoured> UniquePtr;
    typedef std::unique_ptr<const mrpt::viz ::CPointCloudColoured> ConstUniquePtr;

    // fields

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

    // construction

    CPointCloudColoured();

    // 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;
    void push_back(float x, float y, float z, float R, float G, float B, float A = 1);
    void insertPoint(const mrpt::math::TPointXYZfRGBAu8& p);
    void resize(size_t N);
    void reserve(size_t N);
    const mrpt::math::TPoint3Df& getPoint3Df(size_t i) const;
    void setPoint(size_t i, const mrpt::math::TPointXYZfRGBAu8& p);
    void setPoint_fast(size_t i, const mrpt::math::TPointXYZfRGBAu8& p);
    void setPoint_fast(size_t i, const float x, const float y, const float z);
    void setPointColor_fast(size_t index, float R, float G, float B, float A = 1);

    void setPointColor_u8_fast(
        size_t index,
        uint8_t r,
        uint8_t g,
        uint8_t b,
        uint8_t a = 0xff
        );

    void setAllPointsAlpha(uint8_t alpha_channel);
    void getPointColor_fast(size_t index, float& R, float& G, float& B) const;

    void getPointColor_fast(
        size_t index,
        uint8_t& r,
        uint8_t& g,
        uint8_t& b
        ) const;

    mrpt::img::TColor getPointColor(size_t index) const;
    size_t size() const;
    size_t size_unprotected() const;
    bool empty() const;
    void clear();

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

    size_t getActuallyRendered() const;
    void recolorizeByCoordinate(float coord_min, float coord_max, int coord_index = 2, mrpt::img::TColormap color_map = mrpt::img::cmJET);
    void markAllPointsAsNew();
    virtual auto internalBoundingBoxLocal() const;
    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::unique_ptr<CObject> UniquePtr;
    typedef std::unique_ptr<const CObject> ConstUniquePtr;
    typedef std::shared_ptr<CSerializable> Ptr;
    typedef std::shared_ptr<const CSerializable> ConstPtr;
    typedef std::shared_ptr<CVisualObject> Ptr;
    typedef std::shared_ptr<const CVisualObject> ConstPtr;

    // structs

    struct BuffersVersion;
    struct ChangeCounter;
    struct PoseAndScale;
    struct State;

    // methods

    mrpt::rtti::CObject::Ptr duplicateGetSmartPtr() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual CObject* clone() const = 0;
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    void setName(const std::string& n);
    std::string getName() const;
    bool isVisible() const;
    void setVisibility(bool visible = true);
    bool castShadows() const;
    void castShadows(bool doCast);
    void enableShowName(bool showName = true);
    bool isShowNameEnabled() const;
    CVisualObject& setPose(const mrpt::poses::CPose3D& o);
    CVisualObject& setPose(const mrpt::poses::CPose2D& o);
    CVisualObject& setPose(const mrpt::math::TPose3D& o);
    CVisualObject& setPose(const mrpt::math::TPose2D& o);
    CVisualObject& setPose(const mrpt::poses::CPoint3D& o);
    CVisualObject& setPose(const mrpt::poses::CPoint2D& o);
    mrpt::math::TPose3D getPose() const;
    PoseAndScale getPoseAndScale() const;
    mrpt::poses::CPose3D getCPose() const;
    CVisualObject& setLocation(double x, double y, double z);
    CVisualObject& setLocation(const mrpt::math::TPoint3D& p);
    mrpt::img::TColorf getColor() const;
    mrpt::img::TColor getColor_u8() const;
    CVisualObject& setColorA(const float a);
    virtual CVisualObject& setColorA_u8(const uint8_t a);
    float materialShininess() const;
    void materialShininess(float shininess);
    float materialSpecularExponent() const;
    void materialSpecularExponent(float exponent);
    mrpt::img::TColorf materialEmissive() const;
    void materialEmissive(const mrpt::img::TColorf& color);
    CVisualObject& setScale(float s);
    CVisualObject& setScale(float sx, float sy, float sz);
    float getScaleX() const;
    float getScaleY() const;
    float getScaleZ() const;
    CVisualObject& setColor(const mrpt::img::TColorf& c);
    CVisualObject& setColor(float R, float G, float B, float A = 1);
    virtual CVisualObject& setColor_u8(const mrpt::img::TColor& c);
    CVisualObject& setColor_u8(uint8_t R, uint8_t G, uint8_t B, uint8_t A = 255);
    virtual bool cullElegible() const;
    virtual void toYAMLMap(mrpt::containers::yaml& propertiesMap) const;
    virtual bool isCompositeObject() const;
    virtual const std::deque<std::shared_ptr<CVisualObject>>& getInternalChildren() const;
    void notifyChange() const;
    void notifyTransformChange() const;
    void clearChangedFlag() const;
    void notifyBBoxChange() const;
    bool hasToUpdateBuffers() const;
    uint64_t dataVersion() const;
    uint64_t transformVersion() const;
    bool hasToUpdateBuffersSince(uint64_t sinceVersion) const;
    void updateBuffersIfNeeded() const;
    virtual void updateBuffers() const;
    virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const;
    auto getBoundingBox() const;
    auto getBoundingBoxLocal() const;
    auto getBoundingBoxLocalf() const;
    virtual mrpt::math::TPoint3Df getLocalRepresentativePoint() const;
    void setLocalRepresentativePoint(const mrpt::math::TPoint3Df& p);
    mrpt::viz::CText& labelObject() const;
    std::shared_ptr<mrpt::viz::CText> labelObjectPtr() const;
    const auto& shaderPointsVertexPointBuffer() const;
    const auto& shaderPointsVertexColorBuffer() const;
    auto& shaderPointsBuffersMutex() const;
    void setPointSize(float p);
    float getPointSize() const;
    void enableVariablePointSize(bool enable = true);
    bool isEnabledVariablePointSize() const;
    void setVariablePointSize_k(float v);
    float getVariablePointSize_k() const;
    void setVariablePointSize_DepthScale(float v);
    float getVariablePointSize_DepthScale() const;

    bool loadFromPlyFile(
        const std::string& filename,
        std::vector<std::string>* file_comments = nullptr,
        std::vector<std::string>* file_obj_info = nullptr
        );

    std::string getLoadPLYErrorString() const;

    bool saveToPlyFile(
        const std::string& filename,
        bool save_in_binary = false,
        const std::vector<std::string>& file_comments = std::vector<std::string>(),
        const std::vector<std::string>& file_obj_info = std::vector<std::string>()
        ) const;

    std::string getSavePLYErrorString() const;

Typedefs

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

A type for the associated smart pointer.

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.

void push_back(
    float x,
    float y,
    float z,
    float R,
    float G,
    float B,
    float A = 1
    )

Inserts a new point into the point cloud.

void insertPoint(const mrpt::math::TPointXYZfRGBAu8& p)

inserts a new point

void resize(size_t N)

Set the number of points, with undefined contents.

void reserve(size_t N)

Like STL std::vector’s reserve.

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 mrpt::math::TPointXYZfRGBAu8& p)

Write an individual point (checks for “i” in the valid range only in Debug).

void setPoint_fast(size_t i, const mrpt::math::TPointXYZfRGBAu8& p)

Like setPoint() but does not check for index out of bounds.

void setPoint_fast(size_t i, const float x, const float y, const float z)

Like setPoint() but does not check for index out of bounds.

void setPointColor_fast(size_t index, float R, float G, float B, float A = 1)

Like setPointColor but without checking for out-of-index errors.

void setAllPointsAlpha(uint8_t alpha_channel)

Overwrites the alpha (transparency) channel for all existing points.

void getPointColor_fast(size_t index, float& R, float& G, float& B) const

Like getPointColor but without checking for out-of-index errors.

size_t size() const

Return the number of points.

size_t size_unprotected() const

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

void clear()

Erase all the points.

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

Load the points from any other point map class supported by the adapter mrpt::viz::PointCloudAdapter.

size_t getActuallyRendered() const

Get the number of elements actually rendered in the last render event.

void recolorizeByCoordinate(
    float coord_min,
    float coord_max,
    int coord_index = 2,
    mrpt::img::TColormap color_map = mrpt::img::cmJET
    )

Regenerates the color of each point according the one coordinate (coord_index:0,1,2 for X,Y,Z) and the given color map.

virtual auto internalBoundingBoxLocal() const

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

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

Used from Scene::asYAML().

(New in MRPT 2.4.2)