9 #ifndef opengl_CGeneralizedCylinder_H
10 #define opengl_CGeneralizedCylinder_H
40 void calculateNormal();
74 for (
int i=0;i<4;i++) points[i]=p[i];
98 mutable std::vector<TQuadrilateral>
mesh;
111 mutable vector<TPolygonWithPlane>
polys;
138 static CGeneralizedCylinderPtr Create(
const std::vector<TPoint3D> &axis,
const std::vector<TPoint3D> &generatrix);
143 void render_dl()
const;
152 inline void getAxis(std::vector<TPoint3D> &a)
const {
154 size_t N=axis.size();
156 for (
size_t i=0;i<N;i++) {
165 inline void getAxis(std::vector<CPose3D> &a)
const {
171 inline void setAxis(
const std::vector<TPoint3D> &a) {
172 generatePoses(a,axis);
209 void getOrigin(CPolyhedronPtr &poly)
const;
214 void getEnd(CPolyhedronPtr &poly)
const;
219 void generateSetOfPolygons(std::vector<TPolygon3D> &res)
const;
224 void getClosedSection(
size_t index1,
size_t index2,CPolyhedronPtr &poly)
const;
230 getClosedSection(index,index,poly);
236 return axis.size()?(axis.size()-1):0;
242 return fullyVisible?getNumberOfSections():(lastSection-firstSection);
250 last=getNumberOfSections();
268 firstSection=pointer;
278 if (first>last||last>getNumberOfSections())
throw std::logic_error(
"Wrong bound definition");
289 if (fullyVisible||firstSection==0)
throw std::logic_error(
"No more sections");
299 if (fullyVisible||lastSection==getNumberOfSections())
throw std::logic_error(
"No more sections");
308 void removeVisibleSectionAtStart();
314 void removeVisibleSectionAtEnd();
334 void updatePolys()
const;
343 void generatePoses(
const std::vector<TPoint3D> &pIn,std::vector<CPose3D> &pOut);
347 void updateMesh()
const;
355 CGeneralizedCylinder():axis(),generatrix(),mesh(),meshUpToDate(false),polysUpToDate(false),closed(false),fullyVisible(true) {}
359 CGeneralizedCylinder(
const std::vector<TPoint3D> &a,
const std::vector<TPoint3D> &g):generatrix(g),mesh(),meshUpToDate(false),polysUpToDate(false),closed(false),fullyVisible(true) {
360 generatePoses(a,axis);
void setAllSectionsVisible()
Sets all sections visible.
void getAxis(std::vector< TPoint3D > &a) const
Get axis's spatial coordinates.
EIGEN_STRONG_INLINE iterator end()
vector< TPoint3D > generatrix
Object's generatrix, that is, profile which will be extruded.
void setClosed(bool c=true)
Set whether each section is a closed polygon or not.
~TQuadrilateral()
Destructor.
bool fullyVisible
Flag to determine whether the object is fully visible or only some sections are.
vector< CPose3D > axis
Cylinder's axis.
EIGEN_STRONG_INLINE iterator begin()
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
void addVisibleSectionAtStart()
Adds another visible section at the start of the cylinder.
std::vector< TQuadrilateral > mesh
Mutable object with mesh information, used to avoid repeated computations.
const Scalar * const_iterator
bool meshUpToDate
Mutable flag which tells if recalculations are needed.
TQuadrilateral(const TPoint3D &p1, const TPoint3D &p2, const TPoint3D &p3, const TPoint3D &p4)
Constructor from 4 points.
virtual ~CGeneralizedCylinder()
Destructor.
A renderizable object suitable for rendering with OpenGL's display lists.
size_t getVisibleSections() const
Get how many visible sections are in the cylinder.
This base provides a set of functions for maths stuff.
bool closed
Boolean variable which determines if the profile is closed at each section.
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
void setVisibleSections(size_t first, size_t last)
Sets which sections are visible.
size_t getNumberOfSections() const
Get the number of sections in this cylinder.
void getGeneratrix(std::vector< TPoint3D > &g) const
Get cylinder's profile.
void setAllSectionsInvisible(size_t pointer=0)
Hides all sections.
void getAxis(std::vector< CPose3D > &a) const
Get axis, including angular coordinates.
bool polysUpToDate
Mutable flag telling whether ray tracing temporary data must be recalculated or not.
bool BASE_IMPEXP traceRay(const vector< TPolygonWithPlane > &vec, const mrpt::poses::CPose3D &pose, double &dist)
Fast ray tracing method using polygons' properties.
class OPENGL_IMPEXP CGeneralizedCylinder
This template class provides the basic functionality for a general 2D any-size, resizable container o...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#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.
void getClosedSection(size_t index, CPolyhedronPtr &poly) const
Get a polyhedron consisting of a single section of the cylinder.
This object represents any figure obtained by extruding any profile along a given axis...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void setGeneratrix(const std::vector< TPoint3D > &g)
Set cylinder's profile.
TQuadrilateral(const T(&p)[4])
Construction from any array of four compatible objects.
bool isClosed() const
Returns true if each section is a closed polygon.
void getAsPolygonUnsafe(mrpt::math::TPolygon3D &vec) const
Given a polygon with 4 already positions allocated, this method fills it with the quadrilateral point...
CGeneralizedCylinder()
Basic constructor with default initialization.
void setAxis(const std::vector< TPoint3D > &a)
Set the axis points.
Auxiliary struct holding any quadrilateral, represented by foour points.
TQuadrilateral()
Empty constructor.
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
void addVisibleSectionAtEnd()
Adds another visible section at the end of the cylinder.
CGeneralizedCylinder(const std::vector< TPoint3D > &a, const std::vector< TPoint3D > &g)
Constructor with axis and generatrix.
3D polygon, inheriting from std::vector
CMatrixTemplate< TPoint3D > pointsMesh
Mutable object with the cylinder's points, used to avoid repeated computations.
size_t firstSection
First visible section, if fullyVisible is set to false.
vector< TPolygonWithPlane > polys
Mutable set of data used in ray tracing.
void getVisibleSections(size_t &first, size_t &last) const
Gets the cylinder's visible sections.