9 #ifndef opengl_CPolyhedron_H 10 #define opengl_CPolyhedron_H 79 double length(
const std::vector<mrpt::math::TPoint3D>& vs)
const;
100 double area(
const std::vector<mrpt::math::TPoint3D>&
vertices)
const;
103 const std::vector<mrpt::math::TPoint3D>&
vertices,
263 double radius,
bool type =
true);
279 double radius,
bool type =
true);
422 double x1,
double x2,
double y1,
double y2,
double z1,
double z2);
437 const std::vector<mrpt::math::TPoint2D>& baseVertices,
double height);
445 const std::vector<mrpt::math::TPoint2D>& baseVertices,
double height1,
455 const std::vector<mrpt::math::TPoint2D>& baseVertices,
double height,
462 const std::vector<mrpt::math::TPoint2D>& baseVertices,
double height,
471 const std::vector<mrpt::math::TPoint2D>& baseVertices,
double height);
479 const std::vector<mrpt::math::TPoint2D>& bottomBase,
480 const std::vector<mrpt::math::TPoint2D>& topBase,
double height);
495 const std::vector<mrpt::math::TPoint2D>& baseVertices,
double height1,
496 double ratio1,
double height2,
double ratio2);
505 uint32_t numBaseEdges,
double baseRadius,
double basesDistance);
533 uint32_t numBaseEdges,
double baseRadius,
double height1,
542 uint32_t numBaseEdges,
double baseRadius);
550 uint32_t numBaseEdges,
double baseRadius);
556 uint32_t numBaseEdges,
double baseRadius,
double height,
double ratio);
562 uint32_t numBaseEdges,
double baseRadius,
double height,
double ratio);
569 uint32_t numBaseEdges,
double baseRadius,
double height1,
double ratio1,
570 double height2,
double ratio2);
576 uint32_t numBaseEdges,
double edgeLength);
663 inline void getVertices(std::vector<mrpt::math::TPoint3D>& vertices)
const 670 inline void getEdges(std::vector<TPolyhedronEdge>& edges)
const 677 inline void getFaces(std::vector<TPolyhedronFace>& faces)
const 755 for (
size_t i = 0; i <
mVertices.size(); i++)
847 uint32_t numBaseEdges,
double baseRadius);
853 uint32_t numBaseEdges,
double baseRadius);
860 std::vector<mrpt::math::TPoint3D>& vec);
866 uint32_t numBaseEdges,
double baseRadius,
double height,
double shift,
867 std::vector<mrpt::math::TPoint3D>& vec);
871 bool setNormal(TPolyhedronFace& f,
bool doCheck =
true);
875 void addEdges(
const TPolyhedronFace& e);
880 const std::vector<mrpt::math::TPoint3D>& vertices,
881 const std::vector<TPolyhedronFace>& faces);
909 const std::vector<mrpt::math::TPoint3D>& vertices,
910 const std::vector<TPolyhedronFace>& faces,
bool doCheck =
true)
921 const std::vector<mrpt::math::TPoint3D>& vertices,
922 const std::vector<TPolyhedronFace>& faces,
bool doCheck =
true)
925 throw std::logic_error(
"Face list accesses a vertex out of range");
930 throw std::logic_error(
"Bad face specification");
935 CPolyhedron(
const std::vector<math::TPolygon3D>& polys);
938 const std::vector<mrpt::math::TPoint3D>& vertices,
939 const std::vector<std::vector<uint32_t>>& faces);
943 const std::vector<mrpt::math::TPoint3D>& vertices,
944 const std::vector<TPolyhedronFace>& faces);
956 std::vector<mrpt::math::TPolygon3D> polys1, polys2;
957 p1->getSetOfPolygonsAbsolute(polys1);
958 p2->getSetOfPolygonsAbsolute(polys2);
static CPolyhedron::Ptr CreateEmpty()
Creates an empty Polyhedron.
void setLineWidth(double lineWidth)
Sets the width used to render lines, when wireframe rendering is activated.
static CPolyhedron::Ptr CreateRhombicuboctahedron(double radius, bool type=true)
Creates a rhombicuboctahedron, with 18 squares and 8 triangles (see http://en.wikipedia.org/wiki/Rhombicuboctahedron), calculated as an elongated square bicupola.
static CPolyhedron::Ptr CreateBifrustum(const std::vector< mrpt::math::TPoint2D > &baseVertices, double height1, double ratio1, double height2, double ratio2)
Creates a bifrustum, or double truncated pyramid, given a base which will lie on the XY plane...
static CPolyhedron::Ptr CreateTrapezohedron(uint32_t numBaseEdges, double baseRadius, double basesDistance)
Creates a trapezohedron, consisting of 2*N kites, where N is the number of edges in the base...
#define MRPT_DECLARE_TTYPENAME_NAMESPACE(_TYPE, __NS)
bool mWireframe
This flag determines whether the polyhedron will be displayed as a solid object or as a set of edges...
static CPolyhedron::Ptr CreateRhombicTriacontahedron(double radius)
Creates a rhombic triacontahedron, dual to the icosidodecahedron.
static CPolyhedron::Ptr CreateIcosidodecahedron(double radius, bool type=true)
Creates an icosidodecahedron, with 12 pentagons and 20 triangles (see http://en.wikipedia.org/wiki/Icosidodecahedron).
void addEdges(const TPolyhedronFace &e)
Adds, to the existing list of edges, each edge in a given face.
mrpt::utils::CStream & operator<<(mrpt::utils::CStream &out, const mrpt::opengl::CLight &o)
size_t facesInVertex(size_t vertex) const
Returns how many faces converge in a given vertex.
uint32_t getNumberOfVertices() const
Gets the amount of vertices.
size_t edgesInVertex(size_t vertex) const
Returns how many edges converge in a given vertex.
double getVolume() const
Gets the polyhedron volume.
static std::vector< mrpt::math::TPoint2D > generateShiftedBase(uint32_t numBaseEdges, double baseRadius)
Generates a list of 2D vertices constituting a regular polygon, with an angle shift which makes it su...
void InitFromVertAndFaces(const std::vector< mrpt::math::TPoint3D > &vertices, const std::vector< TPolyhedronFace > &faces, bool doCheck=true)
static CPolyhedron::Ptr CreateCuboctahedron(double radius)
Creates a cuboctahedron, consisting of six square faces and eight triangular ones (see http://en...
void makeConvexPolygons()
Recomputes polygons, if necessary, so that each one is convex.
void getFaces(std::vector< TPolyhedronFace > &faces) const
Gets a list with the polyhedron's faces.
static CPolyhedron::Ptr CreateTriakisIcosahedron(double radius)
Creates a triakis icosahedron, dual to the truncated dodecahedron.
CPolyhedron::Ptr getDual() const
Given a polyhedron, creates its dual.
virtual ~CPolyhedron()
Destructor.
std::shared_ptr< CPolyhedron > Ptr
static CPolyhedron::Ptr CreateCatalanDoublePyramid(uint32_t numBaseEdges, double height)
Creates a double pyramid whose dual is exactly an archimedean prism.
CPolyhedron::Ptr rotate(double angle) const
Rotates a polyhedron around the Z axis a given amount of radians.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
static CPolyhedron::Ptr CreateTetrakisHexahedron(double radius)
Creates a tetrakis hexahedron, dual to the truncated octahedron.
static CPolyhedron::Ptr CreateIcosahedron(double radius)
Creates a regular icosahedron (see http://en.wikipedia.org/wiki/Icosahedron).
static CPolyhedron::Ptr CreateRegularPrism(uint32_t numBaseEdges, double baseRadius, double height)
Creates a regular prism whose base is a regular polygon and whose edges are either parallel or perpen...
static CPolyhedron::Ptr CreateArchimedeanRegularAntiprism(uint32_t numBaseEdges, double baseRadius)
Creates a regular antiprism whose lateral polygons are equilateral triangles, and so each face of its...
GLenum GLenum GLuint components
static CPolyhedron::Ptr CreateCubicPrism(double x1, double x2, double y1, double y2, double z1, double z2)
Creates a cubic prism, given the coordinates of two opposite vertices.
static CPolyhedron::Ptr CreateCupola(uint32_t numBaseEdges, double edgeLength)
Creates a cupola.
This class represents arbitrary polyhedra.
static CPolyhedron::Ptr CreateTriakisTetrahedron(double radius)
Creates a triakis tetrahedron, dual to the truncated tetrahedron.
~TPolyhedronFace()
Destructor.
A renderizable object suitable for rendering with OpenGL's display lists.
static CPolyhedron::Ptr CreateJohnsonSolidWithConstantBase(uint32_t numBaseEdges, double baseRadius, const std::string &components, size_t shifts=0)
Creates a series of concatenated solids (most of which are prismatoids) whose base is a regular polyg...
CPolyhedron::Ptr cantellate(double factor) const
Cantellates a polyhedron to a given factor.
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray trace.
static CPolyhedron::Ptr CreateTetrahedron(double radius)
Creates a regular tetrahedron (see http://en.wikipedia.org/wiki/Tetrahedron).
static CPolyhedron::Ptr CreateCatalanTrapezohedron(uint32_t numBaseEdges, double height)
Creates a trapezohedron whose dual is exactly an archimedean antiprism.
uint32_t v2
Second vertex.
static CPolyhedron::Ptr CreateTruncatedPyramid(const std::vector< mrpt::math::TPoint2D > &baseVertices, double height, double ratio)
Creates a truncated pyramid, using a set of vertices which will lie on the XY plane.
static CPolyhedron::Ptr CreateTruncatedDodecahedron(double radius)
Creates a truncated dodecahedron, consisting of 12 dodecagons and 20 triangles (see http://en...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
std::vector< uint32_t > vertices
Vector of indices to the vertex list.
std::vector< mrpt::math::TPolygonWithPlane > tempPolygons
Mutable list of actual polygons, maintained for speed.
static CPolyhedron::Ptr CreateRandomPolyhedron(double radius)
Creates a random polyhedron from the static methods.
uint32_t getNumberOfEdges() const
Gets the amount of edges.
static CPolyhedron::Ptr CreateFrustum(const std::vector< mrpt::math::TPoint2D > &baseVertices, double height, double ratio)
This is a synonym for CreateTruncatedPyramid.
static CPolyhedron::Ptr CreateRhombicosidodecahedron(double radius)
Creates a rhombicosidodecahedron, consisting of 30 squares, 12 pentagons and 20 triangles (see http:/...
static CPolyhedron::Ptr CreatePentagonalRotunda(double radius)
Creates a pentagonal rotunda (half an icosidodecahedron), consisting of six pentagons, ten triangles and a decagon (see http://en.wikipedia.org/wiki/Pentagonal_rotunda).
double getLineWidth() const
Gets the wireframe lines width.
Struct used to store a polyhedron face.
void getSetOfPolygons(std::vector< math::TPolygon3D > &vec) const
Gets the polyhedron as a set of polygons.
static CPolyhedron::Ptr CreateTruncatedOctahedron(double radius)
Creates a truncated octahedron, with eight hexagons and eight squares (see http://en.wikipedia.org/wiki/Truncated_octahedron).
static CPolyhedron::Ptr CreatePyramid(const std::vector< mrpt::math::TPoint2D > &baseVertices, double height)
Creates a custom pyramid, using a set of 2D vertices which will lie on the XY plane.
static CPolyhedron::Ptr CreateRegularPyramid(uint32_t numBaseEdges, double baseRadius, double height)
Creates a regular pyramid whose base is a regular polygon.
void getCenter(const std::vector< mrpt::math::TPoint3D > &vertices, mrpt::math::TPoint3D &p) const
Given a set of vertices, get this face's center.
double normal[3]
Normal vector.
double area(const std::vector< mrpt::math::TPoint3D > &vertices) const
Given a set of vertices, computes the area of this face.
CPolyhedron()
Basic empty constructor.
bool isWireframe() const
Returns whether the polyhedron will be rendered as a wireframe object.
Struct used to store a polyhedron edge.
bool operator==(const TPolyhedronEdge &e) const
Comparison agains another edge.
GLfloat GLfloat GLfloat GLfloat v3
static CPolyhedron::Ptr CreateTriakisOctahedron(double radius)
Creates a triakis octahedron, dual to the truncated hexahedron.
static CPolyhedron::Ptr CreateOctahedron(double radius)
Creates a regular octahedron (see http://en.wikipedia.org/wiki/Octahedron).
void setWireframe(bool enabled=true)
Sets whether the polyhedron will be rendered as a wireframe object.
static std::vector< mrpt::math::TPoint2D > generateBase(uint32_t numBaseEdges, double baseRadius)
Generates a list of 2D vertices constituting a regular polygon.
TPolyhedronFace()
Fast default constructor.
GLsizei const GLchar ** string
static CPolyhedron::Ptr CreateParallelepiped(const mrpt::math::TPoint3D &base, const mrpt::math::TPoint3D &v1, const mrpt::math::TPoint3D &v2, const mrpt::math::TPoint3D &v3)
Creates a parallelepiped, given a base point and three vectors represented as points.
std::vector< TPolyhedronEdge > mEdges
List of polyhedron's edges.
std::vector< mrpt::math::TPoint3D > mVertices
List of vertices presents in the polyhedron.
~TPolyhedronEdge()
Destructor.
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...
CPolyhedron::Ptr scale(double factor) const
Scales a polyhedron to a given factor.
static CPolyhedron::Ptr CreateCustomAntiprism(const std::vector< mrpt::math::TPoint2D > &bottomBase, const std::vector< mrpt::math::TPoint2D > &topBase, double height)
Creates a custom antiprism, using two custom bases.
static CPolyhedron::Ptr CreateTruncatedTetrahedron(double radius)
Creates a truncated tetrahedron, consisting of four triangular faces and for hexagonal ones (see http...
mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, mrpt::opengl::CLight &o)
static CPolyhedron::Ptr CreateRegularAntiprism(uint32_t numBaseEdges, double baseRadius, double height)
Creates an antiprism whose base is a regular polygon.
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...
bool polygonsUpToDate
Whether the set of actual polygons is up to date or not.
bool setNormal(TPolyhedronFace &f, bool doCheck=true)
Calculates the normal vector to a face.
void updatePolygons() const
Updates the mutable list of polygons used in rendering and ray tracing.
static CPolyhedron::Ptr CreateRhombicDodecahedron(double radius)
Creates a rhombic dodecahedron, dual to the cuboctahedron.
static CPolyhedron::Ptr CreateRegularDoublePyramid(uint32_t numBaseEdges, double baseRadius, double height1, double height2)
Creates a regular double pyramid whose base is a regular polygon.
uint32_t getNumberOfFaces() const
Gets the amount of faces.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
static CPolyhedron::Ptr CreateRegularBifrustum(uint32_t numBaseEdges, double baseRadius, double height1, double ratio1, double height2, double ratio2)
Creates a bifrustum (double truncated pyramid) whose base is a regular polygon lying in the XY plane...
static size_t getIntersection(const CPolyhedron::Ptr &p1, const CPolyhedron::Ptr &p2, T &container)
Gets the intersection of two polyhedra, either as a set or as a matrix of intersections.
double length(const std::vector< mrpt::math::TPoint3D > &vs) const
Given a set of vertices, computes the length of the vertex.
static CPolyhedron::Ptr CreateNoCheck(const std::vector< mrpt::math::TPoint3D > &vertices, const std::vector< TPolyhedronFace > &faces)
Creates a polyhedron without checking its correctness.
static CPolyhedron::Ptr CreateTruncatedIcosahedron(double radius)
Creates a truncated icosahedron, consisting of 20 hexagons and 12 pentagons.
TPolyhedronEdge()
Default constructor.
static CPolyhedron::Ptr CreateDodecahedron(double radius)
Creates a regular dodecahedron (see http://en.wikipedia.org/wiki/Dodecahedron).
The namespace for 3D scene representation and rendering.
bool isClosed() const
Returns true if the polygon is a completely closed object.
static CPolyhedron::Ptr CreateRegularTruncatedPyramid(uint32_t numBaseEdges, double baseRadius, double height, double ratio)
Creates a regular truncated pyramid whose base is a regular polygon.
CPolyhedron::Ptr truncate(double factor) const
Truncates a polyhedron to a given factor.
static CPolyhedron::Ptr CreateArchimedeanRegularPrism(uint32_t numBaseEdges, double baseRadius)
Creates a regular prism whose lateral area is comprised of squares, and so each face of its is a regu...
static CPolyhedron::Ptr CreateDeltoidalHexecontahedron(double radius)
Creates a deltoidal hexecontahedron, dual to the rhombicosidodecahedron.
static CPolyhedron::Ptr CreateHexahedron(double radius)
Creates a regular cube, also called hexahedron (see http://en.wikipedia.org/wiki/Hexahedron).
void getEdgesLength(std::vector< double > &lengths) const
Gets a vector with each edge's length.
static CPolyhedron::Ptr CreateRegularFrustum(uint32_t numBaseEdges, double baseRadius, double height, double ratio)
This is a synonym for CreateRegularTruncatedPyramid.
static bool checkConsistence(const std::vector< mrpt::math::TPoint3D > &vertices, const std::vector< TPolyhedronFace > &faces)
Checks whether a set of faces is suitable for a set of vertices.
double mLineWidth
When displaying as wireframe object, this variable stores the width of the edges. ...
void render_dl() const override
Render.
GLfloat GLfloat GLfloat v2
void getCenter(mrpt::math::TPoint3D ¢er) const
Gets the center of the polyhedron.
std::vector< TPolyhedronFace > mFaces
List of polyhedron's faces.
void getFacesArea(std::vector< double > &areas) const
Gets a vector with each face's area.
GLenum GLsizei GLsizei height
unsigned __int32 uint32_t
static CPolyhedron::Ptr CreatePentakisDodecahedron(double radius)
Creates a pentakis dodecahedron, dual to the truncated icosahedron.
void getVertices(std::vector< mrpt::math::TPoint3D > &vertices) const
Gets a list with the polyhedron's vertices.
void getEdges(std::vector< TPolyhedronEdge > &edges) const
Gets a list with the polyhedron's edges.
bool intersect(const TSegment3D &s1, const TSegment3D &s2, TObject3D &obj)
Gets the intersection between two 3D segments.
static CPolyhedron::Ptr CreateDeltoidalIcositetrahedron(double radius)
Creates a deltoidal icositetrahedron, dual to the rhombicuboctahedron.
static CPolyhedron::Ptr CreateCustomPrism(const std::vector< mrpt::math::TPoint2D > &baseVertices, double height)
Creates a custom prism with vertical edges, given any base which will lie on the XY plane...
GLuint GLuint GLsizei GLenum type
static CPolyhedron::Ptr CreateDoublePyramid(const std::vector< mrpt::math::TPoint2D > &baseVertices, double height1, double height2)
Creates a double pyramid, using a set of 2D vertices which will lie on the XY plane.
CPolyhedron::Ptr augment(double height) const
Augments a polyhedron to a given height.
static CPolyhedron::Ptr CreateTruncatedHexahedron(double radius)
Creates a truncated hexahedron, with six octogonal faces and eight triangular ones (see http://en...
void getSetOfPolygonsAbsolute(std::vector< math::TPolygon3D > &vec) const
Gets the polyhedron as a set of polygons, with the pose transformation already applied.