template <class T, int N = 3>
class vtb::geometry::Polyhedron

Three-dimensional polyhedron.

  • Stores vertices, vertex normals, faces, face normals.
  • Fixes the order of faces using reorder.
  • Generates face and vertex normals using normalise.
  • Removes duplicate vertices and faces using unique.

Types
  • using triangle_array = std::vector< triangle_type >
  • using triangle_type = Triangle< T, N >
  • using box_type = Rectangle< T, N >
  • using index_type = typename face_type::value_type
  • using size_type = size_t
  • using face_array = std::vector< face_type >
  • using vertex_array = std::vector< vertex_type >
  • using face_type = Face< 3 >
  • using vertex_type = Vertex< T, N >
  • using scalar_type = T
Fields
  • constexpr const int dimensions
Methods
  • object(std::ostream & out) const -> void
  • gnuplot(std::ostream & out) const -> void
  • mass_moments_below(int dimension, scalar_type level) const -> Mass_moments< T, N >
  • mass_moments() const -> Mass_moments< T, N >

    Calculate volume, centre of mass and inertia tensor. Uses algorithm from [4].

    Date
    2019-06-08
    Author
    Ivan Gankevich
  • rotate(int dimension, int degrees) -> void

    Rotate the geometry by angle which is multiple of 90 degrees.

    dimension
    A dimension over which the rotation is done.

    degrees
    How many degrees to rotate. This should be a multiple of 90.

    Date
    2018-10-22
    Author
    Ivan Gankevich
  • mirror(int dimension) -> void

    Extend the geometry by mirroring it over the specified axis.

  • flip(int dimension) -> void

    Flip the geometry over specified axis.

  • wall(scalar_type thickness) -> void

    Shrink or extend the geometry by thickness in the direction of centroid.

  • scale(const vertex_type & ratio) -> void

    Scale the geometry by specified ratio over each dimension.

  • move(const vertex_type & delta) -> void
  • move_to_centre_of_bounding_box() -> void

    Move origin to centre of bounding box.

  • move_to_centre_of_mass() -> void

    Move origin to centre of mass.

  • blitz_faces() const -> blitz_face_array
  • blitz_vertex_normals() const -> blitz_vertex_array
  • blitz_vertices() const -> blitz_vertex_array
  • triangles() const -> triangle_array
  • empty() const -> bool
  • remove_face(index_type vertex) -> void
  • remove_face(const vertex_type & vertex) -> void
  • cut_duplicate_faces() -> void
  • clean() -> void

    Remove unused vertices.

    Date
    2020-05-20
  • split() const -> std::vector< Polyhedron >
  • split(std::vector< Polyhedron > & parts) const -> void

    Split into independent polyhedrons and append them to parts array.

    Date
    2020-05-20
  • operator+=(const Polyhedron & rhs) -> Polyhedron &
  • merge(const Polyhedron & rhs) -> void

    Add all vertices, faces and normals from rhs.

    • Does not perform deduplication.

    Date
    2019-04-05
    Author
    Ivan Gankevich
  • unique() -> void

    Remove duplicate vertices and faces.

    • Removes faces with duplicate indices as a side effect.

    Date
    2019-03-18
    Author
    Ivan Gankevich
  • reorder() -> void

    Fix face indices winding order.

    • Makes winding order of all face indices compatible with neighbouring faces.
    • The method finds reference face and computes surface normal using simple heuristic (the value of angle between normal and vector from the centre of the geometry to face centre). If the guess is correct, all faces would have the correct surface normal, otherwise they would have normals with the opposite directions.
    • Use unique to make sure that there are no faces with duplicate indices and there are no duplicate vertices.
    • Reference face is a face that is closest to the geometry centre.

    Date
    2019-03-18
    Author
    Vadim Petrunin
    Author
    Ivan Gankevich
  • normalise_vertices() -> void

    Compute vertex normals from face normals.

    Date
    2020-05-19
  • normalise_faces() -> void

    Compute face normals only.

    Date
    2019-09-12
    Author
    Ivan Gankevich
  • normalise() -> void

    Compute face and vertex normals in one loop.

    Date
    2019-03-18
    Author
    Ivan Gankevich
    See
    http://iquilezles.org/www/articles/normals/normals.htm
    • Use reorder to make sure that face indices winding order is correct.
  • signed_volume_below_centroid(int dimension) const -> scalar_type
  • swap(Polyhedron & rhs) -> void
  • bounds(int dimension) const -> Bounds< T >
  • bounding_box() const -> box_type
  • centroid_below(int dimension, scalar_type level) const -> vertex_type
  • centroid() const -> vertex_type
  • centre() const -> vertex_type
  • signed_volume_below(int dimension, scalar_type level) const -> scalar_type
  • signed_volume() const -> scalar_type
  • average_face_area() const -> scalar_type
  • area() const -> scalar_type
  • shrink_to_fit() -> void
  • clear_normals() -> void
  • clear() -> void
  • faces() const -> const face_array &
  • face_normals(vertex_array && rhs) -> void
  • face_normals(const vertex_array & rhs) -> void
  • face_normals() const -> const vertex_array &
  • vertex_normals() -> vertex_array &
  • vertex_normals() const -> const vertex_array &
  • vertices() -> vertex_array &
  • vertices() const -> const vertex_array &
  • template <class Surface>
    Polyhedron(const Surface & surface, size_type resolution_u, size_type resolution_v)
  • Polyhedron(const triangle_array & triangles)explicit
  • Polyhedron(const blitz_vertex_array & vertices, const blitz_face_array & faces)explicit
  • Polyhedron(vertex_array && vertices, vertex_array && vertex_normals, face_array && faces, vertex_array && face_normals)explicit
  • Polyhedron(const vertex_array & vertices, const vertex_array & vertex_normals, const face_array & faces, const vertex_array & face_normals)explicit
  • Polyhedron(const vertex_array & vertices, const vertex_array & vertex_normals, const face_array & faces)explicit
  • Polyhedron(vertex_array && vertices, face_array && faces)explicit
  • Polyhedron(const vertex_array & vertices, const face_array & faces)explicit
  • operator=(Polyhedron &&) -> Polyhedron &
  • Polyhedron(Polyhedron &&)
  • operator=(const Polyhedron &) -> Polyhedron &
  • Polyhedron(const Polyhedron &)
  • ~Polyhedron()
  • Polyhedron()
