Index: GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 1842)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 1845)
@@ -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/Preprocessor2.exe"
+				OutputFile="../bin/release/Preprocessor.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 1843)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 1845)
@@ -467,5 +467,6 @@
 								  const ViewCellContainer &viewCells) const;
 
-	void CompressViewCells();
+	virtual void CompressViewCells();
+
 	/////////////////////////////
 	// static members
@@ -1163,4 +1164,6 @@
 	void CollectViewCells();
 
+	virtual void CompressViewCells();
+
 	/** Prepare view cells for use after loading them from disc.
 	*/
@@ -1183,6 +1186,7 @@
 	/////////////////////////////////////////
 
-    /** collect objects intersecting a given spatial box */
-  virtual void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects);
+    /** collect objects intersecting a given spatial box 
+	*/
+	virtual void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects);
 
 	HierarchyManager *mHierarchyManager;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 1844)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 1845)
@@ -292,5 +292,5 @@
 	void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects);
 
-	void CompressObjectSpace();
+	int CompressObjectSpace();
 	void CreateUniqueObjectIds();
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h	(revision 1844)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h	(revision 1845)
@@ -1028,7 +1028,7 @@
 					AxisAlignedBox3 *forcedBoundingBox);
 
-	void CompressObjects();
-
-	void CompressObjects(VspLeaf *leaf);
+	int CompressObjects();
+
+	int CompressObjects(VspLeaf *leaf);
 
 protected:
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1843)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1845)
@@ -4605,5 +4605,4 @@
  	cout << ss << endl;
 	
-
 	if (0) CompressViewCells();
 	
@@ -6162,4 +6161,27 @@
 
 
+void VspOspViewCellsManager::CompressViewCells()
+{
+	ViewCellsManager::CompressViewCells();
+	return;
+	////////////
+	//-- compression
+
+	if (ViewCellsTreeConstructed() && mCompressViewCells)
+	{
+		int pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot());
+		
+		cout << "compressing in the objects" << endl;
+		cout << "number of entries before compress: " << pvsEntries << endl;
+		Debug << "number of entries before compress: " << pvsEntries << endl;
+
+		pvsEntries = mHierarchyManager->CompressObjectSpace();
+		
+		Debug << "number of entries after compress: " << pvsEntries << endl;
+		cout << "number of entries after compress: " << pvsEntries << endl;
+	}
+}
+
+
 ViewCellsManager *VspOspViewCellsManager::LoadViewCells(const string &filename, 
 														ObjectContainer *objects,
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h	(revision 1844)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h	(revision 1845)
@@ -889,5 +889,5 @@
 			Intersectable *obj = entry.mObject;
 
-			cout << (int)obj << " ";
+			cout << obj << " ";
 		}
 		
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1844)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1845)
@@ -3389,12 +3389,12 @@
 
 
-void VspTree::CompressObjects(VspLeaf *leaf)
+int VspTree::CompressObjects(VspLeaf *leaf)
 {
 	bool compressed = true;
 
-	Intersectable::NewMail(2);
-
 	while (compressed)
 	{
+		BvhNode::NewMail(2);
+
 		ObjectPvsIterator oit = leaf->GetViewCell()->GetPvs().GetIterator();
 		vector<BvhNode *> parents;
@@ -3414,4 +3414,6 @@
 				if (!parent->Mailed())
 				{
+					if (parent->Mailed(1))
+						cout << "error!!" << endl;
 					parent->Mail();
 				}
@@ -3422,4 +3424,5 @@
 					parents.push_back(parent);
 					parent->Mail(1);
+		
 					compressed = true;
 				}
@@ -3439,5 +3442,5 @@
 
 				// add only entries that cannot be exchaned with the parent
-				if (parent->Mailed(1))
+				if (!parent->Mailed(1))
 				{
 					newPvs.AddSampleDirty(obj, entry.mData.mSumPdf);
@@ -3448,4 +3451,5 @@
 		// add parents
 		vector<BvhNode *>::const_iterator bit, bit_end = parents.end();
+
 		for (bit = parents.begin(); bit != bit_end; ++ bit)
 		{
@@ -3453,21 +3457,28 @@
 		}
 
+		//cout << "size " << newPvs.GetSize() << endl;
 		leaf->GetViewCell()->SetPvs(newPvs);
 	}
-}
-
-
-void VspTree::CompressObjects()
+
+	return leaf->GetViewCell()->GetPvs().GetSize();
+}
+
+
+int VspTree::CompressObjects()
 {
 	vector<VspLeaf *> leaves;
 	CollectLeaves(leaves);
 
+	int numEntries = 0;
+
 	vector<VspLeaf *>::const_iterator lit, lit_end = leaves.end();
 
 	for (lit = leaves.begin(); lit != lit_end; ++ lit)
 	{
-		CompressObjects(*lit);
-	}
-}
-
-}
+		numEntries += CompressObjects(*lit);
+	}
+
+	return numEntries;
+}
+
+}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1844)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1845)
@@ -2354,8 +2354,10 @@
 
 
-void HierarchyManager::CompressObjectSpace()
+int HierarchyManager::CompressObjectSpace()
 {
 	//mBvHierarchy->Compress();
-	mVspTree->CompressObjects();
+	return mVspTree->CompressObjects();
+}
+
 
 void HierarchyManager::CreateUniqueObjectIds()
