cgv
Loading...
Searching...
No Matches
cgv::media::mesh::convex_polyhedron< T, TCDim > Class Template Reference

simple mesh templated with per vertex position and texture coordinates and per face plane. More...

#include <convex_polyhedron.h>

Inheritance diagram for cgv::media::mesh::convex_polyhedron< T, TCDim >:
cgv::media::mesh::convex_polyhedron_base

Classes

struct  vertex_type
 type of a vertex More...
 

Public Types

typedef T coord_type
 declare coordinate type
 
typedef cgv::math::fvec< T, 3 > point_type
 position type
 
typedef cgv::math::fvec< T, TCDim > texcoord_type
 texture coordinate type
 
typedef cgv::math::fvec< T, 4 > plane_type
 plane type
 
typedef cgv::media::axis_aligned_box< T, 3 > box_type
 type of axis aligned box
 
- Public Types inherited from cgv::media::mesh::convex_polyhedron_base
enum  VertexPlaneLocation { VPL_INSIDE = -1 , VPL_TOUCH = 0 , VPL_OUTSIDE = 1 }
 enumeration of different vertex locations with respect to plane More...
 
enum  FacePlaneLocation {
  FPL_OUTSIDE = 0 , FPL_INSIDE = 3 , FPL_TOUCH_NOTHING = 0 , FPL_TOUCH_VERTEX = 1 ,
  FPL_TOUCH_EDGE = 2 , FPL_TOUCH_FACE = 6 , FPL_SPLIT_TWO_VERTICES , FPL_SPLIT_VERTEX_EDGE ,
  FPL_SPLIT_TWO_EDGES , FPL_TWO_NON_ADJACENT_VERTICES_TOUCH , FPL_INCOMLETE_TOUCH_FACE , FPL_TOUCH_AND_SPLIT ,
  FPL_MULTI_SPLIT , FPL_ODD_TRANSITION_NUMBER , FPL_UNCONSIDERED_CASE , FPL_FIRST_INVALID_CASE = FPL_TWO_NON_ADJACENT_VERTICES_TOUCH
}
 enumeration of 11 valid and 5 invalid cases that a face can be located with respect to a plane after locating vertices into outside, inside or touching More...
 
typedef std::vector< int > face_type
 a face is an oriented list of vertex indices
 
typedef std::vector< face_typeshell_type
 a shell is simply a list of faces
 

Public Member Functions

vertex handling
size_t get_nr_vertices () const
 return current number of vertices
 
virtual int add_vertex ()
 
void del_vertex (int vi)
 remove a vertex
 
const vertex_typevertex (int vi) const
 
vertex_typevertex (int vi)
 
const point_typeposition (int vi) const
 
point_typeposition (int vi)
 
const texcoord_typetexcoord (int vi) const
 
texcoord_typetexcoord (int vi)
 
- Public Member Functions inherited from cgv::media::mesh::convex_polyhedron_base
FacePlaneLocation get_face_plane_location (const face_type &face, const std::vector< VertexPlaneLocation > &vertex_locations) const
 given a face as a list of vertex indices and a vector of vertex locations, determine the face location with respect to the current clip plane
 
size_t get_nr_shells () const
 return the current number of shells
 
const shell_typeshell (int si) const
 
shell_typeshell (int si)
 
size_t get_nr_faces (int si=0) const
 
const face_typeface (int fi, int si=0) const
 
face_typeface (int fi, int si=0)
 
void remove_redundant_vertices ()
 remove redundant vertices from mesh
 

Public Attributes

const cgv::type::int32_type texcoord_dim = TCDim
 declare dimension of texture coordinates
 

Protected Attributes

std::vector< vertex_typevertices
 vector to store vertices of all components in one vector
 
std::vector< std::vector< plane_type > > face_planes
 per shell a vector to store one plane per face
 
- Protected Attributes inherited from cgv::media::mesh::convex_polyhedron_base
std::vector< shell_typeshells
 vector of shells
 

handling of face planes

const plane_typeface_plane (int fi, int si=0) const
 return const reference to plane of face fi in shell si
 
plane_typeface_plane (int fi, int si=0)
 return reference to plane of face fi in shell si
 
plane_type compute_face_plane (int fi, int si=0) const
 compute a face plane from the vertex positions
 
int add_shell ()
 add a new shell and return shell index
 
void del_shell (int si)
 remove the shell of the given index, be careful as shell indices large si get implizitely decreased
 
void copy_shell (int si_source, int si_target)
 copy a shell onto another one
 
