cells.cpp

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 #include "cells.h"
00012 
00013 #if 0
00014 class CellSmall
00015 {
00016         public:
00020                 void reset();
00021         
00022 //              Point *point; // Pointer to the point in the TempLabelMap
00023                 short prevX, prevY; // Which cell this came from, (-1,-1) if originating cell
00024                 unsigned short CIpenalty; // 'Penalty' of using the cell from CNItem
00025                 unsigned short Cpenalty; // 'Penalty' of using the cell from Connector
00026                 unsigned short bestScore; // Best (lowest) score so far, _the_ best if it is permanent
00027                 unsigned char numCon; // Number of connectors through that point
00028                 bool permanent:1; // Whether the score can be improved on
00029                 bool addedToLabels:1; // Whether the cell has already been added to the list of cells to check
00030 };
00031 
00032 class CellBig
00033 {
00034         public:
00038                 void reset();
00039         
00040                 Point *point; // Pointer to the point in the TempLabelMap
00041                 short prevX, prevY; // Which cell this came from, (-1,-1) if originating cell
00042                 unsigned short CIpenalty; // 'Penalty' of using the cell from CNItem
00043                 unsigned short Cpenalty; // 'Penalty' of using the cell from Connector
00044                 unsigned short bestScore; // Best (lowest) score so far, _the_ best if it is permanent
00045                 unsigned char numCon; // Number of connectors through that point
00046                 bool permanent:1; // Whether the score can be improved on
00047                 bool addedToLabels:1; // Whether the cell has already been added to the list of cells to check
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; // Nice large value
00127 }
00128 
00129 void Cell::reset()
00130 {
00131         addedToLabels = false;
00132         permanent = false;
00133         bestScore = (int)1e9; // Nice large value
00134 }
00135 
00136 
00137 

Generated on Tue May 8 17:05:28 2007 for KTechLab by  doxygen 1.5.1