|
|
|
edgeI.HGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Description 00026 00027 \*---------------------------------------------------------------------------*/ 00028 00029 #include "IOstreams.H" 00030 00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00032 00033 namespace Foam 00034 { 00035 00036 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 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 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 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 // The given vertex is not on the edge in the first place. 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 // No shared vertex. 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 // * * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * // 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 } // End namespace Foam 00166 00167 // ************************************************************************* // |