00001 #ifndef CONNECTION 00002 #define CONNECTION 00003 00004 #include <iostream> 00005 #include <string> 00006 #include <vector> 00007 #include <set> 00008 #include <map> 00009 #include <stdlib.h> 00010 #include <stdio.h> 00011 00012 #include "Point.h" 00013 00017 class Connection { 00018 public: 00019 PType centroid; 00020 00021 // Constructors 00022 Connection() {} 00023 00024 // Destructor 00025 ~Connection() {} 00026 00027 virtual void measure() = 0; 00028 virtual DataType Length() const = 0; 00029 virtual void setLength(DataType val) = 0; 00030 virtual PType Normal() const = 0; 00031 virtual void setNormal(PType val) = 0; 00032 virtual DataType Area() const = 0; 00033 virtual void setArea(DataType val) = 0; 00034 virtual PType Centroid() const = 0; 00035 virtual void setCentroid(PType val) = 0; 00036 virtual void setNthCon(int i, int val) = 0; 00037 virtual int getNthCon(int i) const = 0; 00038 }; 00039 00044 template <class DataType, int dim> 00045 class Segment: public Connection { 00046 typedef Connection base; 00047 public: 00048 friend class Connection; 00049 DataType length; 00050 int cPid[2]; 00051 00052 // Constructors 00053 Segment() { 00054 cPid[0] = -1; cPid[1] = -2; 00055 base::centroid(0) =0; base::centroid(1) =0; 00056 if (dim == 3) base::centroid(2) =0; 00057 length = 0; 00058 } 00059 Segment(int v0, int v1) { 00060 base::centroid(0) =0; base::centroid(1) =0; 00061 if (dim == 3) base::centroid(2) =0; 00062 cPid[0] = v0; cPid[1] = v1; 00063 length = 0; 00064 } 00065 00066 // Destructor 00067 ~Segment() {} 00068 00069 virtual void measure() {} 00070 virtual DataType Length() const { return length; } 00071 virtual void setLength(DataType val) { length = val; } 00072 virtual PType Normal() const { return (PType) 0.; } 00073 virtual void setNormal(PType val) {} 00074 virtual PType Centroid() const { return base::centroid; } 00075 virtual void setCentroid(PType val) { base::centroid = val; } 00076 virtual DataType Area() const { return 0.; } 00077 virtual void setArea(DataType val) {} 00078 virtual void ConArea() {} 00079 virtual void setNthCon(int i, int val) { cPid[i] = val; } 00080 virtual int getNthCon(int i) const { return cPid[i]; } 00081 }; 00082 00087 template <class DataType> 00088 class Facet : public Connection { 00089 typedef Connection base; 00090 public: 00091 friend class Connection; 00092 PType normal; 00093 DataType area; 00094 int cPid[3]; 00095 00096 // Constructors 00097 Facet() { 00098 cPid[0] = -1; cPid[1] = -2; cPid[2] = -3; 00099 base::centroid(0) =0; base::centroid(1) =0; base::centroid(2) =0; 00100 normal(0) = 0; normal(1) = 0; normal(2) = 0; 00101 00102 } 00103 Facet(int v0, int v1, int v2) { 00104 base::centroid(0) =0; base::centroid(1) =0; base::centroid(2) =0; 00105 cPid[0] = v0; cPid[1] = v1; cPid[2] = v2; 00106 normal(0) = 0; normal(1) = 0; normal(2) = 0; 00107 } 00108 00109 // Destructor 00110 ~Facet() {} 00111 00112 virtual void measure() { 00113 PType Ntmp(0.); 00114 setNormal(Ntmp); 00115 } 00116 virtual DataType Length() const { return 0; } 00117 virtual void setLength(DataType val) {} 00118 virtual DataType Area() const { return area; } 00119 virtual void setArea(DataType val) { area = val; } 00120 virtual PType Normal() const { return normal; } 00121 virtual void setNormal(PType val) { normal = val; } 00122 virtual PType Centroid() const { return base::centroid; } 00123 virtual void setCentroid(PType val) { base::centroid = val; } 00124 virtual void setNthCon(int i, int val) { cPid[i] = val; } 00125 virtual int getNthCon(int i) const { return cPid[i]; } 00126 00127 virtual void increment(int val) { 00128 cPid[0] += val; cPid[1] += val; cPid[2] += val; 00129 } 00130 }; 00131 00132 #endif // FACET_H