Physsim::Polyhedron Class Reference

Represents a three-dimensional polyhedron. More...

#include <Polyhedron.h>

List of all members.

Public Types

enum  LocationType {
  Inside, Outside, OnVertex, OnEdge,
  OnFace
}

Public Member Functions

 Polyhedron (const std::vector< TriangleConstPtr > &mesh)
 Constructs a polyhedron from a triangle mesh.
 Polyhedron (const Polyhedron &p)
void operator= (const Polyhedron &p)
 Copies a polyhedron.
void construct_from_mesh (const std::vector< TriangleConstPtr > &mesh)
 Constructs this polyhedron from a given triangle mesh.
const std::list< TriangleConstPtr > & get_incident_facets (Vector3ConstPtr v) const
 Gets the facets incident to the specified vertex.
void transform (const Matrix4 &T)
 Transforms this polyhedron by the given transformation matrix.
const std::vector< Vector3ConstPtr > & get_vertices () const
const std::vector< TriangleConstPtr > & get_facets () const
bool inside (const Vector3 &point) const
 Determines whether the specified point is strictly inside this polyhedron.
bool inside_or_on (const Vector3 &point) const
 Determines whether the specified point is in or on this polyhedron.
LocationType location (const Vector3 &point) const
 Determines the location of the specified point with respect to this polyhedron.
bool contains_facet (TriangleConstPtr t) const
 Determines whether the specified facet exists in the polyhedron.
bool contains_vertex (boost::shared_ptr< Vector3 > v) const
std::list< PolyhedronPtr > convexify (unsigned max_pieces=std::numeric_limits< unsigned >::max(), Real max_volume=std::numeric_limits< Real >::max()) const
 Makes this polyhedron convex by splitting it into multiple disjoint pieces.
Real calc_volume () const
 Calculates the volume of this polyhedron.
std::pair< Vector3, Vector3get_bounding_box_corners () const
 Gets the corners of the bounding box of this polyhedron.
bool is_convex () const
 Gets whether this polyhedron is convex.

Static Public Member Functions

static void to_VRML (std::ostream &out, const Polyhedron &p, Vector3 diffuse_color=Vector3(1, 1, 1), bool wireframe=false)
 Sends this polyhedron to the specified stream using VRML.


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.


Constructor & Destructor Documentation

Polyhedron::Polyhedron ( const std::vector< TriangleConstPtr > &  mesh  ) 

Constructs a polyhedron from a triangle mesh.

Note:
the mesh is cloned (it is not modified)


Member Function Documentation

void Polyhedron::transform ( const Matrix4 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

Polyhedron::LocationType Polyhedron::location ( const Vector3 point  )  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 faces of the polyhedron.

bool Polyhedron::contains_facet ( TriangleConstPtr  t  )  const

Determines whether the specified facet exists in the polyhedron.

Note:
determination is performed in lg n time, where n is the number of facets

std::list< PolyhedronPtr > Polyhedron::convexify ( unsigned  max_pieces = std::numeric_limits<unsigned>::max(),
Real  max_volume = std::numeric_limits<Real>::max() 
) const

Makes this polyhedron convex by splitting it into multiple disjoint pieces.

Parameters:
max_pieces the maximum number of pieces generated
max_volume the maximum volume of the pieces generated
Note:
splitting stops when all pieces are convex, or max_pieces or the maximum volume per piece is reached. If splitting stops prematurely (i.e., before all pieces are convex), the convex hull of non-convex pieces is calculated and used; the resulting pieces will still be disjoint.
Returns:
a list of polyhedra


The documentation for this class was generated from the following files:
Generated on Wed Oct 24 14:54:23 2007 for Physsim by  doxygen 1.5.1