Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp	(revision 1121)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp	(revision 1122)
@@ -2826,7 +2826,6 @@
 	SplitObjects(splitPlane, leaf->mObjects, front->mObjects, back->mObjects);
 
-	ProcessLeafObjects(back, leaf);
-    ProcessLeafObjects(front, leaf);
-  
+	ProcessLeafObjects(leaf, front, back);
+    
 	backData.mNode = back;
 	frontData.mNode = front;
@@ -3408,14 +3407,15 @@
 
 
-void OspTree::ProcessLeafObjects(KdLeaf *leaf, KdLeaf *parent) const
-{
-	ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end();
-
-	for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit)
-	{
-		Intersectable *object = *oit;
-
-		if (parent)
-		{
+void OspTree::ProcessLeafObjects(KdLeaf *parent, KdLeaf *front, KdLeaf *back) const
+{
+	if (parent)
+	{
+		// remove the parents from the set
+		ObjectContainer::const_iterator oit, oit_end = parent->mObjects.end();
+
+		for (oit = parent->mObjects.begin(); oit != oit_end; ++ oit)
+		{
+			Intersectable *object = *oit;
+
 			set<KdLeaf *>::iterator kdit = object->mKdLeaves.find(parent);
 
@@ -3424,10 +3424,62 @@
 				object->mKdLeaves.erase(kdit);
 		}
-
-		object->mKdLeaves.insert(leaf);
-
-		if (object->mKdLeaves.size() > 1)
-			leaf->mMultipleObjects.push_back(object);
-	}
+	}
+
+	//Intersectable::NewMail();
+
+	if (front)
+	{
+		// Add front to leaf kd cells
+		ObjectContainer::const_iterator oit, oit_end = front->mObjects.end();
+
+		for (oit = front->mObjects.begin(); oit != oit_end; ++ oit)
+		{
+			Intersectable *object = *oit;
+			object->mKdLeaves.insert(front);
+		}
+	}
+
+	if (back)
+	{
+		// Add back to leaf kd cells
+		ObjectContainer::const_iterator oit, oit_end = back->mObjects.end();
+
+		for (oit = back->mObjects.begin(); oit != oit_end; ++ oit)
+		{
+			Intersectable *object = *oit;
+			object->mKdLeaves.insert(back);	
+		}
+	}
+
+	// note: can find out about multiple objects only now after adding and deleting
+	// finished 
+	if (front)
+	{
+		// find objects from multiple kd-leaves
+		ObjectContainer::const_iterator oit, oit_end = front->mObjects.end();
+
+		for (oit = front->mObjects.begin(); oit != oit_end; ++ oit)
+		{
+			Intersectable *object = *oit;
+
+			if (object->mKdLeaves.size() > 1)
+				front->mMultipleObjects.push_back(object);
+		}
+	}
+
+	if (back) 
+	{
+		// find objects from multiple kd-leaves
+		ObjectContainer::const_iterator oit, oit_end = back->mObjects.end();
+
+		for (oit = back->mObjects.begin(); oit != oit_end; ++ oit)
+		{
+			Intersectable *object = *oit;
+
+			if (object->mKdLeaves.size() > 1)
+				back->mMultipleObjects.push_back(object);
+		}
+	}
+	
 }
 
@@ -3702,5 +3754,5 @@
 
 		
-	mOspTree.ProcessLeafObjects(kdleaf, NULL);
+	mOspTree.ProcessLeafObjects(NULL, kdleaf, NULL);
 
 	// compute first split candidate
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1121)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1122)
@@ -2695,6 +2695,6 @@
 	}
 	
-	// only for debugging: test valitidy
-	TestSubdivision();
+	// only for debugging purpose: test if the subdivision is valid
+	if (0) TestSubdivision();
 
 	mColorCode = savedColorCode;
@@ -3946,5 +3946,5 @@
 
 	// only for debugging purpose: test if the subdivision is valid
-	TestSubdivision();
+	if (0) TestSubdivision();
 
 	//-- refines the merged view cells
