00001 /*************************************************************************** 00002 * Copyright (C) 2007 by Universidad Nacional de Colombia * 00003 * http://www.unal.edu.co * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 #include "Triangle.h" 00021 00022 #include <set> 00023 #include <iostream> 00024 using namespace std ; 00025 00026 Triangle::Triangle() 00027 { 00028 this->id = -1 ; 00029 this->p1 = Point() ; 00030 this->p2 = Point() ; 00031 this->p3 = Point() ; 00032 this->processed = false ; 00033 } 00034 00035 Triangle::Triangle( int id, Point p1, Point p2, Point p3 ) 00036 { 00037 this->id = id ; 00038 this->p1 = p1 ; 00039 this->p2 = p2 ; 00040 this->p3 = p3 ; 00041 this->processed = false ; 00042 } 00043 00044 Triangle::Triangle( const Triangle& tr ) 00045 { 00046 this->id = tr.getId() ; 00047 this->p1 = tr.getPoint1() ; 00048 this->p2 = tr.getPoint2() ; 00049 this->p3 = tr.getPoint3() ; 00050 this->processed = tr.isProcessed() ; 00051 } 00052 00053 bool Triangle::operator == ( const Triangle& tr ) 00054 { 00055 if( ( p1 == tr.getPoint1() ) && ( p2 == tr.getPoint2() ) && ( p3 == tr.getPoint3() ) ) 00056 return true ; 00057 00058 return false ; 00059 } 00060 00061 bool operator < ( const Triangle& tr1, const Triangle& tr2 ){ 00062 if( ( tr1.getId() < tr2.getId() ) ) 00063 return true ; 00064 00065 return false ; 00066 } 00067 00068 Triangle::~Triangle() 00069 { 00070 } 00071 00072 void Triangle::setId( int id ){ 00073 this->id = id ; 00074 } 00075 00076 void Triangle::setPoint1( Point p1 ) 00077 { 00078 this->p1 = p1 ; 00079 } 00080 00081 void Triangle::setPoint2( Point p2 ) 00082 { 00083 this->p2 = p2 ; 00084 } 00085 00086 void Triangle::setPoint3( Point p3 ) 00087 { 00088 this->p3 = p3 ; 00089 } 00090 00091 int Triangle::getId() const 00092 { 00093 return id ; 00094 } 00095 00096 Point Triangle::getPoint1() const 00097 { 00098 return p1 ; 00099 } 00100 00101 Point Triangle::getPoint2() const 00102 { 00103 return p2 ; 00104 } 00105 00106 Point Triangle::getPoint3() const 00107 { 00108 return p3 ; 00109 } 00110 00111 bool Triangle::isProcessed() const 00112 { 00113 return processed; 00114 } 00115 00116 void Triangle::setProcessed( bool processed ) 00117 { 00118 this->processed = processed; 00119 } 00120 00127 bool Triangle::contains( Point p ) 00128 { 00129 if( p.getId() == p1.getId() ) 00130 return true ; 00131 else if( p.getId() == p2.getId() ) 00132 return true ; 00133 else if( p.getId() == p3.getId() ) 00134 return true ; 00135 else 00136 return false ; 00137 } 00138 00145 bool Triangle::contains( int pointId ) 00146 { 00147 if( pointId == p1.getId() ) 00148 return true ; 00149 else if( pointId == p2.getId() ) 00150 return true ; 00151 else if( pointId == p3.getId() ) 00152 return true ; 00153 else 00154 return false ; 00155 }