00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "cells.h"
00012
00013 #if 0
00014 class CellSmall
00015 {
00016 public:
00020 void reset();
00021
00022
00023 short prevX, prevY;
00024 unsigned short CIpenalty;
00025 unsigned short Cpenalty;
00026 unsigned short bestScore;
00027 unsigned char numCon;
00028 bool permanent:1;
00029 bool addedToLabels:1;
00030 };
00031
00032 class CellBig
00033 {
00034 public:
00038 void reset();
00039
00040 Point *point;
00041 short prevX, prevY;
00042 unsigned short CIpenalty;
00043 unsigned short Cpenalty;
00044 unsigned short bestScore;
00045 unsigned char numCon;
00046 bool permanent:1;
00047 bool addedToLabels:1;
00048 };
00049 #endif
00050
00051
00052 Cells::Cells( const uint w, const uint h )
00053 {
00054 #if 0
00055 kdDebug() << "sizeof(CellSmall)="<<sizeof(CellSmall)<<endl;
00056 kdDebug() << "sizeof(CellBig)="<<sizeof(Cell)<<endl;
00057 kdDebug() << "sizeof(unsigned short)="<<sizeof(unsigned short)<<endl;
00058 kdDebug() << "sizeof(short)="<<sizeof(short)<<endl;
00059 kdDebug() << "sizeof(Point*)="<<sizeof(Point*)<<endl;
00060 kdDebug() << "sizeof(bool)="<<sizeof(bool)<<endl;
00061 kdDebug() << "sizeof(char)="<<sizeof(char)<<endl;
00062 #endif
00063 init( w, h );
00064 }
00065
00066
00067 Cells::~Cells()
00068 {
00069 for ( uint i=0; i<m_w; ++i ) {
00070 delete [] m_cells[i];
00071 }
00072 delete [] m_cells;
00073 }
00074
00075 Cells::Cells( const Cells &c )
00076 {
00077 init( c.width(), c.height() );
00078 for ( uint x=0; x<m_w; x++ )
00079 {
00080 for ( uint y=0; y<m_h; y++ )
00081 {
00082 m_cells[x][y] = c.cell( x, y );
00083 }
00084 }
00085 }
00086
00087
00088 void Cells::init( const uint w, const uint h )
00089 {
00090 m_w = w;
00091 m_h = h;
00092
00093 typedef Cell* cellptr;
00094 m_cells = new cellptr[m_w];
00095 for ( uint i=0; i<m_w; ++i )
00096 {
00097 m_cells[i] = new Cell[m_h];
00098 }
00099 }
00100
00101
00102 void Cells::reset()
00103 {
00104 for ( uint x=0; x<m_w; x++ )
00105 {
00106 for ( uint y=0; y<m_h; y++ )
00107 {
00108 m_cells[x][y].reset();
00109 }
00110 }
00111 }
00112
00113
00114 Point::Point()
00115 {
00116 x = y = prevX = prevY = -1;
00117 }
00118
00119 Cell::Cell()
00120 {
00121 addedToLabels = false;
00122 permanent = false;
00123 CIpenalty = 0;
00124 numCon = 0;
00125 Cpenalty = 0;
00126 bestScore = (int)1e9;
00127 }
00128
00129 void Cell::reset()
00130 {
00131 addedToLabels = false;
00132 permanent = false;
00133 bestScore = (int)1e9;
00134 }
00135
00136
00137