Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 925)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 931)
@@ -96,5 +96,5 @@
 	void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup,
 		QueuedRenderableCollection::OrganisationMode om);
-	void loadVisibilityConfig(const String& filename);
+	
 	/** Override standard function so octree boxes are always of equal side length.
 		This has advantages for CHC, because terrain tiles are in different octree nodes
@@ -124,5 +124,5 @@
 	*/
 	void InitVisibilityCulling(Camera *cam);
-
+#if 0
 	/** Finds object corresponding to this bounding box in the scene.
 	*/
@@ -133,5 +133,5 @@
 	*/
 	void IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects);
-
+#endif
 	/** Loads / unloads pvs of the view cell to set the visibility in the scene.
 	*/
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj	(revision 925)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj	(revision 931)
@@ -180,4 +180,7 @@
 				Filter="h;hpp;hxx;hm;inl;inc">
 				<File
+					RelativePath="..\include\OgreBoundingBoxConverter.h">
+				</File>
+				<File
 					RelativePath="..\include\OgreMeshInstance.h">
 				</File>
@@ -216,4 +219,7 @@
 				Name="Source Files"
 				Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
+				<File
+					RelativePath="..\src\OgreBoundingBoxConverter.cpp">
+				</File>
 				<File
 					RelativePath="..\src\OgreMeshInstance.cpp">
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 925)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 931)
@@ -19,4 +19,5 @@
 #include "OgreMeshInstance.h"
 #include "common.h"
+#include "OgreBoundingBoxConverter.h"
 
 // normal terrain rendering
@@ -998,5 +999,5 @@
    else
    {
-	   SceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup, om);
+	   OctreeSceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup, om);
    }
 }
@@ -1013,109 +1014,4 @@
 	}
 }
-//-------------------------------------------------------------------------
-void OcclusionCullingSceneManager::loadVisibilityConfig(const String& filename)
-{
-	// TODO matt
-	// Set up the options
-	ConfigFile config;
-	String val;
-
-	config.load(filename);
-
-	val = config.getSetting("Algorithm");
-
-    if (!val.empty())
-	{
-		 VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).setOption("Algorithm", val.c_str());
-	}
-
-	val = config.getSetting("UseDepthPass");
-
-	if (!val.empty())
-	{
-		 setOption("UseDepthPass", val.c_str());
-	}
-}
-//-------------------------------------------------------------------------
-inline static AxisAlignedBox EnlargeBox(const AxisAlignedBox &box)
-{
-	const float eps = 1e-3f;
-	const Vector3 veps(eps, eps, eps);
-	Vector3 max = box.getMaximum();
-	Vector3 min = box.getMinimum();
-
-	return AxisAlignedBox(min - veps, max + veps);
-}
-//-----------------------------------------------------------------------
-Entity *OcclusionCullingSceneManager::FindCorrespondingObject(const AxisAlignedBox &box)
-{
-	list<SceneNode *> sceneNodeList;
-	AxisAlignedBox mybox = EnlargeBox(box);
-	//AxisAlignedBox dummy(Vector3(-50000, -50000, -50000), Vector3(50000, 50000, 50000));
-	
-	// get intersecting scene nodes
-	findNodesIn(mybox, sceneNodeList, NULL);
-	
-
-	list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end();
-
-	float overlap = 0;//GtpVisibilityPreprocessor::Limits::Small;
-
-	Entity *bestFittingObj = NULL;
-	float bestFit = overlap;
-
-	// perfect fit threshold
-	const float thresh = 1.0 - GtpVisibilityPreprocessor::Limits::Small;
-
-
-	// find the bbox which is closest to the current bbox
-	for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(); ++ sit)
-	{
-		SceneNode *sn = *sit;
-		SceneNode::ObjectIterator oit = sn->getAttachedObjectIterator();
-
-        while (oit.hasMoreElements())
-		{
-			MovableObject *mo = oit.getNext();
-
-			// we are only interested in scene entities
-			if (mo->getMovableType() != "Entity")
-			{
-				continue;
-			}
-			 
-			const AxisAlignedBox bbox = EnlargeBox(mo->getWorldBoundingBox());
-					
-
-			// compute measure how much aabbs overlap
-			overlap = RatioOfOverlap(OgreTypeConverter::ConvertFromOgre(mybox),
-									 OgreTypeConverter::ConvertFromOgre(bbox));
-	
-			 if (overlap > bestFit)
-			 {
-				 bestFit = overlap;
-			
-				 bestFittingObj = static_cast<Entity *>(mo);
-
-				 // perfect fit => object found, eraly exit
-				 if (overlap >= thresh)
-					 return bestFittingObj;				
-			 }
-		}
-	}
-
-	if (0)
-	{
-		std::stringstream d; 
-		if (bestFittingObj)
-			d << "best fit: " << bestFit;     
-		else
-			d << "warning, objects do not fit\n" << box;
-	
-		Ogre::LogManager::getSingleton().logMessage(d.str());
-	}
-
-	return bestFittingObj;
-}
 //-----------------------------------------------------------------------
 void OcclusionCullingSceneManager::LoadViewCells(string filename)