void swap_shells (int si0, int si1)
 swap two shells
 
int add_face (int si=0)
 
void del_face (int fi, int si=0)
 
void construct_box (const box_type &box)
 construct a polyhedron representing an axis aligned box
 
void clear ()
 clear data structure
 
void compute_vertex_locations (const plane_type &plane, std::vector< VertexPlaneLocation > &vertex_locations, T epsilon=16 *std::numeric_limits< T >::epsilon(), std::vector< T > *vertex_signed_distances_ptr=0) const
 construct a vector of vertex locations relative to given plane
 
bool check_face_locations (unsigned si, const std::vector< VertexPlaneLocation > &vertex_locations, std::vector< FacePlaneLocation > &face_locations) const
 compute face plane locations of the faces of one shell, store them in the vector face_locations and return if all is valid (assuming convex shape and convex faces)
 
bool ensure_vertex_location_consistency (unsigned si, const std::vector< T > &vertex_signed_distances, std::vector< VertexPlaneLocation > &vertex_locations, const std::vector< FacePlaneLocation > &face_locations, T epsilon=16 *std::numeric_limits< T >::epsilon(), T epsilon_flexibiliy=8)
 if the previous check is invalid, call this function to change the vertex signs in order to validate the face plane locations (not implemented yet)
 
int clip_to_inside_of_plane (unsigned si, const plane_type &clip_plane, bool keep_original_shell=false, T epsilon=16 *std::numeric_limits< T >::epsilon(), T epsilon_flexibiliy=8)
 compute the interior of the given shell si with respect to the given clipping plane and either replace the shell or create a new one
 
int clip_to_outside_of_plane (unsigned si, const plane_type &clip_plane, bool keep_original_shell=false, T epsilon=16 *std::numeric_limits< T >::epsilon(), T epsilon_flexibiliy=8)
 compute the exterior of the given shell si with respect to the given clipping plane and either replace the shell or create a new one
 
std::pair< int, int > split_at_plane (unsigned si, const plane_type &split_plane, bool keep_original_shell=false, T epsilon=16 *std::numeric_limits< T >::epsilon(), T epsilon_flexibiliy=8, std::vector< VertexPlaneLocation > *vertex_locations_ptr=0)
 split the given shell into interior and exterior
 
std::vector< vertex_typecompute_intersection_polygon (unsigned si, const plane_type &plane, T epsilon=16 *std::numeric_limits< T >::epsilon(), T epsilon_flexibiliy=8) const
 compute the intersection polygon between a shell and a plane
 
static bool orientation_match (const plane_type &p, const plane_type &q)
 check if planes are oriented in the same normal direction
 

Additional Inherited Members

- Static Public Member Functions inherited from cgv::media::mesh::convex_polyhedron_base
static int to_index (VertexPlaneLocation vertex_location)
 convert VertexPlaneLocation to an index in the range {0 .. 2}
 
static bool is_face_location_on_one_side (FacePlaneLocation face_location)
 check if a face location is on one side of the plane only with potential touch events
 
static bool is_face_location_split (FacePlaneLocation face_location)
 check if a face location corresponds to a split into parts (two for convex faces)
 
static bool is_valid_face_location (FacePlaneLocation face_location)
 check if a face location corresponds to a valid configuration assuming planar convex faces
 
static int box_get_face_vertex_index (int fi, int ci)
 function implementing the connectivity of an axis aligned box
 
static void change_orientation (face_type &face)
 revert the orientation of a face in place, where the face is given by a list of vertex indices
 
static VertexPlaneLocation vertex_location_side (const std::vector< VertexPlaneLocation > &vertex_locations)
 check whether all vertices lay on one side of the plane or on it, but not on the other; return side or VPL_TOUCH if vertices lay on both sides
 
static VertexPlaneLocation shell_location_side (const std::vector< FacePlaneLocation > &face_locations)
 check whether all faces of a shell lay on one side of the plane or touch it, but not on the other side; return side or VPL_TOUCH if shell is intersected by plane
 
static std::pair< int, int > extract_touching_halfedge (const face_type &face, const std::vector< VertexPlaneLocation > &vertex_locations)
 given a face as a list of vertex indices and a vector of vertex locations, find a halfedge that touches the current clip plane
 

Detailed Description

template<typename T, cgv::type::int32_type TCDim = 2>
class cgv::media::mesh::convex_polyhedron< T, TCDim >

simple mesh templated with per vertex position and texture coordinates and per face plane.