@@ -4901,6 +4901,6 @@
 	long startTime;
 
-	mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox);
-
+	//mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox);
+	mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox);
 	
 	//-- stats
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h	(revision 1121)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h	(revision 1122)
@@ -1439,5 +1439,7 @@
 					  ObjectContainer &back);
 
-	void ProcessLeafObjects(KdLeaf *leaf, KdLeaf *parent) const;
+	 /** does some post processing on the objects in the new child leaves.
+	 */
+	void ProcessLeafObjects(KdLeaf *parent, KdLeaf *front, KdLeaf *back) const;
 
 	/** Selects an axis aligned for the next split.
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp	(revision 1108)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp	(revision 1122)
@@ -91,6 +91,4 @@
 	mBox.Include((*mi)->GetBox());
   }
-
-	ProcessLeafObjects(NULL, leaf, NULL);
 
   cout <<"KdTree Root Box:"<<mBox<<endl;
@@ -307,7 +305,4 @@
     mStat.objectRefs += objectsBack + objectsFront;
   }
-  
-   ProcessLeafObjects(leaf, front, back);
-  
 
   delete leaf;
@@ -1094,81 +1089,3 @@
 
 
-void KdTree::ProcessLeafObjects(KdLeaf *parent, KdLeaf *front, KdLeaf *back) const
-{
-	if (parent)
-	{
-		// remove the parents from the set
-		ObjectContainer::const_iterator oit, oit_end = parent->mObjects.end();
-
-		for (oit = parent->mObjects.begin(); oit != oit_end; ++ oit)
-		{
-			Intersectable *object = *oit;
-
-			set<KdLeaf *>::iterator kdit = object->mKdLeaves.find(parent);
-
-			// remove parent leaf
-			if (kdit != object->mKdLeaves.end())
-				object->mKdLeaves.erase(kdit);
-		}
-	}
-
-	//Intersectable::NewMail();
-
-	if (front)
-	{
-		// Add front to leaf kd cells
-		ObjectContainer::const_iterator oit, oit_end = front->mObjects.end();
-
-		for (oit = front->mObjects.begin(); oit != oit_end; ++ oit)
-		{
-			Intersectable *object = *oit;
-			object->mKdLeaves.insert(front);
-		}
-	}
-
-	if (back)
-	{
-		// Add back to leaf kd cells
-		ObjectContainer::const_iterator oit, oit_end = back->mObjects.end();
-
-		for (oit = back->mObjects.begin(); oit != oit_end; ++ oit)
-		{
-			Intersectable *object = *oit;
-			object->mKdLeaves.insert(back);	
-		}
-	}
-
-	// note: can find out about multiple objects only now after adding and deleting
-	// finished 
-	if (front)
-	{
-		// find objects from multiple kd-leaves
-		ObjectContainer::const_iterator oit, oit_end = front->mObjects.end();
-
-		for (oit = front->mObjects.begin(); oit != oit_end; ++ oit)
-		{
-			Intersectable *object = *oit;
-
-			if (object->mKdLeaves.size() > 1)
-				front->mMultipleObjects.push_back(object);
-		}
-	}
-
-	if (back) 
-	{
-		// find objects from multiple kd-leaves
-		ObjectContainer::const_iterator oit, oit_end = back->mObjects.end();
-
-		for (oit = back->mObjects.begin(); oit != oit_end; ++ oit)
-		{
-			Intersectable *object = *oit;
-
-			if (object->mKdLeaves.size() > 1)
-				back->mMultipleObjects.push_back(object);
-		}
-	}
-	
-}
-
-
-}
+}
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h	(revision 1121)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h	(revision 1122)
@@ -541,8 +541,4 @@
 
 
-  /** does some post processing on the objects in the new child leaves.
-  */
-  void ProcessLeafObjects(KdLeaf *parent, KdLeaf *front, KdLeaf *back) const;
-
   int mTermMaxNodes;
   float mSplitBorder;
