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

ISEdge.H

Go to the documentation of this file.
00001 
00010 #ifndef ISEDGE_H
00011 #define ISEDGE_H
00012 
00013 // Gluebase includes
00014 #define OUTSIDE_GLUE_CORE
00015 #include <mlib/points.H>
00016 
00017 namespace InSpace {
00018 
00019 class ISVertex;
00020 class ISFace;
00021 class ISMesh;
00022 
00023 class ISEdge
00024 {
00025  public:
00026   ISEdge(ISVertex *u, ISVertex *v);
00027   virtual ~ISEdge() {};
00028 
00029   ISVertex* vertex1() const { return _v1; }
00030   ISVertex* vertex2() const { return _v2; }
00031 
00032   ISFace* face1() const { return _f1; }
00033   ISFace* face2() const { return _f2; }
00034 
00035   // if v is a vertex of this edge, return the other vertex
00036   ISVertex* otherVertex(ISVertex *v) const {
00037     return (v==_v1)?_v2:(v==_v2)?_v1:NULL;
00038   }
00039 
00040   // if f is a face adjacent to this edge, return the other face
00041   ISFace *otherFace(ISFace *f) const {
00042     return (f==_f1)?_f2:(f==_f2)?_f1:NULL;
00043   }
00044 
00045   double length();
00046   Wvec vec();
00047 
00048   int isBorder() { return (nfaces() == 1); }
00049 
00050   // building / redefining adjacent faces
00051   int addFace(ISFace *face) {
00052     if (_f1 && _f2) {
00053       cerr << "ISEdge Error: Attempt to add 3rd face!" << endl;
00054       return 0;
00055     }
00056     else if (_f1) 
00057       _f2 = face;
00058     else
00059       _f1 = face;
00060     return 1;
00061   }
00062 
00063   int removeFace(ISFace *face) {
00064     if (face == _f1)
00065       _f1 = NULL;
00066     else if (face == _f2)
00067       _f2 = NULL;
00068     else {
00069       cerr << "ISEdge Error: Attempt to remove unknown face!" << endl;
00070       return 0;
00071     }
00072     return 1;
00073   }
00074 
00075   void setMesh(ISMesh *m);
00076 
00077   int nfaces() {
00078     int ret = 0;
00079     if (_f1) ret++;
00080     if (_f2) ret++;
00081     return ret;
00082   }
00083 
00084   int contains(ISVertex* v) const { return (v==_v1 || v==_v2); }
00085 
00086  protected:
00087   ISVertex *_v1;
00088   ISVertex *_v2;
00089   ISFace *_f1;
00090   ISFace *_f2;
00091 
00092   ISMesh *_mesh;  // the mesh that this ISEdge belongs to
00093 
00094 };
00095 
00096 }
00097 
00098 #endif
00099 
00100 
00101 
00102 
00103 
00104 

Generated on Thu Jul 8 15:19:28 2004 for inspace by doxygen 1.3.4