95 double length(
const std::vector<mrpt::math::TPoint3D>& vs)
const;
116 double area(
const std::vector<mrpt::math::TPoint3D>&
vertices)
const;
119 const std::vector<mrpt::math::TPoint3D>&
vertices,
274 double radius,
bool type =
true);
290 double radius,
bool type =
true);
433 double x1,
double x2,
double y1,
double y2,
double z1,
double z2);
448 const std::vector<mrpt::math::TPoint2D>& baseVertices,
double height);
456 const std::vector<mrpt::math::TPoint2D>& baseVertices,
double height1,
466 const std::vector<mrpt::math::TPoint2D>& baseVertices,
double height,
473 const std::vector<mrpt::math::TPoint2D>& baseVertices,
double height,
482 const std::vector<mrpt::math::TPoint2D>& baseVertices,
double height);
490 const std::vector<mrpt::math::TPoint2D>& bottomBase,
491 const std::vector<mrpt::math::TPoint2D>& topBase,
double height);
506 const std::vector<mrpt::math::TPoint2D>& baseVertices,
double height1,
507 double ratio1,
double height2,
double ratio2);
516 uint32_t numBaseEdges,
double baseRadius,
double basesDistance);
525 uint32_t numBaseEdges,
double baseRadius,
double height);
532 uint32_t numBaseEdges,
double baseRadius,
double height);
538 uint32_t numBaseEdges,
double baseRadius,
double height);
544 uint32_t numBaseEdges,
double baseRadius,
double height1,
553 uint32_t numBaseEdges,
double baseRadius);
561 uint32_t numBaseEdges,
double baseRadius);
567 uint32_t numBaseEdges,
double baseRadius,
double height,
double ratio);
573 uint32_t numBaseEdges,
double baseRadius,
double height,
double ratio);
580 uint32_t numBaseEdges,
double baseRadius,
double height1,
double ratio1,
581 double height2,
double ratio2);
587 uint32_t numBaseEdges,
double edgeLength);
596 uint32_t numBaseEdges,
double height);
605 uint32_t numBaseEdges,
double height);
656 uint32_t numBaseEdges,
double baseRadius,
const std::string& components,
666 inline void getVertices(std::vector<mrpt::math::TPoint3D>& vertices)
const 673 inline void getEdges(std::vector<TPolyhedronEdge>& edges)
const 680 inline void getFaces(std::vector<TPolyhedronFace>& faces)
const 745 for (
size_t i = 0; i <
m_Vertices.size(); i++)
837 uint32_t numBaseEdges,
double baseRadius);
843 uint32_t numBaseEdges,
double baseRadius);
849 uint32_t numBaseEdges,
double baseRadius,
double height,
850 std::vector<mrpt::math::TPoint3D>& vec);
856 uint32_t numBaseEdges,
double baseRadius,
double height,
double shift,
857 std::vector<mrpt::math::TPoint3D>& vec);
861 bool setNormal(TPolyhedronFace& f,
bool doCheck =
true);
865 void addEdges(
const TPolyhedronFace& e);
870 const std::vector<mrpt::math::TPoint3D>& vertices,
871 const std::vector<TPolyhedronFace>& faces);
891 const std::vector<mrpt::math::TPoint3D>& vertices,
892 const std::vector<TPolyhedronFace>& faces,
bool doCheck =
true)
902 const std::vector<mrpt::math::TPoint3D>& vertices,
903 const std::vector<TPolyhedronFace>& faces,
bool doCheck =
true)
906 throw std::logic_error(
"Face list accesses a vertex out of range");
910 throw std::logic_error(
"Bad face specification");
915 CPolyhedron(
const std::vector<math::TPolygon3D>& polys);
918 const std::vector<mrpt::math::TPoint3D>& vertices,
919 const std::vector<std::vector<uint32_t>>& faces);
923 const std::vector<mrpt::math::TPoint3D>& vertices,
924 const std::vector<TPolyhedronFace>& faces);
936 std::vector<mrpt::math::TPolygon3D> polys1, polys2;
937 p1->getSetOfPolygonsAbsolute(polys1);
938 p2->getSetOfPolygonsAbsolute(polys2);
static CPolyhedron::Ptr CreateEmpty()
Creates an empty Polyhedron.
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)
Declares a typename to be "namespace::type".
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.
~CPolyhedron() override=default
Destructor.
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
size_t facesInVertex(size_t vertex) const
Returns how many faces converge in a given vertex.
virtual shader_list_t requiredShaders() const override
Returns the ID of the OpenGL shader program required to render this class.
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CPolyhedron::TPolyhedronEdge &o)
Reads a polyhedron edge from a binary stream.
uint32_t getNumberOfVertices() const
Gets the amount of vertices.
TPolyhedronEdge()=default
Default constructor.
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 freeOpenGLResources() override
Free opengl buffers.
void onUpdateBuffers_Triangles() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
void InitFromVertAndFaces(const std::vector< mrpt::math::TPoint3D > &vertices, const std::vector< TPolyhedronFace > &faces, bool doCheck=true)
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
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.
COpenGLScene::Ptr & operator<<(COpenGLScene::Ptr &s, const CRenderizable::Ptr &r)
Inserts an openGL object into a scene.
CPolyhedron::Ptr getDual() const
Given a polyhedron, creates its dual.
static CPolyhedron::Ptr CreateCatalanDoublePyramid(uint32_t numBaseEdges, double height)
Creates a double pyramid whose dual is exactly an archimedean prism.
bool m_Wireframe
This flag determines whether the polyhedron will be displayed as a solid object or as a set of edges...
mrpt::math::TVector3D normal
Normal vector.
CPolyhedron::Ptr rotate(double angle) const
Rotates a polyhedron around the Z axis a given amount of radians.
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...
Renderizable generic renderer for objects using the triangles shader.
std::vector< TPolyhedronFace > m_Faces
List of polyhedron's faces.
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.
std::vector< TPolyhedronEdge > m_Edges
List of polyhedron's edges.
std::vector< shader_id_t > shader_list_t
A list of shader IDs.
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.
Context for calls to render()
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
Simulation of ray-trace, given a pose.
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.
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...
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).
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 constexpr shader_id_t WIREFRAME
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 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.
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.
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.
~TPolyhedronEdge()=default
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...
void onUpdateBuffers_Wireframe() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
CPolyhedron::Ptr scale(double factor) const
Scales a polyhedron to a given factor.
static constexpr shader_id_t TRIANGLES
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...
void freeOpenGLResources() override
Free opengl buffers.
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.
std::shared_ptr< mrpt::opengl ::CPolyhedron > Ptr
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.
Virtual base class for "archives": classes abstracting I/O streams.
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).
mrpt::vision::TStereoCalibResults out
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.
Renderizable generic renderer for objects using the wireframe shader.
static CPolyhedron::Ptr CreateTruncatedIcosahedron(double radius)
Creates a truncated icosahedron, consisting of 20 hexagons and 12 pentagons.
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...
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.
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).
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
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.
~TPolyhedronFace()=default
Destructor.
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.
void getCenter(mrpt::math::TPoint3D ¢er) const
Gets the center of the polyhedron.
void getFacesArea(std::vector< double > &areas) const
Gets a vector with each face's area.
std::vector< mrpt::math::TPoint3D > m_Vertices
List of vertices presents in the polyhedron.
void freeOpenGLResources() override
Free opengl buffers.
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...
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.