Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 1740)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 1741)
@@ -1723,4 +1723,5 @@
 	{
 		root = root->GetParent();
+		cout << "h";
 		pvs.MergeInPlace(root->GetPvs());
 	}
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h	(revision 1740)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h	(revision 1741)
@@ -22,4 +22,6 @@
 {
 public:
+
+	PvsEntry() {}
 
 	PvsEntry(T sample, const S &data): mObject(sample), mData(data) {}
@@ -371,27 +373,113 @@
 	std::vector<PvsEntry<T, S> >::const_iterator ait = a.mEntries.begin(), ait_end = a.mEntries.end();
 	std::vector<PvsEntry<T, S> >::const_iterator bit = b.mEntries.begin(), bit_end = b.mEntries.end();
-
-	while (1)
-	{
-		for (; (ait != ait_end) && ((*ait).mObject < (*bit).mObject); ++ ait)
+	Intersectable::NewMail();
+	cout << "a: " << a.mEntries.size() << " b " << b.mEntries.size() << endl;
+	
+	for (; (ait != ait_end); ++ ait)
+	{
+		Intersectable *aObj = (*ait).mObject;
+		Intersectable *bObj = NULL;
+		PvsEntry<T, S> aEntry = (*ait);
+
+		for (; (bit != bit_end) && ((*bit).mObject <= (*ait).mObject); ++ bit)
 		{
-			if ((*ait).mObject != (*bit).mObject)
-				mergedPvs.mEntries.push_back(*ait);
-		}
-
-		for (; (bit != bit_end) && ((ait == ait_end) || ((*bit).mObject <= (*bit).mObject)); ++ bit)
-		{
-			if ((*ait).mObject == (*bit).mObject)
+			bObj = (*bit).mObject;
+
+			// object found => add up probabilities
+			if (bObj != aEntry.mObject)
 			{
-				PvsData newData((*ait).mData.mSumPdf + (*bit).mData.mSumPdf);
-				PvsEntry<T, S> entry((*ait).mObject, newData);
+				PvsData newData(aEntry.mData.mSumPdf + (*bit).mData.mSumPdf);
+				PvsEntry<T, S> entry(bObj, newData);
 				mergedPvs.mEntries.push_back(entry);
+				if (bObj->Mailed())
+					cout << "Error2 " << bObj << endl;
+				bObj->Mail();
+				cout << "e: " << (int)bObj;
 			}
 			else
 			{
+				if (bObj->Mailed())
+					cout << "Error3 " << bObj << endl;
+				bObj->Mail();
 				mergedPvs.mEntries.push_back(*bit);
+				cout << "e: " << (int)bObj;
 			}
 		}
-	}
+
+		// only push back if objects different 
+		// (equal case is handled by second loop)
+		if (aObj != bObj)
+		{
+			mergedPvs.mEntries.push_back(*ait);
+			if (aObj->Mailed())
+				cout << "Error1 " << aObj << endl;
+			aObj->Mail();
+			cout << "e: " << (int)aObj;
+		}
+	}
+
+	// add the rest
+	for (; (bit != bit_end); ++ bit)
+	{
+		Intersectable *bObj = (*bit).mObject;
+		
+		mergedPvs.mEntries.push_back(*bit);
+		if (bObj->Mailed())
+			cout << "Error4 " << bObj << endl;
+		bObj->Mail();
+		cout << "e: " << (int)bObj;
+	}
+
+/*
+	while ((ait != ait_end) || (bit != bit_end))
+	{cout << "x";
+
+		// first iterate through first vector until we find the objects
+		for (; (ait != ait_end) && ((bit == bit_end) || ((*ait).mObject <= (*bit).mObject)); ++ ait)
+		{
+			Intersectable *obj = (*ait).mObject;
+			aEntry = (*ait);
+			//bObject = (bit != bit_end) ? (*bit).mObject : NULL;
+
+			// only push back if objects different 
+			// (equal case is handled by second loop)
+			if (obj != bEntry.mObject)
+			{
+				mergedPvs.mEntries.push_back(*ait);
+				if (obj->Mailed())
+					cout << "Error1 " << obj << endl;
+				obj->Mail();
+				cout << "e: " << obj;
+			}
+		}
+
+		// iterate through second pvs
+		for (; (bit != bit_end) && ((ait == ait_end) || ((*bit).mObject <= (*ait).mObject)); ++ bit)
+		{
+			Intersectable *obj = (*bit).mObject;
+			bEntry = (*bit);
+			//aObject = (ait != ait_end) ? (*ait).mObject : NULL;
+
+			// object found => add up probabilities
+			if (obj != aEntry.mObject)
+			{
+				PvsData newData(aEntry.mData.mSumPdf + bEntry.mData.mSumPdf);
+				PvsEntry<T, S> entry(obj, newData);
+				mergedPvs.mEntries.push_back(entry);
+				if (obj->Mailed())
+					cout << "Error2 " << obj << endl;
+				obj->Mail();
+				cout << "e: " << obj;
+			}
+			else
+			{
+				if (obj->Mailed())
+					cout << "Error3 " << obj << endl;
+				obj->Mail();
+				mergedPvs.mEntries.push_back(*bit);
+				cout << "e: " << obj;
+			}
+		}
+	}*/
 }
 
@@ -457,5 +545,5 @@
 		S &data = (*it).mData;
 		data.mSumPdf += pdf;
-
+cout << "w";
 		return data.mSumPdf;
 	}
@@ -463,5 +551,5 @@
 	{
 		PvsEntry<T, S> entry(sample, pdf);
-		
+		cout << "i";
 		mEntries.insert(it, entry);
 		return pdf;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1740)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1741)
@@ -1943,14 +1943,15 @@
 			//subStats.mEntriesInPvs += entriesIncr;
 
-			// if (rcDecr <= 0)
 			if (nextCandidate->Type() == SubdivisionCandidate::VIEW_SPACE)
 			{
 				++ subStats.mViewSpaceSplits;
-				cout << "v";//cout << "vsp t: " << timeStamp << " rc: " << rcDecr << " pvs: " << entriesIncr << endl;
+				cout << "v";
+				//cout << "vsp t: " << timeStamp << " rc: " << rcDecr << " pvs: " << entriesIncr << endl;
 			}
 			else
 			{
 				++ subStats.mObjectSpaceSplits;
-				cout << "o";//"osp t: " << timeStamp << " rc: " << rcDecr << " pvs: " << entriesIncr << endl;
+				cout << "o";
+				//"osp t: " << timeStamp << " rc: " << rcDecr << " pvs: " << entriesIncr << endl;
 			}
 
@@ -1974,5 +1975,5 @@
 
 
-void HierarchyManager::EvaluateSubdivision(const VssRayContainer &sampleRays,											 							   
+void HierarchyManager::EvaluateSubdivision(const VssRayContainer &sampleRays,
 										   const ObjectContainer &objects,
 										   const string &filename)
