00001 //=========================================================================== 00002 // GoTools - SINTEF Geometry Tools version 1.1 00003 // 00004 // GoTools module: parametrization 00005 // 00006 // Copyright (C) 2000-2005 SINTEF ICT, Applied Mathematics, Norway. 00007 // 00008 // This program is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU General Public License 00010 // as published by the Free Software Foundation version 2 of the License. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with this program; if not, write to the Free Software 00019 // Foundation, Inc., 00020 // 59 Temple Place - Suite 330, 00021 // Boston, MA 02111-1307, USA. 00022 // 00023 // Contact information: E-mail: tor.dokken@sintef.no 00024 // SINTEF ICT, Department of Applied Mathematics, 00025 // P.O. Box 124 Blindern, 00026 // 0314 Oslo, Norway. 00027 // 00028 // Other licenses are also available for this software, notably licenses 00029 // for: 00030 // - Building commercial software. 00031 // - Building software whose source code you wish to keep private. 00032 //=========================================================================== 00033 #ifndef PRTRIANGLE_H 00034 #define PRTRIANGLE_H 00035 00036 #include <iostream> 00037 00038 /*<PrTriangle-syntax: */ 00039 00050 class PrTriangle 00051 { 00052 private: 00053 int n1_,n2_,n3_; 00054 int t1_,t2_,t3_; 00055 00056 public: 00057 00059 PrTriangle() {} 00061 PrTriangle(int n1, int n2, int n3, int t1, int t2, int t3) 00062 { n1_ = n1; n2_ = n2; n3_ = n3; t1_ = t1; t2_ = t2; t3_ = t3; } 00064 PrTriangle(const PrTriangle& t) 00065 {n1_ = t.n1_; n2_ = t.n2_; n3_ = t.n3_; 00066 t1_ = t.t1_; t2_ = t.t2_; t3_ = t.t3_; } 00068 ~PrTriangle() {} 00069 00070 inline void init(int n1, int n2, int n3, int t1, int t2, int t3); 00071 00072 inline const int& n1() const; 00073 inline const int& n2() const; 00074 inline const int& n3() const; 00075 inline const int& t1() const; 00076 inline const int& t2() const; 00077 inline const int& t3() const; 00078 00079 inline int& n1(); 00080 inline int& n2(); 00081 inline int& n3(); 00082 inline int& t1(); 00083 inline int& t2(); 00084 inline int& t3(); 00085 00087 int getOppositeTriangle(int node) const; 00088 00090 int getLeftTriangle(int node) const; 00091 00093 int getRightTriangle(int node) const; 00094 00097 int getAnticlockwiseNode(int node) const; 00098 00100 int getClockwiseNode(int node) const; 00101 00103 bool isVertex(int node) const; 00104 00106 void replaceNode(int n1, int n2); 00107 00109 void replaceTriangle(int t1, int t2); 00110 00113 int getEdge(int triangle, int &n1, int &n2) const; 00114 00116 void print(std::ostream& os) const; 00117 00119 void scan(std::istream& is); 00120 }; 00121 00122 00123 /*>PrTriangle-syntax: */ 00124 00125 //----------------------------------------------------------------------------- 00126 inline void PrTriangle::init(int n1, int n2, int n3, int t1, int t2, int t3) 00127 //----------------------------------------------------------------------------- 00128 { 00129 n1_ = n1; 00130 n2_ = n2; 00131 n3_ = n3; 00132 t1_ = t1; 00133 t2_ = t2; 00134 t3_ = t3; 00135 } 00136 00137 //----------------------------------------------------------------------------- 00138 inline const int& PrTriangle::n1() const 00139 //----------------------------------------------------------------------------- 00140 { 00141 return n1_; 00142 } 00143 00144 //----------------------------------------------------------------------------- 00145 inline const int& PrTriangle::n2() const 00146 //----------------------------------------------------------------------------- 00147 { 00148 return n2_; 00149 } 00150 00151 //----------------------------------------------------------------------------- 00152 inline const int& PrTriangle::n3() const 00153 //----------------------------------------------------------------------------- 00154 { 00155 return n3_; 00156 } 00157 00158 //----------------------------------------------------------------------------- 00159 inline const int& PrTriangle::t1() const 00160 //----------------------------------------------------------------------------- 00161 { 00162 return t1_; 00163 } 00164 00165 //----------------------------------------------------------------------------- 00166 inline const int& PrTriangle::t2() const 00167 //----------------------------------------------------------------------------- 00168 { 00169 return t2_; 00170 } 00171 00172 //----------------------------------------------------------------------------- 00173 inline const int& PrTriangle::t3() const 00174 //----------------------------------------------------------------------------- 00175 { 00176 return t3_; 00177 } 00178 00179 //----------------------------------------------------------------------------- 00180 inline int& PrTriangle::n1() 00181 //----------------------------------------------------------------------------- 00182 { 00183 return n1_; 00184 } 00185 00186 //----------------------------------------------------------------------------- 00187 inline int& PrTriangle::n2() 00188 //----------------------------------------------------------------------------- 00189 { 00190 return n2_; 00191 } 00192 00193 //----------------------------------------------------------------------------- 00194 inline int& PrTriangle::n3() 00195 //----------------------------------------------------------------------------- 00196 { 00197 return n3_; 00198 } 00199 00200 //----------------------------------------------------------------------------- 00201 inline int& PrTriangle::t1() 00202 //----------------------------------------------------------------------------- 00203 { 00204 return t1_; 00205 } 00206 00207 //----------------------------------------------------------------------------- 00208 inline int& PrTriangle::t2() 00209 //----------------------------------------------------------------------------- 00210 { 00211 return t2_; 00212 } 00213 00214 //----------------------------------------------------------------------------- 00215 inline int& PrTriangle::t3() 00216 //----------------------------------------------------------------------------- 00217 { 00218 return t3_; 00219 } 00220 00221 /*Class:PrTriangle 00222 00223 Name: PrTriangle 00224 Syntax: @PrTriangle-syntax 00225 Keywords: 00226 Description: This class represents a triangle for use in 00227 PrTriangulation_OP. It has three indices of its 00228 three vertices in some anticlockwise order. 00229 Its three neighbouring triangles t1,t2,t3 are opposite 00230 to its vertices. Thus t1 is the triangle opposite n1, 00231 t2 is opposite n2 and t3 opposite n3. If any of the 00232 neighbouring triangles do not exist in the triangulation 00233 their index is -1 (which is out of range in the array 00234 of triangles in the triangulation). 00235 Member functions: 00236 "getOppositeTriangle(int node)" --\\ 00237 Return the neighbouring triangle which lies 00238 opposite to the given node. 00239 00240 "getLeftTriangle(int node)" --\\ 00241 Return the neighbouring triangle which lies 00242 to the left of the given node. 00243 00244 "getRightTriangle(int node)" --\\ 00245 Return the neighbouring triangle which lies 00246 to the right of the given node. 00247 00248 "getAnticlockwiseNode(int node)" --\\ 00249 Return the node following "node" in an anticlockwise 00250 direction around the triangle. 00251 00252 "getClockwiseNode(int node)" --\\ 00253 Return the node following "node" in a clockwise 00254 direction around the triangle. 00255 00256 "isVertex(int node)" --\\ 00257 Boolean routine: does "node" belong to the triangle? 00258 00259 Constructors: 00260 Files: 00261 Example: 00262 See also: 00263 Developed by: SINTEF Applied Mathematics, Oslo, Norway 00264 Author: Michael Floater, SINTEF 00265 Date: August 97 00266 */ 00267 00268 #endif // PRTRIANGLE_H