Physsim::TriangleMesh Class Reference

Represents a triangle mesh "primitive" for inertia properties, collision detection, and visualization. More...

#include <TriangleMesh.h>

Inheritance diagram for Physsim::TriangleMesh:

Physsim::Primitive Physsim::Base List of all members.

Public Member Functions

 TriangleMesh (TriangleArrayConstPtr trimesh, bool center=true)
 Constructs this object from the given mesh and optionally centers it.
 TriangleMesh (TriangleArrayConstPtr trimesh, const Matrix4 &T, bool center=true)
 Constructs this triangle mesh using a mesh and the given transform.
 TriangleMesh (const std::string &filename, bool center=true)
 Creates the triangle mesh from a geometry file and optionally centers it.
 TriangleMesh (const std::string &filename, const Matrix4 &T, bool center=true)
 Creates the triangle mesh from a geometry file and optionally centers it.
virtual void load_from_xml (XMLTreeConstPtr node, std::map< std::string, BasePtr > &id_map)
 Implements Base::load_from_xml().
virtual void save_to_xml (XMLTreePtr node, std::list< BaseConstPtr > &shared_objects) const
 Implements Base::save_to_xml().

Static Public Member Functions

static void write_to_obj (const std::string &filename, const std::vector< TriangleConstPtr > &mesh)
 Writes a triangle array to a Wavefront OBJ file.
static TriangleArrayConstPtr read_from_obj (const std::string &filename)
 Reads a triangle array from a Wavefront OBJ file.
static void transform_mesh (const std::vector< TrianglePtr > &mesh, const Matrix4 &T)
 Applies a given transform to all triangles in a mesh.
static void subdivide (std::vector< TrianglePtr > &mesh, Real max_tri_area)
 Subdivides a triangle mesh using Steiner points until no triangle is bigger than the specified area.
static TriangleArrayPtr clone_mesh (const std::vector< TriangleConstPtr > &mesh)
 Clones a triangle mesh.
template<class ForwardIterator>
static void get_unique_vertices (ForwardIterator first, ForwardIterator last, std::list< Vector3ConstPtr > &result)
 Gets the set of (unique) vertices from a triangle mesh.
template<class ForwardIterator>
static Real calc_signed_distance (ForwardIterator first, ForwardIterator last, const Vector3 &point, TriangleConstPtr &closest_tri)
 Computes the signed distance from the triangle mesh to a point.
template<class ForwardIterator>
static Real calc_signed_distance (ForwardIterator first, ForwardIterator last, const Vector3 &point)
 Computes the signed distance from the triangle mesh to a point.

Detailed Description

Represents a triangle mesh "primitive" for inertia properties, collision detection, and visualization.


Member Function Documentation

void TriangleMesh::load_from_xml ( XMLTreeConstPtr  node,
std::map< std::string, BasePtr > &  id_map 
) [virtual]

Implements Base::load_from_xml().

Note:
if centering is done, it is done <i<before any transform is applied

Reimplemented from Physsim::Primitive.

void TriangleMesh::subdivide ( std::vector< TrianglePtr > &  mesh,
Real  max_tri_area 
) [static]

Subdivides a triangle mesh using Steiner points until no triangle is bigger than the specified area.

Note:
the size of the mesh, as well as its ordering, may change

TriangleArrayPtr TriangleMesh::clone_mesh ( const std::vector< TriangleConstPtr > &  mesh  )  [static]

Clones a triangle mesh.

Note:
ordering is preserving on the cloned mesh

template<class ForwardIterator>
void Physsim::TriangleMesh::get_unique_vertices ( ForwardIterator  first,
ForwardIterator  last,
std::list< Vector3ConstPtr > &  result 
) [static]

Gets the set of (unique) vertices from a triangle mesh.

Note:
the list result is cleared on entry

template<class ForwardIterator>
Real Physsim::TriangleMesh::calc_signed_distance ( ForwardIterator  first,
ForwardIterator  last,
const Vector3 point,
TriangleConstPtr &  closest_tri 
) [static]

Computes the signed distance from the triangle mesh to a point.

Note:
pointer to the closest triangle is returned in closest_tri

signed distance for points *just* outside the mesh (i.e., numerically close to one of the faces) will be somewhat inaccurate

template<class ForwardIterator>
Real Physsim::TriangleMesh::calc_signed_distance ( ForwardIterator  first,
ForwardIterator  last,
const Vector3 point 
) [static]

Computes the signed distance from the triangle mesh to a point.

Note:
signed distance for points *just* outside the mesh (i.e., numerically close to one of the faces) will be somewhat inaccurate


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