Index: GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 2048)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 2053)
@@ -197,4 +197,5 @@
 				AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(QTDIR)\include\Qt&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include&quot;;QtInterface"
 				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;USE_QT;USE_CG"
+				ExceptionHandling="TRUE"
 				RuntimeLibrary="2"
 				EnableEnhancedInstructionSet="2"
@@ -209,5 +210,5 @@
 				Name="VCLinkerTool"
 				AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib Preprocessor.lib RTScene.lib RTWorld.lib QtCore4.lib qtmain.lib cg.lib cgGL.lib QtOpenGL4.lib Qt3Support4.lib QtTest4.lib QtGui4.lib QtInterface.lib"
-				OutputFile="../bin/release/Preprocessor2.exe"
+				OutputFile="../bin/release/Preprocessor.exe"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\src\GL;..\lib\release;..\..\Preprocessing\lib\release;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\MultiLevelRayTracing\RTScene\Release;..\MultiLevelRayTracing\RTWorld\Release;&quot;$(QTDIR)\lib&quot;;.\QtInterface\Release;&quot;$(CG_LIB_PATH)&quot;"
@@ -217,4 +218,5 @@
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
+				OptimizeForWindows98="1"
 				TargetMachine="1"
 				FixedBaseAddress="1"/>
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h	(revision 2048)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h	(revision 2053)
@@ -217,5 +217,5 @@
 	void DeterminePvsObjects(VssRayContainer &rays);
 
-	virtual void ComputeRenderError();
+	//virtual void ComputeRenderError();
 
 	void StorePvs(const ObjectContainer &objectPvs);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2050)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2053)
@@ -658,5 +658,5 @@
   
   // export the preprocessed information to a file
-  if (mExportVisibility)
+  if (1 && mExportVisibility)
   {
 	  ExportPreprocessedData(mVisibilityFileName);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp	(revision 1571)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp	(revision 2053)
@@ -65,9 +65,4 @@
 	mVertices.push_back(tri.mVertices[1]);
 	mVertices.push_back(tri.mVertices[2]);
-
-	VertexContainer::iterator it, it_end = mVertices.end();
-
-	//for (it = mVertices.begin(); it != it_end;  ++ it){cout << (*it) << " ";}cout<<endl<<endl;
-	//cout << "poly n: " << GetNormal() << " t normal: " << tri.GetNormal() << endl;
 }
 
@@ -105,4 +100,5 @@
     Vector3 lastSplit;
 		
+	/////////////
 	//-- find line - plane intersections
 
@@ -139,8 +135,10 @@
 			if (sideA > 0)
 			{
+				////////////
 				//-- plane - line intersection
+
 				Vector3 splitPt = partition.FindIntersection(ptA, ptB);
-				// test if split point not too close to other split point
-					// test if split point not too close to previous split point
+				
+				// test if split point not too close to previous split point
 				if (!foundSplit || (!EpsilonEqualV3(splitPt, lastSplit, epsilon)))
 				{
@@ -153,4 +151,5 @@
 				}	
 			}
+
 			back.mVertices.push_back(ptB);
 		}
@@ -249,5 +248,5 @@
 		sum += mVertices[i];
 	
-	return sum/(float)i;
+	return sum / (float)i;
 }
 
@@ -258,6 +257,8 @@
 	int i;
 	Vector3 center = Center();
-	for (i=0; i < mVertices.size(); i++) {
-		mVertices[i] = center + scale*(mVertices[i] - center);
+	
+	for (i=0; i < mVertices.size(); i++) 
+	{
+		mVertices[i] = center + scale * (mVertices[i] - center);
 	}
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2051)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2053)
@@ -536,5 +536,5 @@
 
 		if (GenerateViewPoint(viewCell, pt))
-		{cout<<"here4"<<endl;
+		{
 			++ generatedPts;
 			cout << "generated view point " << generatedPts << endl;
@@ -1102,8 +1102,9 @@
 		vm->mMaxPvsSize = (int)objects->size();
 
+		
 		if (finalizeViewCells)
 		{
 			// create the meshes and compute volumes
-			vm->FinalizeViewCells(true);
+			vm->FinalizeViewCells(false);
 			// vm->mViewCellsTree->AssignRandomColors();
 		}
@@ -1113,4 +1114,7 @@
 			cout << "=============== " << vm->GetViewCellById(5318)->GetPvs().GetSize() << "========" << endl;
 		}
+
+		cout << (int)vm->mViewCells.size() << " view cells loaded in "
+			 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
 
 		Debug << (int)vm->mViewCells.size() << " view cells loaded in "
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2050)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2053)
@@ -89,6 +89,6 @@
   mUseForcedColors = false;
   mRenderBoxes = false;
