Class CCylinder
Defined in File CCylinder.h
Inheritance Relationships
Base Types
public mrpt::viz::CVisualObject(Class CVisualObject)public mrpt::viz::VisualObjectParams_Triangles(Class VisualObjectParams_Triangles)
Class Documentation
-
class CCylinder : public virtual mrpt::viz::CVisualObject, public mrpt::viz::VisualObjectParams_Triangles
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
Geometry Configuration
-
inline void setRadius(float radius)
Sets both radii to a single value, configuring the object as a cylinder.
See also
-
inline void setHeight(float height)
Changes cylinder’s height.
-
inline float getBottomRadius() const
Gets the bottom radius.
-
inline float getTopRadius() const
Gets the top radius.
-
inline float getHeight() const
Gets the cylinder’s height.
-
inline void setSlicesCount(uint32_t slices)
Number of radial divisions (affects mesh smoothness)
-
inline uint32_t getSlicesCount() const
Returns the number of radial divisions
Base Caps Configuration
-
inline 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
-
inline bool hasTopBase() const
Check whether top base is displayed.
See also
-
inline bool hasBottomBase() const
Check whether bottom base is displayed.
See also
CVisualObject Interface
-
virtual bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
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 override
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 override
Updates the internal triangle buffer for rendering.
Generates the triangulated mesh for the lateral surface and optional top/bottom caps.
Public Functions
-
CCylinder() = default
Default constructor: unit cylinder
-
inline 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)
-
~CCylinder() override = default
Destructor
Protected Attributes
-
float m_baseRadius = 1.0f
Radius at z=0
-
float m_topRadius = 1.0f
Radius at z=height
-
float m_height = 1.0f
Cylinder height
-
uint32_t m_slices = 20
Number of radial divisions
-
bool m_hasTopBase = true
Whether to draw the top cap
-
bool m_hasBottomBase = true
Whether to draw the bottom cap