Index: GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 1912)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 1917)
@@ -206,5 +206,5 @@
 				Name="VCLinkerTool"
 				AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib Preprocessor.lib RTScene.lib RTWorld.lib QtCore4.lib qtmain.lib QtOpenGL4.lib Qt3Support4.lib QtTest4.lib QtGui4.lib QtGlRenderer.lib"
-				OutputFile="../bin/release/Preprocessor2.exe"
+				OutputFile="../bin/release/Preprocessor.exe"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\src\GL;..\lib\release;..\..\Preprocessing\lib\release;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\MultiLevelRayTracing\RTScene\Release;..\MultiLevelRayTracing\RTWorld\Release;&quot;$(QTDIR)\lib&quot;;.\QtGlRenderer\Release"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1900)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1917)
@@ -1212,13 +1212,11 @@
 }
 
-void
-Preprocessor::EvalViewCellHistogram()
-{
-  char filename[256];
-  Environment::GetSingleton()->GetStringValue("Preprocessor.histogram.file",
-											  filename);
+void Preprocessor::EvalViewCellHistogram()
+{
+	char filename[256];
+	Environment::GetSingleton()->GetStringValue("Preprocessor.histogram.file", filename);
   
-  // mViewCellsManager->EvalViewCellHistogram(filename, 1000000);
-  mViewCellsManager->EvalViewCellHistogramForPvsSize(filename, 1000000);
+	// mViewCellsManager->EvalViewCellHistogram(filename, 1000000);
+	mViewCellsManager->EvalViewCellHistogramForPvsSize(filename, 1000000);
 }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1916)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1917)
@@ -638,13 +638,14 @@
 	// high avg ray contri, the result is influenced by undersampling
 	splitCandidate.SetAvgRayContribution(avgRayContri);
-
-	const float oldVolume = EvalViewCellsVolume(leaf->mObjects) / GetViewSpaceVolume();
-	const float oldRatio = tData.mVolume > 0 ? oldVolume / tData.mVolume : 1;
+	const float viewSpaceVol =  GetViewSpaceVolume();
+
+	const float oldVolume = EvalViewCellsVolume(leaf->mObjects) / viewSpaceVol;
+	const float oldRatio = (tData.mVolume) > 0 ? oldVolume / tData.mVolume : 1;
 	const float parentVol = tData.mCorrectedVolume * oldRatio;
 
 	// this leaf is a pvs entry in all the view cells
 	// that see one of the objects.
-	const float frontVol = EvalViewCellsVolume(splitCandidate.mFrontObjects) / GetViewSpaceVolume();
-	const float backVol = EvalViewCellsVolume(splitCandidate.mBackObjects) / GetViewSpaceVolume();
+	const float frontVol = EvalViewCellsVolume(splitCandidate.mFrontObjects) / viewSpaceVol;
+	const float backVol = EvalViewCellsVolume(splitCandidate.mBackObjects) / viewSpaceVol;
 
 	splitCandidate.mCorrectedFrontVolume = 
@@ -670,7 +671,8 @@
 	splitCandidate.SetPvsEntriesIncr(pvsEntriesIncr);
 
+	if (0)
 	cout << "bvh volume cost"
 		 << " avg ray contri: " << avgRayContri << " ratio: " << oldRatio 
-		 << " parent: " << parentVol << " " << " old vol: " << oldVolume 
+		 << " parent: " << parentVol << " old vol: " << oldVolume 
 		 << " frontvol: " << frontVol << " corr. " << splitCandidate.mCorrectedFrontVolume 
 		 << " backvol: " << backVol << " corr. " << splitCandidate.mCorrectedBackVolume << endl;
@@ -707,4 +709,5 @@
 		mHierarchyManager->EvalCorrectedPvs((float)backViewCells, parentPvs, avgRayContri);
 
+	if (0)
 	cout << "bvh pvs"
 		 << " avg ray contri: " << avgRayContri << " ratio: " << oldPvsRatio 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1916)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1917)
@@ -706,5 +706,6 @@
 	int smallerCostSum = 0;
 	
