Index: GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 1751)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 1760)
@@ -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/Preprocessor.exe"
+				OutputFile="../bin/release/Preprocessor2.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/ViewCellsManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 1743)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 1760)
@@ -611,6 +611,7 @@
 	void ExportViewCellsForViz(Exporter *exporter, 
 							   const AxisAlignedBox3 *box,
-							   const AxisAlignedPlane *clipPlane = NULL,
-							   const bool colorCode = 0) const;
+							   const bool colorCode,
+							   const AxisAlignedPlane *clipPlane
+							   ) const;
 
 	/** Sets exporter color.
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1758)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1760)
@@ -274,5 +274,5 @@
 	//mMemoryConst = (float)(sizeof(VspLeaf) + sizeof(VspViewCell));
 	//mMemoryConst = (float)sizeof(BvhLeaf);
-	mMemoryConst = (float)sizeof(ObjectContainer);
+	mMemoryConst = 16;//(float)sizeof(ObjectContainer);
 
     mUseBboxAreaForSah = true;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1758)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1760)
@@ -42,6 +42,6 @@
 // HACK
 const static bool SAMPLE_AFTER_SUBDIVISION = true;
-//const static bool CLAMP_TO_BOX = false;
-const static bool CLAMP_TO_BOX = true;
+const static bool CLAMP_TO_BOX = false;
+//const static bool CLAMP_TO_BOX = true;
 
 
@@ -484,5 +484,5 @@
 
 			exporter->SetWireframe();
-			ExportViewCellsForViz(exporter, NULL, GetClipPlane());
+			ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane());
 
 			delete exporter;
@@ -534,5 +534,4 @@
 	}
 
-	
 	if (0)
 	{
@@ -1562,4 +1561,5 @@
 		mViewCellsTree->UpdateViewCellsStats(*it, mCurrentViewCellsStats);
 	}
+	cout << "here44 " << mCurrentViewCellsStats.maxPvs << endl;
 }
 
@@ -2194,14 +2194,14 @@
 void ViewCellsManager::ExportViewCellsForViz(Exporter *exporter,
 											 const AxisAlignedBox3 *sceneBox,
-											 const AxisAlignedPlane *clipPlane,
-											 const bool colorCode
+											 const bool colorCode,
+											 const AxisAlignedPlane *clipPlane
 											 ) const
 {
 	ViewCellContainer::const_iterator it, it_end = mViewCells.end();
-
+cout << "here2" << endl;
 	for (it = mViewCells.begin(); it != it_end; ++ it)
-	{
+	{cout << "here4 " << mOnlyValidViewCells << " " << (*it)->GetValid() <<  endl;
 		if (!mOnlyValidViewCells || (*it)->GetValid())
-		{
+		{cout << "here5 " << mColorCode << endl;
 			ExportColor(exporter, *it, colorCode);	
 			ExportViewCellGeometry(exporter, *it, sceneBox, clipPlane);
@@ -2732,5 +2732,5 @@
 	float importance = 0;
 	static Material m;
-
+	//cout << "color code: " << colorCode << endl;
 	switch (mColorCode)
 	{
@@ -2755,7 +2755,10 @@
 		
 	case 1: // pvs
-		{
+		{ //cout << "here22 " << mCurrentViewCellsStats.maxPvs << endl;
 			if (mCurrentViewCellsStats.maxPvs)
 			{
+				//cout << "pvscost : " << (float)mViewCellsTree->GetPvsCost(vc) << endl;
+				//cout << "maxPvs : " << (float)mCurrentViewCellsStats.maxPvs << endl;
+
 				importance = 
 					(float)mViewCellsTree->GetPvsCost(vc) / 
@@ -2780,4 +2783,5 @@
 #endif
 	default:
+		cout << "here10" << endl;
 		break;
 	}
@@ -3034,5 +3038,5 @@
 
 		exporter->SetFilled();
-		ExportViewCellsForViz(exporter, NULL, GetClipPlane());
+		ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane());
 
 		delete exporter;
@@ -3041,6 +3045,5 @@
 
 	// export merged view cells using pvs color coding
-	mColorCode = 1;
-
+	
 	exporter = Exporter::GetExporter("merged_view_cells_pvs.wrl");
 	cout << "exporting view cells after merge (pvs size) ... ";	
@@ -3054,5 +3057,7 @@
 
 		exporter->SetFilled();
-		ExportViewCellsForViz(exporter, NULL, GetClipPlane());
+		mColorCode = 1;
+cout << "here49 " << mColorCode << endl;
+		ExportViewCellsForViz(exporter, NULL,  mColorCode, GetClipPlane());
 
 		delete exporter;
@@ -3144,5 +3149,5 @@
 
 	//  visualization of the view cells
-	if (1) ExportMergedViewCells(objects);
+	if (0) ExportMergedViewCells(objects);
 
 	// compute final meshes and volume / area
@@ -3186,5 +3191,5 @@
 			}
 
-			ExportViewCellsForViz(exporter, NULL, GetClipPlane());
+			ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane());
 			delete exporter;
 		}
@@ -4237,5 +4242,5 @@
 				exporter->SetFilled();
 
-			ExportViewCellsForViz(exporter, NULL, GetClipPlane());
+			ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane());
 
 			if (mExportGeometry)
@@ -4266,5 +4271,5 @@
 			exporter->SetFilled();
 
-			ExportViewCellsForViz(exporter, NULL, GetClipPlane());
+			ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane());
 
 			if (mExportGeometry)
@@ -4535,5 +4540,5 @@
 				exporter->ExportRays(visRays, RgbColor(1, 0, 0));
 			}
-			ExportViewCellsForViz(exporter, NULL, GetClipPlane());
+			ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane());
 
 			delete exporter;
@@ -5491,9 +5496,10 @@
 		}
 
-		mHierarchyManager->ExportObjectSpaceHierarchy(exporter, 
-				objects, CLAMP_TO_BOX ? &bbox : NULL, false);
-		ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, GetClipPlane());
+		mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, 
+													  CLAMP_TO_BOX ? &bbox : NULL, false);
+		ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, mColorCode, GetClipPlane());
 
 		delete exporter;
+
 		cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl;
 		mColorCode = savedColorCode;
@@ -5517,8 +5523,13 @@
 		cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl;
 	}
-
-	
-	//  visualization of the view cells
-	if (0) ExportMergedViewCells(objects);
+	
+	cout << "here92 " << mHierarchyManager->GetVspTree()->GetStatistics().maxPvs << endl;
+
+	// visualization of the view cells
+    if (1) 
+	{	
+		EvaluateViewCellsStats();
+		ExportMergedViewCells(objects);
+	}
 
 	// export some view cell
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1749)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1760)
@@ -473,5 +473,5 @@
 
 	//mMemoryConst = (float)(sizeof(VspLeaf) + sizeof(ObjectPvs));
-	mMemoryConst = (float)sizeof(ObjectPvs);
+	mMemoryConst = 16;//(float)sizeof(ObjectPvs);
 	cout << "vsp memcost: " << mMemoryConst << endl;
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 1723)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 1760)
@@ -251,14 +251,4 @@
 		Cleanup();
 		exit(1);
-	}
-
-	if (0){
-	Exporter *exporter= Exporter::GetExporter("test1.wrl");
-	AxisAlignedBox3 bbox = preprocessor->mViewCellsManager->GetViewSpaceBox(); 
-    exporter->SetWireframe();
-	exporter->ExportBox(bbox);
-	exporter->SetFilled();
-	exporter->ExportGeometry(preprocessor->mObjects, true);
-	delete exporter;
 	}
 	
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1758)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1760)
@@ -2170,5 +2170,5 @@
 		
 		const float objectSpaceHierarchyMem = float(
-											  subStats.mObjectSpaceSplits * sizeof(ObjectContainer)
+											  subStats.mObjectSpaceSplits * mBvHierarchy->mMemoryConst//sizeof(ObjectContainer)
 											  //+ (subStats.mObjectSpaceSplits - 1) * sizeof(BvhInterior)
 											  //+sizeof(BvHierarchy)
@@ -2177,5 +2177,5 @@
 			
 		const float viewSpaceHierarchyMem = float(
-											subStats.mViewSpaceSplits * sizeof(ObjectPvs)
+											subStats.mViewSpaceSplits * mVspTree->mMemoryConst//sizeof(ObjectPvs)
 											//+ (subStats.mViewSpaceSplits - 1) * sizeof(VspInterior)
 											+ sizeof(ObjectPvs)
