Index: GTP/trunk/Lib/Vis/Preprocessing/src/run_test2
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2634)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2635)
@@ -4,5 +4,5 @@
 
 #COMMAND="./release/preprocessor.exe -preprocessor_quit_on_finish+"
-COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish- -preprocessor_use_gl_renderer+ -preprocessor_evaluate_filter- -samples_per_evaluation=5000000 -samples_per_pass=500000 -total_samples=20000000 -mutation_use_pass_importance- -mutation_silhouette_search_steps=3 -preprocessor_ray_cast_method=2 -preprocessor_detect_empty_viewspace-"
+COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish- -preprocessor_use_gl_renderer+ -preprocessor_evaluate_filter- -samples_per_evaluation=5000000 -samples_per_pass=1000000 -total_samples=20000000 -mutation_use_pass_importance- -mutation_silhouette_search_steps=3 -preprocessor_ray_cast_method=1 -preprocessor_detect_empty_viewspace+"
 
 #SCENE="../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d"
@@ -29,12 +29,12 @@
 #VIEWCELLS=../data/test1/test-viewcells.xml
 
-SCENE=../data/Arena/arena-high-lods.obj
-VIEWCELLS=../data/Arena/arena-high-lods-5000-viewcells.xml.gz
+#SCENE=../data/Arena/arena-high-lods.obj
+#VIEWCELLS=../data/Arena/arena-high-lods-5000-viewcells.xml.gz
 #VIEWCELLS=../data/Arena/viewcells-5000.xml.gz
 #VIEWCELLS=../data/Arena/arena-high-lods-57000-viewcells.xml.gz
 
 
-#SCENE=../data/vienna/vienna_cropped.obj
-#VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz
+SCENE=../data/vienna/vienna_cropped.obj
+VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz
 
 #VIEWCELLS=../data/vienna/vienna-sequential-30000-single-viewcell.xml
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ObjectPvs.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ObjectPvs.cpp	(revision 2606)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ObjectPvs.cpp	(revision 2635)
@@ -10,4 +10,6 @@
 #include "BvHierarchy.h"
 
+// $$ switched off by JB for testing
+#define USE_MULTIPLE_OBJECTS  0
 using namespace std;
 
@@ -38,5 +40,5 @@
 			{
 				KdLeaf *leaf = static_cast<KdLeaf *>(node);
-                       
+#if USE_MULTIPLE_OBJECTS				
 				// add #objects exclusivly in this node
 				pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size());
@@ -56,7 +58,25 @@
 					}
 				}
+#else
+
+				// Objects already accounted for can only be found among those
+				// which are referenced in more than one leaf
+				ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end();
+				
+				for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit)
+				  {
+					Intersectable *object = *oit;						
+					
+					if (!object->Mailed())
+					  {
+						object->Mail();
+						++ pvs;
+					  }
+				  }
+				
+#endif
 			}
 			else // traverse tree
-			{
+			  {
 				KdInterior *interior = static_cast<KdInterior *>(node);
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2634)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2635)
@@ -152,9 +152,11 @@
 	if (!evaluateFilter) 
 	  pvs = viewcell->GetPvs();
-	else 
+	else {
+
 	  mViewCellsManager->ApplyFilter2(viewcell,
 									  false,
 									  mViewCellsManager->GetFilterWidth(),
 									  pvs);
+	}
 
 	mUseForcedColors = true;
@@ -516,5 +518,5 @@
 				//mMutex.lock();
 				// mSpatialFilter size is in range 0.001 - 0.1
-				mViewCellsManager->ApplyFilter2(viewcell,
+			  mViewCellsManager->ApplyFilter2(viewcell,
 					                            mUseFilter,
 					                            100.0f * mSpatialFilterSize,
Index: GTP/trunk/Lib/Vis/Preprocessing/src/default.env
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 2629)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 2635)
@@ -558,7 +558,7 @@
   #rayCastMethod 1
   # Havran - 2 - static scene
-  rayCastMethod 2
+  # rayCastMethod 2
   # Havran - 3 - dynamic scene
