cgv
|
simple mesh templated with per vertex position and texture coordinates and per face plane. More...
#include <convex_polyhedron.h>
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 | |
![]() | |
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_type > | shell_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_type & | vertex (int vi) const |
vertex_type & | vertex (int vi) |
const point_type & | position (int vi) const |
point_type & | position (int vi) |
const texcoord_type & | texcoord (int vi) const |
texcoord_type & | texcoord (int vi) |
![]() | |
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_type & | shell (int si) const |
shell_type & | shell (int si) |
size_t | get_nr_faces (int si=0) const |
const face_type & | face (int fi, int si=0) const |
face_type & | face (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_type > | vertices |
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 | |
![]() | |
std::vector< shell_type > | shells |
vector of shells | |
handling of face planes | |
const plane_type & | face_plane (int fi, int si=0) const |
return const reference to plane of face fi in shell si | |
plane_type & | face_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_type > | compute_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 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 | |
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.
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.
typedef T cgv::media::mesh::convex_polyhedron< T, TCDim >::coord_type |
declare coordinate type
Definition at line 128 of file convex_polyhedron.h.
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.
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.
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.
|
inlinevirtual |
Reimplemented from cgv::media::mesh::convex_polyhedron_base.
Definition at line 219 of file convex_polyhedron.h.
|
inlinevirtual |
add a new shell and return shell index
Reimplemented from cgv::media::mesh::convex_polyhedron_base.
Definition at line 199 of file convex_polyhedron.h.
References cgv::media::mesh::convex_polyhedron_base::add_shell(), and cgv::media::mesh::convex_polyhedron< T, TCDim >::face_planes.
|
inlinevirtual |
Definition at line 156 of file convex_polyhedron.h.
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.
void cgv::media::mesh::convex_polyhedron< T, TCDim >::clear | ( | ) |
clear data structure
Definition at line 290 of file convex_polyhedron.h.
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 , |
||
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
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.
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 , |
||
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
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.
|
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().
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, | ||
T | epsilon = 16 * std::numeric_limits<T>::epsilon() , |
||
T | epsilon_flexibiliy = 8 |
||
) | const |
compute the intersection polygon between a shell and a plane
Definition at line 639 of file convex_polyhedron.h.
void cgv::media::mesh::convex_polyhedron< T, TCDim >::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
Definition at line 364 of file convex_polyhedron.h.
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().
|
inlinevirtual |
copy a shell onto another one
Reimplemented from cgv::media::mesh::convex_polyhedron_base.
Definition at line 209 of file convex_polyhedron.h.
References cgv::media::mesh::convex_polyhedron_base::copy_shell(), and cgv::media::mesh::convex_polyhedron< T, TCDim >::face_planes.
|
inlinevirtual |
Reimplemented from cgv::media::mesh::convex_polyhedron_base.
Definition at line 224 of file convex_polyhedron.h.
|
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.
|
inlinevirtual |
remove a vertex
Implements cgv::media::mesh::convex_polyhedron_base.
Definition at line 158 of file convex_polyhedron.h.
References cgv::media::mesh::convex_polyhedron< T, TCDim >::vertices.
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, | ||
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)
Definition at line 321 of file convex_polyhedron.h.
|
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.
|
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.
|
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.
|
inlinestatic |
check if planes are oriented in the same normal direction
Definition at line 177 of file convex_polyhedron.h.
|
inline |
Definition at line 166 of file convex_polyhedron.h.
|
inline |
Definition at line 164 of file convex_polyhedron.h.
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 , |
||
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
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.
|
inlinevirtual |
swap two shells
Reimplemented from cgv::media::mesh::convex_polyhedron_base.
Definition at line 214 of file convex_polyhedron.h.
References cgv::media::mesh::convex_polyhedron< T, TCDim >::face_planes, and cgv::media::mesh::convex_polyhedron_base::swap_shells().
|
inline |
Definition at line 170 of file convex_polyhedron.h.
|
inline |
Definition at line 168 of file convex_polyhedron.h.
|
inline |
Definition at line 162 of file convex_polyhedron.h.
|
inline |
Definition at line 160 of file convex_polyhedron.h.
|
protected |
per shell a vector to store one plane per face
Definition at line 149 of file convex_polyhedron.h.
Referenced by cgv::media::mesh::convex_polyhedron< T, TCDim >::add_shell(), cgv::media::mesh::convex_polyhedron< T, TCDim >::copy_shell(), cgv::media::mesh::convex_polyhedron< T, TCDim >::del_shell(), cgv::media::mesh::convex_polyhedron< T, TCDim >::face_plane(), cgv::media::mesh::convex_polyhedron< T, TCDim >::face_plane(), and cgv::media::mesh::convex_polyhedron< T, TCDim >::swap_shells().
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.
|
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().