9 #ifndef opengl_CGeneralizedCylinder_H 10 #define opengl_CGeneralizedCylinder_H 21 class CGeneralizedCylinder;
84 for (
int i = 0; i < 4; i++)
points[i] =
p[i];
105 mutable std::vector<TQuadrilateral>
mesh;
115 mutable std::vector<mrpt::math::TPolygonWithPlane>
polys;
141 const std::vector<mrpt::math::TPoint3D>&
axis,
142 const std::vector<mrpt::math::TPoint3D>&
generatrix);
156 inline void getAxis(std::vector<mrpt::math::TPoint3D>&
a)
const 159 size_t N =
axis.size();
161 for (
size_t i = 0; i < N; i++)
163 a[i].x =
axis[i].x();
164 a[i].y =
axis[i].y();
165 a[i].z =
axis[i].z();
178 inline void setAxis(
const std::vector<mrpt::math::TPoint3D>&
a)
250 return axis.size() ? (
axis.size() - 1) : 0;
302 throw std::logic_error(
"Wrong bound definition");
318 throw std::logic_error(
"No more sections");
333 throw std::logic_error(
"No more sections");
388 const std::vector<mrpt::math::TPoint3D>& pIn,
399 const std::vector<TQuadrilateral>& m,
421 const std::vector<mrpt::math::TPoint3D>&
a,
422 const std::vector<mrpt::math::TPoint3D>&
g)
void generateSetOfPolygons(std::vector< mrpt::math::TPolygon3D > &res) const
Get the cylinder as a set of polygons in 3D.
void calculateNormal()
Automatically compute a vector normal to this quadrilateral.
void generatePoses(const std::vector< mrpt::math::TPoint3D > &pIn, mrpt::aligned_std_vector< mrpt::poses::CPose3D > &pOut)
Updates the axis, transforming each point into a pose pointing to the next section.
void setAllSectionsVisible()
Sets all sections visible.
void getOrigin(CPolyhedron::Ptr &poly) const
Get a polyhedron containing the starting point of the cylinder (its "base").
void getAsPolygonUnsafe(mrpt::math::TPolygon3D &vec) const
Given a polygon with 4 already positions allocated, this method fills it with the quadrilateral point...
double normal[3]
Normal vector.
GLsizei const GLvoid * pointer
void getEnd(CPolyhedron::Ptr &poly) const
Get a polyhedron containing the ending point of the cylinder (its "base").
bool getFirstSectionPose(mrpt::poses::CPose3D &p)
Gets the axis pose of the first section, returning false if there is no such pose.
void setClosed(bool c=true)
Set whether each section is a closed polygon or not.
~TQuadrilateral()
Destructor.
size_t getNumberOfSections() const
Get the number of sections in this cylinder.
void removeVisibleSectionAtStart()
Removes a visible section from the start of the currently visible set.
bool fullyVisible
Flag to determine whether the object is fully visible or only some sections are.
static Ptr Create(Args &&... args)
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
EIGEN_STRONG_INLINE iterator begin()
void addVisibleSectionAtStart()
Adds another visible section at the start of the cylinder.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
std::vector< TQuadrilateral > mesh
Mutable object with mesh information, used to avoid repeated computations.
bool meshUpToDate
Mutable flag which tells if recalculations are needed.
void getMeshIterators(const std::vector< TQuadrilateral > &m, std::vector< TQuadrilateral >::const_iterator &begin, std::vector< TQuadrilateral >::const_iterator &end) const
Given a vector of polyhedrons, gets the starting and ending iterators to the section to be actually r...
std::vector< T, mrpt::aligned_allocator_cpp11< T > > aligned_std_vector
bool getLastSectionPose(mrpt::poses::CPose3D &p)
Gets the axis pose of the last section, returning false if there is no such pose. ...
CGeneralizedCylinder(const std::vector< mrpt::math::TPoint3D > &a, const std::vector< mrpt::math::TPoint3D > &g)
Constructor with axis and generatrix.
void getClosedSection(size_t index, CPolyhedron::Ptr &poly) const
Get a polyhedron consisting of a single section of the cylinder.
void removeVisibleSectionAtEnd()
Removes a visible section from the ending of the currently visible set.
GLsizei const GLfloat * points
virtual ~CGeneralizedCylinder()
Destructor.
A renderizable object suitable for rendering with OpenGL's display lists.
void render_dl() const override
Render.
bool closed
Boolean variable which determines if the profile is closed at each section.
void setVisibleSections(size_t first, size_t last)
Sets which sections are visible.
void getGeneratrix(std::vector< mrpt::math::TPoint3D > &g) const
Get cylinder's profile.
void setGeneratrix(const std::vector< mrpt::math::TPoint3D > &g)
Set cylinder's profile.
void setAllSectionsInvisible(size_t pointer=0)
Hides all sections.
void getVisibleSections(size_t &first, size_t &last) const
Gets the cylinder's visible sections.
bool getFirstVisibleSectionPose(mrpt::poses::CPose3D &p)
Gets the axis pose of the first visible section, returning false if there is no such pose...
mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D > pointsMesh
Mutable object with the cylinder's points, used to avoid repeated computations.
std::vector< mrpt::math::TPolygonWithPlane > polys
Mutable set of data used in ray tracing.
bool polysUpToDate
Mutable flag telling whether ray tracing temporary data must be recalculated or not.
void setAxis(const std::vector< mrpt::math::TPoint3D > &a)
Set the axis points.
void getAxis(std::vector< mrpt::math::TPoint3D > &a) const
Get axis's spatial coordinates.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
size_t lastSection
Last visible section, if fullyVisible is set to false.
This object represents any figure obtained by extruding any profile along a given axis...
size_t getVisibleSections() const
Get how many visible sections are in the cylinder.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void updateMesh() const
Updates the mutable mesh.
std::vector< mrpt::math::TPoint3D > generatrix
Object's generatrix, that is, profile which will be extruded.
mrpt::aligned_std_vector< mrpt::poses::CPose3D > axis
Cylinder's axis.
void updatePolys() const
Updates the mutable set of polygons used in ray tracing.
The namespace for 3D scene representation and rendering.
TQuadrilateral(const T(&p)[4])
Construction from any array of four compatible objects.
void getClosedSection(size_t index1, size_t index2, CPolyhedron::Ptr &poly) const
Get a polyhedron consisting of a set of closed sections of the cylinder.
bool isClosed() const
Returns true if each section is a closed polygon.
CGeneralizedCylinder()
Basic constructor with default initialization.
void getAxis(mrpt::aligned_std_vector< mrpt::poses::CPose3D > &a) const
Get axis, including angular coordinates.
bool getLastVisibleSectionPose(mrpt::poses::CPose3D &p)
Gets the axis pose of the last section, returning false if there is no such pose. ...
TQuadrilateral(const mrpt::math::TPoint3D &p1, const mrpt::math::TPoint3D &p2, const mrpt::math::TPoint3D &p3, const mrpt::math::TPoint3D &p4)
Constructor from 4 points.
Auxiliary struct holding any quadrilateral, represented by foour points.
TQuadrilateral()
Empty constructor.
void addVisibleSectionAtEnd()
Adds another visible section at the end of the cylinder.
GLubyte GLubyte GLubyte a
const Scalar * const_iterator
3D polygon, inheriting from std::vector<TPoint3D>
size_t firstSection
First visible section, if fullyVisible is set to false.
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray tracing.