00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 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 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your 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, see <http://www.gnu.org/licenses/>. 00023 00024 \*---------------------------------------------------------------------------*/ 00025 00026 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // 00027 00028 // Edge to the right of face vertex i 00029 inline Foam::label Foam::face::right(const label i) const 00030 { 00031 return i; 00032 } 00033 00034 00035 // Edge to the left of face vertex i 00036 inline Foam::label Foam::face::left(const label i) const 00037 { 00038 return i ? i-1 : size()-1; 00039 } 00040 00041 00042 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 00043 00044 inline Foam::face::face() 00045 {} 00046 00047 00048 inline Foam::face::face(label s) 00049 : 00050 labelList(s, -1) 00051 {} 00052 00053 00054 inline Foam::face::face(const UList<label>& lst) 00055 : 00056 labelList(lst) 00057 {} 00058 00059 00060 inline Foam::face::face(const labelList& lst) 00061 : 00062 labelList(lst) 00063 {} 00064 00065 00066 inline Foam::face::face(const Xfer<labelList>& lst) 00067 : 00068 labelList(lst) 00069 {} 00070 00071 00072 inline Foam::face::face(Istream& is) 00073 { 00074 is >> *this; 00075 } 00076 00077 00078 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 00079 00080 inline Foam::pointField Foam::face::points(const pointField& meshPoints) const 00081 { 00082 // There are as many points as there labels for them 00083 pointField p(size()); 00084 00085 // For each point in list, set it to the point in 'pnts' addressed 00086 // by 'labs' 00087 forAll(p, i) 00088 { 00089 p[i] = meshPoints[operator[](i)]; 00090 } 00091 00092 // Return list 00093 return p; 00094 } 00095 00096 00097 inline Foam::scalar Foam::face::mag(const pointField& p) const 00098 { 00099 return ::Foam::mag(normal(p)); 00100 } 00101 00102 00103 inline Foam::label Foam::face::nEdges() const 00104 { 00105 // for a closed polygon a number of edges is the same as number of points 00106 return size(); 00107 } 00108 00109 00110 inline Foam::edge Foam::face::faceEdge(const label n) const 00111 { 00112 return edge(operator[](n), operator[](fcIndex(n))); 00113 } 00114 00115 00116 // Next vertex on face 00117 inline Foam::label Foam::face::nextLabel(const label i) const 00118 { 00119 return operator[](fcIndex(i)); 00120 } 00121 00122 00123 // Previous vertex on face 00124 inline Foam::label Foam::face::prevLabel(const label i) const 00125 { 00126 return operator[](rcIndex(i)); 00127 } 00128 00129 // Number of triangles directly known from number of vertices 00130 inline Foam::label Foam::face::nTriangles() const 00131 { 00132 return size() - 2; 00133 } 00134 00135 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // 00136 00137 inline bool Foam::operator==(const face& a, const face& b) 00138 { 00139 return face::compare(a,b) != 0; 00140 } 00141 00142 00143 inline bool Foam::operator!=(const face& a, const face& b) 00144 { 00145 return face::compare(a,b) == 0; 00146 } 00147 00148 00149 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // 00150 00151 inline Foam::Istream& Foam::operator>>(Istream& is, face& f) 00152 { 00153 if (is.version() == IOstream::originalVersion) 00154 { 00155 // Read starting ( 00156 is.readBegin("face"); 00157 00158 // Read the 'name' token for the face 00159 token t(is); 00160 00161 // Read labels 00162 is >> static_cast<labelList&>(f); 00163 00164 // Read end) 00165 is.readEnd("face"); 00166 } 00167 else 00168 { 00169 is >> static_cast<labelList&>(f); 00170 } 00171 00172 // Check state of Ostream 00173 is.check("Istream& operator>>(Istream&, face&)"); 00174 00175 return is; 00176 } 00177 00178 // ************************ vim: set sw=4 sts=4 et: ************************ //