Files Class List
TriMesh Class Reference

Detailed Description

Triangular Mesh Class.

#include <cyTriMesh.h>

Classes

struct  Mtl
 
struct  Str
 
struct  TriFace
 

Public Member Functions

Constructors and Destructor
 TriMesh ()
 
 TriMesh (const TriMesh &t)
 
virtual ~TriMesh ()
 
Component Access Methods
const Point3fV (int i) const
 
Point3fV (int i)
 
const TriFaceF (int i) const
 
TriFaceF (int i)
 
const Point3fVN (int i) const
 
Point3fVN (int i)
 
const TriFaceFN (int i) const
 
TriFaceFN (int i)
 
const Point3fVT (int i) const
 
Point3fVT (int i)
 
const TriFaceFT (int i) const
 
TriFaceFT (int i)
 
const MtlM (int i) const
 
MtlM (int i)
 
unsigned int NV () const
 
unsigned int NF () const
 
unsigned int NVN () const
 
unsigned int NVT () const
 
unsigned int NM () const
 
bool HasNormals () const
 
bool HasTextureVertices () const
 
Set Component Count
void Clear ()
 
void SetNumVertex (unsigned int n)
 
void SetNumFaces (unsigned int n)
 
void SetNumNormals (unsigned int n)
 
void SetNumTexVerts (unsigned int n)
 
void SetNumMtls (unsigned int n)
 
void operator= (const TriMesh &t)
 
Get Property Methods
bool IsBoundBoxReady () const
 
Point3f GetBoundMin () const
 
Point3f GetBoundMax () const
 
Point3f GetPoint (int faceID, const Point3f &bc) const
 
Point3f GetNormal (int faceID, const Point3f &bc) const
 
Point3f GetTexCoord (int faceID, const Point3f &bc) const
 
int GetMaterialIndex (int faceID) const
 
int GetMaterialFaceCount (int mtlID) const
 
int GetMaterialFirstFace (int mtlID) const
 
Compute Methods
void ComputeBoundingBox ()
 
void ComputeNormals (bool clockwise=false)
 

Protected Attributes

Point3fv
 
TriFacef
 
Point3fvn
 
TriFacefn
 
Point3fvt
 
TriFaceft
 
Mtlm
 
int * mcfc
 
unsigned int nv
 
unsigned int nf
 
unsigned int nvn
 
unsigned int nvt
 
unsigned int nm
 
Point3f boundMin
 
Point3f boundMax
 

Load and Save methods

bool LoadFromFileObj (const char *filename, bool loadMtl=true, std::ostream *outStream=&std::cout)
 
bool SaveToFileObj (const char *filename, std::ostream *outStream)
 

Member Function Documentation

§ V() [1/2]

const Point3f& V ( int  i) const

returns the i^th vertex

§ V() [2/2]

Point3f& V ( int  i)

returns the i^th vertex

§ F() [1/2]

const TriFace& F ( int  i) const

returns the i^th face

§ F() [2/2]

TriFace& F ( int  i)

returns the i^th face

§ VN() [1/2]

const Point3f& VN ( int  i) const

returns the i^th vertex normal

§ VN() [2/2]

Point3f& VN ( int  i)

returns the i^th vertex normal

§ FN() [1/2]

const TriFace& FN ( int  i) const

returns the i^th normal face

§ FN() [2/2]

TriFace& FN ( int  i)

returns the i^th normal face

§ VT() [1/2]

const Point3f& VT ( int  i) const

returns the i^th vertex texture

§ VT() [2/2]

Point3f& VT ( int  i)

returns the i^th vertex texture

§ FT() [1/2]

const TriFace& FT ( int  i) const

returns the i^th texture face

§ FT() [2/2]

TriFace& FT ( int  i)

returns the i^th texture face

§ M() [1/2]

const Mtl& M ( int  i) const

returns the i^th material

§ M() [2/2]

Mtl& M ( int  i)

returns the i^th material

§ NV()

unsigned int NV ( ) const

returns the number of vertices

§ NF()

unsigned int NF ( ) const

returns the number of faces

§ NVN()

unsigned int NVN ( ) const

returns the number of vertex normals

§ NVT()