@@ -1124,38 +1020,16 @@
 	SetObjectsVisible(false);
 
-	// identify the corresponding Ogre meshes using the bounding boxes
-	IdentifyObjects(mObjects);
+	const string bboxesFilename = mVisibilityManager->GetVisibilityEnvironment()->getViewCellsFileName();
+
+	GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes;
+	OgreBoundingBoxConverter bconverter(this);
 
 	// load the view cells assigning the found objects to the pvss
 	mViewCellsManager = 
-		GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects);
+		GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, &bconverter);
 
 	std::stringstream d;
 	d << "view cells loaded" << endl;
 	Ogre::LogManager::getSingleton().logMessage(d.str());
-}
-//-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects)
-{
-	const string bboxesFilename = "boxes.out";
-
-	GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes;
-	mViewCellsManager->LoadBoundingBoxes(bboxesFilename, iboxes);
-
-	GtpVisibilityPreprocessor::IndexedBoundingBoxContainer::
-		const_iterator iit, iit_end = iboxes.end();
-
-	for (iit = iboxes.begin(); iit != iit_end; ++ iit)
-	{
-		  const GtpVisibilityPreprocessor::AxisAlignedBox3 box = (*iit).second;
-		  const AxisAlignedBox currentBox = OgreTypeConverter::ConvertToOgre(box);
-		 
-		  Entity *ent = FindCorrespondingObject(currentBox);
-
-		  // create new mesh instance
-		  OgreMeshInstance *omi = new OgreMeshInstance(ent);
-		  omi->SetId((*iit).first);
-		  objects.push_back(omi);
-	}
 }
 //-------------------------------------------------------------------------
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp	(revision 925)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp	(revision 931)
@@ -20,8 +20,8 @@
 //-----------------------------------------------------------------------
 void OcclusionQueriesQueryManager::ComputeCameraVisibility(const Camera &camera,
-			    GtpVisibility::NodeInfoContainer *visibleNodes,
-			    GtpVisibility::MeshInfoContainer *visibleGeometry,
-				GtpVisibility::PatchInfoContainer *visiblePatches,
-			    bool relativeVisibility)
+														   GtpVisibility::NodeInfoContainer *visibleNodes,
+														   GtpVisibility::MeshInfoContainer *visibleGeometry,
+														   GtpVisibility::PatchInfoContainer *visiblePatches,
+														   bool relativeVisibility)
 {
 	// we need access to the scene manager and the rendersystem
Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj	(revision 879)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj	(revision 931)
@@ -123,4 +123,7 @@
 			</File>
 			<File
+				RelativePath="..\src\BoundingBoxConverter.h">
+			</File>
+			<File
 				RelativePath="..\src\Camera.cpp">
 			</File>
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h	(revision 860)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h	(revision 931)
@@ -9,4 +9,5 @@
 class ViewCellsManager;
 class VspBspTree;
+class BoundingBoxConverter;
 
 class ViewCellsParser : public Parser
@@ -18,5 +19,6 @@
   bool ParseFile(const string filename, 
 				 ViewCellsManager **viewCells,
-				 ObjectContainer *objects);
+				 ObjectContainer *objectsm,
+				 BoundingBoxConverter *bconverter);
 };
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 904)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 931)
@@ -32,4 +32,6 @@
 class ViewCellsTree;
 class MergeCandidate;
