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

An array of triangles indexed into shared vertices. More...

#include <IndexedTriArray.h>

Public Member Functions

 IndexedTriArray (boost::shared_ptr< const std::vector< Ravelin::Origin3d > > vertices, const std::vector< IndexedTri > &facets)
 
 IndexedTriArray (boost::shared_ptr< const std::vector< Ravelin::Origin3d > > vertices, boost::shared_ptr< const std::vector< IndexedTri > > facets)
 
template<class ForwardIterator1 , class ForwardIterator2 >
 IndexedTriArray (ForwardIterator1 vertices, ForwardIterator1 verts_end, ForwardIterator2 facets_begin, ForwardIterator2 facets_end)
 Creates an indexed triangle mesh from containers of vertices and facets. More...
 
template<class OutputIterator >
OutputIterator get_tris (OutputIterator output_begin, boost::shared_ptr< const Ravelin::Pose3d > P) const
 Converts an indexed triangle mesh to a container of triangles.
 
unsigned num_tris () const
 
Triangle get_triangle (unsigned i, boost::shared_ptr< const Ravelin::Pose3d > P) const
 Gets the i'th triangle from this mesh.
 
IndexedTriArray transform (const Ravelin::Transform3d &T) const
 Transforms this mesh to a new mesh.
 
IndexedTriArray compress_vertices () const
 Compresses the vertices used in an IndexedTriArray to create a new mesh.
 
void write_to_obj (const std::string &filename) const
 
IndexedTriArrayoperator= (const IndexedTriArray &mesh)
 Copies one mesh to another.
 
std::vector< std::list
< unsigned > > 
determine_vertex_edge_map () const
 Determines a map from vertices to edges. More...
 
std::vector< std::list
< unsigned > > 
determine_vertex_facet_map () const
 Determines a map from vertices to facet indices.
 
std::map< Ravelin::sorted_pair
< unsigned >, std::list
< unsigned > > 
determine_edge_facet_map () const
 Determines a map from edges to facet indices.
 
void calc_volume_ints (double volume_ints[10]) const
 Calculates the volume integrals of this primitive as a triangle mesh.
 
const std::list< unsigned > & get_incident_facets (unsigned i) const
 Gets the indices of facets incident to a vertex.
 
boost::shared_ptr< const
std::vector< IndexedTri > > 
get_facets_pointer () const
 Gets the pointer to the vector of facets.
 
boost::shared_ptr< const
std::vector< Ravelin::Origin3d > > 
get_vertices_pointer () const
 Gets the pointer to the vector of vertices.
 
const std::vector< IndexedTri > & get_facets () const
 Gets the vector of facets.
 
const std::vector
< Ravelin::Origin3d > & 
get_vertices () const
 Gets the vector of verties.
 
bool is_coplanar (unsigned vidx) const
 Determines whether a vertex is coplanar (all faces touching the vertex are coplanar)
 
bool is_coplanar (unsigned v1, unsigned v2) const
 Determines whether an edge (v1,v2) is coplanar (all faces touching the edge are coplanar)
 
template<class ForwardIterator1 , class ForwardIterator2 >
 IndexedTriArray (ForwardIterator1 verts_begin, ForwardIterator1 verts_end, ForwardIterator2 facets_begin, ForwardIterator2 facets_end)
 Creates an indexed triangle mesh from containers of vertices and facets. More...
 
template<class OutputIterator >
OutputIterator get_tris (OutputIterator output_begin, boost::shared_ptr< const Ravelin::Pose3d > P) const
 Converts an indexed triangle mesh to a container of triangles.
 
template<class OutputIterator >
OutputIterator intersect (const IndexedTriArray &mesh_a, const IndexedTriArray &mesh_b, OutputIterator output_begin, boost::shared_ptr< const Ravelin::Pose3d > Pa, boost::shared_ptr< const Ravelin::Pose3d > Pb, bool exit_early)
 Intersects two meshes together and returns indices of intersecting triangles. More...
 

Static Public Member Functions

template<class OutputIterator >
static OutputIterator intersect (const IndexedTriArray &mesh_a, const IndexedTriArray &mesh_b, OutputIterator output_begin, boost::shared_ptr< const Ravelin::Pose3d > Pa, boost::shared_ptr< const Ravelin::Pose3d > Pb, bool exit_early)
 Intersects two meshes together and returns indices of intersecting triangles. More...
 
