00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "IOstreams.H"
00030
00031
00032
00033 namespace Foam
00034 {
00035
00036
00037
00038 inline edge::edge()
00039 {}
00040
00041
00042 inline edge::edge(const label a, const label b)
00043 {
00044 start() = a;
00045 end() = b;
00046 }
00047
00048
00049 inline edge::edge(Istream& is)
00050 :
00051 FixedList<label, 2>(is)
00052 {}
00053
00054
00055
00056
00057 inline label edge::start() const
00058 {
00059 return operator[](0);
00060 }
00061
00062 inline label& edge::start()
00063 {
00064 return operator[](0);
00065 }
00066
00067
00068 inline label edge::end() const
00069 {
00070 return operator[](1);
00071 }
00072
00073 inline label& edge::end()
00074 {
00075 return operator[](1);
00076 }
00077
00078
00079 inline label edge::otherVertex(const label a) const
00080 {
00081 if (a == start())
00082 {
00083 return end();
00084 }
00085 else if (a == end())
00086 {
00087 return start();
00088 }
00089 else
00090 {
00091
00092 return -1;
00093 }
00094 }
00095
00096
00097 inline label edge::commonVertex(const edge& a) const
00098 {
00099 if (start() == a.start() || start() == a.end())
00100 {
00101 return start();
00102 }
00103 else if (end() == a.start() || end() == a.end())
00104 {
00105 return end();
00106 }
00107 else
00108 {
00109
00110 return -1;
00111 }
00112 }
00113
00114
00115 inline edge edge::reverseEdge() const
00116 {
00117 return edge(end(), start());
00118 }
00119
00120
00121 inline point edge::centre(const pointField& p) const
00122 {
00123 return 0.5*(p[start()] + p[end()]);
00124 }
00125
00126
00127 inline vector edge::vec(const pointField& p) const
00128 {
00129 return p[end()] - p[start()];
00130 }
00131
00132
00133 inline scalar edge::mag(const pointField& p) const
00134 {
00135 return ::Foam::mag(vec(p));
00136 }
00137
00138
00139 inline linePointRef edge::line(const pointField& p) const
00140 {
00141 return linePointRef(p[start()], p[end()]);
00142 }
00143
00144
00145
00146
00147 inline bool operator==(const edge& a, const edge& b)
00148 {
00149 return
00150 (
00151 (a[0] == b[0] && a[1] == b[1])
00152 || (a[0] == b[1] && a[1] == b[0])
00153 );
00154 }
00155
00156
00157 inline bool operator!=(const edge& a, const edge& b)
00158 {
00159 return !(a == b);
00160 }
00161
00162
00163
00164
00165 }
00166
00167