class mrpt::viz::CVectorField3D

Overview

A 3D vector field representation, consisting of points and arrows drawn at any spatial position.

This opengl object has been created to represent scene flow, and hence both the vector field and the coordinates of the points at which the vector field is represented are stored in matrices because they are computed from intensity and depth images.

mrpt::viz::CVectorField3D

See also:

opengl::Scene

#include <mrpt/viz/CVectorField3D.h>

class CVectorField3D:
    public mrpt::viz::CVisualObject,
    public mrpt::viz::VisualObjectParams_Points,
    public mrpt::viz::VisualObjectParams_Lines
{
public:
    // typedefs

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

    // fields

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

    // construction

    CVectorField3D();
    CVectorField3D(mrpt::math::CMatrixFloat x_vf_ini, mrpt::math::CMatrixFloat y_vf_ini, mrpt::math::CMatrixFloat z_vf_ini, mrpt::math::CMatrixFloat x_p_ini, mrpt::math::CMatrixFloat y_p_ini, mrpt::math::CMatrixFloat z_p_ini);

    // 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 clear();
    void setPointColor(const float R, const float G, const float B, const float A = 1);
    mrpt::img::TColorf getPointColor() const;
    void setVectorFieldColor(const float R, const float G, const float B, const float A = 1);
    void getVectorFieldColor(mrpt::img::TColorf Cmin, mrpt::img::TColorf Cmax) const;

    void setMotionFieldColormap(
        const float Rmin,
        const float Gmin,
        const float Bmin,
        const float Rmax,
        const float Gmax,
        const float Bmax,
        const float Amin = 1,
        const float Amax = 1
        );

    mrpt::img::TColorf getVectorFieldColor() const;
    void setMaxSpeedForColor(const float s);
    float getMaxSpeedForColor() const;
    void getVectorField(mrpt::math::CMatrixFloat& Matrix_x, mrpt::math::CMatrixFloat& Matrix_y, mrpt::math::CMatrixFloat& Matrix_z) const;

    template <class MATRIX>
    void getVectorField(
        MATRIX& Matrix_x,
        MATRIX& Matrix_y,
        MATRIX& Matrix_z
        ) const;

    void getPointCoordinates(mrpt::math::CMatrixFloat& Coord_x, mrpt::math::CMatrixFloat& Coord_y, mrpt::math::CMatrixFloat& Coord_z) const;

    template <class MATRIX>
    void getPointCoordinates(
        MATRIX& Coord_x,
        MATRIX& Coord_y,
        MATRIX& Coord_z
        ) const;

    const mrpt::math::CMatrixFloat& getVectorField_x() const;
    mrpt::math::CMatrixFloat& getVectorField_x();
    const mrpt::math::CMatrixFloat& getVectorField_y() const;
    mrpt::math::CMatrixFloat& getVectorField_y();
    const mrpt::math::CMatrixFloat& getVectorField_z() const;
    mrpt::math::CMatrixFloat& getVectorField_z();
    void setVectorField(mrpt::math::CMatrixFloat& Matrix_x, mrpt::math::CMatrixFloat& Matrix_y, mrpt::math::CMatrixFloat& Matrix_z);

    template <class MATRIX>
    void setVectorField(
        MATRIX& Matrix_x,
        MATRIX& Matrix_y,
        MATRIX& Matrix_z
        );

    void setPointCoordinates(mrpt::math::CMatrixFloat& Matrix_x, mrpt::math::CMatrixFloat& Matrix_y, mrpt::math::CMatrixFloat& Matrix_z);

    template <class MATRIX>
    void setPointCoordinates(
        MATRIX& Matrix_x,
        MATRIX& Matrix_y,
        MATRIX& Matrix_z
        );

    void resize(size_t rows, size_t cols);
    size_t cols() const;
    size_t rows() const;
    virtual void updateBuffers() const;
    virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const;
    void enableColorFromModule(bool enable = true);
    void enableShowPoints(bool enable = true);
    bool isColorFromModuleEnabled() 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;
    const auto& shaderLinesVertexPointBuffer() const;
    const auto& shaderLinesVertexColorBuffer() const;
    auto& shaderLinesBufferMutex() const;
    void setLineWidth(float w);
    float getLineWidth() const;
    void enableAntiAliasing(bool enable = true);
    bool isAntiAliasingEnabled() const;

Typedefs

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

A type for the associated smart pointer.

Construction

CVectorField3D()

Constructor.

CVectorField3D(mrpt::math::CMatrixFloat x_vf_ini, mrpt::math::CMatrixFloat y_vf_ini, mrpt::math::CMatrixFloat z_vf_ini, mrpt::math::CMatrixFloat x_p_ini, mrpt::math::CMatrixFloat y_p_ini, mrpt::math::CMatrixFloat z_p_ini)

Constructor with a initial set of lines.

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

Clear the matrices.

void setPointColor(
    const float R,
    const float G,
    const float B,
    const float A = 1
    )

Set the point color in the range [0,1].

mrpt::img::TColorf getPointColor() const

Get the point color in the range [0,1].

void setVectorFieldColor(
    const float R,
    const float G,
    const float B,
    const float A = 1
    )

Set the arrow color in the range [0,1].

void getVectorFieldColor(mrpt::img::TColorf Cmin, mrpt::img::TColorf Cmax) const

Get the motion field min and max colors (colormap) in the range [0,1].

void setMotionFieldColormap(
    const float Rmin,
    const float Gmin,
    const float Bmin,
    const float Rmax,
    const float Gmax,
    const float Bmax,
    const float Amin = 1,
    const float Amax = 1
    )

Set the motion field min and max colors (colormap) in the range [0,1].

mrpt::img::TColorf getVectorFieldColor() const

Get the arrow color in the range [0,1].

void setMaxSpeedForColor(const float s)

Set the max speed associated for the color map ( m_still_color, m_maxspeed_color)

float getMaxSpeedForColor() const

Get the max_speed with which lines are drawn.

void getVectorField(mrpt::math::CMatrixFloat& Matrix_x, mrpt::math::CMatrixFloat& Matrix_y, mrpt::math::CMatrixFloat& Matrix_z) const

Get the vector field in three independent matrices: Matrix_x, Matrix_y and Matrix_z.

void getPointCoordinates(mrpt::math::CMatrixFloat& Coord_x, mrpt::math::CMatrixFloat& Coord_y, mrpt::math::CMatrixFloat& Coord_z) const

Get the coordiantes of the points at which the vector field is plotted: Coord_x, Coord_y and Coord_z.

const mrpt::math::CMatrixFloat& getVectorField_x() const

Get the “x” component of the vector field as a matrix.

mrpt::math::CMatrixFloat& getVectorField_x()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const mrpt::math::CMatrixFloat& getVectorField_y() const

Get the “y” component of the vector field as a matrix.

mrpt::math::CMatrixFloat& getVectorField_y()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const mrpt::math::CMatrixFloat& getVectorField_z() const

Get the “z” component of the vector field as a matrix.

mrpt::math::CMatrixFloat& getVectorField_z()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void setVectorField(mrpt::math::CMatrixFloat& Matrix_x, mrpt::math::CMatrixFloat& Matrix_y, mrpt::math::CMatrixFloat& Matrix_z)

Set the vector field with Matrix_x, Matrix_y and Matrix_z.

void setPointCoordinates(mrpt::math::CMatrixFloat& Matrix_x, mrpt::math::CMatrixFloat& Matrix_y, mrpt::math::CMatrixFloat& Matrix_z)

Set the coordinates of the points at which the vector field is plotted with Matrix_x, Matrix_y and Matrix_z.

void resize(size_t rows, size_t cols)

Resizes the set.

size_t cols() const

Returns the total count of rows used to represent the vector field.

size_t rows() const

Returns the total count of columns used to represent the vector field.

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