Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

ISFace.H

Go to the documentation of this file.
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 class ISVertex;
00033 class ISEdge;
00034 class ISMesh;
00035 
00036 class ISFace
00037 {
00038  public:
00039   ISFace(ISVertex* v1, ISVertex* v2, ISVertex* v3,
00040        ISEdge* e1, ISEdge* e2, ISEdge* e3){
00041     _v1 = v1;
00042     _v2 = v2;
00043     _v3 = v3;
00044     _e1 = e1;
00045     _e2 = e2;
00046     _e3 = e3;
00047 
00048     _norm = Wvec(0,0,0);
00049     _mesh = NULL;
00050   };
00051 
00052   virtual ~ISFace() {};
00053   
00054   void setVertex1(ISVertex * v){_v1 = v;}
00055   void setVertex2(ISVertex * v){_v2 = v;}
00056   void setVertex3(ISVertex * v){_v3 = v;}
00057 
00058   ISVertex* vertex1() const { return _v1; }
00059   ISVertex* vertex2() const { return _v2; }
00060   ISVertex* vertex3() const { return _v3; }
00061 
00062   ISEdge* edge1() const { return _e1; }
00063   ISEdge* edge2() const { return _e2; }
00064   ISEdge* edge3() const { return _e3; }
00065   
00066   // either set the normal yourself or call compute normal, then
00067   // use norm() to access it.
00068   void   setNormal(cWvec &n) { _norm = n; }
00069   cWvec& computeNormal();
00070   cWvec& norm() const { return _norm; }
00071   
00072   Wplane plane();
00073 
00074   double area();
00075   double volume_el();
00076   
00077   // returns 1 if p lies within the triangle formed by this face, assumes 
00078   // p has already been projected onto the plane of the face.
00079   int containsPt(Wpt p);
00080 
00081   int contains(ISVertex* v) const { return (v==_v1 || v==_v2 || v==_v3); }
00082   int contains(ISEdge* e)   const { return (e==_e1 || e==_e2 || e==_e3); }
00083 
00084   void setMesh(ISMesh *m);
00085 
00086  protected:
00087   ISVertex *_v1;
00088   ISVertex *_v2;
00089   ISVertex *_v3;
00090   ISEdge *_e1;
00091   ISEdge *_e2;
00092   ISEdge *_e3;
00093 
00094   Wvec _norm;
00095   ISMesh *_mesh;  // the mesh this face belongs to
00096 };
00097 
00098 #endif

Generated on Mon Sep 15 16:27:56 2003 for inspace by doxygen1.2.18