edgeI.H
Go to the documentation of this file.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 #include "IOstreams.H"
00028
00029
00030
00031
00032
00033
00034
00035
00036 inline int Foam::edge::compare(const edge& a, const edge& b)
00037 {
00038 if (a[0] == b[0] && a[1] == b[1])
00039 {
00040 return 1;
00041 }
00042 else if (a[0] == b[1] && a[1] == b[0])
00043 {
00044 return -1;
00045 }
00046 else
00047 {
00048 return 0;
00049 }
00050 }
00051
00052
00053
00054
00055 inline Foam::edge::edge()
00056 {}
00057
00058
00059 inline Foam::edge::edge(const label a, const label b)
00060 {
00061 start() = a;
00062 end() = b;
00063 }
00064
00065
00066 inline Foam::edge::edge(const FixedList<label, 2>& a)
00067 {
00068 start() = a[0];
00069 end() = a[1];
00070 }
00071
00072
00073 inline Foam::edge::edge(Istream& is)
00074 :
00075 FixedList<label, 2>(is)
00076 {}
00077
00078
00079
00080
00081 inline Foam::label Foam::edge::start() const
00082 {
00083 return operator[](0);
00084 }
00085
00086 inline Foam::label& Foam::edge::start()
00087 {
00088 return operator[](0);
00089 }
00090
00091
00092 inline Foam::label Foam::edge::end() const
00093 {
00094 return operator[](1);
00095 }
00096
00097 inline Foam::label& Foam::edge::end()
00098 {
00099 return operator[](1);
00100 }
00101
00102
00103 inline Foam::label Foam::edge::otherVertex(const label a) const
00104 {
00105 if (a == start())
00106 {
00107 return end();
00108 }
00109 else if (a == end())
00110 {
00111 return start();
00112 }
00113 else
00114 {
00115
00116 return -1;
00117 }
00118 }
00119
00120
00121 inline Foam::label Foam::edge::commonVertex(const edge& a) const
00122 {
00123 if (start() == a.start() || start() == a.end())
00124 {
00125 return start();
00126 }
00127 else if (end() == a.start() || end() == a.end())
00128 {
00129 return end();
00130 }
00131 else
00132 {
00133
00134 return -1;
00135 }
00136 }
00137
00138
00139 inline Foam::edge Foam::edge::reverseEdge() const
00140 {
00141 return edge(end(), start());
00142 }
00143
00144
00145 inline Foam::point Foam::edge::centre(const pointField& p) const
00146 {
00147 return 0.5*(p[start()] + p[end()]);
00148 }
00149
00150
00151 inline Foam::vector Foam::edge::vec(const pointField& p) const
00152 {
00153 return p[end()] - p[start()];
00154 }
00155
00156
00157 inline Foam::scalar Foam::edge::mag(const pointField& p) const
00158 {
00159 return ::Foam::mag(vec(p));
00160 }
00161
00162
00163 inline Foam::linePointRef Foam::edge::line(const pointField& p) const
00164 {
00165 return linePointRef(p[start()], p[end()]);
00166 }
00167
00168
00169
00170
00171 inline bool Foam::operator==(const edge& a, const edge& b)
00172 {
00173 return edge::compare(a,b) != 0;
00174 }
00175
00176
00177 inline bool Foam::operator!=(const edge& a, const edge& b)
00178 {
00179 return edge::compare(a,b) == 0;
00180 }
00181
00182
00183
Copyright © 2000-2009 OpenCFD Ltd