First template parameter is common type and the second is the dimension of texture coordinates

Definition at line 124 of file convex_polyhedron.h.

Member Typedef Documentation

◆ box_type

template<typename T , cgv::type::int32_type TCDim = 2>
typedef cgv::media::axis_aligned_box<T, 3> cgv::media::mesh::convex_polyhedron< T, TCDim >::box_type

type of axis aligned box

Definition at line 138 of file convex_polyhedron.h.

◆ coord_type

template<typename T , cgv::type::int32_type TCDim = 2>
typedef T cgv::media::mesh::convex_polyhedron< T, TCDim >::coord_type

declare coordinate type

Definition at line 128 of file convex_polyhedron.h.

◆ plane_type

template<typename T , cgv::type::int32_type TCDim = 2>
typedef cgv::math::fvec<T, 4> cgv::media::mesh::convex_polyhedron< T, TCDim >::plane_type

plane type

Definition at line 136 of file convex_polyhedron.h.

◆ point_type

template<typename T , cgv::type::int32_type TCDim = 2>
typedef cgv::math::fvec<T, 3> cgv::media::mesh::convex_polyhedron< T, TCDim >::point_type

position type

Definition at line 132 of file convex_polyhedron.h.

◆ texcoord_type

template<typename T , cgv::type::int32_type TCDim = 2>
typedef cgv::math::fvec<T, TCDim> cgv::media::mesh::convex_polyhedron< T, TCDim >::texcoord_type

texture coordinate type

Definition at line 134 of file convex_polyhedron.h.

Member Function Documentation

◆ add_face()

template<typename T , cgv::type::int32_type TCDim = 2>
int cgv::media::mesh::convex_polyhedron< T, TCDim >::add_face ( int  si = 0)
inlinevirtual

Reimplemented from cgv::media::mesh::convex_polyhedron_base.

Definition at line 219 of file convex_polyhedron.h.

◆ add_shell()

template<typename T , cgv::type::int32_type TCDim = 2>
int cgv::media::mesh::convex_polyhedron< T, TCDim >::add_shell ( )
inlinevirtual

◆ add_vertex()

template<typename T , cgv::type::int32_type TCDim = 2>
virtual int cgv::media::mesh::convex_polyhedron< T, TCDim >::add_vertex ( )
inlinevirtual

Definition at line 156 of file convex_polyhedron.h.

◆ check_face_locations()

template<typename T , cgv::type::int32_type TCDim>
bool cgv::media::mesh::convex_polyhedron< T, TCDim >::check_face_locations ( unsigned  si,
const std::vector< VertexPlaneLocation > &  vertex_locations,
std::vector< FacePlaneLocation > &  face_locations 
) const

compute face plane locations of the faces of one shell, store them in the vector face_locations and return if all is valid (assuming convex shape and convex faces)

Definition at line 299 of file convex_polyhedron.h.

◆ clear()

template<typename T , cgv::type::int32_type TCDim>
void cgv::media::mesh::convex_polyhedron< T, TCDim >::clear ( )

clear data structure

Definition at line 290 of file convex_polyhedron.h.

◆ clip_to_inside_of_plane()

template<typename T , cgv::type::int32_type TCDim>
int cgv::media::mesh::convex_polyhedron< T, TCDim >::clip_to_inside_of_plane ( unsigned  si,
const plane_type clip_plane,
bool  keep_original_shell = false,
epsilon = 16 * std::numeric_limits<T>::epsilon(),
epsilon_flexibiliy = 8 
)

compute the interior of the given shell si with respect to the given clipping plane and either replace the shell or create a new one

return the index of the new shell or -1 if the shell was empty and therefore not created. If the current shell was to be replace with an empty result, it is simply deleted.

Definition at line 328 of file convex_polyhedron.h.

◆ clip_to_outside_of_plane()

template<typename T , cgv::type::int32_type TCDim>
int cgv::media::mesh::convex_polyhedron< T, TCDim >::clip_to_outside_of_plane ( unsigned  si,
const plane_type clip_plane,
bool  keep_original_shell = false,
epsilon = 16 * std::numeric_limits<T>::epsilon(),
epsilon_flexibiliy = 8 
)

compute the exterior of the given shell si with respect to the given clipping plane and either replace the shell or create a new one

return the index of the new shell or -1 if the shell was empty and therefore not created. If the current shell was to be replace with an empty result, it is simply deleted.

Definition at line 346 of file convex_polyhedron.h.

◆ compute_face_plane()

