Example #1
0
void World::menuChoice(int n) {
    BuildingBlock *bb = getSelectedBuildingBlock();

	switch (n) {
	case 1 : {
		OUTPUT << "ADD block link to : " << bb->blockId << "     num Face : " << numSelectedFace << endl;
		vector<Cell3DPosition> nCells = lattice->getRelativeConnectivity(bb->position);
		Cell3DPosition nPos = bb->position + nCells[numSelectedFace];

		addBlock(0, bb->buildNewBlockCode, nPos, bb->color);
		linkBlock(nPos);
		linkNeighbors(nPos);
	} break;
	case 2 : {
		OUTPUT << "DEL num block : " << tabGlBlocks[numSelectedGlBlock]->blockId << endl;
		deleteBlock(bb);
	} break;
	case 3 : {
		tapBlock(getScheduler()->now(), bb->blockId, numSelectedFace);
	} break;
	case 4:                 // Save current configuration
		exportConfiguration();
		break;
	}
}
Example #2
0
void World::connectBlock(BuildingBlock *block) {
    Cell3DPosition pos = block->position;
    OUTPUT << "Connect Block " << block->blockId << " pos = " << pos << endl;
    lattice->insert(block, pos);
    linkBlock(pos);
    linkNeighbors(pos);
}
Example #3
0
void World::linkNeighbors(const Cell3DPosition &pos) {
	vector<Cell3DPosition> nCells = lattice->getActiveNeighborCells(pos);

	// Check neighbors for each interface
	for (Cell3DPosition nPos : nCells) {
		linkBlock(nPos);
	}
}
Example #4
0
static void linkAllBlocks()
{
    auto e = gBlockMap.end();
    auto i = gBlockMap.begin();
    while(i!=e) {

        Block *block = (i++)->second;
        linkBlock(block);
    }
}
Example #5
0
void World::linkBlocks() {
	Cell3DPosition p;

	for (p.pt[2] = 0; p[2] < lattice->gridSize[2]; p.pt[2]++) { // z
		for (p.pt[1] = 0; p[1] < lattice->gridSize[1]; p.pt[1]++) { // y
			for(p.pt[0] = 0; p[0] < lattice->gridSize[0]; p.pt[0]++) { // x
				if (lattice->cellHasBlock(p)) {
					// cerr << "l.cellHasBlock(" << p << "/" << lattice->getIndex(p) << ")  = true ; id: "
					//	 << lattice->getBlock(p)->blockId << endl;
					linkBlock(p);
				}
			}
		}
	}
}