1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
/***************************************************************************
* Copyright (C) 2003-2004 by David Saxton *
* [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "cells.h"
#if 0
class CellSmall
{
public:
/**
* Resets bestScore, prevX, prevY, addedToLabels, it, permanent for each cell
*/
void reset();
// Point *point; // Pointer to the point in the TempLabelMap
short prevX, prevY; // Which cell this came from, (-1,-1) if originating cell
unsigned short CIpenalty; // 'Penalty' of using the cell from CNItem
unsigned short Cpenalty; // 'Penalty' of using the cell from Connector
unsigned short bestScore; // Best (lowest) score so far, _the_ best if it is permanent
unsigned char numCon; // Number of connectors through that point
bool permanent:1; // Whether the score can be improved on
bool addedToLabels:1; // Whether the cell has already been added to the list of cells to check
};
class CellBig
{
public:
/**
* Resets bestScore, prevX, prevY, addedToLabels, it, permanent for each cell
*/
void reset();
Point *point; // Pointer to the point in the TempLabelMap
short prevX, prevY; // Which cell this came from, (-1,-1) if originating cell
unsigned short CIpenalty; // 'Penalty' of using the cell from CNItem
unsigned short Cpenalty; // 'Penalty' of using the cell from Connector
unsigned short bestScore; // Best (lowest) score so far, _the_ best if it is permanent
unsigned char numCon; // Number of connectors through that point
bool permanent:1; // Whether the score can be improved on
bool addedToLabels:1; // Whether the cell has already been added to the list of cells to check
};
#endif
Cells::Cells( const uint w, const uint h )
{
#if 0
kdDebug() << "sizeof(CellSmall)="<<sizeof(CellSmall)<<endl;
kdDebug() << "sizeof(CellBig)="<<sizeof(Cell)<<endl;
kdDebug() << "sizeof(unsigned short)="<<sizeof(unsigned short)<<endl;
kdDebug() << "sizeof(short)="<<sizeof(short)<<endl;
kdDebug() << "sizeof(Point*)="<<sizeof(Point*)<<endl;
kdDebug() << "sizeof(bool)="<<sizeof(bool)<<endl;
kdDebug() << "sizeof(char)="<<sizeof(char)<<endl;
#endif
init( w, h );
}
Cells::~Cells()
{
for ( uint i=0; i<m_w; ++i )
{
delete [] m_cells[i];
}
delete [] m_cells;
}
Cells::Cells( const Cells &c )
{
init( c.width(), c.height() );
for ( uint x=0; x<m_w; x++ )
{
for ( uint y=0; y<m_h; y++ )
{
m_cells[x][y] = c.cell( x, y );
}
}
}
void Cells::init( const uint w, const uint h )
{
m_w = w;
m_h = h;
typedef Cell* cellptr;
m_cells = new cellptr[m_w];
for ( uint i=0; i<m_w; ++i )
{
m_cells[i] = new Cell[m_h];
}
}
void Cells::reset()
{
for ( uint x=0; x<m_w; x++ )
{
for ( uint y=0; y<m_h; y++ )
{
m_cells[x][y].reset();
}
}
}
Point::Point()
{
x = y = prevX = prevY = -1;
}
Cell::Cell()
{
addedToLabels = false;
permanent = false;
CIpenalty = 0;
numCon = 0;
Cpenalty = 0;
bestScore = (int)1e9; // Nice large value
}
void Cell::reset()
{
addedToLabels = false;
permanent = false;
bestScore = (int)1e9; // Nice large value
}
|