/home/enzo/treballs/fib/pfc/nanocomp/src/forbiddenPattern.cpp

Go to the documentation of this file.
00001 /*
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   This program is distributed in the hope that it will be useful,       *
00009  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00010  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00011  *   GNU General Public License for more details.                          *
00012  *                                                                         *
00013  *   You should have received a copy of the GNU General Public License     *
00014  *   along with this program; if not, write to the                         *
00015  *   Free Software Foundation, Inc.,                                       *
00016  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00017                                                                           */
00018 
00019 // $Revision: 1.13 $
00020 
00021 #include "forbiddenPattern.hpp"
00022 #include <iostream>
00023 using namespace std;
00024 
00026 
00030 ForbiddenPattern::ForbiddenPattern(int width, int height)
00031     : grid(width, height)
00032 {
00033     this->width = width;
00034     this->height = height;
00035 }
00036 
00037 
00039 ForbiddenPattern::~ForbiddenPattern()
00040 {
00041 }
00042 
00043 
00045 
00048 int ForbiddenPattern::getWidth()
00049 {
00050     return width;
00051 }
00052 
00053 
00055 
00058 int ForbiddenPattern::getHeight()
00059 {
00060     return height;
00061 }
00062 
00063 
00065 
00073 bool ForbiddenPattern::cellChanged(int x, int y)
00074 {
00075     switch (grid(x, y))
00076     {
00077         case nDONTCARE:
00078         {
00079             grid(x, y) = nENABLED;
00080             break;
00081         }
00082         case nENABLED:
00083         {
00084             grid(x, y) = nDISABLED;
00085             break;
00086         }
00087         case nDISABLED:
00088         {
00089             grid(x, y) = nDONTCARE;
00090             break;
00091         }
00092         default:
00093         {
00094         }
00095     }
00096 
00097     return true;
00098 }
00099 
00100 
00102 
00105 Grid ForbiddenPattern::getGrid()
00106 {
00107     return grid;    
00108 }
00109 
00110 
00112 
00116 bool ForbiddenPattern::equals(ForbiddenPattern *fp)
00117 {
00118     return ((fp->getGrid().getCells() == grid.getCells()));
00119 }
00120 
00121 
00123 
00126 matrix ForbiddenPattern::getMatrix()
00127 {
00128     return grid.getCells();
00129 }
00130 
00131 
00133 
00140 void ForbiddenPattern::cellChanged(int x, int y, int status)
00141 {
00142     grid(x, y) = status;
00143 }
00144 
00145 
00147 
00151 bool ForbiddenPattern::operator ==(ForbiddenPattern pattern)
00152 {
00153     return ((getWidth() == pattern.getWidth()) &&
00154             (getHeight() == pattern.getHeight()) &&
00155             (grid == pattern.getGrid()));
00156 }
00157 
00158 
00160 
00163 void ForbiddenPattern::setGrid(Grid newGrid)
00164 {
00165     grid.init(newGrid);
00166     width = grid.getWidth();
00167     height = grid.getHeight();
00168 }

Generated on Fri Sep 1 23:55:13 2006 for NanoComp by  doxygen 1.4.6