Index: /GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env	(revision 2064)
+++ /GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env	(revision 2065)
@@ -6,12 +6,14 @@
 Scene {
 #	filename ../data/vienna/vienna_cropped.obj
-	filename ../data/soda/soda5.dat
+	filename ../data/soda/soda5.obj
 }
 
 
 Preprocessor {
+samplesPerPass 3000000
 	useGlRenderer false
 	type vss
 	detectEmptyViewSpace true
+	#loadMeshes true
 	loadMeshes false
 	# internal raycaster
@@ -84,5 +86,5 @@
 		maxDepth 20
 		
-		maxCostRatio 1.5
+		maxCostRatio 2.5
 		ct_div_ci 0.5
 	}
@@ -92,4 +94,5 @@
 	splitBorder 0.01
 }
+
 
 MeshKdTree {
@@ -151,5 +154,5 @@
 	Visualization {
 		# how much samples we use for visualization
-		samples 0
+		samples 20000
 		exportRays true
 		exportGeometry true
@@ -184,5 +187,5 @@
 VspBspTree {
 	Construction {
-		samples 500000
+		samples 300000
 		epsilon 0.0000001
 		randomize false
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2053)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2065)
@@ -1313,4 +1313,6 @@
 	}
 
+	cout << "here5" << endl;
+
 	DeterminePvsObjects(vssRays);
 }
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp	(revision 2063)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp	(revision 2065)
@@ -406,5 +406,6 @@
 	else
 	{
-		while (totalSamples < mInitialSamples) {
+		while (totalSamples < mInitialSamples) 
+		{
 			int passContributingSamples = 0;
 			int passSampleContributions = 0;
@@ -477,14 +478,4 @@
 		ExportSamples(mVssRays);
 		cout << "finished\n" << endl;
-
-		/*VssRayContainer dummyRays;
-		LoadSamples(dummyRays, mObjects);
-		Debug << "rays " << (int)mVssRays.size() << " " << dummyRays.size() << endl;
-
-		for (int i = 0; i < (int)mVssRays.size(); ++ i)
-		{
-		Debug << mVssRays[i]->GetOrigin() << " " << mVssRays[i]->GetTermination() << " " << mVssRays[i]->mOriginObject << " " << mVssRays[i]->mTerminationObject << endl;
-		Debug << dummyRays[i]->GetOrigin() << " " << dummyRays[i]->GetTermination() << " " << dummyRays[i]->mOriginObject << " " << dummyRays[i]->mTerminationObject << endl << endl;
-		}*/
 	}
 
@@ -519,5 +510,6 @@
 	// get viewcells as kd tree boxes
 	vector<AxisAlignedBox3> kdViewcells;
-	if (0) {
+	if (0) 
+	{
 		vector<KdLeaf *> leaves;
 		mKdTree->CollectLeaves(leaves);
@@ -541,10 +533,10 @@
 	while (samples < mVssSamples) 
 	{
-
 		int num = mVssSamplesPerPass;
 		SimpleRayContainer rays;
 		VssRayContainer vssRays;
 
-		if (!mUseImportanceSampling) {
+		if (!mUseImportanceSampling) 
+		{
 			for (int j=0; j < num; j++) {
 				Vector3 viewpoint; 
@@ -556,5 +548,7 @@
 							   );
 			}
-		} else {
+		} 
+		else 
+		{
 			num = GenerateImportanceRays(vssTree, num, rays);
 		}
@@ -563,5 +557,6 @@
 		vssTree->AddRays(vssRays);
 
-		if (0) {
+		if (0) 
+		{
 			int subdivided = vssTree->UpdateSubdivision();
 			cout<<"subdivided leafs = "<<subdivided<<endl;
@@ -584,5 +579,6 @@
 		}
 
-		samples+=num;
+		samples += num;
+
 		float pvs = vssTree->GetAvgPvsSize();
 		cout<<"*****************************\n";
@@ -627,4 +623,7 @@
 void VssPreprocessor::DeterminePvsObjects(VssRayContainer &rays)
 {
+	//Preprocessor::DeterminePvsObjects(rays);
+
+	cout << "here4";
 	mViewCellsManager->DeterminePvsObjects(rays, true);
 }
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 2048)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 2065)
@@ -740,5 +740,5 @@
 	{
 		cout << "bvh local termination criteria met:" << endl;
-		cout << "objects: " << (int)tData.mNode->mObjects.size() << " " << mTermMinObjects << endl;
+		cout << "objects: " << (int)tData.mNode->mObjects.size() << " (" << mTermMinObjects << ")" << endl;
 	}
 #endif
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2064)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2065)
@@ -742,4 +742,5 @@
 	vector<int>::const_iterator iit, iit_end = strategies.end();
 
+	cout << "===============================\n" << endl;
 	for (iit = strategies.begin(); iit != iit_end; ++ iit)
 	{
@@ -762,4 +763,5 @@
 		 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
 
+	cout << "===============================\n" << endl;
 	return (int)passSamples.size();
 }
@@ -1810,7 +1812,9 @@
 {
 
-	if ((vc->GetPvs().EvalPvsCost() > maxPvsSize) ||
-		(vc->GetPvs().EvalPvsCost() < minPvsSize))
-	{
+	const float pvsCost = vc->GetPvs().EvalPvsCost();
+
+	if ((pvsCost > maxPvsSize) || (pvsCost < minPvsSize))
+	{
+		cout << "err: " << pvsCost << " " << minPvsSize << " " << maxPvsSize << endl;
 		return false;
 	}
@@ -2687,14 +2691,17 @@
 									  const bool useHitObjects)
 {
-  if (!useHitObjects) {
-	VssRayContainer::const_iterator it, it_end = rays.end();
-	for (it = rays.begin(); it != it_end; ++ it) {
-	  VssRay *vssRay = *it;
-	  // set only the termination object
-	  vssRay->mTerminationObject = GetIntersectable(
-													*vssRay,
-													true);
-	}
-  }
+	if (!useHitObjects) 
+	{
+		VssRayContainer::const_iterator it, it_end = rays.end();
+        
+		for (it = rays.begin(); it != it_end; ++ it) 
+		{
+			VssRay *vssRay = *it;
+			// set only the termination object
+			vssRay->mTerminationObject = GetIntersectable(
+				*vssRay,
+				true);
+		}
+	}
 }
 
@@ -2756,5 +2763,5 @@
 
 	if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) {
-	  //	  cerr<<"ray outside view space box\n";
+	  // cerr<<"ray outside view space box\n";
 	  return 0;
 	}
@@ -2785,5 +2792,5 @@
 	if (storeViewCells)
 	{	
-	  cerr<<"Store viewcells should not be used in the test!"<<endl;
+	  // cerr << "Store viewcells should not be used in the test!" << endl;
 	  // copy viewcells memory efficiently
 #if VSS_STORE_VIEWCELLS
@@ -5320,4 +5327,5 @@
 		{
 			cout << "exporting view cells after post process ... ";
+
 			if (0)
 			{	// export view space box
@@ -6306,5 +6314,5 @@
 			if (!node->IsLeaf())
 			{
-				cout << "error, can only do leaves" << endl;
+				cout << "error, can only process leaves" << endl;
 				return 0;
 			}
@@ -6372,46 +6380,7 @@
 		const int savedColorCode = mColorCode;
 
-		const float maxRenderCost = UpdateObjectCosts();
+		const float maxRenderCost = -1;//UpdateObjectCosts();
 		cout << "maxRenderCost: " << maxRenderCost << endl;
 		mColorCode = 0; // 0 = random, 1 = export pvs
-
-		if (0)
-		mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, 
-													  CLAMP_TO_BOX ? &bbox : NULL, maxRenderCost, false);
-		
-
-		//ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, mColorCode, GetClipPlane());
-		ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane());
-
-		delete exporter;
-
-		cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl;
-		mColorCode = savedColorCode;
-	}
-
-	exporter = Exporter::GetExporter("final_object_partition.wrl");
-
-	if (exporter)
-	{
-		if (CLAMP_TO_BOX)
-		{	
-			exporter->mClampToBox = true; 	
-		}
-
-		EvaluateViewCellsStats();
-
-		const long starttime = GetTime();
-		cout << "exporting final objects (after initial construction + post process) ... ";
-
-		// matt: hack for clamping scene
-		AxisAlignedBox3 bbox = mViewSpaceBox;
-		bbox.Scale(scale);
-
-		// hack color code (show pvs size)
-		const int savedColorCode = mColorCode;
-
-		mColorCode = 1; // 0 = random, 1 = export pvs
-		// don't visualize render cost
-		const float maxRenderCost = -1;
 
 		if (1)
@@ -6420,7 +6389,51 @@
 		
 
-		//ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, mColorCode, GetClipPlane());
-		if (0)
+		if (1)
+		{
+			//ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, mColorCode, GetClipPlane());
 			ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane());
+		}
+
+		delete exporter;
+
+		cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl;
+		mColorCode = savedColorCode;
+	}
+
+	exporter = Exporter::GetExporter("final_object_partition.wrl");
+
+	if (exporter)
+	{
+		if (CLAMP_TO_BOX)
+		{	
+			exporter->mClampToBox = true; 	
+		}
+
+		EvaluateViewCellsStats();
+
+		const long starttime = GetTime();
+		cout << "exporting final objects (after initial construction + post process) ... ";
+
+		// matt: hack for clamping scene
+		AxisAlignedBox3 bbox = mViewSpaceBox;
+		bbox.Scale(scale);
+
+		// hack color code (show pvs size)
+		const int savedColorCode = mColorCode;
+
+		mColorCode = 1; // 0 = random, 1 = export pvs
+		// don't visualize render cost
+		const float maxRenderCost = -1;
+
+		if (1)
+		mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, 
+													  CLAMP_TO_BOX ? &bbox : NULL, maxRenderCost, false);
+		
+
+		if (1)
+		{
+			ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane());
+			//ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, mColorCode, GetClipPlane());
+		}
 
 		delete exporter;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp	(revision 2017)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp	(revision 2065)
@@ -150,5 +150,5 @@
 		SetFilled();
 		
-		if (0)
+		if (1)
 			ExportGeometry(leaf->mObjects, true, box);
 		else
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp	(revision 2017)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp	(revision 2065)
@@ -143,5 +143,6 @@
 	Intersectable::NewMail();
 	KdLeaf::NewMail();
-	BvhNode::NewMail();
+
+	cout << "here55 " << GetSize() << endl;
 
 	ObjectPvsEntries::const_iterator it, it_end = mEntries.end();
@@ -161,5 +162,5 @@
 				}
 			case Intersectable::BVH_INTERSECTABLE:
-				{
+				{cout<< "i";
 					BvhNode *bvhObj = static_cast<BvhNode *>(obj);
 					pvs += EvalBvhNodeContribution(bvhObj);
@@ -172,4 +173,5 @@
 	}
 
+	cout << "here44 " << pvs << endl;
 	return pvs;
 }
