Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2003)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2004)
@@ -266,5 +266,4 @@
 	cout << "binary obj dump available, loading " << filename.c_str() << endl;
 	
-
 	// table for vertices
 	VertexContainer vertices; 
@@ -275,10 +274,19 @@
 		cout << "not using face parents" << endl;
 
-	int dummy = 0;
-	vector<Triangle3> triangles;
-	//triangles.reserve(sizeof(Triangle3) * 13000000);
-	//triangles.reserve(13000000);
+	// read in triangle size
+	int numTriangles;
+
+	samplesIn.read(reinterpret_cast<char *>(&numTriangles), sizeof(int));
+	root->mGeometry.reserve(numTriangles);
+	cout << "reserved " << numTriangles << " triangles " << endl;
 	//root->mGeometry.reserve(13000000);
-
+	
+	cout << "using " << numTriangles * (sizeof(TriangleIntersectable) + sizeof(TriangleIntersectable *)) / (1024 * 1024) << " MBs" << endl;
+
+	//vector<Triangle3> dummy;
+	//cout << "using " << numTriangles * sizeof(Triangle3) / (1024 * 1024) << " MBs" << endl;
+	//dummy.reserve(numTriangles);
+
+	int i = 0;
 	while (1)
 	{
@@ -295,11 +303,19 @@
 		TriangleIntersectable *obj = new TriangleIntersectable(tri);
 		root->mGeometry.push_back(obj);
-		//triangles.push_back(tri);
-		//dummy ++;
-		//if (dummy % 100000 == 9999)
-		//cout << "idx: " << dummy << endl;
-	}
-	
-	//cout << "here411" << endl;
+		//dummy.push_back(tri);
+		i ++;
+	
+		if (i % 500000 == 0)
+			cout << "idx: " << i << endl;
+	}
+	
+	if (i != numTriangles)
+	{
+		cout << "warning: triangle size does not match with loaded triangle size" << endl;
+		return false;
+	}
+
+	cout << "loaded " << numTriangles << " triangles" << endl;
+
 	return true;
 }
@@ -308,8 +324,12 @@
 bool Preprocessor::ExportBinaryObj(const string filename, SceneGraphNode *root)
 {
-	//ifstream samplesIn(filename, ios::binary);
 	ogzstream samplesOut(filename.c_str());
+
 	if (!samplesOut.is_open())
 		return false;
+
+	int numTriangles = (int)root->mGeometry.size();
+
+	samplesOut.write(reinterpret_cast<char *>(&numTriangles), sizeof(int));
 
 	ObjectContainer::const_iterator oit, oit_end = root->mGeometry.end();
@@ -333,4 +353,6 @@
 	}
 
+	cout << "exported " << numTriangles << " triangles" << endl;
+
 	return true;
 }
@@ -346,5 +368,5 @@
 	ObjectContainer::const_iterator oit, oit_end = objects.end();
 