+class BoundingBoxConverter;
+
 
 struct BspRay;
@@ -50,14 +52,4 @@
 };
 
-
-struct IndexedBoundingBox: public std::pair<int, AxisAlignedBox3>
-{
-	typedef std::pair<int, AxisAlignedBox3> IndexedBoundingBoxParent;
-
-	IndexedBoundingBox(int idx, const AxisAlignedBox3 &box): IndexedBoundingBoxParent(idx, box)
-	{
-
-	}
-};
 
 /**	Manages different higher order operations on the view cells.
@@ -77,5 +69,5 @@
 	enum {BSP, KD, VSP_KD, VSP_BSP};
   
-	/// view cells evaluation type
+	/// render cost evaluation type
 	enum {PER_OBJECT, PER_TRIANGLE};
 
@@ -308,5 +300,5 @@
 	/** Writes view cells to disc.
 	*/
-	virtual bool ExportViewCells(const string filename, const bool exportPvs);
+	virtual bool ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects);
 
 	/** Casts beam to collect view cells.
@@ -418,16 +410,5 @@
 	float EvalRenderCost(Intersectable *obj) const;
 
-    void
-	ApplyFilter(KdTree *kdTree,
-				const float viewSpaceFilterSize,
-				const float spatialFilterSize
-				);
-
-  void
-  ApplySpatialFilter(
-					 KdTree *kdTree,
-					 const float spatialFilterSize,
-					 ObjectPvs &pvs
-					 );
+   
 	
 	/** Returns bounding box of a view cell.
@@ -438,12 +419,13 @@
 	*/
 	bool ExportBoundingBoxes(const string filename, const ObjectContainer &objects) const;
-
+    
 	/** Load the bounding boxes into the container.
 	*/
 	bool LoadBoundingBoxes(const string filename, IndexedBoundingBoxContainer &boxes) const;
 
-  bool GetExportPvs() const {
-	return mExportPvs;
-  }
+	bool GetExportPvs() const 
+	{
+		return mExportPvs;
+	}
 
 	/** Loads view cells from file. The view cells manager is created with 
@@ -452,27 +434,39 @@
 		@returns the view cells manager if loading was successful, false otherwise
 	*/
-	static ViewCellsManager *LoadViewCells(const string filename, ObjectContainer *objects);
-
-  float GetFilterWidth() {
-	return mFilterWidth;
-  }
-
-  float GetAbsFilterWidth() {
-	return Magnitude(mViewSpaceBox.Size())*mFilterWidth;
-  }
+	static ViewCellsManager *LoadViewCells(const string filename, 
+										   ObjectContainer *objects, 
+										   BoundingBoxConverter *bconverter = NULL);
+
+
+	////////////////////////////////////////////////////////7
+	// visiblity filter options
+	// TODO: write own visibiltiy filter class
+	void ApplyFilter(KdTree *kdTree,
+					 const float viewSpaceFilterSize,
+					 const float spatialFilterSize);
+
+	void ApplySpatialFilter(KdTree *kdTree,
+							const float spatialFilterSize,
+							ObjectPvs &pvs);
+
+	 void ApplyFilter(ViewCell *viewCell,
+					  KdTree *kdTree,
+					  const float viewSpaceFilterSize,
+					  const float spatialFilterSize,
+					  ObjectPvs &pvs);
+
+	float GetFilterWidth();
+
+	float GetAbsFilterWidth();
+
+	
+	/** Returns the bounding box of filter width.
+	*/
+	AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint, const float width) const;
 
 protected:
