7 #ifndef _INDEXED_TRIANGLE_ARRAY_H 
    8 #define _INDEXED_TRIANGLE_ARRAY_H 
   15 #include <boost/foreach.hpp> 
   16 #include <Ravelin/sorted_pair> 
   17 #include <Moby/Types.h> 
   18 #include <Moby/Triangle.h> 
   19 #include <Moby/InvalidIndexException.h> 
   20 #include <Moby/IndexedTri.h> 
   29     IndexedTriArray(boost::shared_ptr<
const std::vector<Ravelin::Origin3d> > vertices, 
const std::vector<IndexedTri>& facets);
 
   30     IndexedTriArray(boost::shared_ptr<
const std::vector<Ravelin::Origin3d> > vertices, boost::shared_ptr<
const std::vector<IndexedTri> > facets);
 
   32     template <
class ForwardIterator1, 
class ForwardIterator2>
 
   33     IndexedTriArray(ForwardIterator1 vertices, ForwardIterator1 verts_end, ForwardIterator2 facets_begin, ForwardIterator2 facets_end);
 
   35     template <
class OutputIterator>
 
   36     OutputIterator 
get_tris(OutputIterator output_begin, boost::shared_ptr<const Ravelin::Pose3d> P) 
const; 
 
   38     template <
class OutputIterator>
 
   39     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);
 
   41     unsigned num_tris()
 const { 
return (_facets) ? _facets->size() : 0; }
 
   42     Triangle 
get_triangle(
unsigned i, boost::shared_ptr<const Ravelin::Pose3d> P) 
const;
 
   46     static void write_to_obj(
const IndexedTriArray& mesh, 
const std::string& filename);
 
   47     void write_to_obj(
const std::string& filename)
 const { write_to_obj(*
this, filename); }
 
   48     static IndexedTriArray 
merge(
const IndexedTriArray& mesh1, 
const IndexedTriArray& mesh2, 
double equal_tol = 0.0);
 
   49     IndexedTriArray& 
operator=(
const IndexedTriArray& mesh);
 
   62     boost::shared_ptr<const std::vector<Ravelin::Origin3d> > 
get_vertices_pointer()
 const { 
return _vertices; }
 
   65     const std::vector<IndexedTri>& 
get_facets()
 const { 
return *_facets; }
 
   68     const std::vector<Ravelin::Origin3d>& 
get_vertices()
 const { 
return *_vertices; }
 
   71     bool is_coplanar(
unsigned vidx)
 const { 
return std::binary_search(_coplanar_verts.begin(), _coplanar_verts.end(), vidx); }
 
   74    bool is_coplanar(
unsigned v1, 
unsigned v2)
 const { 
return std::binary_search(_coplanar_edges.begin(), _coplanar_edges.end(), Ravelin::make_sorted_pair(v1, v2)); }
 
   77     void determine_coplanar_features();
 
   78     static bool query_intersect_tri_tri(
const Triangle& t1, 
const Triangle& t2);
 
   79     void validate() 
const;
 
   80     void calc_incident_facets();
 
   83     std::vector<Ravelin::sorted_pair<unsigned> > _coplanar_edges;
 
   86     std::vector<unsigned> _coplanar_verts;
 
   88     boost::shared_ptr<const std::vector<IndexedTri> > _facets;
 
   89     boost::shared_ptr<const std::vector<Ravelin::Origin3d> > _vertices;
 
   90     boost::shared_ptr<const std::vector<std::list<unsigned > > > _incident_facets;
 
   94 #include "IndexedTriArray.inl" 
std::vector< std::list< unsigned > > determine_vertex_edge_map() const 
Determines a map from vertices to edges. 
Definition: IndexedTriArray.cpp:180
std::map< Ravelin::sorted_pair< unsigned >, std::list< unsigned > > determine_edge_facet_map() const 
Determines a map from edges to facet indices. 
Definition: IndexedTriArray.cpp:198
const std::list< unsigned > & get_incident_facets(unsigned i) const 
Gets the indices of facets incident to a vertex. 
Definition: IndexedTriArray.h:56
static IndexedTriArray read_from_obj(const std::string &filename)
Reads triangle mesh from a Wavefront OBJ file. 
Definition: IndexedTriArray.cpp:413
boost::shared_ptr< const std::vector< Ravelin::Origin3d > > get_vertices_pointer() const 
Gets the pointer to the vector of vertices. 
Definition: IndexedTriArray.h:62
IndexedTriArray(ForwardIterator1 vertices, ForwardIterator1 verts_end, ForwardIterator2 facets_begin, ForwardIterator2 facets_end)
Creates an indexed triangle mesh from containers of vertices and facets. 
Definition: IndexedTriArray.h:31
void calc_volume_ints(double volume_ints[10]) const 
Calculates the volume integrals of this primitive as a triangle mesh. 
Definition: IndexedTriArray.cpp:62
Triangle get_triangle(unsigned i, boost::shared_ptr< const Ravelin::Pose3d > P) const 
Gets the i'th triangle from this mesh. 
Definition: IndexedTriArray.cpp:213
An array of triangles indexed into shared vertices. 
Definition: IndexedTriArray.h:25
static IndexedTriArray merge(const IndexedTriArray &mesh1, const IndexedTriArray &mesh2, double equal_tol=0.0)
Merges two meshes together to create a new mesh. 
Definition: IndexedTriArray.cpp:241
Exception thrown when trying to access the index beyond the range of the data. 
Definition: InvalidIndexException.h:15
const std::vector< IndexedTri > & get_facets() const 
Gets the vector of facets. 
Definition: IndexedTriArray.h:65
bool is_coplanar(unsigned vidx) const 
Determines whether a vertex is coplanar (all faces touching the vertex are coplanar) ...
Definition: IndexedTriArray.h:71
IndexedTriArray transform(const Ravelin::Transform3d &T) const 
Transforms this mesh to a new mesh. 
Definition: IndexedTriArray.cpp:302
std::vector< std::list< unsigned > > determine_vertex_facet_map() const 
Determines a map from vertices to facet indices. 
Definition: IndexedTriArray.cpp:160
boost::shared_ptr< const std::vector< IndexedTri > > get_facets_pointer() const 
Gets the pointer to the vector of facets. 
Definition: IndexedTriArray.h:59
const std::vector< Ravelin::Origin3d > & get_vertices() const 
Gets the vector of verties. 
Definition: IndexedTriArray.h:68
IndexedTriArray & operator=(const IndexedTriArray &mesh)
Copies one mesh to another. 
Definition: IndexedTriArray.cpp:148
IndexedTriArray compress_vertices() const 
Compresses the vertices used in an IndexedTriArray to create a new mesh. 
Definition: IndexedTriArray.cpp:341
OutputIterator get_tris(OutputIterator output_begin, boost::shared_ptr< const Ravelin::Pose3d > P) const 
Converts an indexed triangle mesh to a container of triangles. 
Definition: IndexedTriArray.h:51
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. 
Definition: IndexedTriArray.h:76
bool is_coplanar(unsigned v1, unsigned v2) const 
Determines whether an edge (v1,v2) is coplanar (all faces touching the edge are coplanar) ...
Definition: IndexedTriArray.h:74