Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2172)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2183)
@@ -22,4 +22,5 @@
 #include "InternalRayCaster.h"
 #include "GlobalLinesRenderer.h"
+#include "ObjectsParser.h"
 
 
@@ -27,4 +28,5 @@
 #define SHOW_RAYCAST_TIMING 1
 
+using namespace std;
 
 namespace GtpVisibilityPreprocessor {
@@ -265,5 +267,5 @@
 
 
-bool Preprocessor::LoadBinaryObj(const string filename,
+bool Preprocessor::LoadBinaryObj(const string &filename,
 								 SceneGraphNode *root,
 								 vector<FaceParentInfo> *parents)
@@ -277,12 +279,4 @@
 	cout << "binary obj dump available, loading " << filename.c_str() << endl;
 	
-	// table for vertices
-	VertexContainer vertices; 
-	
-	if (parents)
-		cout << "using face parents" << endl;
-	else
-		cout << "not using face parents" << endl;
-
 	// read in triangle size
 	int numTriangles;
@@ -309,7 +303,5 @@
 		root->mGeometry.push_back(obj);
 		
-		i ++;
-	
-		if (i % 500000 == 499999)
+		if ((i ++) % 500000 == 499999)
 			 cout<<"\r"<<i<<"/"<<numTriangles<<"\r";
 	}
@@ -488,4 +480,5 @@
 	const int files = SplitFilenames(filename, filenames);
 	cout << "number of input files: " << files << endl;
+
 	bool result = false;
 	bool isObj = false;
@@ -547,17 +540,16 @@
 						
 				cout << "loaded " << (int)mSceneGraph->GetRoot()->mGeometry.size() << " entities" << endl;
+
 				// only works for triangles
 				if (result && !mLoadMeshes)
 				{
 					cout << "exporting binary obj to " << bnFile << "... " << endl;
+
 					ExportBinaryObj(bnFile, mSceneGraph->GetRoot());
+				
 					cout << "finished" << endl;
 				}
 
 				delete parser;
-			}
-			else if (0)
-			{
-				ExportBinaryObj("../data/test.bn", mSceneGraph->GetRoot());
 			}
 		}
@@ -740,8 +732,28 @@
 	if (mLoadViewCells)
 	{	
+		
+#ifdef USE_BIT_PVS
+		// HACK: for kd pvs, set pvs size to maximal number of kd nodes
+		vector<KdLeaf *> leaves;
+		preprocessor->mKdTree->CollectLeaves(leaves);
+
+		ObjectPvs::SetPvsSize((int)leaves.size());
+#endif
+
 		Environment::GetSingleton()->GetStringValue("ViewCells.filename", buf);
-		cout << "loading view cells from " << buf << endl<<flush;
-
-		mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, true, NULL);
+		cout << "loading objects from " << buf << endl;
+
+		// load objects which will be used as pvs entries
+		ObjectContainer pvsObjects;
+		if (0) LoadObjects(buf, pvsObjects, mObjects);
+
+		const bool finalizeViewCells = true;
+		cout << "loading view cells from " << buf << endl;
+
+		mViewCellsManager = ViewCellsManager::LoadViewCells(buf, 
+															pvsObjects,
+															mObjects, 
+															finalizeViewCells, 
+															NULL);
 
 		cout << "view cells loaded." << endl<<flush;
@@ -1262,5 +1274,5 @@
 	const long t1 = GetTime();
 	
-	if (0 && (int)rays.size() > 10000) {
+	if ((int)rays.size() > 10000) {
 	
 		mRayCaster->SortRays(rays);
@@ -1356,5 +1368,4 @@
 	
 		if ((int)rays.size() > 100000 && i % 100000 == 0)
-			//cout << "here2 " << vssRays.size()<<endl;
 			cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r";
 	}
@@ -1632,3 +1643,29 @@
 
 
-}
+bool Preprocessor::LoadObjects(const string &filename,
+							   ObjectContainer &pvsObjects, 
+							   const ObjectContainer &preprocessorObjects)
+{
+	ObjectsParser parser;
+
+	const bool success = parser.ParseObjects(filename, 
+											 pvsObjects, 
+											 preprocessorObjects);
+
+	if (!success)
+	{
+		Debug << "Error: loading objects failed!" << endl;
+	}
+
+	// hack: no bvh object could be found => take preprocessor objects
+	if (pvsObjects.empty())
+	{
+		Debug << "no objects" << endl;
+		pvsObjects = preprocessorObjects;
+	}
+
+	return success;
+}
+
+
+}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2176)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2183)
@@ -263,9 +263,9 @@
 protected:
 
-	bool LoadBinaryObj(const string &filename,
+	bool LoadBinaryObj(const std::string &filename,
 					   SceneGraphNode *root,
-					   vector<FaceParentInfo> *parents);
-
-	bool ExportBinaryObj(const string filename, SceneGraphNode *root);
+					   std::vector<FaceParentInfo> *parents);
+
+	bool ExportBinaryObj(const std::string filename, SceneGraphNode *root);
 
 	void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction) const;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp	(revision 2116)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp	(revision 2183)
@@ -283,5 +283,5 @@
 		if (GetArea() < AREA_LIMIT)
 		{
-			Debug << "area too small: " << GetArea() << endl;
+			Debug << "area too small: " << GetArea() << std::endl;
 			return false;
 		}