template<typename T , cgv::type::int32_type TCDim = 2>
plane_type cgv::media::mesh::convex_polyhedron< T, TCDim >::compute_face_plane ( int  fi,
int  si = 0 
) const
inline

compute a face plane from the vertex positions

Definition at line 185 of file convex_polyhedron.h.

References cgv::math::fvec< T, N >::normalize().

◆ compute_intersection_polygon()

template<typename T , cgv::type::int32_type TCDim>
std::vector< typename convex_polyhedron< T, TCDim >::vertex_type > cgv::media::mesh::convex_polyhedron< T, TCDim >::compute_intersection_polygon ( unsigned  si,
const plane_type plane,
epsilon = 16 * std::numeric_limits<T>::epsilon(),
epsilon_flexibiliy = 8 
) const

compute the intersection polygon between a shell and a plane

Definition at line 639 of file convex_polyhedron.h.

◆ compute_vertex_locations()

template<typename T , cgv::type::int32_type TCDim>
void cgv::media::mesh::convex_polyhedron< T, TCDim >::compute_vertex_locations ( const plane_type plane,
std::vector< VertexPlaneLocation > &  vertex_locations,
epsilon = 16 * std::numeric_limits<T>::epsilon(),
std::vector< T > *  vertex_signed_distances_ptr = 0 
) const

construct a vector of vertex locations relative to given plane

Definition at line 364 of file convex_polyhedron.h.

◆ construct_box()

template<typename T , cgv::type::int32_type TCDim>
void cgv::media::mesh::convex_polyhedron< T, TCDim >::construct_box ( const box_type box)

construct a polyhedron representing an axis aligned box

Definition at line 258 of file convex_polyhedron.h.

References cgv::media::axis_aligned_box< T, N >::get_max_pnt(), cgv::media::axis_aligned_box< T, N >::get_min_pnt(), and cgv::math::fvec< T, N >::zeros().

◆ copy_shell()

template<typename T , cgv::type::int32_type TCDim = 2>
void cgv::media::mesh::convex_polyhedron< T, TCDim >::copy_shell ( int  si_source,
int  si_target 
)
inlinevirtual

◆ del_face()

template<typename T , cgv::type::int32_type TCDim = 2>
void cgv::media::mesh::convex_polyhedron< T, TCDim >::del_face ( int  fi,
int  si = 0 
)
inlinevirtual

Reimplemented from cgv::media::mesh::convex_polyhedron_base.

Definition at line 224 of file convex_polyhedron.h.

◆ del_shell()

template<typename T , cgv::type::int32_type TCDim = 2>
void cgv::media::mesh::convex_polyhedron< T, TCDim >::del_shell ( int  si)
inlinevirtual

remove the shell of the given index, be careful as shell indices large si get implizitely decreased

Reimplemented from cgv::media::mesh::convex_polyhedron_base.

Definition at line 204 of file convex_polyhedron.h.

References cgv::media::mesh::convex_polyhedron_base::del_shell(), and cgv::media::mesh::convex_polyhedron< T, TCDim >::face_planes.

◆ del_vertex()

template<typename T , cgv::type::int32_type TCDim = 2>
void cgv::media::mesh::convex_polyhedron< T, TCDim >::del_vertex ( int  vi)
inlinevirtual

◆ ensure_vertex_location_consistency()

template<typename T , cgv::type::int32_type TCDim>
bool cgv::media::mesh::convex_polyhedron< T, TCDim >::ensure_vertex_location_consistency ( unsigned  si,
const std::vector< T > &  vertex_signed_distances,
std::vector< VertexPlaneLocation > &  vertex_locations,
const std::vector< FacePlaneLocation > &  face_locations,
epsilon = 16 * std::numeric_limits<T>::epsilon(),
epsilon_flexibiliy = 8 
)

if the previous check is invalid, call this function to change the vertex signs in order to validate the face plane locations (not implemented yet)

Definition at line 321 of file convex_polyhedron.h.

◆ face_plane() [1/2]

template<typename T , cgv::type::int32_type TCDim = 2>
plane_type & cgv::media::mesh::convex_polyhedron< T, TCDim >::face_plane ( int  fi,
int  si = 0 
)
inline

return reference to plane of face fi in shell si

Definition at line 183 of file convex_polyhedron.h.

References cgv::media::mesh::convex_polyhedron< T, TCDim >::face_planes.

◆ face_plane() [2/2]

