#include <MeshFaces.h>
Inheritance diagram for Track::MeshFaces:
Public Types | |
typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, FaceGraph, EdgeGraph > | Graph |
The type of graph we use to explain the navigation of the surface of the mesh. | |
typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, btVector3, FaceEdgePointers > | VertexGraph |
Type of graph that maps vertices and edges directly. | |
Public Member Functions | |
MeshFaces (std::istream &source) | |
Initalise from a stream. | |
MeshFaces (std::string &filename) | |
Initalise from a file. | |
MeshFaces () | |
Construct an empty MeshFaces. | |
virtual | ~MeshFaces () |
btVector3 | get_vertex_pos (std::size_t index) const |
get the position of a vertex Vertices are indexed from 0. | |
void | add_vertex (const btVector3 &position) |
add a vertex to the mesh | |
void | add_normal (const btVector3 &normal) |
add a vertex normal that can optionally be refered to when creating a face. | |
void | add_texture_coord (const btVector3 &normal) |
add a texture coordinate that can optionally be refered to when creating a face. | |
std::size_t | get_num_vertices () const |
get the number of vertices in the mesh. | |
const Face & | get_face (std::size_t index) const |
get the vertex indices of a face | |
std::vector< Edge > | get_edges_for_face (std::size_t face) const |
get the edges shared by a face | |
void | add_face (std::size_t v1, std::size_t v2, std::size_t v3) |
Add a face from the index of 3 vertices. | |
void | add_face (std::size_t v1, std::size_t n1, std::size_t v2, std::size_t n2, std::size_t v3, std::size_t n3) |
Add a face from the index of 3 vertices and normals. | |
void | add_face (Face face) |
add a face from a face description | |
std::size_t | get_number_of_faces () const |
return the number of faces in the mesh | |
Graph | get_connectivity () const |
Get an edge connectivity graph for all the faces. | |
VertexGraph | get_vertex_graph () |
Make a graph of vertices and their edges. | |
void | copy_faces (const MeshFaces &other) |
Copy the faces from another MeshFaces. | |
void | add_faces (btTriangleMesh &shape) const |
Add faces in the mesh to a btTriangleMesh. | |
virtual AxisAlignedBoundingBox | get_bounds () const |
Return the axis aligned bounding box of the vertices in the mesh. | |
void | merge_doubles (btScalar distance2=1.0/32.0) |
Merge vertices very close together. | |
void | operator|= (const MeshFaces &source) |
Add vertices and faces from another MeshFaces. | |
void | set_source (bool is_edge, unsigned long int object_name) |
Set the source data in all faces of the mesh. | |
Protected Member Functions | |
void | load_from_stream (std::istream &source) |
void | add_edge (std::size_t v1, std::size_t v2, std::size_t face_index, std::map< EdgeGraph, std::size_t > &edge_to_face, std::vector< std::pair< std::size_t, std::size_t > > &graph_edges, std::vector< EdgeGraph > &edge_properties) const |
Protected Attributes | |
std::vector< btVector3 > | vertices_position |
Positions of vertcies. | |
std::vector< Face > | faces |
Faces. | |
AxisAlignedBoundingBox | bounds |
Classes | |
struct | Edge |
An edge between two vertices in the same face. More... | |
struct | EdgeGraph |
Extra edge information useful for the graph. More... | |
struct | Face |
A structure to store information about a single triangular face. More... | |
struct | FaceEdgePointers |
Structure used for an edge in a graph showing vertices connected by face edges. More... | |
struct | FaceGraph |
struct | FaceVertex |
vertex information for a vertex in a face More... |
Each face is a triangle. Stores shared vertex positions. This allows us to produce a connectivity graph of faces by shared edges. Use merge_doubles() to remove duplicate vertex positions, changing the faces to share common vertices.
Vertices must be added before the faces that use them.
Definition at line 44 of file MeshFaces.h.
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, FaceGraph, EdgeGraph> Track::MeshFaces::Graph |
The type of graph we use to explain the navigation of the surface of the mesh.
Definition at line 177 of file MeshFaces.h.
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, btVector3, FaceEdgePointers> Track::MeshFaces::VertexGraph |
Track::MeshFaces::MeshFaces | ( | std::istream & | source | ) |
Initalise from a stream.
The stream is advanced to the end of the MeshFaces description.
Definition at line 143 of file MeshFaces.cpp.
Track::MeshFaces::MeshFaces | ( | std::string & | filename | ) |
Initalise from a file.
filename | The name of the file to get the mesh information from. |
Definition at line 148 of file MeshFaces.cpp.
Track::MeshFaces::MeshFaces | ( | ) |
Track::MeshFaces::~MeshFaces | ( | ) | [virtual] |
Definition at line 196 of file MeshFaces.cpp.
void Track::MeshFaces::add_edge | ( | std::size_t | v1, | |
std::size_t | v2, | |||
std::size_t | face_index, | |||
std::map< EdgeGraph, std::size_t > & | edge_to_face, | |||
std::vector< std::pair< std::size_t, std::size_t > > & | graph_edges, | |||
std::vector< EdgeGraph > & | edge_properties | |||
) | const [protected] |
Definition at line 247 of file MeshFaces.cpp.
void Track::MeshFaces::add_face | ( | Face | face | ) |
void Track::MeshFaces::add_face | ( | std::size_t | v1, | |
std::size_t | n1, | |||
std::size_t | v2, | |||
std::size_t | n2, | |||
std::size_t | v3, | |||
std::size_t | n3 | |||
) |
Add a face from the index of 3 vertices and normals.
void Track::MeshFaces::add_face | ( | std::size_t | v1, | |
std::size_t | v2, | |||
std::size_t | v3 | |||
) |
void Track::MeshFaces::add_faces | ( | btTriangleMesh & | shape | ) | const |
void Track::MeshFaces::add_normal | ( | const btVector3 & | normal | ) |
add a vertex normal that can optionally be refered to when creating a face.
void Track::MeshFaces::add_texture_coord | ( | const btVector3 & | normal | ) |
add a texture coordinate that can optionally be refered to when creating a face.
void Track::MeshFaces::add_vertex | ( | const btVector3 & | position | ) |
void Track::MeshFaces::copy_faces | ( | const MeshFaces & | other | ) |
Copy the faces from another MeshFaces.
The current vertex's positions are kept, but everything else is copied from the other MeshFaces. This is used to distort the Mesh by altering the positions of the vertices.
other | The MeshFaces to copy infromation from. |
Definition at line 361 of file MeshFaces.cpp.
AxisAlignedBoundingBox Track::MeshFaces::get_bounds | ( | ) | const [virtual] |
Return the axis aligned bounding box of the vertices in the mesh.
Implements Track::AABBBounded.
Definition at line 395 of file MeshFaces.cpp.
MeshFaces::Graph Track::MeshFaces::get_connectivity | ( | ) | const |
Get an edge connectivity graph for all the faces.
Note that the vertices represent faces in the mesh. The edges in the graph represent shared edges in the mesh. This is because you will drive over the edges to get form one face to another in most cases. The size of a vertex is 0, and our meshes are well built, so we can neglect the posibility of driving across a vertex to another face without crossing an edge.
Meshes should have the following characteristics for graph generation: * An edge can only be shared by at most two faces * At most one edge can be shared by any two faces. * If two faces share a vertex, there must be a path across edges of faces between them.
Definition at line 278 of file MeshFaces.cpp.
std::vector< MeshFaces::Edge > Track::MeshFaces::get_edges_for_face | ( | std::size_t | face | ) | const |
const MeshFaces::Face & Track::MeshFaces::get_face | ( | std::size_t | index | ) | const |
std::size_t Track::MeshFaces::get_num_vertices | ( | ) | const |
std::size_t Track::MeshFaces::get_number_of_faces | ( | ) | const |
MeshFaces::VertexGraph Track::MeshFaces::get_vertex_graph | ( | ) |
Make a graph of vertices and their edges.
Vertices in the graph represent vertices in the mesh. The edges in the graph are all edges of faces.
Definition at line 333 of file MeshFaces.cpp.
btVector3 Track::MeshFaces::get_vertex_pos | ( | std::size_t | index | ) | const |
get the position of a vertex Vertices are indexed from 0.
Definition at line 200 of file MeshFaces.cpp.
void Track::MeshFaces::load_from_stream | ( | std::istream & | source | ) | [protected] |
Definition at line 154 of file MeshFaces.cpp.
void Track::MeshFaces::merge_doubles | ( | btScalar | distance2 = 1.0/32.0 |
) |
Merge vertices very close together.
Makes the connectivity graph show faces that touch, even if they didn't originally share vertices. Deletes some vertices near to other ones.
distance2 | The square of the distance between two vertices that are close enough to be merged. |
Definition at line 400 of file MeshFaces.cpp.
void Track::MeshFaces::operator|= | ( | const MeshFaces & | source | ) |
Add vertices and faces from another MeshFaces.
source | The MeshFaces to copy data from. |
Definition at line 469 of file MeshFaces.cpp.
void Track::MeshFaces::set_source | ( | bool | is_edge, | |
unsigned long int | object_name | |||
) |
Set the source data in all faces of the mesh.
Sets is_face and object_name to the same values for all faces.
is_edge | true if an edge, false if a vertex. | |
object_name | the unique object identifier of the source. |
Definition at line 497 of file MeshFaces.cpp.
AxisAlignedBoundingBox Track::MeshFaces::bounds [protected] |
Definition at line 309 of file MeshFaces.h.
std::vector<Face> Track::MeshFaces::faces [protected] |
std::vector<btVector3> Track::MeshFaces::vertices_position [protected] |
Generated at Mon Sep 6 00:41:18 2010 by Doxygen version 1.4.7 for Racer version svn335.