-  mUseGlLists = true;
-  //mUseGlLists = false;
+ // mUseGlLists = true;
+  mUseGlLists = false;
 
   if (mViewCellsManager->GetViewCellPoints()->size())
@@ -447,5 +447,7 @@
 
 			if (id != 0xFFFFFF)
+			{
 				++ mObjects[id]->mCounter;
+			}
 		}
 	}
@@ -511,4 +513,5 @@
 
 		pixelCount = mOcclusionQueries[j]->GetQueryResult();
+		
 		mObjects[j]->mCounter += pixelCount;
 	}
@@ -554,4 +557,5 @@
 			//	cout <<"o="<<j+q<<" q="<<mOcclusionQueries[q]->GetQueryId()<<" pc="<<pixelCount<<" ";
 			mObjects[j + t]->mCounter += pixelCount;
+		
 		}
 
@@ -735,4 +739,5 @@
 	{
 	  (*it)->mCounter = 0;
+	 
 	}
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp	(revision 1942)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp	(revision 2053)
@@ -997,8 +997,11 @@
 		if (!object->Mailed()) {
 		  object->Mail();
+		  
 		  object->mCounter = 1;
 		} else
+		{
+			
 		  object->mCounter++;
-	  
+		}
 #if EVAL_VIEWCELLS	 
 	  // and do the same for all viewcells
@@ -1010,7 +1013,11 @@
 		  currInfo.viewCells++;
 		  viewcell->Mail();
+		  
 		  viewcell->mCounter = 1;
 		} else
+		{
+			
 		  viewcell->mCounter++;
+		}
 	  }
 #endif
@@ -1059,5 +1066,7 @@
 		}
 		if (--object->mCounter == 0)
+		{
 		  currInfo.pvsFront--;
+		}
 	  }
 
@@ -1071,5 +1080,7 @@
 		}
 		if (--viewcell->mCounter == 0)
+		{
 		  currInfo.viewCellsFront--;
+		}
 	  }
 #endif
@@ -2386,4 +2397,5 @@
 		if (!object->Mailed()) {
 		  object->Mail();
+		  
 		  object->mCounter = 1;
 		  pvs.push_back(object);
@@ -2843,5 +2855,8 @@
 		  object->mCounter = 1;
 		} else
+		{
+		
 		  object->mCounter++;
+		}
 		samples++;
 	  }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 2049)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 2053)
@@ -366,5 +366,5 @@
 		  new QtGlRendererBuffer(1024, 1024,
 								 preprocessor->mSceneGraph,
-							   preprocessor->mViewCellsManager,
+								 preprocessor->mViewCellsManager,
 								 preprocessor->mKdTree);
 	  }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2048)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2053)
@@ -16,5 +16,5 @@
 {
   
-#define GVS_DEBUG 0
+#define GVS_DEBUG 1
 
 struct VizStruct
@@ -140,5 +140,5 @@
 
 		// set flag for visualization
-		newRay->mFlags |= VssRay::ReverseSample;
+		//newRay->mFlags |= VssRay::ReverseSample;
 		
 		// if ray is not further processed => delete ray
@@ -154,5 +154,5 @@
 }
 
-// #id: 1270
+
 bool GvsPreprocessor::HasContribution(VssRay &ray)
 {
@@ -314,5 +314,5 @@
 	if (!newRay) return castRays;
 
-	newRay->mFlags |= VssRay::BorderSample;
+	//newRay->mFlags |= VssRay::BorderSample;
 
 	// add new ray to queue
@@ -391,6 +391,6 @@
 	GenerateRays(numRandomRays, vcStrat, simpleRays);
 
+
 	/////////////////////
-
 
 	// keep origin for per view cell sampling
@@ -398,15 +398,9 @@
 
 	const int numBorderSamples = (int)vssRays.size() - numRandomRays;
-
 	// set flags
-	VssRayContainer::const_iterator rit, rit_end = vssRays.end();
-	int i = 0;
-  
+	/*VssRayContainer::const_iterator rit, rit_end = vssRays.end();
 	for (rit = vssRays.begin(); rit != rit_end; ++ rit, ++ i)
-	{
-		if (i < numBorderSamples)
-			(*rit)->mFlags |= VssRay::BorderSample;
-	}
-
+		(*rit)->mFlags |= VssRay::BorderSample;
+		*/
 	int castRays = (int)simpleRays.size();
 
@@ -429,5 +423,5 @@
 	mGvsStats.mBorderSamples += castRays;
 
-	CLEAR_CONTAINER(invalidSamples);
+	//CLEAR_CONTAINER(invalidSamples);
 	
 	//cout << "cast rays: " << castRays << endl;
@@ -585,5 +579,5 @@
 	EnqueueRays(samples, invalidSamples);
 
-	CLEAR_CONTAINER(invalidSamples);
+	//CLEAR_CONTAINER(invalidSamples);
 	//Debug << "generated " <<  numSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
 	return (int)simpleRays.size();
@@ -599,6 +593,8 @@
 		VssRay *ray = *vit;
 
-		if (!HandleRay(ray))
-			invalidSamples.push_back(ray);
+		HandleRay(ray);
+
+		//if (!HandleRay(ray));
+		//	invalidSamples.push_back(ray);
 	}
 }