-    void
-	ApplyFilter(ViewCell *viewCell,
-				KdTree *kdTree,
-				const float viewSpaceFilterSize,
-				const float spatialFilterSize,
-				ObjectPvs &pvs
-				);
-
-  
-	/** Returns the bounding box of filter width.
-	*/
-	AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint, const float width) const;
+	/** Exports bounding boxes as xml stream
+	*/
+	bool ExportBoundingBoxes(ofstream &xmlstream, const ObjectContainer &objects) const;
 
 	/** Intersects box with the tree and returns the number of intersected boxes.
@@ -486,6 +480,5 @@
 	virtual void TestFilter(const ObjectContainer &objects) {};
 
-	/**
-		if the view cells tree was already constructed or not.
+	/** If the view cells tree was already constructed or not.
 	*/
 	bool ViewCellsTreeConstructed() const;
@@ -495,4 +488,6 @@
 						VssRayContainer &vssRays) const;
 
+	/** Parse the options from the environment file.
+	*/
 	void ParseEnvironment();
 
@@ -700,5 +695,5 @@
 	void Finalize(ViewCell *viewCell, const bool createMesh);
 
-	bool ExportViewCells(const string filename, const bool exportPvs);
+	bool ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects);
 
 	/** Constructs merge hierarchy which corresponds to the spatial hierarchy.
@@ -908,5 +903,5 @@
 	void CreateMesh(ViewCell *vc);
 
-	bool ExportViewCells(const string filename, const bool exportPvs);
+	bool ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects);
 
 	int CastBeam(Beam &beam);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 925)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 931)
@@ -265,6 +265,5 @@
 {
   
-  mViewCellsManager->ExportViewCells(filename,
-									 true);
+  mViewCellsManager->ExportViewCells(filename, true, mObjects);
   
   return true;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp	(revision 871)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp	(revision 931)
@@ -627,5 +627,5 @@
 	  VssRayContainer dummies;
 	  mViewCellsManager->Visualize(mObjects, dummies);
-	  mViewCellsManager->ExportViewCells("test.xml", mViewCellsManager->GetExportPvs());
+	  mViewCellsManager->ExportViewCells("test.xml", mViewCellsManager->GetExportPvs(), mObjects);
   }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h	(revision 860)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h	(revision 931)
@@ -7,4 +7,5 @@
 #include <xercesc/sax/HandlerBase.hpp>
 #include "Mesh.h"
+#include "BoundingBoxConverter.h"
 
 namespace GtpVisibilityPreprocessor {
@@ -27,5 +28,5 @@
   //  Constructors and Destructor
   // -----------------------------------------------------------------------
-  ViewCellsParseHandlers(ObjectContainer *objects);
+  ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter);
   ~ViewCellsParseHandlers();
   
@@ -78,6 +79,9 @@
   ViewCellsManager *mViewCellsManager;
   ObjectContainer *mObjects;
+  BoundingBoxConverter *mBoundingBoxConverter;
 
   AxisAlignedBox3 mViewSpaceBox;
+
+  IndexedBoundingBoxContainer mIBoundingBoxes;
 
   bool mParseViewCells;
@@ -90,4 +94,5 @@
   void StartViewCell(ViewCell *viewCell, AttributeList&  attributes);
   void EndViewCells();
+  void EndBoundingBoxes();
 	
   void StartHierarchy(AttributeList& attributes);
@@ -96,4 +101,5 @@
   void StartViewSpaceBox(AttributeList&  attributes);
 
+  void StartBoundingBox(AttributeList& attributes);
   void StartViewCellLeaf(AttributeList& attributes);
   void StartViewCellInterior(AttributeList& attributes);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 881)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 931)
@@ -65,5 +65,5 @@
 //  StdInParseHandlers: Constructors and Destructor
 // ---------------------------------------------------------------------------
-ViewCellsParseHandlers::ViewCellsParseHandlers(ObjectContainer *objects):
+ViewCellsParseHandlers::ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter):
   mElementCount(0)
   , mAttrCount(0)
@@ -77,6 +77,8 @@
   , mCurrentViewCell(NULL)
   , mCurrentBspNode(NULL)
-{
-	mObjects = objects;
+  , mObjects(objects)
+  , mBoundingBoxConverter(bconverter)
+{
+	// mObjects = objects;
 }
 
@@ -132,4 +134,5 @@
 }
 
+
 inline static bool vlt(ViewCell *v1, ViewCell *v2)
 {
@@ -144,4 +147,11 @@
 }
 
+
+void ViewCellsParseHandlers::EndBoundingBoxes()
+{
+	// bounding boxes gathered: associate object ids with bounding boxes
+	if (mBoundingBoxConverter)
+		mBoundingBoxConverter->IdentifyObjects(mIBoundingBoxes, *mObjects);
+}
 
 
@@ -208,8 +218,14 @@
 	if (element == "ViewSpaceBox")
 	{
+		Debug << "v";
+		StartViewSpaceBox(attributes);
+	}
+
+	// decides the used view cell hierarchy
+	if (element == "BoundingBox")
+	{
 		Debug << "b";
-		StartViewSpaceBox(attributes);
-	}
-
+		StartBoundingBox(attributes);
+	}
 
 	// use different methods for the given view cell hierarchy types
@@ -379,4 +395,42 @@
 
 
+void ViewCellsParseHandlers::StartBoundingBox(AttributeList& attributes)
+{
+	int len = attributes.getLength();
+
+	Vector3 bmin, bmax;
+	int id;
+
+	for (int i = 0; i < len; ++ i) 
+	{
+		string attrName(StrX(attributes.getName(i)).LocalForm());
+		StrX attrValue(attributes.getValue(i));
+		const char *ptr = attrValue.LocalForm();
+
+
+		if (attrName == "id")
+		{
+			sscanf(ptr, "%d", &id);
+		}
+
+		if (attrName == "min") 
+		{
+			sscanf(ptr, "%f %f %f",
+				   &bmin.x, &bmin.y, &bmin.z);
+		}
+		else if (attrName == "max") 
+		{
+			sscanf(ptr, "%f %f %f",
+				   &bmax.x, &bmax.y, &bmax.z);
+		}
+	}
+
+	AxisAlignedBox3 box(bmin, bmax);
+	mIBoundingBoxes.push_back(IndexedBoundingBox(id, box));
+
+	Debug << "view space box: " << mViewSpaceBox << endl;
+}
+
+
 void ViewCellsParseHandlers::StartBspLeaf(AttributeList& attributes)
 {
@@ -637,5 +691,6 @@
 bool ViewCellsParser::ParseFile(const string filename, 
 								ViewCellsManager **viewCells,
-								ObjectContainer *objects)
+								ObjectContainer *objects,
+								BoundingBoxConverter *bconverter)
 {
   // Initialize the XML4C system
@@ -669,5 +724,5 @@
   //  to do.
   //
-  ViewCellsParseHandlers handler(objects);
+  ViewCellsParseHandlers handler(objects, bconverter);
   parser->setDocumentHandler(&handler);
   parser->setErrorHandler(&handler);
@@ -724,5 +779,5 @@
   XMLPlatformUtils::Terminate();
   
-   // assign new view cells manager
+  //-- assign new view cells manager
   *viewCells = handler.mViewCellsManager;
   
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 904)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 931)
@@ -15,4 +15,6 @@
 #include "VssPreprocessor.h"
 #include "RssPreprocessor.h"
+#include "BoundingBoxConverter.h"
+
 
 namespace GtpVisibilityPreprocessor {
@@ -1858,5 +1860,5 @@
 
 
-bool ViewCellsManager::ExportViewCells(const string filename, const bool exportPvs)
+bool ViewCellsManager::ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects)
 {
 	return false;
@@ -1956,7 +1958,4 @@
 										 IndexedBoundingBoxContainer &boxes) const
 {
-	// HACK: needed only for lower_bound algorithm to find the 
-	// intersected objects
-
 	Vector3 bmin, bmax;
 	int id;
@@ -2021,6 +2020,44 @@
 }
 
+
+float ViewCellsManager::GetFilterWidth() 
+{
+	return mFilterWidth;
+}
+
+
+float ViewCellsManager::GetAbsFilterWidth() 
+{
+	return Magnitude(mViewSpaceBox.Size()) * mFilterWidth;
+}
+
+
+bool ViewCellsManager::ExportBoundingBoxes(ofstream &xmlstream, 
+										   const ObjectContainer &objects) const
+{
+	//-- export the view cells and the pvs
+	xmlstream << "<BoundingBoxes>" << endl;
+
+	ObjectContainer::const_iterator oit, oit_end = objects.end();
+
+	for (oit = objects.begin(); oit != oit_end; ++ oit)
+	{
+			MeshInstance *mi = dynamic_cast<MeshInstance *>(*oit);
+			const AxisAlignedBox3 box = mi->GetBox();
+
+			//-- the bounding boxes
+			xmlstream << "<BoundingBox" << " id=\"" << mi->GetId() << "\""
+				      << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\""
+					  << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl;
+	}
+
+	xmlstream << "</BoundingBoxes>" << endl;
+
+	return true;
+}
+
+
 /**********************************************************************/