-	AxisAlignedBox3 bbox = mSceneGraph->GetBox(); bbox.Enlarge(30.0);
+	//AxisAlignedBox3 bbox = mSceneGraph->GetBox(); bbox.Enlarge(30.0);
 	for (oit = objects.begin(); oit != oit_end; ++ oit)
 	{
@@ -354,9 +376,9 @@
 		{
 			Triangle3 tri = dynamic_cast<TriangleIntersectable *>(obj)->GetItem();
-			//if (bbox.IsInside(tri.mVertices[0]) && bbox.IsInside(tri.mVertices[1]) && bbox.IsInside(tri.mVertices[2]))
-			//{
-				samplesOut << "v " << tri.mVertices[0].x << " " << tri.mVertices[0].y << " " << tri.mVertices[0].z << endl;
-				samplesOut << "v " << tri.mVertices[1].x << " " << tri.mVertices[1].y << " " << tri.mVertices[1].z << endl;
-				samplesOut << "v " << tri.mVertices[2].x << " " << tri.mVertices[2].y << " " << tri.mVertices[2].z << endl;
+			//if (!(bbox.IsInside(tri.mVertices[0]) && bbox.IsInside(tri.mVertices[1]) && bbox.IsInside(tri.mVertices[2])))continue;
+			
+			samplesOut << "v " << tri.mVertices[0].x << " " << tri.mVertices[0].y << " " << tri.mVertices[0].z << endl;
+			samplesOut << "v " << tri.mVertices[1].x << " " << tri.mVertices[1].y << " " << tri.mVertices[1].z << endl;
+			samplesOut << "v " << tri.mVertices[2].x << " " << tri.mVertices[2].y << " " << tri.mVertices[2].z << endl;
 			//}
 		}
@@ -375,10 +397,9 @@
 		{
 			//Triangle3 tri = dynamic_cast<TriangleIntersectable *>(obj)->GetItem();
-			//if (bbox.IsInside(tri.mVertices[0]) && bbox.IsInside(tri.mVertices[1]) && bbox.IsInside(tri.mVertices[2]))
-			//{
-				Triangle3 tri = dynamic_cast<TriangleIntersectable *>(obj)->GetItem();
-				samplesOut << "f " << i << " " << i + 1 << " " << i + 2 << endl;
-				i += 3;
-			//}
+			//if (!(bbox.IsInside(tri.mVertices[0]) && bbox.IsInside(tri.mVertices[1]) && bbox.IsInside(tri.mVertices[2]))) continue;
+			
+			Triangle3 tri = dynamic_cast<TriangleIntersectable *>(obj)->GetItem();
+			samplesOut << "f " << i << " " << i + 1 << " " << i + 2 << endl;
+			i += 3;
 		}
 		else
@@ -408,5 +429,5 @@
 	if (index < 0)
 	{
-		cerr << "Warning: triangle index smaller zero! " << index << endl;
+		//cerr << "Warning: triangle index smaller zero! " << index << endl;
 		return NULL;
 	}
@@ -502,12 +523,13 @@
 
 			// hack: load binary dump
-			string binFile = ReplaceSuffix(filename, ".obj", ".bin");
-
+			const string bnFile = ReplaceSuffix(filename, ".obj", ".bn");
+			
 			if (!mLoadMeshes)
 			{
-				result = LoadBinaryObj(binFile, mSceneGraph->GetRoot(), fi);
+				result = LoadBinaryObj(bnFile, mSceneGraph->GetRoot(), fi);
 			}
 
-			if (!result)
+			// parse obj
+            if (!result)
 			{
 				cout << "no binary dump available or loading full meshes, parsing file" << endl;
@@ -519,9 +541,10 @@
 								   fi);
 						
+				cout << "loaded " << (int)mSceneGraph->GetRoot()->mGeometry.size() << " entities" << endl;
 				// only works for triangles
-				if (!mLoadMeshes)
+				if (result && !mLoadMeshes)
 				{
-					cout << "exporting binary obj to " << binFile << "... " << endl;
-					ExportBinaryObj(binFile, mSceneGraph->GetRoot());
+					cout << "exporting binary obj to " << bnFile << "... " << endl;
+					ExportBinaryObj(bnFile, mSceneGraph->GetRoot());
 					cout << "finished" << endl;
 				}
@@ -531,5 +554,5 @@
 			else if (0)
 			{
-				ExportBinaryObj("../data/test.bin", mSceneGraph->GetRoot());
+				ExportBinaryObj("../data/test.bn", mSceneGraph->GetRoot());
 			}
 		}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 2003)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 2004)
@@ -1737,5 +1737,5 @@
 
 
-float BvHierarchy::EvalAbsCost(const ObjectContainer &objects)// const
+float BvHierarchy::EvalAbsCost(const ObjectContainer &objects)
 {
 #if USE_BETTER_RENDERCOST_EST
@@ -2346,8 +2346,9 @@
 
 		frontData.mSortedObjects[i]->reserve((int)sc.mFrontObjects.size());
-		backData.mSortedObjects[i]->reserve((int)sc.mFrontObjects.size());
+		backData.mSortedObjects[i]->reserve((int)sc.mBackObjects.size());
 
 		ObjectContainer::const_iterator oit, oit_end = sc.mParentData.mSortedObjects[i]->end();
 
+		// all the front objects are mailed => assign the sorted object lists
 		for (oit = sc.mParentData.mSortedObjects[i]->begin(); oit != oit_end; ++ oit)
 		{
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2003)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2004)
@@ -342,5 +342,5 @@
 ViewCellsManager::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects)
 {
-  GetPreprocessor()->mKdTree->CollectObjects(box, objects);
+	GetPreprocessor()->mKdTree->CollectObjects(box, objects);
 }
 
@@ -4321,6 +4321,6 @@
 			exporter->SetWireframe();
 
-			// matt: no kd pvs
-			/*
+			// matt: we don't have no kd pvs
+#if 0
 			KdPvsMap::iterator kit = object->mKdPvs.mEntries.begin();
 			Intersectable::NewMail();
@@ -4348,5 +4348,5 @@
 			exporter->SetForcedMaterial(m);
 			exporter->ExportIntersectable(object);
-*/
+#endif
 			delete exporter;
 		}
@@ -6404,5 +6404,5 @@
 VspOspViewCellsManager::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects)
 {
-  mHierarchyManager->CollectObjects(box, objects);
+	mHierarchyManager->CollectObjects(box, objects);
 }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp	(revision 2003)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp	(revision 2004)
@@ -43,5 +43,5 @@
 							)
 {
-	cout << "intel ray" << endl;
+	//cout << "intel ray" << endl;
 	VssRay *vssRay  = NULL;
 	int hits = 0;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2003)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2004)
@@ -653,5 +653,5 @@
 					if (strcmp(curr, "mutation")==0) {
 					  // temp matt: still no mutationstrategy!
-					  mDistributions.push_back(new MutationBasedDistribution(mPreprocessor));
+					  //mDistributions.push_back(new MutationBasedDistribution(mPreprocessor));
 					}
 	
