class mrpt::viz::CMeshFast

Python API: mrpt.viz.CMeshFast

Overview

A planar (XY) grid where each cell has an associated height and, optionally, a texture map.

To make it faster to render, instead of drawing lines and triangles it draws a point at each gridcell. A typical usage example would be an elevation map or a 3D model of a terrain.

mrpt::viz::CMeshFast

See also:

opengl::Scene

#include <mrpt/viz/CMeshFast.h>

class CMeshFast:
    public mrpt::viz::CVisualObject,
    public mrpt::viz::VisualObjectParams_Points
{
public:
    // typedefs

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

    // fields

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

    // construction

    CMeshFast(
        bool enableTransparency = false,
        float xMin_p = -1.0f,
        float xMax_p = 1.0f,
        float yMin_p = -1.0f,
        float yMax_p = 1.0f
        );

    // 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 setGridLimits(
        float xmin,
        float xmax,
        float ymin,
        float ymax
        );

    void getGridLimits(
        float& xmin,
        float& xmax,
        float& ymin,
        float& ymax
        ) const;

    void enableTransparency(bool v);

    void enableColorFromZ(
        bool v,
        mrpt::img::TColormap colorMap = mrpt::img::cmJET
        );

    void setZ(const mrpt::math::CMatrixDynamic<float>& in_Z);
    void getZ(mrpt::math::CMatrixFloat& out) const;
    float getXMin() const;
    float getXMax() const;
    float getYMin() const;
    float getYMax() const;
    void setXMin(float nxm);
    void setXMax(float nxm);
    void setYMin(float nym);
    void setYMax(float nym);

    void getXBounds(
        float& min,
        float& max
        ) const;

    void getYBounds(
        float& min,
        float& max
        ) const;

    void setXBounds(
        float min,
        float max
        );

    void setYBounds(
        float min,
        float max
        );

    virtual void updateBuffers() const;
    virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const;
    void assignImage(const mrpt::img::CImage& img);
    void assignImageAndZ(const mrpt::img::CImage& img, const mrpt::math::CMatrixDynamic<float>& in_Z);
    void adjustGridToImageAR();
};

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;

Typedefs

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

A type for the associated smart pointer.

Construction

CMeshFast(
    bool enableTransparency = false,
    float xMin_p = -1.0f,
    float xMax_p = 1.0f,
    float yMin_p = -1.0f,
    float yMax_p = 1.0f
    )

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.

void setZ(const mrpt::math::CMatrixDynamic<float>& in_Z)

This method sets the matrix of heights for each position (cell) in the mesh grid.

void getZ(mrpt::math::CMatrixFloat& out) const

Returns a reference to the internal Z matrix, allowing changing it efficiently.

virtual void updateBuffers() const

Called by the rendering system to update internal geometry buffers.

Derived classes should override this to populate their data buffers (triangles, points, lines) when the object geometry changes.

This is called automatically when hasToUpdateBuffers() returns true, which happens after notifyChange() was called.

The base implementation does nothing; derived classes should override.

Thread safety: implementations should lock the appropriate mutexes when writing to shared buffers.

virtual mrpt::math::TBoundingBoxf 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()

void assignImage(const mrpt::img::CImage& img)

Assigns a texture image, and disable transparency.

void assignImageAndZ(const mrpt::img::CImage& img, const mrpt::math::CMatrixDynamic<float>& in_Z)

Assigns a texture image and Z simultaneously, and disable transparency.

void adjustGridToImageAR()

Adjust grid limits according to the image aspect ratio, maintaining the X limits and resizing in the Y direction.