template<typename T , cgv::type::int32_type TCDim = 2>
const plane_type & cgv::media::mesh::convex_polyhedron< T, TCDim >::face_plane ( int  fi,
int  si = 0 
) const
inline

return const reference to plane of face fi in shell si

Definition at line 181 of file convex_polyhedron.h.

References cgv::media::mesh::convex_polyhedron< T, TCDim >::face_planes.

◆ get_nr_vertices()

template<typename T , cgv::type::int32_type TCDim = 2>
size_t cgv::media::mesh::convex_polyhedron< T, TCDim >::get_nr_vertices ( ) const
inlinevirtual

return current number of vertices

Implements cgv::media::mesh::convex_polyhedron_base.

Definition at line 154 of file convex_polyhedron.h.

References cgv::media::mesh::convex_polyhedron< T, TCDim >::vertices.

◆ orientation_match()

template<typename T , cgv::type::int32_type TCDim = 2>
static bool cgv::media::mesh::convex_polyhedron< T, TCDim >::orientation_match ( const plane_type p,
const plane_type q 
)
inlinestatic

check if planes are oriented in the same normal direction

Definition at line 177 of file convex_polyhedron.h.

◆ position() [1/2]

template<typename T , cgv::type::int32_type TCDim = 2>
point_type & cgv::media::mesh::convex_polyhedron< T, TCDim >::position ( int  vi)
inline

Definition at line 166 of file convex_polyhedron.h.

◆ position() [2/2]

template<typename T , cgv::type::int32_type TCDim = 2>
const point_type & cgv::media::mesh::convex_polyhedron< T, TCDim >::position ( int  vi) const
inline

Definition at line 164 of file convex_polyhedron.h.

◆ split_at_plane()

template<typename T , cgv::type::int32_type TCDim>
std::pair< int, int > cgv::media::mesh::convex_polyhedron< T, TCDim >::split_at_plane ( unsigned  si,
const plane_type split_plane,
bool  keep_original_shell = false,
epsilon = 16 * std::numeric_limits<T>::epsilon(),
epsilon_flexibiliy = 8,
std::vector< VertexPlaneLocation > *  vertex_locations_ptr = 0 
)

split the given shell into interior and exterior

return shell index pair where first index corresponds to interior part and second to exterior part. If a shell is empty the returned shell index is set to -1.

Definition at line 381 of file convex_polyhedron.h.

◆ swap_shells()

template<typename T , cgv::type::int32_type TCDim = 2>
void cgv::media::mesh::convex_polyhedron< T, TCDim >::swap_shells ( int  si0,
int  si1 
)
inlinevirtual

◆ texcoord() [1/2]

template<typename T , cgv::type::int32_type TCDim = 2>
texcoord_type & cgv::media::mesh::convex_polyhedron< T, TCDim >::texcoord ( int  vi)
inline

Definition at line 170 of file convex_polyhedron.h.

◆ texcoord() [2/2]

template<typename T , cgv::type::int32_type TCDim = 2>
const texcoord_type & cgv::media::mesh::convex_polyhedron< T, TCDim >::texcoord ( int  vi) const
inline

Definition at line 168 of file convex_polyhedron.h.

◆ vertex() [1/2]

template<typename T , cgv::type::int32_type TCDim = 2>
vertex_type & cgv::media::mesh::convex_polyhedron< T, TCDim >::vertex ( int  vi)
inline

Definition at line 162 of file convex_polyhedron.h.

◆ vertex() [2/2]

template<typename T , cgv::type::int32_type TCDim = 2>
const vertex_type & cgv::media::mesh::convex_polyhedron< T, TCDim >::vertex ( int  vi) const
inline

Definition at line 160 of file convex_polyhedron.h.

Member Data Documentation

◆ face_planes

◆ texcoord_dim

template<typename T , cgv::type::int32_type TCDim = 2>
const cgv::type::int32_type cgv::media::mesh::convex_polyhedron< T, TCDim >::texcoord_dim = TCDim

declare dimension of texture coordinates

Definition at line 130 of file convex_polyhedron.h.

◆ vertices

template<typename T , cgv::type::int32_type TCDim = 2>
std::vector<vertex_type> cgv::media::mesh::convex_polyhedron< T, TCDim >::vertices
protected

vector to store vertices of all components in one vector

Definition at line 147 of file convex_polyhedron.h.

Referenced by cgv::media::mesh::convex_polyhedron< T, TCDim >::del_vertex(), and cgv::media::mesh::convex_polyhedron< T, TCDim >::get_nr_vertices().


The documentation for this class was generated from the following file: