Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1584)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1586)
@@ -911,8 +911,11 @@
 		cout << "compute new statistics ... " << endl;
 	
+		///////////////7
 		//-- propagate pvs or pvs size information
+
 		ObjectPvs pvs;
 		UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs);
 
+		///////////
 		//-- output stats
 		sprintf(str, "-%09d-eval.log", castSamples);
@@ -1128,12 +1131,15 @@
 									   ) const
 {
-  if (!vc->IsLeaf() && vc->GetMergeCost() < 0.0f) {
-	ViewCellInterior *vci = (ViewCellInterior *) vc;
-	ViewCellContainer::const_iterator it, it_end = vci->mChildren.end();
-	
-	for (it = vci->mChildren.begin(); it != it_end; ++ it)
-	  DeleteLocalMergeTree(*it);
-	vci->mChildren.clear();
-	delete vci;
+	if (!vc->IsLeaf() && vc->GetMergeCost() < 0.0f) 
+	{	
+		ViewCellInterior *vci = (ViewCellInterior *) vc;
+		ViewCellContainer::const_iterator it, it_end = vci->mChildren.end();
+
+        for (it = vci->mChildren.begin(); it != it_end; ++ it)
+			DeleteLocalMergeTree(*it);
+		
+		vci->mChildren.clear();
+		
+		delete vci;
   }
 }
@@ -1489,5 +1495,5 @@
 	//-- extrude new vertices for top of prism
 
-	Vector3 triNorm = baseTri.GetNormal();
+	const Vector3 triNorm = baseTri.GetNormal();
 	Triangle3 topTri;
 
@@ -2236,5 +2242,5 @@
   	if (viewSpaceFilterSize >= 0.0f) {
 
-  bool usePrVS = false;
+  const bool usePrVS = false;
 
   if (!usePrVS) {
@@ -2351,13 +2357,13 @@
 
 	// $$ warning collect objects takes only unmailed ones!
-	kdTree->CollectObjects(box,
-						   objects);
+	kdTree->CollectObjects(box, objects);
 	//	cout<<"collected objects="<<objects.size()<<endl;
 	ObjectContainer::const_iterator noi = objects.begin();
-	for (; noi != objects.end(); ++noi) {
-	  Intersectable *o = *noi;
-	  // $$ JB warning: pdfs are not correct at this point!
-	  nPvs.AddSample(o, Limits::Small);
-	  nPvsSize++;
+	for (; noi != objects.end(); ++ noi) 
+	{
+		Intersectable *o = *noi;
+		// $$ JB warning: pdfs are not correct at this point!	  
+		nPvs.AddSample(o, Limits::Small);
+		nPvsSize ++;
 	}
   }
@@ -2455,5 +2461,7 @@
 	}
 	
-	//-- interior node => propagate pvs up
+	////////////////
+	//-- interior node => propagate pvs up the tree
+
 	ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root);
 	interior->GetPvs().Clear();
@@ -2467,5 +2475,7 @@
 		ObjectPvs objPvs;
 		
+		//////////////////
 		//-- recursivly compute child pvss
+
 		UpdatePvsForEvaluation(*vit, objPvs);
 
@@ -2478,7 +2488,8 @@
 
 	//-- faster way of computing pvs:
-	//   construct merged pvs by adding 
-	//   and only those of the next pvs which were not mailed.
-	//   note: sumpdf is not correct!!
+	//-- construct merged pvs by adding
+	//-- and only those of the next pvs which were not mailed.
+	//-- note: sumpdf is not correct!!
+
 	vector<ObjectPvs>::iterator oit = pvsList.begin();
 
@@ -2508,6 +2519,6 @@
 	UpdateScalarPvsSize(interior, pvs.CountObjectsInPvs(), pvs.GetSize());
 	
-
-#else // really merge cells: slow put sumPdf is correct
+#else 
+	// really merge cells: slow put sumPdf is correct
 	viewCellInterior->GetPvs().Merge(backVc->GetPvs());
 	viewCellInterior->GetPvs().Merge(frontVc->GetPvs());
@@ -2561,4 +2572,5 @@
 
 	const float prop = (float)limit / ((float)rays.size() + Limits::Small);
+
 	for (it = rays.begin(); it != it_end; ++ it)
 	{
@@ -4046,16 +4058,16 @@
 	////////////
 	//-- compression
-
+//#if HAS_TO_BE_REDONE
 	if (ViewCellsTreeConstructed() && mCompressViewCells)
 	{
-		int pvsEntries = mViewCellsTree->GetStoredPvsEntriesNum(mViewCellsTree->GetRoot());
+		int pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot());
 		Debug << "number of entries before compress: " << pvsEntries << endl;
 
 		mViewCellsTree->SetViewCellsStorage(ViewCellsTree::COMPRESSED);
 
-		pvsEntries = mViewCellsTree->GetStoredPvsEntriesNum(mViewCellsTree->GetRoot());
+		pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot());
 		Debug << "number of entries after compress: " << pvsEntries << endl;
 	}
-
+//#endif
 
 	// collapse sibling leaves that share the same view cell
@@ -4919,17 +4931,19 @@
 	
 
-	///////////////
+	///////////
 	//-- compression
 
+//#if HAS_TO_BE_REDONE
 	if (ViewCellsTreeConstructed() && mCompressViewCells)
 	{
-		int pvsEntries = mViewCellsTree->GetStoredPvsEntriesNum(mViewCellsTree->GetRoot());
+		int pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot());
 		Debug << "number of entries before compress: " << pvsEntries << endl;
 
 		mViewCellsTree->SetViewCellsStorage(ViewCellsTree::COMPRESSED);
 
-		pvsEntries = mViewCellsTree->GetStoredPvsEntriesNum(mViewCellsTree->GetRoot());
+		pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot());
 		Debug << "number of entries after compress: " << pvsEntries << endl;
 	}
+//#endif
 
 	/////////////