-  rayCastMethod 3
+  # rayCastMethod 3
 
   loadMeshes false
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp	(revision 2130)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp	(revision 2635)
@@ -141,5 +141,4 @@
 		if (vssRays[j]->mFlags & VssRay::Valid) {
 		  Intersectable *obj = vssRays[j]->mTerminationObject;
-		  
 		  if (obj) {
 			// if ray not outside of view space
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2634)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2635)
@@ -3206,6 +3206,8 @@
 							   )
 {
-	pvs.Reserve(viewCell->GetFilteredPvsSize());
-
+
+  
+  pvs.Reserve(viewCell->GetFilteredPvsSize());
+	
 	PvsFilterStatistics stats;
 
@@ -3369,6 +3371,6 @@
 			// $$ warning collect objects takes only unmailed ones!
 			if (mUseKdPvs) {
-			  GetPreprocessor()->mKdTree->CollectKdObjects(box, objects);
-			  //GetPreprocessor()->mKdTree->CollectSmallKdObjects(box, objects, 0.02f);
+			  //			  GetPreprocessor()->mKdTree->CollectKdObjects(box, objects);
+			  GetPreprocessor()->mKdTree->CollectSmallKdObjects(box, objects, 0.02f);
 
 			} else
@@ -3407,4 +3409,8 @@
 	viewCell->SetFilteredPvsSize(pvs.GetSize());
 
+	//	cout<<"pvsCost="<<basePvs.EvalPvsCost()<<endl;
+	//	cout<<"fPvsCost="<<pvs.EvalPvsCost()<<endl;
+
+	
 	// warning: not thread-safe!
 	if (!mUseKdPvs)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.cpp	(revision 2629)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.cpp	(revision 2635)
@@ -243,5 +243,5 @@
 #endif
 
-#if 0
+#if 1
   // This is shooting ray by ray
   SimpleRayContainer::const_iterator sit, sit_end = rays.end();
Index: GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 2629)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 2635)
@@ -9,4 +9,6 @@
 namespace GtpVisibilityPreprocessor {
 
+
+#define DEBUG_PROCESS_RAY 0
 
 #define DEBUG_RAYCAST 0
@@ -412,4 +414,7 @@
 	{
 	  if (!hitA.mObject && !hitB.mObject) {
+#if DEBUG_PROCESS_RAY
+		cout<<"I1 ";
+#endif
 		return 0;
 	  }
@@ -419,4 +424,7 @@
 	// rays whic degenerate to a point
 	if (EpsilonEqualV3(hitA.mPoint, hitB.mPoint, Limits::Small)) {
+#if DEBUG_PROCESS_RAY
+		cout<<"I2 ";
+#endif
 	  return 0;
 	}
@@ -435,5 +443,9 @@
 	  if (0 || pruneInvalidRays)
 		return 0;
-	  
+
+#if DEBUG_PROCESS_RAY
+		cout<<"I2 ";
+#endif
+
 	  // reset both contributions of this ray
 	  hitA.mObject = NULL;
@@ -459,6 +471,11 @@
 							  hitB.mPoint,
 							  clipA,
-							  clipB))
+							  clipB)) {
+#if DEBUG_PROCESS_RAY
+		cout<<"I3 ";
+#endif
+
 		return 0;
+	  }
 
 	  if (!pruneInvalidRays || hitA.mObject) {
Index: GTP/trunk/Lib/Vis/Preprocessing/src/PvsDefinitions.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/PvsDefinitions.h	(revision 2634)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/PvsDefinitions.h	(revision 2635)
@@ -9,5 +9,5 @@
 //$$ 19.1. 2008 test for speed
 //#define USE_BIT_PVS
-#define USE_HASH_PVS
+//#define USE_HASH_PVS
 
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Camera.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Camera.cpp	(revision 2629)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Camera.cpp	(revision 2635)
@@ -18,4 +18,5 @@
 #include "RayCaster.h"
 #include "tgaimg.h"
+
 
 #ifdef USE_HAVRAN_RAYCASTER
