00001 /*************************************************************************** 00002 * Copyright (C) 2003-2004 by David Saxton * 00003 * david@bluehaze.org * 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 00011 #ifndef CELLS_H 00012 #define CELLS_H 00013 00014 #include <map> 00015 00016 class Point 00017 { 00018 public: 00019 Point(); 00020 00021 short x; 00022 short y; 00023 short prevX; 00024 short prevY; 00025 }; 00026 00027 // Key = cell, data = previous cell, compare = score 00028 typedef std::multimap< unsigned short, Point > TempLabelMap; 00029 00030 // Used for mapping out connections 00031 const int cellSize = 8; 00032 class Cell 00033 { 00034 public: 00035 Cell(); 00039 void reset(); 00040 00041 unsigned short CIpenalty; // 'Penalty' of using the cell from CNItem 00042 unsigned short Cpenalty; // 'Penalty' of using the cell from Connector 00043 unsigned short bestScore; // Best (lowest) score so far, _the_ best if it is permanent 00044 short prevX, prevY; // Which cell this came from, (-1,-1) if originating cell 00045 bool permanent:1; // Whether the score can be improved on 00046 bool addedToLabels:1; // Whether the cell has already been added to the list of cells to check 00047 Point *point; // Pointer to the point in the TempLabelMap 00048 unsigned short numCon; // Number of connectors through that point 00049 }; 00050 00051 00055 class Cells 00056 { 00057 public: 00058 Cells( const uint w, const uint h ); 00059 ~Cells(); 00063 void reset(); 00064 00065 inline Cell* operator[] ( const uint x ) const 00066 { 00067 if ( x<m_w ) return m_cells[x]; 00068 return 0; 00069 } 00070 00071 const uint width() const { return m_w; } 00072 const uint height() const { return m_h; } 00073 00074 const Cell &cell( const uint x, const uint y ) const { return m_cells[x][y]; } 00075 00076 private: 00077 Cells( const Cells & ); 00078 Cells & operator= ( const Cells & ); 00079 void init( const uint w, const uint h ); 00080 00081 uint m_w; 00082 uint m_h; 00083 00084 Cell **m_cells; 00085 }; 00086 00087 #endif 00088
1.5.1