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 CRenderizable object using the “object pose” in the base class).

Three drawing modes are possible:

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

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

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

mrpt::viz::CBox mrpt::viz::CBox mrpt::viz::CBox mrpt::viz::CBox

See also:

mrpt::viz::Scene, mrpt::viz::CRenderizable

#include <mrpt/viz/CBox.h>

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

    CBox();

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

    // methods

    virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const;
    virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) 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;
    void setBoxCorners(const mrpt::math::TPoint3D& corner1, const mrpt::math::TPoint3D& corner2);

    void getBoxCorners(
        mrpt::math::TPoint3D& corner1,
        mrpt::math::TPoint3D& corner2
        ) 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;

    // structs

    struct OutdatedState;
    struct State;

    // methods

    void setLineWidth(float w);
    float getLineWidth() const;
    void enableAntiAliasing(bool enable = true);
    bool isAntiAliasingEnabled() const;
    const auto& shaderTrianglesBuffer() const;
    auto& shaderTrianglesBufferMutex() 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;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();

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 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::CRenderizable

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.