PrTriangle.C

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 #include "PrTriangle.h"
00034 #include <iostream>
00035 
00036 // MEMBER FUNCTIONS
00037 
00038 //-----------------------------------------------------------------------------
00039 int PrTriangle::getOppositeTriangle(int node) const
00040 //-----------------------------------------------------------------------------
00041 {
00042   if(n1_ == node) return t1_;
00043   else if(n2_ == node) return t2_;
00044   else if(n3_ == node) return t3_;
00045   else return -1;
00046 }
00047 
00048 //-----------------------------------------------------------------------------
00049 int PrTriangle::getLeftTriangle(int node) const
00050 //-----------------------------------------------------------------------------
00051 {
00052   if(n1_ == node) return t2_;
00053   else if(n2_ == node) return t3_;
00054   else if(n3_ == node) return t1_;
00055   else return -1;
00056 }
00057 
00058 //-----------------------------------------------------------------------------
00059 int PrTriangle::getRightTriangle(int node) const
00060 //-----------------------------------------------------------------------------
00061 {
00062   if(n1_ == node) return t3_;
00063   else if(n2_ == node) return t1_;
00064   else if(n3_ == node) return t2_;
00065   else return -1;
00066 }
00067 
00068 //-----------------------------------------------------------------------------
00069 int PrTriangle::getAnticlockwiseNode(int node) const
00070 //-----------------------------------------------------------------------------
00071 {
00072   if(n1_ == node) return n2_;
00073   else if(n2_ == node) return n3_;
00074   else if(n3_ == node) return n1_;
00075   else return -1;
00076 }
00077 
00078 //-----------------------------------------------------------------------------
00079 int PrTriangle::getClockwiseNode(int node) const
00080 //-----------------------------------------------------------------------------
00081 {
00082   if(n1_ == node) return n3_;
00083   else if(n2_ == node) return n1_;
00084   else if(n3_ == node) return n2_;
00085   else return -1;
00086 }
00087 
00088 //-----------------------------------------------------------------------------
00089 bool PrTriangle::isVertex(int node) const
00090 //-----------------------------------------------------------------------------
00091 {
00092   if(n1_ == node || n2_ == node || n3_ == node) return true;
00093   else return false;
00094 }
00095 
00096 //-----------------------------------------------------------------------------
00097 void PrTriangle::replaceNode(int n1, int n2)
00098 //-----------------------------------------------------------------------------
00099 {
00100   if(n1_ == n1) n1_ = n2;
00101   else if(n2_ == n1) n2_ = n2;
00102   else if(n3_ == n1) n3_ = n2;
00103 }
00104 
00105 //-----------------------------------------------------------------------------
00106 void PrTriangle::replaceTriangle(int t1, int t2)
00107 //-----------------------------------------------------------------------------
00108 {
00109   if(t1_ == t1) t1_ = t2;
00110   else if(t2_ == t1) t2_ = t2;
00111   else if(t3_ == t1) t3_ = t2;
00112 }
00113 
00114 //-----------------------------------------------------------------------------
00115 int PrTriangle::getEdge(int triangle, int &n1, int &n2) const
00116 //-----------------------------------------------------------------------------
00117 {
00118    if (t1_==triangle)
00119    {
00120       n1=n2_;
00121       n2=n3_;
00122    } else if (t2_==triangle)
00123    {
00124       n1=n3_;
00125       n2=n1_;
00126    } else if (t3_==triangle)
00127    {
00128       n1=n1_;
00129       n2=n2_;
00130    } else
00131       return false;
00132    return true;
00133 }
00134 
00135 
00136 
00137 //-----------------------------------------------------------------------------
00138 void PrTriangle::print(std::ostream& os) const
00139 //-----------------------------------------------------------------------------
00140 {
00141   os << n1_ << ' ' << n2_ << ' ' << n3_ << "    "
00142      << t1_ << ' ' << t2_ << ' ' << t3_ << std::endl;
00143 }
00144 //-----------------------------------------------------------------------------
00145 
00146 void PrTriangle::scan(std::istream& is)
00147 //-----------------------------------------------------------------------------
00148 {
00149   is >> n1_ >> n2_ >> n3_ >> t1_ >> t2_ >> t3_;
00150 }

Generated on Tue Jun 12 11:05:05 2007 for GoTools Parametrization Library by  doxygen 1.5.1