string Maze::dispayMaze()
{
	string mazeDsp = "";
	string* maze = new string[height*3];
	for (int y = 0; y < height*3;y++)
	{
		maze[y] = "";

		// populate the string
		for (int x = 0; x < width * 3;x++)
			maze[y] += "#";

		maze[y] += "\n";
	}

	clearVisited(root);
	buildCell(*root, maze);

	// append the lines into one string
	for (int y = 0; y < height * 3; y++)
		mazeDsp += maze[y];

	delete[] maze;
	maze = 0;

	return mazeDsp;
}
        std::vector<double> CHeatFlowBalance::calcBalanceMatrix()
        {
            auto aSolidLayers = m_IGU.getSolidLayers();
            m_MatrixA.setZeros();
            std::fill(m_VectorB.begin(), m_VectorB.end(), 0);
			for ( size_t i = 0; i < aSolidLayers.size(); ++i ) {
				buildCell(*aSolidLayers[i], i);
			}
            return FenestrationCommon::CLinearSolver::solveSystem(m_MatrixA, m_VectorB);
        }
void Maze::buildCell(MazeNode & node, string * maze)
{
	// calc the center
	int xCenter = (node.getXpos() * 3) + 1;
	int yCenter = (node.getYpos() * 3) + 1;

	// set the current node as visited
	node.setVisited();

	// clear the center or set it as traped
	int trapProb = rand()%100;
	maze[yCenter][xCenter] = trapProb < trapChance ? 'T' : ' ';

	// draw the cell
	for (int index = 0; index < node.getNumOfConnections(); index++)
	{
		// check if there is a wall or not
		if (node.getNode(index) != 0)
		{
			int xOffset = 0;
			int yOffset = 0;

			// find the correct wall and open it
			switch (index)
			{
			case MazeNode::North:
				yOffset = -1;
				break;
			case MazeNode::East:
				xOffset = 1;
				break;
			case MazeNode::South:
				yOffset = 1;
				break;
			case MazeNode::West:
				xOffset = -1;
				break;
			}

			maze[yCenter + yOffset][xCenter + xOffset] = ' ';

			// move to the next cell
			if(!node.getNode(index)->isVisited())
				buildCell(*node.getNode(index), maze);
		}
	}
}
Beispiel #4
0
void build(table* table) {
    int col = table->matrix->col;
    int row = table->matrix->row;
    int i,j;
    
    table_cell *cellTemp;
    _processing = table;
    
    for (i = 1; i<=row; i++) {
        for (j = 1; j<=col; j++) {
            cellTemp = getCell(table,i,j);
            if (cellTemp != NULL) {
                buildCell(cellTemp);
            }
        }
    }
}