-	// note can skip computations for view cells already evaluated and delete them from vector ...
+	// note can skip computations for view cells already 
+	// evaluated and delete them from vector ...
     while (1)
 	{
@@ -746,5 +747,4 @@
 
 
-
 ViewCellsManager *ViewCellsManager::LoadViewCells(const string &filename, 
 												  ObjectContainer *objects,
@@ -904,9 +904,11 @@
 	viewCells = mViewCells;
 #endif
-	ViewCellContainer::iterator it = viewCells.begin(),
-	  it_end = viewCells.end();		
-	for (; it != it_end; ++it) {
-	  //(*it)->UpdatePvsCost();
-	  (*it)->SetPvsCost((float)(*it)->GetFilteredPvsSize());
+	ViewCellContainer::iterator it = viewCells.begin(), it_end = viewCells.end();		
+	for (; it != it_end; ++it) 
+	{
+		if (1)
+			(*it)->UpdatePvsCost();
+		else
+			(*it)->SetPvsCost((float)(*it)->GetFilteredPvsSize());
 	}
 
@@ -921,6 +923,5 @@
 	// hack: normalize pvs size
 	int histoMaxVal;
-	Environment::GetSingleton()->GetIntValue(
-											 "Preprocessor.histogram.maxValue", histoMaxVal);
+	Environment::GetSingleton()->GetIntValue("Preprocessor.histogram.maxValue", histoMaxVal);
 	maxVal = max((float)histoMaxVal, maxPvs);
 		
@@ -938,6 +939,9 @@
 	if (!stepSize) stepSize = 1;
 	
+	Debug << "intervals " << histoIntervals << endl;
 	Debug << "stepsize: " << stepSize << endl;
-	
+	cout << "intervals " << histoIntervals << endl;
+	cout << "stepsize: " << stepSize << endl;
+
 	const float totalRenderCost = mViewCellsTree->GetRoot()->GetRenderCost();
 	const float totalVol = GetViewSpaceBox().GetVolume();
@@ -987,5 +991,4 @@
 
 	outstream.close();
-
 }
 
@@ -6044,5 +6047,5 @@
 
 	// mix of sampling strategies
-	mStrategies.push_back(SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION);
+	evalStrats.push_back(SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION);
 
 	//evalStrats.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION);
@@ -6168,9 +6171,52 @@
 		disposeRays(evaluationSamples, NULL);
 	}
-	
-}
+
+	////////////
+	//-- histogram
+
+	const int numLeaves = mViewCellsTree->GetNumInitialViewCells(mViewCellsTree->GetRoot());
+	bool useHisto;
+	int histoStepSize;
+
+	Environment::GetSingleton()->GetBoolValue("ViewCells.Evaluation.histogram", useHisto);
+	Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.histoStepSize", histoStepSize);
+
+	if (useHisto)
+	{
+		// evaluate view cells in a histogram		
+		char s[64];
+
+		// hack: just show final view cells
+		int pass = (int)mViewCells.size();
+		//for (int pass = histoStepSize; pass <= numLeaves; pass += histoStepSize)
+		if (1)
+		{
+			string filename;
+
+			cout << "computing histogram for " << pass << " view cells" << endl;
+#if 0
+			//-- evaluate histogram for render cost
+			sprintf(s, "-%09d-histo.log", pass);
+			filename = string(statsPrefix) + string(s);
+
+			EvalViewCellHistogram(filename, pass);
+
 #endif
-
-
-
-}
+			//////////////////////////////////////////
+            //-- evaluate histogram for pvs size
+
+			cout << "computing pvs histogram for " << pass << " view cells" << endl;
+
+			sprintf(s, "-%09d-histo-pvs.log", pass);
+			filename = string(statsPrefix) + string(s);
+
+			EvalViewCellHistogramForPvsSize(filename, pass);
+		}
+	}
+}
+
+#endif
+
+
+
+}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1916)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1917)
@@ -908,5 +908,5 @@
 											splitCandidate.GetAvgRayContribution());
 	
-	
+	if (0)
 	cout << "vsp pvs"
 		 << " avg ray contri: " << splitCandidate.GetAvgRayContribution() << " ratio: " << oldPvsRatio 
@@ -1621,4 +1621,5 @@
 	const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol;
 
+	if (0)
 	cout << "vsp render cost"
 		 << " avg ray contri: " << avgRayContri << " ratio: " << oldRenderCostRatio
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1916)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1917)
@@ -747,5 +747,5 @@
 	}
 	// assume pvs not sampled sufficiently => take total pvs
-	if (avgRayContri > mMaxAvgRayContri)
+	if (avgRayContri >= mMaxAvgRayContri)
 	{
 		return totalPvs;
