void GeometryGenerator::Execute(bool skipNonIntersectingBlocks)
		throw (GenerationError) {

	if (skipNonIntersectingBlocks) {
		throw GenerationErrorMessage(
				"Skip non intersecting blocks functionality currently not available. See ticket #651");
	}

	this->PreExecute();
	double bounds[6];
	this->ComputeBounds(bounds);
	Domain domain(this->OriginWorking, this->SiteCounts);

	GeometryWriter writer(this->OutputGeometryFile, domain.GetBlockSize(),
			domain.GetBlockCounts());

	for (BlockIterator blockIt = domain.begin(); blockIt != domain.end();
			++blockIt) {
		// Open the BlockStarted context of the writer; this will
		// deal with flushing the state to the file (or not, in the
		// case where there are no fluid sites).
		BlockWriter* blockWriterPtr = writer.StartNextBlock();
		Block& block = *blockIt;

		int side = 0; // represents whether the block is inside (-1) outside (+1) or undetermined (0)

		if (skipNonIntersectingBlocks) {
			side = this->BlockInsideOrOutsideSurface(block);
		} else { // don't use the optimisation -- check every site
			side = 0;
		}

		switch (side) {
		case 1:
			// Block is entirely outside the domain.
			// We don't have to do anything.
			break;
		case 0:
			// Block has some surface within it.
			for (SiteIterator siteIt = block.begin(); siteIt != block.end();
					++siteIt) {
				Site& site = **siteIt;
				this->ClassifySite(site);
				// here we should check site
				if (site.IsFluid) {
					blockWriterPtr->IncrementFluidSitesCount();
					WriteFluidSite(*blockWriterPtr, site);
				} else {
					WriteSolidSite(*blockWriterPtr, site);
				}

			}
			break;
		case -1:
			// Block is entirely inside the domain
			for (SiteIterator siteIt = block.begin(); siteIt != block.end();
					++siteIt) {
				Site& site = **siteIt;
				site.IsFluidKnown = true;
				site.IsFluid = true;
				site.CreateLinksVector();
				for (unsigned int link_index = 0;
						link_index < site.Links.size(); ++link_index) {
					site.Links[link_index].Type = geometry::CUT_NONE;
				}
				blockWriterPtr->IncrementFluidSitesCount();
				WriteFluidSite(*blockWriterPtr, site);
			}
			break;
		default:
			break;
		}
		blockWriterPtr->Finish();
		blockWriterPtr->Write(writer);
		delete blockWriterPtr;
	}
	writer.Close();
}