Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 955)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 979)
@@ -462,4 +462,5 @@
 	AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint, const float width) const;
 
+
 protected:
 	/** Exports bounding boxes as xml stream
@@ -552,4 +553,5 @@
 
 
+	////////////////////////////////////////////////
 
 	/// if bounding boxes should also be exported
@@ -846,4 +848,6 @@
 
 	virtual void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) {};
+
+
 protected:
 
@@ -960,7 +964,12 @@
 
 
-	// HACK
+	/// HACK for testing visibility filter functionality
 	void TestFilter(const ObjectContainer &objects);
 
+
+	/** Visualization of the pvs difference to exact visubility using 
+		from point queries.
+	*/
+	void VisualizeWithFromPointQueries();
 
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 975)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 979)
@@ -16,5 +16,5 @@
 #include "RssPreprocessor.h"
 #include "BoundingBoxConverter.h"
-
+#include "GlRenderer.h"
 
 
@@ -631,4 +631,119 @@
 
 
+
+ViewCellsManager *ViewCellsManager::LoadViewCells(const string &filename, 
+												  ObjectContainer *objects,
+												  Environment *env,
+												  const bool finalizeViewCells,
+												  BoundingBoxConverter *bconverter)
+												 
+{
+	ViewCellsParser parser;
+
+	ViewCellsManager *vm = NULL;
+
+	if (parser.ParseFile(filename, &vm, objects, bconverter, env))
+	{
+		long startTime = GetTime();
+
+		//vm->PrepareLoadedViewCells();
+		vm->ResetViewCells();
+
+		vm->mViewCellsFinished = true;
+		vm->mMaxPvsSize = (int)objects->size();
+
+		// create the meshes and compute volumes
+		if (finalizeViewCells)
+		{
+			vm->FinalizeViewCells(true);
+			vm->mViewCellsTree->AssignRandomColors();
+		}
+
+		Debug << (int)vm->mViewCells.size() << " view cells loaded in "
+			  << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
+	}
+	else
+	{
+		Debug << "Error: loading view cells failed!" << endl;
+		DEL_PTR(vm);
+	}
+
+	return vm;
+}
+
+
+bool VspBspViewCellsManager::ExportViewCells(const string filename, 
+											 const bool exportPvs, 
+											 const ObjectContainer &objects)
+{
+	cout << "exporting view cells to xml ... ";
+	
+#if ZIPPED_VIEWCELLS
+	ogzstream stream(filename.c_str());
+	cout << "!!!!!!!!!!!!!!!!!!!!!!" << endl;
+#else
+	std::ofstream stream(filename.c_str());
+#endif
+
+	// for output we need unique ids for each view cell
+	CreateUniqueViewCellIds();
+
+	stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl;
+	stream << "<VisibilitySolution>" << endl;
+
+	//-- the view space bounding box
+	stream << "<ViewSpaceBox" 
+		   << " min=\"" << mViewSpaceBox.Min().x << " " << mViewSpaceBox.Min().y << " " << mViewSpaceBox.Min().z << "\""
+		   << " max=\"" << mViewSpaceBox.Max().x << " " << mViewSpaceBox.Max().y << " " << mViewSpaceBox.Max().z << "\" />" << endl;
+
+	
+	//-- export bounding boxes
+	stream << "<BoundingBoxes>" << endl;
+
+	ObjectContainer::const_iterator oit, oit_end = objects.end();
+
+	for (oit = objects.begin(); oit != oit_end; ++ oit)
+	{
+			MeshInstance *mi = dynamic_cast<MeshInstance *>(*oit);
+			const AxisAlignedBox3 box = mi->GetBox();
+
+			//-- the bounding boxes
+			stream << "<BoundingBox" << " id=\"" << mi->GetId() << "\""
+				   << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\""
+				   << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl;
+	}
+
+	stream << "</BoundingBoxes>" << endl;
+
+
+	//-- export the view cells and the pvs
+	stream << "<HierarchyType name=\"vspBspTree\" />" << endl;
+
+	const int numViewCells = mCurrentViewCellsStats.viewCells;
+
+	stream << "<ViewCells number=\"" << numViewCells << "\" >" << endl;
+	
+	mViewCellsTree->Export(stream, exportPvs);
+
+	stream << "</ViewCells>" << endl;
+
+
+	//-- export the spatial hierarchy
+	
+	// the type of the view cells hierarchy
+	stream << "<Hierarchy>" << endl;
+	mVspBspTree->Export(stream);
+	stream << endl << "</Hierarchy>" << endl;
+
+	stream << "</VisibilitySolution>" << endl;
+
+
+	stream.close();
+	cout << "finished" << endl;
+
+	return true;
+}
+
+
 void ViewCellsManager::EvalViewCellHistogramForPvsSize(const string filename, 
 													   const int nViewCells)
@@ -660,5 +775,6 @@
 	
 	if (!stepSize) stepSize = 1;
-Debug << "stepsize: " << stepSize << endl;
+	
+	Debug << "stepsize: " << stepSize << endl;
 	cout << "stepsize: " << stepSize << endl;
 