static IndexedTriArray read_from_obj (const std::string &filename)
 Reads triangle mesh from a Wavefront OBJ file.
 
static void write_to_obj (const IndexedTriArray &mesh, const std::string &filename)
 
static IndexedTriArray merge (const IndexedTriArray &mesh1, const IndexedTriArray &mesh2, double equal_tol=0.0)
 Merges two meshes together to create a new mesh. More...
 

Detailed Description

An array of triangles indexed into shared vertices.

Constructor & Destructor Documentation

template<class ForwardIterator1 , class ForwardIterator2 >
Moby::IndexedTriArray::IndexedTriArray ( ForwardIterator1  verts_begin,
ForwardIterator1  verts_end,
ForwardIterator2  facets_begin,
ForwardIterator2  facets_end 
)

Creates an indexed triangle mesh from containers of vertices and facets.

Parameters
verticesan iterator to the beginning of a container of Point3d objects
verts_endan iterator to the end of a container of Point3d objects
facets_beginan iterator to the beginning of a container of IndexedTri objects
facets_endan iterator to the end of a container of IndexedTri objects
template<class ForwardIterator1 , class ForwardIterator2 >
Moby::IndexedTriArray::IndexedTriArray ( ForwardIterator1  verts_begin,
ForwardIterator1  verts_end,
ForwardIterator2  facets_begin,
ForwardIterator2  facets_end 
)

Creates an indexed triangle mesh from containers of vertices and facets.

Parameters
verticesan iterator to the beginning of a container of Point3d objects
verts_endan iterator to the end of a container of Point3d objects
facets_beginan iterator to the beginning of a container of IndexedTri objects
facets_endan iterator to the end of a container of IndexedTri objects

Member Function Documentation

vector< list< unsigned > > IndexedTriArray::determine_vertex_edge_map ( ) const

Determines a map from vertices to edges.

Returns
a map from vertices to edges; each element in the map repesents the second vertex of the edge (the key is the first)

Referenced by Moby::OBB::calc_min_volume_OBB().

template<class OutputIterator >
OutputIterator Moby::IndexedTriArray::intersect ( const IndexedTriArray mesh_a,
const IndexedTriArray mesh_b,
OutputIterator  output_begin,
boost::shared_ptr< const Ravelin::Pose3d >  Pa,
boost::shared_ptr< const Ravelin::Pose3d >  Pb,
bool  exit_early 
)
static

Intersects two meshes together and returns indices of intersecting triangles.

Parameters
mesh_athe first mesh
mesh_bthe second mesh
output_beginan iterator pointing to the beginning of a container of std::pair<unsigned, unsigned> objects (on return, container will hold indices of intersecting triangles of mesh_a and mesh_b)
exit_earlyif true, exits after first intersection detected
Returns
an iterator pointing to the end of a container of std::pair<unsigned, unsigned> objects (on return, container will hold indices of intersecting triangles of mesh_a and mesh_b)
template<class OutputIterator >
OutputIterator Moby::IndexedTriArray::intersect ( const IndexedTriArray mesh_a,
const IndexedTriArray mesh_b,
OutputIterator  output_begin,
boost::shared_ptr< const Ravelin::Pose3d >  Pa,
boost::shared_ptr< const Ravelin::Pose3d >  Pb,
bool  exit_early 
)

Intersects two meshes together and returns indices of intersecting triangles.

Parameters
mesh_athe first mesh
mesh_bthe second mesh
output_beginan iterator pointing to the beginning of a container of std::pair<unsigned, unsigned> objects (on return, container will hold indices of intersecting triangles of mesh_a and mesh_b)
exit_earlyif true, exits after first intersection detected
Returns
an iterator pointing to the end of a container of std::pair<unsigned, unsigned> objects (on return, container will hold indices of intersecting triangles of mesh_a and mesh_b)

References get_tris().

IndexedTriArray IndexedTriArray::merge ( const IndexedTriArray mesh1,
const IndexedTriArray mesh2,
double  equal_tol = 0.0 
)
static

Merges two meshes together to create a new mesh.

Note
this method runs in time O(nm)

References get_facets(), and get_vertices().


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