class mrpt::viz::CCylinder
Overview
A cylinder or cone whose base lies in the XY plane.
The cylinder extends along the +Z axis from z=0 to z=height.
If baseRadius == topRadius: regular cylinder
If baseRadius != topRadius: truncated cone (frustum)
If topRadius == 0: cone with apex at the top
If baseRadius == 0: inverted cone with apex at the bottom
See also:
mrpt::viz::Scene, mrpt::viz::CDisk
#include <mrpt/viz/CCylinder.h> class CCylinder: public mrpt::viz::CVisualObject, public mrpt::viz::VisualObjectParams_Triangles { public: // typedefs typedef std::shared_ptr<mrpt::viz ::CCylinder> Ptr; typedef std::shared_ptr<const mrpt::viz ::CCylinder> ConstPtr; typedef std::unique_ptr<mrpt::viz ::CCylinder> UniquePtr; typedef std::unique_ptr<const mrpt::viz ::CCylinder> ConstUniquePtr; // fields static constexpr const char* className = "mrpt::viz" "::" "CCylinder"; // construction CCylinder(); CCylinder(float baseRadius, float topRadius, float height = 1.0f, int slices = 20); // 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 setRadius(float radius); void setRadii(float bottom, float top); void setHeight(float height); float getBottomRadius() const; float getTopRadius() const; float getHeight() const; void setSlicesCount(uint32_t slices); uint32_t getSlicesCount() const; void setHasBases(bool top = true, bool bottom = true); bool hasTopBase() const; bool hasBottomBase() const; virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const; virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() 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& 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 ::CCylinder> Ptr
A type for the associated smart pointer.
Construction
CCylinder()
Default constructor: unit cylinder.
CCylinder( float baseRadius, float topRadius, float height = 1.0f, int slices = 20 )
Constructor with parameters.
Parameters:
baseRadius |
Radius at z=0 |
topRadius |
Radius at z=height |
height |
Height of the cylinder (along +Z) |
slices |
Number of radial divisions (higher = smoother) |
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 setRadius(float radius)
Sets both radii to a single value, configuring the object as a cylinder.
See also:
void setRadii(float bottom, float top)
Sets both radii independently.
See also:
void setHeight(float height)
Changes cylinder’s height.
float getBottomRadius() const
Gets the bottom radius.
float getTopRadius() const
Gets the top radius.
float getHeight() const
Gets the cylinder’s height.
void setSlicesCount(uint32_t slices)
Number of radial divisions (affects mesh smoothness)
uint32_t getSlicesCount() const
Returns the number of radial divisions.
void setHasBases(bool top = true, bool bottom = true)
Configuration of the cylinder’s bases display.
Parameters:
top |
Whether to draw the top cap |
bottom |
Whether to draw the bottom cap |
bool hasTopBase() const
Check whether top base is displayed.
See also:
bool hasBottomBase() const
Check whether bottom base is displayed.
See also:
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 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 void updateBuffers() const
Updates the internal triangle buffer for rendering.
Generates the triangulated mesh for the lateral surface and optional top/bottom caps.