class mrpt::viz::CSetOfObjects

Python API: mrpt.viz.CSetOfObjects

Overview

A set of object, which are referenced to the coordinates framework established in this object.

It can be established a hierarchy of “CSetOfObjects”, where the coordinates framework of each one will be referenced to the parent’s one. The list of child objects is accessed directly as in the class Scene

See also:

opengl::Scene

#include <mrpt/viz/CSetOfObjects.h>

class CSetOfObjects: public mrpt::viz::CVisualObject
{
public:
    // typedefs

    typedef std::shared_ptr<mrpt::viz ::CSetOfObjects> Ptr;
    typedef std::shared_ptr<const mrpt::viz ::CSetOfObjects> ConstPtr;
    typedef std::unique_ptr<mrpt::viz ::CSetOfObjects> UniquePtr;
    typedef std::unique_ptr<const mrpt::viz ::CSetOfObjects> ConstUniquePtr;
    typedef mrpt::containers::deep_const_iterator<ListVisualObjects::const_iterator> const_iterator;
    typedef ListVisualObjects::iterator iterator;

    // fields

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

    // construction

    CSetOfObjects();

    // 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;
    static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPosePDF& o);
    static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPointPDF& o);
    static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPose3DPDF& o);
    static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPose3DQuatPDF& o);
    const_iterator begin() const;
    const_iterator end() const;
    iterator begin();
    iterator end();

    template <class T>
    void insertCollection(const T& objs);

    void insert(const CVisualObject::Ptr& newObject);

    template <class T_it>
    void insert(const T_it& begin, const T_it& end);

    void clear();
    size_t size() const;
    bool empty() const;
    CVisualObject::ConstPtr getByName(const std::string& str) const;
    CVisualObject::Ptr getByName(const std::string& str);

    template <typename T>
    T::ConstPtr getByClass(size_t ith = 0) const;

    template <typename T>
    T::Ptr getByClass(size_t ith = 0);

    void removeObject(const CVisualObject::Ptr& obj);
    void dumpListOfObjects(std::vector<std::string>& lst) const;
    mrpt::containers::yaml asYAML() const;
    virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const;
    virtual CVisualObject& setColor_u8(const mrpt::img::TColor& c);
    virtual CVisualObject& setColorA_u8(const uint8_t a);
    bool contains(const CVisualObject::Ptr& obj) const;
    virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const;
};

// direct descendants

class CAssimpModel;

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;

Typedefs

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

A type for the associated smart pointer.

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

typedef mrpt::containers::deep_const_iterator<ListVisualObjects::const_iterator> const_iterator

Dereferencing it yields a CVisualObject::ConstPtr, so that a const container cannot hand out mutable objects.

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.

static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPosePDF& o)

Returns a representation of a the PDF - this is just an auxiliary function, it’s more natural to call mrpt::poses::CPosePDF::getAs3DObject

static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPointPDF& o)

Returns a representation of a the PDF - this is just an auxiliary function, it’s more natural to call mrpt::poses::CPointPDF::getAs3DObject

static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPose3DPDF& o)

Returns a representation of a the PDF - this is just an auxiliary function, it’s more natural to call mrpt::poses::CPose3DPDF::getAs3DObject

static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPose3DQuatPDF& o)

Returns a representation of a the PDF - this is just an auxiliary function, it’s more natural to call mrpt::poses::CPose3DQuatPDF::getAs3DObject

template <class T>
void insertCollection(const T& objs)

Inserts a set of objects into the list.

void insert(const CVisualObject::Ptr& newObject)

Insert a new object to the list.

template <class T_it>
void insert(const T_it& begin, const T_it& end)

Inserts a set of objects, bounded by iterators, into the list.

void clear()

Clear the list of objects in the scene, deleting objects’ memory.

size_t size() const

Returns number of objects.

bool empty() const

Returns true if there are no objects.

CVisualObject::ConstPtr getByName(const std::string& str) const

Returns the first object with a given name, or a nullptr pointer if not found.

template <typename T>
T::ConstPtr getByClass(size_t ith = 0) const

Returns the i’th object of a given class (or of a descendant class), or nullptr (an empty smart pointer) if not found.

Example:

CSphere::Ptr obs = myscene.getByClass<CSphere>();

By default (ith=0), the first observation is returned.

void removeObject(const CVisualObject::Ptr& obj)

Removes the given object from the scene (it also deletes the object to free its memory).

void dumpListOfObjects(std::vector<std::string>& lst) const

Retrieves a list of all objects in text form.

Deprecated Prefer asYAML() (since MRPT 2.1.3)

mrpt::containers::yaml asYAML() const

Prints all objects in human-readable YAML form.

(New in MRPT 2.1.3)

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

Simulation of ray-trace, given a pose.

Returns true if the ray effectively collisions with the object (returning the distance to the origin of the ray in “dist”), or false in other case. “dist” variable yields undefined behaviour when false is returned

virtual CVisualObject& setColorA_u8(const uint8_t a)

Set alpha (transparency) color component in the range [0,255].

Returns:

a ref to this

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