unsigned int NVT ( ) const

returns the number of texture vertices

§ NM()

unsigned int NM ( ) const

returns the number of materials

§ HasNormals()

bool HasNormals ( ) const

returns true if the mesh has vertex normals

§ HasTextureVertices()

bool HasTextureVertices ( ) const

returns true if the mesh has texture vertices

§ Clear()

void Clear ( )

Deletes all components of the mesh.

§ SetNumVertex()

void SetNumVertex ( unsigned int  n)

Sets the number of vertices and allocates memory for vertex positions.

§ SetNumFaces()

void SetNumFaces ( unsigned int  n)

Sets the number of faces and allocates memory for face data. Normal faces and texture faces are also allocated, if they are used.

§ SetNumNormals()

void SetNumNormals ( unsigned int  n)

Sets the number of normals and allocates memory for normals and normal faces.

§ SetNumTexVerts()

void SetNumTexVerts ( unsigned int  n)

Sets the number of texture coordinates and allocates memory for texture coordinates and texture faces.

§ SetNumMtls()

void SetNumMtls ( unsigned int  n)

Sets the number of materials and allocates memory for material data.

§ operator=()

void operator= ( const TriMesh t)

Copies mesh data from the given mesh.

§ IsBoundBoxReady()

bool IsBoundBoxReady ( ) const

Returns true if the bounding box has been computed.

§ GetBoundMin()

Point3f GetBoundMin ( ) const

Returns the minimum values of the bounding box.

§ GetBoundMax()

Point3f GetBoundMax ( ) const

Returns the maximum values of the bounding box.

§ GetPoint()

Point3f GetPoint ( int  faceID,
const Point3f bc 
) const

Returns the point on the given face with the given barycentric coordinates (bc).

§ GetNormal()

Point3f GetNormal ( int  faceID,
const Point3f bc 
) const

Returns the the surface normal on the given face at the given barycentric coordinates (bc). The returned vector is not normalized.

§ GetTexCoord()

Point3f GetTexCoord ( int  faceID,
const Point3f bc 
) const

Returns the texture coordinate on the given face at the given barycentric coordinates (bc).

§ GetMaterialIndex()

int GetMaterialIndex ( int  faceID) const

Returns the material index of the face. This method goes through material counts of all materials to find the material index of the face. Returns a negative number if the face as no material.

§ GetMaterialFaceCount()

int GetMaterialFaceCount ( int  mtlID) const

Returns the number of faces associated with the given material ID.

§ GetMaterialFirstFace()

int GetMaterialFirstFace ( int  mtlID) const

Returns the first face index associated with the given material ID. Other faces associated with the same material are placed are placed consecutively.

§ ComputeBoundingBox()

void ComputeBoundingBox ( )

Computes the bounding box.

§ ComputeNormals()

void ComputeNormals ( bool  clockwise = false)

Computes and stores vertex normals.

§ LoadFromFileObj()

bool LoadFromFileObj ( const char *  filename,
bool  loadMtl = true,
std::ostream *  outStream = &std::cout 
)

Loads the mesh from an OBJ file. Automatically converts all faces to triangles.

§ SaveToFileObj()

bool SaveToFileObj ( const char *  filename,
std::ostream *  outStream 
)

Saves the mesh to an OBJ file with the given name.

Member Data Documentation

§ v

Point3f* v
protected

vertices

§ f

TriFace* f
protected

faces

§ vn

Point3f* vn
protected

vertex normal

§ fn

TriFace* fn
protected

normal faces

§ vt

Point3f* vt
protected

texture vertices

§ ft

TriFace* ft
protected

texture faces

§ m

Mtl* m
protected

materials

§ mcfc

int* mcfc
protected

material cumulative face count

§ nv

unsigned int nv
protected

number of vertices

§ nf

unsigned int nf
protected

number of faces

§ nvn

unsigned int nvn
protected

number of vertex normals

§ nvt

unsigned int nvt
protected

number of texture vertices

§ nm

unsigned int nm
protected

number of materials

§ boundMin

Point3f boundMin
protected

Bounding box minimum bound.

§ boundMax

Point3f boundMax
protected

Bounding box maximum bound.