DART 6.12.2
Loading...
Searching...
No Matches
dart::math::Icosphere< S_ > Class Template Reference

The class Icosphere represents an icosphere where the subdivision and radius are configurable. More...

#include <Icosphere.hpp>

Inheritance diagram for dart::math::Icosphere< S_ >:
dart::math::TriMesh< S_ > dart::math::Mesh< S_ >

Public Types

using S = S_
 
using Base = TriMesh< S >
 
using Index = typename Base::Index
 
using Vector3 = typename Base::Vector3
 
using Triangle = typename Base::Triangle
 
using Vertices = std::vector< Vector3 >
 
using Normals = typename Base::Normals
 
using Triangles = std::vector< Triangle >
 
using Indices = std::vector< Index >
 

Public Member Functions

 Icosphere (S radius, std::size_t subdivisions)
 Construct an icosphere given radius and subdivisions.
 
S getRadius () const
 Returns the radius of the icosphere.
 
std::size_t getNumSubdivisions () const
 Returns the number of subdivisions of the icosphere.
 
void setTriangles (const Vertices &vertices, const Triangles &triangles)
 Sets vertices and triangles.
 
void computeVertexNormals ()
 Computes vertex normals.
 
bool hasTriangles () const
 Returns true if the mesh contains triangles.
 
bool hasTriangleNormals () const
 Returns true if the mesh contains triangle normals.
 
const TrianglesgetTriangles () const
 Returns the triangles of the mesh.
 
const NormalsgetTriangleNormals () const
 Returns the triangle normals of the mesh.
 
void clear () override
 Clears all the data in the trimesh.
 
TriMesh operator+ (const TriMesh &other) const
 Addition operator.
 
Mesh operator+ (const Mesh &other) const
 Addition operator.
 
TriMeshoperator+= (const TriMesh &other)
 Addition assignment operator.
 
Meshoperator+= (const Mesh &other)
 Addition assignment operator.
 
std::shared_ptr< TriMesh< S > > generateConvexHull (bool optimize=true) const
 Generates a convex hull that encloses the trimesh.
 
bool hasVertices () const
 Returns true if the mesh contains vertices.
 
bool hasVertexNormals () const
 Returns true if the mesh contains vertex normals.
 
const VerticesgetVertices () const
 Returns the vertices of the mesh.
 
const NormalsgetVertexNormals () const
 Returns the vertex normals of the mesh.
 
bool isEmpty () const
 Returns true if the mesh has no vertices.
 
void translate (const Vector3 &translation)
 Translates the mesh vertices by adding translation to the vertices.
 

Static Public Member Functions

static std::size_t getNumVertices (std::size_t subdivisions)
 Returns the number of vertices of icosphere given subdivisions.
 
static std::size_t getNumEdges (std::size_t subdivisions)
 Returns the number of edges of icosphere given subdivisions.
 
static std::size_t getNumTriangles (std::size_t subdivisions)
 Returns the number of triangles of icosphere given subdivisions.
 
static std::pair< Vertices, TrianglescomputeIcosahedron (S radius)
 Returns vertices and faces of icosahedron given radius.
 

Protected Member Functions

void computeTriangleNormals ()
 Computes triangle normals.
 
void normalizeTriangleNormals ()
 Normalizes triangle normals.
 
void normalizeVertexNormals ()
 Normalizes the vertex normals.
 

Protected Attributes

Triangles mTriangles
 Triangle indices of the mesh.
 
Normals mTriangleNormals
 Triangle normals of the mesh.
 
Vertices mVertices
 Vertices of the mesh.
 
Normals mVertexNormals
 Vertex normals of the mesh.
 

Private Member Functions

void build ()
 Internal function to build icosphere given radius and subdivisions.
 

Private Attributes

S mRadius
 Radius of icosphere.
 
std::size_t mSubdivisions
 Number of subdividing an icosahedron.
 

Detailed Description

template<typename S_>
class dart::math::Icosphere< S_ >

The class Icosphere represents an icosphere where the subdivision and radius are configurable.

Member Typedef Documentation

◆ Base

template<typename S_ >
using dart::math::Icosphere< S_ >::Base = TriMesh<S>

◆ Index

◆ Indices

template<typename S_ >
using dart::math::Mesh< S_ >::Indices = std::vector<Index>
inherited

◆ Normals

◆ S

◆ Triangle

◆ Triangles

template<typename S_ >
using dart::math::Icosphere< S_ >::Triangles = std::vector<Triangle>

◆ Vector3

◆ Vertices

template<typename S_ >
using dart::math::Icosphere< S_ >::Vertices = std::vector<Vector3>

Constructor & Destructor Documentation

◆ Icosphere()

template<typename S >
dart::math::Icosphere< S >::Icosphere ( S  radius,
std::size_t  subdivisions 
)

Construct an icosphere given radius and subdivisions.

Parameters
[in]radiusThe radius of the icosphere.
[in]subdivisionsThe number of subdividing an icosahedron. Passing 1 generates icosahedron without subdividing.

Member Function Documentation

◆ build()

template<typename S >
void dart::math::Icosphere< S >::build ( )
private

Internal function to build icosphere given radius and subdivisions.

◆ clear()

template<typename S >
void dart::math::TriMesh< S >::clear ( )
overridevirtualinherited

Clears all the data in the trimesh.

Reimplemented from dart::math::Mesh< S_ >.

◆ computeIcosahedron()

template<typename S >
std::pair< typename Icosphere< S >::Vertices, typename Icosphere< S >::Triangles > dart::math::Icosphere< S >::computeIcosahedron ( S  radius)
static

Returns vertices and faces of icosahedron given radius.

