class mrpt::viz::CBox

Overview

A solid or wireframe box in 3D, defined by 6 rectangular faces parallel to the planes X, Y and Z (note that the object can be translated and rotated afterwards as any other CVisualObject object using the “object pose” in the base class).

Three drawing modes are possible:

  • Wireframe: setWireframe(true). Used color is the CVisualObject color

  • Solid box: setWireframe(false). Used color is the CVisualObject color

  • Solid box with border: setWireframe(false) + enableBoxBorder(true). Solid color is the CVisualObject color, border line can be set with setBoxBorderColor().

mrpt::viz::CBox

See also:

mrpt::viz::Scene, mrpt::viz::CVisualObject

#include <mrpt/viz/CBox.h>

class CBox:
    public mrpt::viz::CVisualObject,
    public mrpt::viz::VisualObjectParams_Lines,
    public mrpt::viz::VisualObjectParams_Triangles
{
public:
    // typedefs

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

    // fields

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

    // construction

    CBox();

    CBox(
        const mrpt::math::TPoint3D& corner1,
        const mrpt::math::TPoint3D& corner2,
        bool is_wireframe = false,
        float lineWidth = 1.0
        );

    // 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 setBoxCorners(const mrpt::math::TPoint3D& corner1, const mrpt::math::TPoint3D& corner2);
    void getBoxCorners(mrpt::math::TPoint3D& corner1, mrpt::math::TPoint3D& corner2) const;
    const mrpt::math::TPoint3D& getCornerMin() const;
    const mrpt::math::TPoint3D& getCornerMax() const;
    void setWireframe(bool is_wireframe = true);
    bool isWireframe() const;
    void enableBoxBorder(bool drawBorder = true);
    bool isBoxBorderEnabled() const;
    void setBoxBorderColor(const mrpt::img::TColor& c);
    mrpt::img::TColor getBoxBorderColor() const;
    virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const;
    virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const;
    virtual void updateBuffers() 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;
    typedef std::shared_ptr<CVisualObject> Ptr;
    typedef std::shared_ptr<const CVisualObject> ConstPtr;
    typedef std::unique_ptr<CObject> UniquePtr;
    typedef std::unique_ptr<const CObject> ConstUniquePtr;

    // 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& shaderLinesVertexPointBuffer() const;
    const auto& shaderLinesVertexColorBuffer() const;
    auto& shaderLinesBufferMutex() const;
    void setLineWidth(float w);
    float getLineWidth() const;
    void enableAntiAliasing(bool enable = true);
    bool isAntiAliasingEnabled() const;
    const auto& shaderTrianglesBuffer() const;
    auto& shaderTrianglesBufferMutex() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    PoseAndScale getPoseAndScale() const;
    virtual CVisualObject& setColor_u8(const mrpt::img::TColor& c);
    bool isLightEnabled() const;
    void enableLight(bool enable = true);
    TCullFace cullFaces() const;
    void notifyBBoxChange() const;
    auto getBoundingBoxLocalf() const;

Typedefs

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

A type for the associated smart pointer.

Construction

CBox()

Basic empty constructor.

Set all parameters to default.

CBox(
    const mrpt::math::TPoint3D& corner1,
    const mrpt::math::TPoint3D& corner2,
    bool is_wireframe = false,
    float lineWidth = 1.0
    )

Constructor with all the parameters.

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 setBoxCorners(const mrpt::math::TPoint3D& corner1, const mrpt::math::TPoint3D& corner2)

Set the position and size of the box, from two corners in 3D.

void getBoxCorners(mrpt::math::TPoint3D& corner1, mrpt::math::TPoint3D& corner2) const

Get the current box corners.

const mrpt::math::TPoint3D& getCornerMin() const

Returns the minimum corner.

const mrpt::math::TPoint3D& getCornerMax() const

Returns the maximum corner.

void setWireframe(bool is_wireframe = true)

Sets wireframe rendering mode (true) or solid mode (false, default)

bool isWireframe() const

Returns true if wireframe mode is enabled.

void enableBoxBorder(bool drawBorder = true)

Enable/disable drawing a border around solid boxes.

bool isBoxBorderEnabled() const

Returns true if box border is enabled.

void setBoxBorderColor(const mrpt::img::TColor& c)

Set the color of the box border lines.

mrpt::img::TColor getBoxBorderColor() const

Get the color of the box border lines.

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

virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const

Ray tracing.

See also:

mrpt::viz::CVisualObject

virtual void updateBuffers() const

Updates the internal geometry buffers for rendering.

This is called automatically by the rendering system when hasToUpdateBuffers() returns true (i.e., after notifyChange() was called).