#ifndef CCS_FACE_GUARD #define CCS_FACE_GUARD #include "EdgeUse.h" #include "../txs/TiffImage.h" namespace CCS { class Face { public: list edgeUses; list uvs; // Used during catmull-clark Vertex *newFacePt; TXS::TiffImage *txtr; Face(list &edgeUses, TXS::TiffImage *txtr, list &uvs) : edgeUses(edgeUses), uvs(uvs), txtr(txtr), newFacePt(NULL) { } /* * Returns the normal for this face at the given vertex. * The normal returned is calculated by: the CCW cross * product of the two edges incident to v. * * So keep in mind, this is a very specific notion of "normal" */ Vector calcNormalAt(Vertex* v); TXS::NormRGB getColorAt(Vertex *v); list::iterator getUvIterAtVert(Vertex *v); void getItersForVert(Vertex *v, list::iterator &eu_out, list::iterator &uv_out); /* * Iterate through the vertices of the face */ class VertexIterator { public: list::iterator eu_iter; Face *face; VertexIterator() : face(NULL) { } void start(Face *face) { this->face = face; this->eu_iter = face->edgeUses.begin(); } bool done() { if(face == NULL) { return true; } else { return this->eu_iter == face->edgeUses.end(); } } Vertex *get_vertex() { if(this->done()) { __ERROR__("tried to retrieve iteration object when iter was done."); return NULL; } else { EdgeUse eu = *this->eu_iter; return eu.getUseStart(); } } Point get_point() { Vertex *vert = this->get_vertex(); return vert->p; } void advance() { ++(this->eu_iter); } }; }; } #endif /* CCS_FACE_GUARD */