static void Check(const char *S, const bool cHO, const vector<PointPriorityQueue::Entry*>& heap, const SparseMatrix<size_t*>& map, const uint w, const uint h)
{
	for (size_t i = 0; i < heap.size(); ++i)
	{
		const PointPriorityQueue::Entry *e = heap[i];
		assert(i == e->index);
		if (i && cHO)
			assert(e->score >= heap[(i-1)/2]->score);
		assert(e->I == e->x + e->y * w);
		assert(&e->index == map.Get(e->x, e->y));
	}
	for (uint y = 0; y < h; ++y)
	{
		for (uint x = 0; x < w; ++x)
		{
			const size_t *index = map.Get(x, y);
			size_t i;
			assert(index == NULL || ((i = *index) < heap.size() && heap[i]->I == (x + y * w)));
		}
	}
}
Пример #2
0
void Livewire::WriteBitmap(const SparseMatrix<uint> &data, uint w, uint h, const char *name)
{
	QImage b(w, h, QImage::Format_Indexed8);
	b.setColorTable(*GetGrayscaleColorTable());
	uint max = 0;
	for (uint y = 0; y < h; ++y)
	{
		for (uint x = 0; x < w; ++x)
		{
			uint val = data.Get(x, y);
			if (val > max)
				max = val;
		}
	}
	for (uint y = 0; y < h; ++y)
	{
		byte *line = b.scanLine(y);
		for (uint x = 0; x < w; ++x)
			line[x] = (byte)(data.Get(x, y) * 255 / max);
	}
	b.save(QString::number(QDateTime::currentMSecsSinceEpoch()) + "-" + QString(name) + ".png");
}