◆ computeTriangleNormals()

template<typename S >
void dart::math::TriMesh< S >::computeTriangleNormals ( )
protectedinherited

Computes triangle normals.

◆ computeVertexNormals()

template<typename S >
void dart::math::TriMesh< S >::computeVertexNormals ( )
inherited

Computes vertex normals.

◆ generateConvexHull()

template<typename S >
std::shared_ptr< TriMesh< S > > dart::math::TriMesh< S >::generateConvexHull ( bool  optimize = true) const
inherited

Generates a convex hull that encloses the trimesh.

Parameters
[in]optimize(Optional) Whether to discard vertices that are not used in the convex hull.

◆ getNumEdges()

template<typename S >
std::size_t dart::math::Icosphere< S >::getNumEdges ( std::size_t  subdivisions)
static

Returns the number of edges of icosphere given subdivisions.

◆ getNumSubdivisions()

template<typename S >
std::size_t dart::math::Icosphere< S >::getNumSubdivisions ( ) const

Returns the number of subdivisions of the icosphere.

◆ getNumTriangles()

template<typename S >
std::size_t dart::math::Icosphere< S >::getNumTriangles ( std::size_t  subdivisions)
static

Returns the number of triangles of icosphere given subdivisions.

◆ getNumVertices()

template<typename S >
std::size_t dart::math::Icosphere< S >::getNumVertices ( std::size_t  subdivisions)
static

Returns the number of vertices of icosphere given subdivisions.

◆ getRadius()

template<typename S >
S dart::math::Icosphere< S >::getRadius ( ) const

Returns the radius of the icosphere.

◆ getTriangleNormals()

template<typename S >
const TriMesh< S >::Normals & dart::math::TriMesh< S >::getTriangleNormals ( ) const
inherited

Returns the triangle normals of the mesh.

◆ getTriangles()

template<typename S >
const TriMesh< S >::Triangles & dart::math::TriMesh< S >::getTriangles ( ) const
inherited

Returns the triangles of the mesh.

◆ getVertexNormals()

template<typename S >
const Mesh< S >::Normals & dart::math::Mesh< S >::getVertexNormals ( ) const
inherited

Returns the vertex normals of the mesh.

◆ getVertices()

template<typename S >
const Mesh< S >::Vertices & dart::math::Mesh< S >::getVertices ( ) const
inherited

Returns the vertices of the mesh.

◆ hasTriangleNormals()

template<typename S >
bool dart::math::TriMesh< S >::hasTriangleNormals ( ) const
inherited

Returns true if the mesh contains triangle normals.

◆ hasTriangles()

template<typename S >
bool dart::math::TriMesh< S >::hasTriangles ( ) const
inherited

Returns true if the mesh contains triangles.

◆ hasVertexNormals()

template<typename S >
bool dart::math::Mesh< S >::hasVertexNormals ( ) const
inherited

Returns true if the mesh contains vertex normals.

◆ hasVertices()

template<typename S >
bool dart::math::Mesh< S >::hasVertices ( ) const
inherited

Returns true if the mesh contains vertices.

◆ isEmpty()

template<typename S >
bool dart::math::Mesh< S >::isEmpty ( ) const
inherited

Returns true if the mesh has no vertices.

◆ normalizeTriangleNormals()

template<typename S >
void dart::math::TriMesh< S >::normalizeTriangleNormals ( )
protectedinherited

Normalizes triangle normals.

◆ normalizeVertexNormals()

template<typename S >
void dart::math::Mesh< S >::normalizeVertexNormals ( )
protectedinherited

Normalizes the vertex normals.

◆ operator+() [1/2]

template<typename S >
Mesh< S > dart::math::Mesh< S >::operator+ ( const Mesh< S_ > &  other) const
inherited

Addition operator.

◆ operator+() [2/2]

template<typename S >
TriMesh< S > dart::math::TriMesh< S >::operator+ ( const TriMesh< S_ > &  other) const
inherited

Addition operator.

◆ operator+=() [1/2]

template<typename S >
Mesh< S > & dart::math::Mesh< S >::operator+= ( const Mesh< S_ > &  other)
inherited

Addition assignment operator.

◆ operator+=() [2/2]

template<typename S >
TriMesh< S > & dart::math::TriMesh< S >::operator+= ( const TriMesh< S_ > &  other)
inherited

Addition assignment operator.

◆ setTriangles()

template<typename S >
void dart::math::TriMesh< S >::setTriangles ( const Vertices vertices,
const Triangles triangles 
)
inherited

Sets vertices and triangles.

◆ translate()

template<typename S >
void dart::math::Mesh< S >::translate ( const Vector3 translation)
inherited

Translates the mesh vertices by adding translation to the vertices.

Member Data Documentation

◆ mRadius

template<typename S_ >
S dart::math::Icosphere< S_ >::mRadius
private

Radius of icosphere.

◆ mSubdivisions

template<typename S_ >
std::size_t dart::math::Icosphere< S_ >::mSubdivisions
private

Number of subdividing an icosahedron.

◆ mTriangleNormals

template<typename S_ >
Normals dart::math::TriMesh< S_ >::mTriangleNormals
protectedinherited

Triangle normals of the mesh.

◆ mTriangles

template<typename S_ >
Triangles dart::math::TriMesh< S_ >::mTriangles
protectedinherited

Triangle indices of the mesh.

◆ mVertexNormals

template<typename S_ >
Normals dart::math::Mesh< S_ >::mVertexNormals
protectedinherited

Vertex normals of the mesh.

◆ mVertices

template<typename S_ >
Vertices dart::math::Mesh< S_ >::mVertices
protectedinherited

Vertices of the mesh.