Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 1589)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 1614)
@@ -225,4 +225,6 @@
 	} 
 
+	void ExportBoundingBoxes(OUT_STREAM &stream, const ObjectContainer &objects);
+
 
 protected:
@@ -333,4 +335,5 @@
 		const VssRayContainer &rays, 
 		const ObjectContainer &objects);
+
 
 protected:
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1610)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1614)
@@ -115,4 +115,12 @@
 }
 
+void BvhLeaf::CollectObjects(ObjectContainer &objects)
+{
+	ObjectContainer::const_iterator oit, oit_end = objects.end();
+	for (oit = objects.begin(); oit != oit_end; ++ oit)
+	{
+		objects.push_back(*oit);
+	}
+}
 
 /******************************************************************/
@@ -161,4 +169,10 @@
 }
 
+
+void BvhInterior::CollectObjects(ObjectContainer &objects)
+{
+	mFront->CollectObjects(objects);
+	mBack->CollectObjects(objects);
+}
 
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1613)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1614)
@@ -660,5 +660,21 @@
 		//-- export bounding boxes
 		stream << "<BoundingBoxes>" << endl;
-		ObjectContainer::const_iterator oit, oit_end = objects.end();
+#if USE_KD_PVS 
+	KdIntersectableMap::const_iterator kit, kit_end = GetPreprocessor()->mKdTree->mKdIntersectables.end();
+
+		int id = 0;
+		for (kit = GetPreprocessor()->mKdTree->mKdIntersectables.begin(); kit != kit_end; ++ kit, ++ id)
+		{
+			Intersectable *obj = (*kit).second;
+			const AxisAlignedBox3 box = obj->GetBox();
+		
+			obj->SetId(id);
+
+			stream << "<BoundingBox" << " id=\"" << id << "\""
+				   << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\""
+				   << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl;
+		}
+#else
+	ObjectContainer::const_iterator oit, oit_end = objects.end();
 
 		for (oit = objects.begin(); oit != oit_end; ++ oit)
@@ -672,5 +688,5 @@
 				   << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl;
 		}
-
+#endif
 		stream << "</BoundingBoxes>" << endl;
 	}
@@ -5339,18 +5355,5 @@
 		//-- The bounding boxes are used to identify 
 		//-- the objects in the rendering engine
-
-		stream << "<BoundingBoxes>" << endl;
-		ObjectContainer::const_iterator oit, oit_end = objects.end();
-        
-		for (oit = objects.begin(); oit != oit_end; ++ oit)
-		{
-			const AxisAlignedBox3 box = (*oit)->GetBox();
-			stream << "<BoundingBox" << " id=\"" << (*oit)->GetId() << "\""
-				<< " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\""
-				
-				<< " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl;
-		}
-		
-		stream << "</BoundingBoxes>" << endl;
+		mHierarchyManager->ExportBoundingBoxes(stream, objects);
 	}
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 1605)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 1614)
@@ -13,4 +13,6 @@
 #include "ViewCellsManager.h"
 #include "Exporter.h"
+#include "BvHierarchy.h"
+
 
 
@@ -2375,5 +2377,22 @@
 	for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it)
 	{
-		stream << (*it).first->GetId() << " ";
+		Intersectable *obj = (*it).first;
+		// hack: just output full pvs
+		if (obj->Type() == Intersectable::BVH_INTERSECTABLE)
+		{
+			ObjectContainer objects; 
+			BvhNode *node = dynamic_cast<BvhIntersectable *>(obj)->GetItem();
+			node->CollectObjects(objects);
+		
+			ObjectContainer::const_iterator oit, oit_end = objects.end();
+			for (oit = objects.begin(); oit != oit_end; ++ oit)
+			{
+				stream << (*oit)->GetId() << " ";
+			}
+		}
+		else
+		{
+			stream << (*it).first->GetId() << " ";
+		}
 	}
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1589)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1614)
@@ -182,4 +182,6 @@
 	void SetParent(BvhInterior *parent);
 
+	// collects all objects under this node
+	virtual void CollectObjects(ObjectContainer &objects) = 0;
 	/** The bounding box specifies the node extent.
 	*/
@@ -255,5 +257,5 @@
 		return s << A.mBoundingBox;
 	}
-
+virtual void CollectObjects(ObjectContainer &objects);
 protected:
 
@@ -291,5 +293,5 @@
 		mSubdivisionCandidate = candidate; 
 	}
-
+virtual void CollectObjects(ObjectContainer &objects);
 public:
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h	(revision 1613)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h	(revision 1614)
@@ -589,5 +589,5 @@
   AxisAlignedBox3 mBox;
   KdTreeStatistics mStat;
-
+public:
   /// stores the kd node intersectables used for pvs
   KdIntersectableMap mKdIntersectables;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1610)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1614)
@@ -1103,3 +1103,42 @@
 }
 
-}
+
+void HierarchyManager::ExportBoundingBoxes(OUT_STREAM &stream, const ObjectContainer &objects)
+{
+	stream << "<BoundingBoxes>" << endl;
+	    
+	if (mObjectSpaceSubdivisionType == KD_BASED_OBJ_SUBDIV)
+	{
+		KdIntersectableMap::const_iterator kit, kit_end = mOspTree->mKdIntersectables.end();
+
+		int id = 0;
+		for (kit = mOspTree->mKdIntersectables.begin(); kit != kit_end; ++ kit, ++ id)
+		{
+			Intersectable *obj = (*kit).second;
+			const AxisAlignedBox3 box = obj->GetBox();
+		
+			obj->SetId(id);
+
+			stream << "<BoundingBox" << " id=\"" << id << "\""
+				   << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\""
+				   << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl;
+		}
+	}
+	else
+	{
+		ObjectContainer::const_iterator oit, oit_end = objects.end();
+
+		for (oit = objects.begin(); oit != oit_end; ++ oit)
+		{
+			const AxisAlignedBox3 box = (*oit)->GetBox();
+		
+			stream << "<BoundingBox" << " id=\"" << (*oit)->GetId() << "\""
+				   << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\""
+				   << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl;
+		}
+	}
+		
+	stream << "</BoundingBoxes>" << endl;
+}
+
+}