-/*                   BspViewCellsManager implementation               */
+/*                 BspViewCellsManager implementation                 */
 /**********************************************************************/
 
@@ -2282,9 +2319,9 @@
 		char filename[100];
 		environment->GetStringValue("ViewCells.filename", filename);
-		ExportViewCells(filename, mExportPvs);
+		ExportViewCells(filename, mExportPvs, objects);
 	}
 	
 	// export bounding boxes
-	if (mExportBboxesForPvs)
+	if (0 && mExportBboxesForPvs)
 	{
 		char filename[100];
@@ -2729,5 +2766,5 @@
 
 
-bool BspViewCellsManager::ExportViewCells(const string filename, const bool exportPvs)
+bool BspViewCellsManager::ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects)
 {
 	cout << "exporting view cells to xml ... ";
@@ -3974,5 +4011,5 @@
 		char filename[100];
 		environment->GetStringValue("ViewCells.filename", filename);
-		ExportViewCells(filename, mExportPvs);
+		ExportViewCells(filename, mExportPvs, objects);
 	}
 
@@ -4687,5 +4724,6 @@
 
 ViewCellsManager *ViewCellsManager::LoadViewCells(const string filename, 
-												  ObjectContainer *objects)
+												  ObjectContainer *objects,
+												  BoundingBoxConverter *bconverter)
 {
 	ViewCellsParser parser;
@@ -4695,5 +4733,7 @@
 	Debug << "vc filename: " << filename << endl;
 
-	if (parser.ParseFile(filename, &vm, objects))
+	//BoundingBoxConverter bconverter;
+
+	if (parser.ParseFile(filename, &vm, objects, bconverter))
 	{
 		//vm->PrepareLoadedViewCells();
@@ -4719,6 +4759,7 @@
 
 
-
-bool VspBspViewCellsManager::ExportViewCells(const string filename, const bool exportPvs)
+bool VspBspViewCellsManager::ExportViewCells(const string filename, 
+											 const bool exportPvs, 
+											 const ObjectContainer &objects)
 {
 	cout << "exporting view cells to xml ... ";
@@ -4737,5 +4778,5 @@
 		   << " max=\"" << mViewSpaceBox.Max().x << " " << mViewSpaceBox.Max().y << " " << mViewSpaceBox.Max().z << "\" />" << endl;
 
-
+	ExportBoundingBoxes(stream, objects);
 
 	//-- the type of the view cells hierarchy
@@ -4750,5 +4791,5 @@
 
 
-	//-- export the hierarchy
+	//-- export the spatial hierarchy
 	stream << "<Hierarchy>" << endl;
 	mVspBspTree->Export(stream);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 904)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 931)
@@ -930,5 +930,5 @@
 	RenderIntersectable(*oi);
 
-  ViewCell *viewcell;
+  ViewCell *viewcell = NULL;
 
   QImage im1, im2;