template <class T>
class vtb::geometry::Bounds
Methods
  • max() const -> T
  • min() const -> T
  • Bounds(T a, T b)
  • Bounds()
template <class T, int N>
winding_number(const Polyhedron< T, N > & geometry, const Vertex< T, N > & origin) -> T
template <class T, int N>
inertia_tensor(const Polyhedron< T, N > & body) -> Inertia_tensor< T, N >

Calculate inertia tensor (matrix) of a body as a sum of inertia tensors for tetrahedrons. Uses formulae from [13].

template <class T, int N>
area(const Polyhedron< T, N > & polyhedron) -> T
template <class T, int N>
swap(Polyhedron< T, N > & lhs, Polyhedron< T, N > & rhs) -> void
template <class T, int N>
operator>>(vtb::core::bstream & in, Polyhedron< T, N > & rhs) -> vtb::core::bstream &
template <class T, int N>
centroid(const Polyhedron< T, N > & geometry) -> Vertex< T, N >
template <class T, int N>
signed_volume(const Polyhedron< T, N > & geometry) -> T
template <class T, int N>
operator+(const Polyhedron< T, N > & lhs, const Polyhedron< T, N > & rhs) -> Polyhedron< T, N >
template <class T, int N>
volume(const Polyhedron< T, N > & geometry) -> T
template <class T, int N>
operator<<(vtb::core::bstream & out, const Polyhedron< T, N > & rhs) -> vtb::core::bstream &