@@ -4589,4 +4705,35 @@
 
 
+void VspBspViewCellsManager::VisualizeWithFromPointQueries()
+{
+	int numSamples;
+	environment->GetIntValue("RenderSampler.samples", numSamples);
+	cout << "samples" << numSamples << endl;
+
+	vector<RenderCostSample> samples;
+  
+	if (!preprocessor->GetRenderer())
+		return;
+
+	// doing the query
+	long startTime = GetTime();
+	cout << "starting sampling of render cost ... ";
+	
+	preprocessor->GetRenderer()->SampleRenderCost(numSamples, samples);
+
+	cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
+
+
+	// counting the pvss
+	vector<RenderCostSample>::const_iterator rit, rit_end = samples.end();
+
+	for (rit = samples.begin(); rit != rit_end; ++ rit)
+	{
+		RenderCostSample sample = *rit;
+		//ViewCell *vc = GetViewCell(sample.)pos;
+	}
+}
+
+
 void VspBspViewCellsManager::ExportViewCellGeometry(Exporter *exporter,
                                                     ViewCell *vc,
@@ -4702,118 +4849,4 @@
 	// put mesh into mesh container so we can savely delete it
 	mMeshContainer.push_back(mesh);
-}
-
-
-ViewCellsManager *ViewCellsManager::LoadViewCells(const string &filename, 
-												  ObjectContainer *objects,
-												  Environment *env,
-												  const bool finalizeViewCells,
-												  BoundingBoxConverter *bconverter)
-												 
-{
-	ViewCellsParser parser;
-
-	ViewCellsManager *vm = NULL;
-
-	if (parser.ParseFile(filename, &vm, objects, bconverter, env))
-	{
-		long startTime = GetTime();
-
-		//vm->PrepareLoadedViewCells();
-		vm->ResetViewCells();
-
-		vm->mViewCellsFinished = true;
-		vm->mMaxPvsSize = (int)objects->size();
-
-		// create the meshes and compute volumes
-		if (finalizeViewCells)
-		{
-			vm->FinalizeViewCells(true);
-			vm->mViewCellsTree->AssignRandomColors();
-		}
-
-		Debug << (int)vm->mViewCells.size() << " view cells loaded in "
-			  << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
-	}
-	else
-	{
-		Debug << "Error: loading view cells failed!" << endl;
-		DEL_PTR(vm);
-	}
-
-	return vm;
-}
-
-
-bool VspBspViewCellsManager::ExportViewCells(const string filename, 
-											 const bool exportPvs, 
-											 const ObjectContainer &objects)
-{
-	cout << "exporting view cells to xml ... ";
-	
-#if ZIPPED_VIEWCELLS
-	ogzstream stream(filename.c_str());
-	cout << "!!!!!!!!!!!!!!!!!!!!!!" << endl;
-#else
-	std::ofstream stream(filename.c_str());
-#endif
-
-	// for output we need unique ids for each view cell
-	CreateUniqueViewCellIds();
-
-	stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl;
-	stream << "<VisibilitySolution>" << endl;
-
-	//-- the view space bounding box
-	stream << "<ViewSpaceBox" 
-		   << " min=\"" << mViewSpaceBox.Min().x << " " << mViewSpaceBox.Min().y << " " << mViewSpaceBox.Min().z << "\""
-		   << " max=\"" << mViewSpaceBox.Max().x << " " << mViewSpaceBox.Max().y << " " << mViewSpaceBox.Max().z << "\" />" << endl;
-
-	
-	//-- export bounding boxes
-	stream << "<BoundingBoxes>" << endl;
-
-	ObjectContainer::const_iterator oit, oit_end = objects.end();
-
-	for (oit = objects.begin(); oit != oit_end; ++ oit)
-	{
-			MeshInstance *mi = dynamic_cast<MeshInstance *>(*oit);
-			const AxisAlignedBox3 box = mi->GetBox();
-
-			//-- the bounding boxes
-			stream << "<BoundingBox" << " id=\"" << mi->GetId() << "\""
-				   << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\""
-				   << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl;
-	}
-
-	stream << "</BoundingBoxes>" << endl;
-
-
-	//-- export the view cells and the pvs
-	stream << "<HierarchyType name=\"vspBspTree\" />" << endl;
-
-	const int numViewCells = mCurrentViewCellsStats.viewCells;
-
-	stream << "<ViewCells number=\"" << numViewCells << "\" >" << endl;
-	
-	mViewCellsTree->Export(stream, exportPvs);
-
-	stream << "</ViewCells>" << endl;
-
-
-	//-- export the spatial hierarchy
-	
-	// the type of the view cells hierarchy
-	stream << "<Hierarchy>" << endl;
-	mVspBspTree->Export(stream);
-	stream << endl << "</Hierarchy>" << endl;
-
-	stream << "</VisibilitySolution>" << endl;
-
-
-	stream.close();
-	cout << "finished" << endl;
-
-	return true;
 }
 
