KrisLibrary
1.0.0
|
A basic triangle mesh. More...
#include <TriMesh.h>
Public Types | |
typedef IntTriple | Tri |
Public Member Functions | |
bool | Load (const char *fn) |
bool | Save (const char *fn) const |
Accessors | |
Vector3 & | TriangleVertex (int tri, int v) |
Returns the v'th vertex of triangle tri. | |
const Vector3 & | TriangleVertex (int tri, int v) const |
Vector3 | TriangleNormal (int tri) const |
Calculates the normal of triangle tri. | |
void | GetTriangle (int tri, Triangle3D &t) const |
Returns a Triangle3D structure for triangle tri. | |
void | GetIncidentTris (int v, vector< int > &tris) const |
Calculates a list of triangle indices incident to vertex v. O(T) time. | |
void | AppendIncidentTris (int v, vector< int > &t) const |
Same as above, but appends the triangles to the end of t. | |
void | GetEdge (int tri, int e, int &v1, int &v2) const |
Returns the vertex indices (v1,v2) of the e'th edge of triangle tri. | |
int | GetAdjacentTri (int tri, int e) const |
Calculations | |
bool | IsValid () const |
void | GetAABB (Vector3 &bmin, Vector3 &bmax) const |
int | ClosestPoint (const Vector3 &pt, Vector3 &cp) const |
int | RayCast (const Ray3D &r, Vector3 &pt) const |
bool | Intersects (const Plane3D &) const |
bool | PlaneSplits (const Plane3D &, Real &dmin, Real &dmax) const |
Modifiers | |
void | Transform (const Matrix4 &mat) |
void | FlipFaces () |
void | Merge (const vector< TriMesh > &meshes) |
void | MergeWith (const TriMesh &mesh) |
void | RemoveUnusedVerts () |
Public Attributes | |
vector< Vector3 > | verts |
vector< Tri > | tris |
A basic triangle mesh.
The mesh is represented by a list of vertices (Vector3's) and a list of indexed triangles. A triangle is represented by a set of 3 integers (an IntTriple) that index into the vertex list to produce the actual triangle vertices. So a triangle whose vertices are verts[1], verts[2], and verts[3] will be represented by the IntTriple [1,2,3].
There are several "types" of indices floating around:
Vertex index - an index into the verts array.
Triangle index - an index into the tris array.
i'th vertex of a triangle t, i={0,1,2} - t[i] is a vertex index.
j'th edge of a triangle t, j={0,1,2} - the edge between vertices indexed by t[j+1] and t[j+2] (indices modulo 3), that is, the edge opposite the j'th vertex of t.
int Meshing::TriMesh::GetAdjacentTri | ( | int | tri, |
int | e | ||
) | const |
Returns the index of the triangle adjacent to tri, at the e'th edge or -1 if there is none. O(T) time.
References GetEdge(), GetTriangle(), and Math3D::Matrix4::mulPoint().