@@ -729,5 +725,5 @@
 	//exporter->SetFilled();
 
-	DEL_PTR(exporter);
+	delete exporter;
 }
 
@@ -820,10 +816,14 @@
 	vector<ViewCellPoints *> *vcPoints = mViewCellsManager->GetViewCellPoints();
 
+	
+	int i = 0;
 	if (!vcPoints->empty())
 	{
+		cout << "loading view cell list" << endl;
+		
 		vector<ViewCellPoints *>::const_iterator vit, vit_end = vcPoints->end();
 
 		for (vit = vcPoints->begin(); vit != vit_end; ++ vit)
-		{
+		{//cout << i ++ << " " << (*vit)->first->GetId() << endl;
 			mViewCells.push_back((*vit)->first);
 		}
@@ -913,7 +913,10 @@
 		(*oit)->mCounter = 0;
 	}
-//int dummy = 0;
+	int dummy = 0;
 	while (NextViewCell())// && (dummy < 3))
-	{//++ dummy;
+	{
+		//++ dummy;
+		//if (mProcessedViewCells < 53) continue;
+	
 		long startTime = GetTime();
 		cout << "\n***********************\n" 
@@ -969,5 +972,5 @@
 		// is this really necessary?
 		//ClearRayQueue();
-
+		cout << "finished" << endl;
 		if (mEvaluatePixelError || mExportVisibility)
 		{
@@ -988,5 +991,5 @@
 }
 
-
+/*
 void GvsPreprocessor::ComputeRenderError()
 {
@@ -1012,5 +1015,5 @@
 	}
 }
-
+*/
 
 void GvsPreprocessor::UpdatePvs(ViewCell *currentViewCell)
@@ -1047,4 +1050,6 @@
 void GvsPreprocessor::GetObjectPvs(ObjectContainer &objectPvs) const
 {
+	objectPvs.reserve((int)mTrianglePvs.size());
+
 	BvhLeaf::NewMail();
 
@@ -1056,4 +1061,7 @@
 	
 		BvhLeaf *bv = intersect->mBvhLeaf;
+
+		// hack: reset counter
+		(*oit)->mCounter = 0;
 
 		if (!bv || bv->Mailed())
@@ -1063,6 +1071,4 @@
 
 		objectPvs.push_back(bv);
-		// hack: reset counter
-		(*oit)->mCounter = 0;
 	}
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 2049)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 2053)
@@ -396,6 +396,4 @@
 {
 	//cout << "exchanging pvs" << endl;
-
-	sort(mBvhLeaves.begin(), mBvhLeaves.end(), ilt);
 	ObjectPvs newPvs;
 
@@ -449,7 +447,10 @@
 {
 	ViewCellContainer::const_iterator vit, vit_end = mViewCells.end();
-
+	
+	sort(mBvhLeaves.begin(), mBvhLeaves.end(), ilt);
+
+	//cout << "viewcells : " << mViewCells.size() << endl;
 	for (vit = mViewCells.begin(); vit != vit_end; ++ vit)
-	{//cout << "j";
+	{
 		ExchangePvs(*vit);
 	}
@@ -773,4 +774,5 @@
 		//ViewCellsMap::iterator vit = mViewCells.find(viewCellId);
 //		BspViewCell *viewCell = static_cast<BspViewCell *>((*vit).second);
+
 		BspViewCell *viewCell = static_cast<BspViewCell *>(*vit);
 		if (viewCell->GetId() == viewCellId)
@@ -1508,5 +1510,5 @@
 #endif
 
-	if (0 && PVS_HACK)
+	if (1 && PVS_HACK)
 		handler.ExchangeElements();
 
