Moby
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Moby::TessellatedPolyhedron Class Reference

Represents a three-dimensional polyhedron. More...

#include <TessellatedPolyhedron.h>

Public Types

enum  LocationType {
  eInside, eOutside, eOnVertex, eOnEdge,
  eOnFace
}
 

Public Member Functions

 TessellatedPolyhedron (const IndexedTriArray &mesh)
 Constructs a polyhedron from an indexed triangle array.
 
 TessellatedPolyhedron (const TessellatedPolyhedron &p)
 
void operator= (const TessellatedPolyhedron &p)
 Copies a polyhedron.
 
const IndexedTriArrayget_mesh () const
 
void transform (const Ravelin::Transform3d &T)
 Transforms this polyhedron by the given transformation matrix. More...
 
const std::vector
< Ravelin::Origin3d > & 
get_vertices () const
 
const std::vector< IndexedTri > & get_facets () const
 
bool inside (const Ravelin::Origin3d &point, double tol=NEAR_ZERO)
 Determines whether the specified point is strictly inside this polyhedron.
 
bool inside_or_on (const Ravelin::Origin3d &point, double tol=NEAR_ZERO)
 Determines whether the specified point is in or on this polyhedron.
 
LocationType location (const Ravelin::Origin3d &point, double tol=NEAR_ZERO) const
 Determines the location of the specified point with respect to this polyhedron. More...
 
double calc_volume () const
 Calculates the volume of this polyhedron.
 
bool consistent () const
 Checks whether this polyhedron is consistent.
 
bool degenerate () const
 Checks whether this polyhedron is degenerate.
 
const Ravelin::Origin3d & find_extreme_vertex (const Ravelin::Origin3d &direction)
 Does an extremal point query for the Polyhedron; returns a vertex furthest along the given direction.
 
void to_polyhedron (Polyhedron &p) const
 Creates a polyhedron from this tessellated polyhedron.
 
template<class InputIterator1 , class InputIterator2 >
 TessellatedPolyhedron (InputIterator1 verts_begin, InputIterator1 verts_end, InputIterator2 facets_begin, InputIterator2 facets_end)
 Constructs a TessellatedPolyhedron from iterators to a container holding Point3d objects and iterators to a container holding IndexedTri types.
 
const std::list< unsigned > & get_incident_facets (unsigned i) const
 Gets the list of facets coincident to the i'th facet.
 
double calc_signed_distance (const Ravelin::Origin3d &point, unsigned &closest_facet)
 Gets the signed distance and closest facet to a point.
 
double calc_signed_distance (const Ravelin::Origin3d &point)
 Gets the signed distance from a point to the polyhedron.
 
std::pair< Ravelin::Origin3d,
Ravelin::Origin3d > 
get_bounding_box_corners () const
 Gets the corners of the axis-aligned bounding box of this polyhedron.
 
bool is_convex ()
 Determines whether this polyhedron convex (to w/in floating point tolerance)
 
double convexity ()
 Gets the convexity of this polyhedron. More...
 
template<class InputIterator1 , class InputIterator2 >
 TessellatedPolyhedron (InputIterator1 verts_begin, InputIterator1 verts_end, InputIterator2 facets_begin, InputIterator2 facets_end)
 Constructs a TessellatedPolyhedron from iterators to a container holding Point3d objects and iterators to a container holding IndexedTri types.
 

Static Public Member Functions

static TessellatedPolyhedronPtr minkowski (TessellatedPolyhedron &p1, boost::shared_ptr< const Ravelin::Pose3d > T1, TessellatedPolyhedron &p2, boost::shared_ptr< const Ravelin::Pose3d > T2, bool reflect_p2=true)
 Computes the Minkowski sum of two convex polyhedra.
 
static void to_vrml (std::ostream &out, const TessellatedPolyhedron &p, Ravelin::Origin3d diffuse_color=Ravelin::Origin3d(1, 1, 1), bool wireframe=false)
 Sends this polyhedron to the specified stream using VRML.
 
static IndexedTriArray construct_intersection (TessellatedPolyhedron &p1, TessellatedPolyhedron &p2)
 Intersects two non-convex polyhedra. More...
 
static IndexedTriArray construct_union (TessellatedPolyhedron &p1, TessellatedPolyhedron &p2)
 Unions two non-convex polyhedra.
 
static IndexedTriArray construct_difference (TessellatedPolyhedron &p1, TessellatedPolyhedron &p2)
 Constructs the Boolean difference p1 - p2.
 

Detailed Description

Represents a three-dimensional polyhedron.

Though this class is used for representing polyhedron, it is possible to represent arbitrary (i.e., non-closed) triangle meshes as well.

Member Function Documentation

IndexedTriArray TessellatedPolyhedron::construct_intersection ( TessellatedPolyhedron p1,
TessellatedPolyhedron p2 
)
static

Intersects two non-convex polyhedra.

The running time for this algorithm is O(nm), where n and m are the number of triangles of p1 and p2, respectively. A faster algorithm can be obtained if p1 and p2 are both convex, but it is not implemented here.

References Moby::IndexedTriArray::compress_vertices(), and consistent().

double Moby::TessellatedPolyhedron::convexity ( )
inline

Gets the convexity of this polyhedron.

Convexity values less than epsilon (where epsilon is some number near zero) indicate that the polyhedron is convex; greater values indicate that the polyhedron is non-convex.

Referenced by is_convex().

TessellatedPolyhedron::LocationType TessellatedPolyhedron::location ( const Ravelin::Origin3d &  point,
double  tol = NEAR_ZERO 
) const

Determines the location of the specified point with respect to this polyhedron.

This method handles queries when the polyhedron is not convex or more detail is necessary. Adapted from O'Rourke, p. 247-250. Runs in worst-case time O(f), where f is the number of facets of the polyhedron.

void TessellatedPolyhedron::transform ( const Ravelin::Transform3d &  T)

Transforms this polyhedron by the given transformation matrix.

Note
none of the vertex or triangle pointers change; rather the data that they point to changes

Referenced by minkowski().


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