00001 00009 /* 00010 * 3-sided face, vertices listed in CCW order. 00011 * 00012 * v3 00013 * / \ 00014 * / \ 00015 * / \ 00016 * e3 e2 00017 * / \ 00018 * / \ 00019 * / \ 00020 * v1 -------e1------ v2 00021 */ 00022 00023 00024 00025 #ifndef FACE_H 00026 #define FACE_H 00027 00028 // Gluebase includes 00029 #define OUTSIDE_GLUE_CORE 00030 #include <mlib/points.H> 00031 00032 namespace InSpace { 00033 00034 class ISVertex; 00035 class ISEdge; 00036 class ISMesh; 00037 00038 class ISFace 00039 { 00040 public: 00041 ISFace(ISVertex* v1, ISVertex* v2, ISVertex* v3, 00042 ISEdge* e1, ISEdge* e2, ISEdge* e3){ 00043 _v1 = v1; 00044 _v2 = v2; 00045 _v3 = v3; 00046 _e1 = e1; 00047 _e2 = e2; 00048 _e3 = e3; 00049 00050 _norm = Wvec(0,0,0); 00051 _mesh = NULL; 00052 }; 00053 00054 virtual ~ISFace() {}; 00055 00056 void setVertex1(ISVertex * v){_v1 = v;} 00057 void setVertex2(ISVertex * v){_v2 = v;} 00058 void setVertex3(ISVertex * v){_v3 = v;} 00059 00060 ISVertex* vertex1() const { return _v1; } 00061 ISVertex* vertex2() const { return _v2; } 00062 ISVertex* vertex3() const { return _v3; } 00063 00064 ISEdge* edge1() const { return _e1; } 00065 ISEdge* edge2() const { return _e2; } 00066 ISEdge* edge3() const { return _e3; } 00067 00068 // either set the normal yourself or call compute normal, then 00069 // use norm() to access it. 00070 void setNormal(cWvec &n) { _norm = n; } 00071 cWvec& computeNormal(); 00072 cWvec& norm() const { return _norm; } 00073 00074 Wplane plane(); 00075 00076 double area(); 00077 double volume_el(); 00078 00079 // returns 1 if p lies within the triangle formed by this face, assumes 00080 // p has already been projected onto the plane of the face. 00081 int containsPt(Wpt p); 00082 00083 int contains(ISVertex* v) const { return (v==_v1 || v==_v2 || v==_v3); } 00084 int contains(ISEdge* e) const { return (e==_e1 || e==_e2 || e==_e3); } 00085 00086 void setMesh(ISMesh *m); 00087 00088 protected: 00089 ISVertex *_v1; 00090 ISVertex *_v2; 00091 ISVertex *_v3; 00092 ISEdge *_e1; 00093 ISEdge *_e2; 00094 ISEdge *_e3; 00095 00096 Wvec _norm; 00097 ISMesh *_mesh; // the mesh this face belongs to 00098 }; 00099 00100 00101 } 00102 #endif