Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 1824)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 1843)
@@ -467,5 +467,5 @@
 								  const ViewCellContainer &viewCells) const;
 
-
+	void CompressViewCells();
 	/////////////////////////////
 	// static members
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 1825)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 1843)
@@ -2617,5 +2617,5 @@
 	RegisterOption("Hierarchy.Construction.maxRepairs",
 					optInt,
-					"hierarchy_construction_maxRepairs=",
+					"hierarchy_construction_max_repairs=",
 					"1000");
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 1830)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 1843)
@@ -292,4 +292,7 @@
 	void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects);
 
+	void CreateUniqueObjectIds();
+
+
 	float mInitialRenderCost;
 
@@ -530,4 +533,6 @@
 	float EvalFullMem() const;
 
+
+
 protected:
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1842)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1843)
@@ -45,4 +45,6 @@
 	return obj1->GetBox().SurfaceArea() < obj2->GetBox().SurfaceArea();
 }
+
+
 
 /***************************************************************/
@@ -2026,5 +2028,6 @@
 		
 		//-- export objects
-		ExportObjects(leaf, stream);
+		// tmp matt
+		if (0) ExportObjects(leaf, stream);
 		
 		stream << "\" />" << endl;
@@ -2538,4 +2541,28 @@
 
 
+void BvHierarchy::CreateUniqueObjectIds()
+{
+	stack<BvhNode *> nodeStack;
+	nodeStack.push(mRoot);
+
+	int currentId = 0;
+	while (!nodeStack.empty()) 
+	{
+		BvhNode *node = nodeStack.top();
+		nodeStack.pop();
+
+		node->SetId(currentId ++);
+
+		if (!node->IsLeaf()) 
+		{
+			BvhInterior *interior = (BvhInterior *)node;
+
+			nodeStack.push(interior->GetFront());
+			nodeStack.push(interior->GetBack());
+		}
+	}
+}
+
+
 void BvHierarchy::ApplyInitialSubdivision(SubdivisionCandidate *firstCandidate,
 										  vector<SubdivisionCandidate *> &candidateContainer)
@@ -2619,5 +2646,5 @@
 	const float areaLarge = largeObj->GetBox().SurfaceArea();
 
-	return areaLarge / (areaLarge - areaSmall + Limits::Small);
+	return areaSmall / (areaLarge - areaSmall + Limits::Small);
 }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1842)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1843)
@@ -562,12 +562,4 @@
 	disposeRays(postProcessSamples, outRays);
 
-		
-	// write view cells to disc
-	if (mExportViewCells)
-	{
-		char filename[100];
-		Environment::GetSingleton()->GetStringValue("ViewCells.filename", filename);
-		ExportViewCells(filename, mExportPvs, mPreprocessor->mObjects);
-	}
 
 	////////////////
@@ -610,4 +602,14 @@
 	// recalculate view cells
 	EvaluateViewCellsStats();
+
+	if (1) CompressViewCells();
+
+	// write view cells to disc
+	if (mExportViewCells)
+	{
+		char filename[100];
+		Environment::GetSingleton()->GetStringValue("ViewCells.filename", filename);
+		ExportViewCells(filename, mExportPvs, mPreprocessor->mObjects);
+	}
 
 	return numSamples;
@@ -1626,4 +1628,26 @@
 {
 	return viewCell->GetVolume();
+}
+
+
+void ViewCellsManager::CompressViewCells()
+{
+	////////////
+	//-- compression
+
+	if (ViewCellsTreeConstructed() && mCompressViewCells)
+	{
+		int pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot());
+		
+		cout << "number of entries before compress: " << pvsEntries << endl;
+		Debug << "number of entries before compress: " << pvsEntries << endl;
+
+		mViewCellsTree->SetViewCellsStorage(ViewCellsTree::COMPRESSED);
+
+		pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot());
+		
+		Debug << "number of entries after compress: " << pvsEntries << endl;
+		cout << "number of entries after compress: " << pvsEntries << endl;
+	}
 }
 
@@ -4582,22 +4606,6 @@
 	
 
-	////////////
-	//-- compression
-
-	if (ViewCellsTreeConstructed() && mCompressViewCells)
-	{
-		int pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot());
-		
-		cout << "number of entries before compress: " << pvsEntries << endl;
-		Debug << "number of entries before compress: " << pvsEntries << endl;
-
-		mViewCellsTree->SetViewCellsStorage(ViewCellsTree::COMPRESSED);
-
-		pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot());
-		
-		Debug << "number of entries after compress: " << pvsEntries << endl;
-		cout << "number of entries after compress: " << pvsEntries << endl;
-	}
-
+	if (0) CompressViewCells();
+	
 	// collapse sibling leaves that share the same view cell
 	if (0) mVspBspTree->CollapseTree();
@@ -5500,21 +5508,10 @@
 	
 
+	mHierarchyManager->CreateUniqueObjectIds();
+
 	///////////
 	//-- compression
 
-	if (ViewCellsTreeConstructed() && mCompressViewCells)
-	{
-		int pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot());
-		
-		cout << "number of entries before compress: " << pvsEntries << endl;
-		Debug << "number of entries before compress: " << pvsEntries << endl;
-
-		mViewCellsTree->SetViewCellsStorage(ViewCellsTree::COMPRESSED);
-
-		pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot());
-		
-		Debug << "number of entries after compress: " << pvsEntries << endl;
-		cout << "number of entries after compress: " << pvsEntries << endl;
-	}
+	if (0) CompressViewCells();
 
 	/////////////
@@ -5924,5 +5921,6 @@
 	stream << "<VisibilitySolution>" << endl;
 
-	if (exportPvs) 
+	// §§ tmp matt: for storage cost
+	if (0 && exportPvs) 
 	{
         ///////////////
@@ -6227,7 +6225,4 @@
 		evalStrats.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION);
 		evalStrats.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION);
-
-		Debug << "casting volume strategies" << endl;
-		cout << "casting volume strategies" << endl;
 	}
 	else
@@ -6238,7 +6233,4 @@
 		//evalStrats.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION);
 		//evalStrats.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION);
-
-		Debug << "casting surface strategies" << endl;
-		cout << "casting surface strategies" << endl;
 	}
 	
@@ -6247,4 +6239,9 @@
 		Debug << evalStrats[i] << " ";
 	Debug << endl;
+
+	cout << "casting eval strategies: ";
+	for (int i = 0; i < (int)evalStrats.size(); ++ i)
+		cout << evalStrats[i] << " ";
+	cout << endl;
 
 	while (castSamples < numSamples)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp	(revision 1764)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp	(revision 1843)
@@ -149,4 +149,6 @@
 
 		SetFilled();
+		// hack
+		if (1 || (leaf->mObjects.size() < 50000))
 		ExportGeometry(leaf->mObjects, true, box);
 	}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 1842)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 1843)
@@ -2392,5 +2392,5 @@
 
 		// hack: just output full pvs
-		if (obj->Type() == Intersectable::BVH_INTERSECTABLE)
+		if (0 && (obj->Type() == Intersectable::BVH_INTERSECTABLE))
 		{
 			ObjectContainer objects; 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1789)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1843)
@@ -627,4 +627,5 @@
 	float GetRenderCostIncrementially(BvhNode *node) const;
 
+	void CreateUniqueObjectIds();
 
 protected:
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1842)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1843)
@@ -2352,3 +2352,11 @@
 }
 
-}
+
+void HierarchyManager::CreateUniqueObjectIds()
+{
+	mBvHierarchy->CreateUniqueObjectIds();
+}
+
+
+
+}
