Index: GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp	(revision 2643)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp	(revision 2662)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2660)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2662)
@@ -132,7 +132,7 @@
 {
 
-  MakeCurrent();
-
-  float pErrorPixels = -1.0f;
+	MakeCurrent();
+
+	float pErrorPixels = -1.0f;
 
 
@@ -142,6 +142,4 @@
 
 	ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint);
-	
-	//cout << "vp: " << mViewPoint << endl;
 
 	if (viewcell == NULL)
@@ -154,11 +152,11 @@
 
 	if (!evaluateFilter) 
-	  pvs = viewcell->GetPvs();
+		pvs = viewcell->GetPvs();
 	else {
 
-	  mViewCellsManager->ApplyFilter2(viewcell,
-									  false,
-									  mViewCellsManager->GetFilterWidth(),
-									  pvs);
+		mViewCellsManager->ApplyFilter2(viewcell,
+			false,
+			mViewCellsManager->GetFilterWidth(),
+			pvs);
 	}
 
@@ -174,10 +172,8 @@
 	glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); 
 
-
 	pvsSize = pvs.GetSize();
-	cout << "vc id: " << viewcell->GetId() << " pvs: " << pvsSize << endl;
 	
 	RenderPvs(pvs);
-	
+
 	//glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
 	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
@@ -185,9 +181,7 @@
 	glColor3f(1,0,0);
 
-	
+
 	OcclusionQuery *query = mOcclusionQueries[0];
 
-	//	SetupCamera();
-
 	Intersectable::NewMail();
 
@@ -195,5 +189,5 @@
 
 	RenderScene();
-	
+
 	query->EndQuery();
 	glDisable(GL_STENCIL_TEST); 
@@ -204,56 +198,60 @@
 	//  	wait++;
 	//  }
-	
+
 
 	pixelCount = query->GetQueryResult();
-	//	cout<<"pc="<<pixelCount<<endl;
-	
-	pErrorPixels = ((float)pixelCount)/(GetWidth()*GetHeight());
-
-
-	if (mSnapErrorFrames && (pErrorPixels >= 0.01f)) {
-	  glReadBuffer(GL_BACK);
-	  //glReadBuffer(GL_FRONT);
-	  
-	  char filename[256];
-	  sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels);
-	  QImage im = toImage();
-	  string str = mSnapPrefix + filename;
-	  QString qstr(str.c_str());
-	  
-	  im.save(qstr, "PNG");
-	  if (0) { //0 && mFrame == 1543) {
-		int x,y;
-		int lastIndex = -1;
-		for (y=0; y < im.height(); y++)
-		  for (x=0; x < im.width(); x++) {
-			QRgb p = im.pixel(x,y);
-			int index = qRed(p) + (qGreen(p)<<8) + (qBlue(p)<<16);
-			if (qGreen(p) != 255 && index!=0) {
-			  if (index != lastIndex) {
-				//				Debug<<"ei="<<index<<" ";
-				lastIndex = index;
-			  }
-			}
-		  }
-	  }
-	  
-	  mUseFalseColors = false;
-	  glPushAttrib(GL_CURRENT_BIT);
-	  glColor3f(0,1,0);
-	  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-	  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-	  
-	  RenderPvs(pvs);
-
-	  mUseForcedColors = false;
-	  im = toImage();
-	  sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels);
-	  str = mSnapPrefix + filename;
-	  qstr = str.c_str();
-	  im.save(qstr, "PNG");
-	  glPopAttrib();
-	}
-	
+
+	if ((pixelCount > 0) && (pvsSize > 0))
+	{
+		cout << "vc id: " << viewcell->GetId() << " pvs: " << pvsSize << " pc: " << pixelCount << endl;
+	}
+
+	pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight());
+
+
+	if (mSnapErrorFrames && (pixelCount > 0)) {
+		glReadBuffer(GL_BACK);
+		//glReadBuffer(GL_FRONT);
+
+		char filename[256];
+		sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels);
+		QImage im = toImage();
+		string str = mSnapPrefix + filename;
+		QString qstr(str.c_str());
+
+		im.save(qstr, "PNG");
+		if (0) { //0 && mFrame == 1543) {
+			int x,y;
+			int lastIndex = -1;
+			for (y=0; y < im.height(); y++)
+				for (x=0; x < im.width(); x++) {
+					QRgb p = im.pixel(x,y);
+					int index = qRed(p) + (qGreen(p)<<8) + (qBlue(p)<<16);
+					if (qGreen(p) != 255 && index!=0) {
+						if (index != lastIndex) {
+							//				Debug<<"ei="<<index<<" ";
+							lastIndex = index;
+						}
+					}
+				}
+		}
+
+		mUseFalseColors = false;
+		glPushAttrib(GL_CURRENT_BIT);
+		glColor3f(0,1,0);
+		glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+		RenderPvs(pvs);
+
+		mUseForcedColors = false;
+		im = toImage();
+		sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels);
+		str = mSnapPrefix + filename;
+		qstr = str.c_str();
+		im.save(qstr, "PNG");
+		glPopAttrib();
+	}
+
 	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
 
@@ -614,9 +612,4 @@
 	glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); 
 
-	//mUseForcedColors = true;
-
-	//	glColor3f(0.0f, 0.8f, 0.2f);
-	//	glColor3f(0.5f, 0.5f, 0.5f);
-
 	glColor3f(0.6f, 0.6f, 0.6f);
 
@@ -626,16 +619,15 @@
 	glEnable(GL_STENCIL_TEST); 
 
-	//mUseFalseColors = true;
-
 	glDisable(GL_LIGHTING);
+
+	SetupCamera();
+
+	mUseForcedColors = true;
+
+	glColor3f(1.0f, 0.0f, 0.0f);
+
 
 	OcclusionQuery *query = mOcclusionQueries[0];
 	query->BeginQuery();
-
-	SetupCamera();
-
-	mUseForcedColors = true;
-
-	glColor3f(1.0f, 0.0f, 0.0f);
 
 	RenderScene();
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2653)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2662)
@@ -125,4 +125,5 @@
 
 #endif
+
 	mFrame = 0;
 	mWireFrame = false;
@@ -1533,18 +1534,5 @@
 		mPvsErrorBuffer[i].mError = -1.0f;
 	}
-	
-	
-	// atlanta problematic frames: 325 525 691 1543
-#if 0
-	if (mFrame != 325 &&
-		mFrame != 525 &&
-		mFrame != 691 &&
-		mFrame != 1543)
-	  mPvsErrorBuffer[i] = -1;
-	else {
-	  Debug<<"frame ="<<mFrame<<" vp="<<mViewPoint<<" vd="<<mViewDirection<<endl;
-	}
-#endif
-	
+
 
  	if (mPvsErrorBuffer[i].mError > 0.0f) {
@@ -1615,68 +1603,75 @@
 void GlRenderer::EvalPvsStat(const SimpleRayContainer &viewPoints)
 {
-  mPvsStat.Reset();
-
-  SetupProjection(GetWidth(), GetHeight());
-  
-  cout << "mPvsStatFrames=" << viewPoints.size() << endl;
-  
-  SimpleRayContainer::const_iterator sit, sit_end = viewPoints.end();
-  int i = 0;
-  
-  for (sit = viewPoints.begin(); sit != sit_end; ++ sit, ++ i) 
-	{
-	  //cout << "\n\nvp: " << (*sit) << endl;
-	  SimpleRay sray = *sit;
-	  
-	  // set frame id for saving the error buffer
-	  mFrame = i;
-	  mViewPoint = sray.mOrigin;
-	  mViewDirection = sray.mDirection;
-
-	  // skip all frames which have already 0 pixel error
-	  // $$ Reverted back by JB for efficiency
-	  if (mPvsErrorBuffer[i].mError > 0.0f) 
-	  {
-		  int pvsSize;
-
-		  // compute the pixel error
-		  float error = GetPixelError(pvsSize);
-		  
-		  mPvsErrorBuffer[i].mError = error;
-		  mPvsErrorBuffer[i].mPvsSize = pvsSize;
-
-		  cout << "(" << i << "," << mViewPoint << "," << mViewDirection << mPvsErrorBuffer[i].mError <<")";
-		  //		  cout << "(vc: " << i << ", er: " << mPvsErrorBuffer[i].mError <<")" << endl;
-	  }
-
-	  const float err = mPvsErrorBuffer[i].mError;
-
-	  // do not account for the case that no PVS is rendered - hack for 08 rebuttal GVS evaluation
-	  // (correct would be >=0.0f)
-	  if (err >= 0.0f && err < 0.99999f) 
-	  {
-		  if (err > mPvsStat.maxError)
-		  {
-			  mPvsStat.maxError = err;
-			  cout << "new max error: " << mPvsStat.maxError << endl;
-		  }
-
-		  mPvsStat.sumError += err;
-		  mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize;
-
-		  if (err == 0.0f)
-			  ++ mPvsStat.errorFreeFrames;
-
-		  // $$ JB
-		  // moved it back here not to count frames with negative err (backfacing triangle)
-		  ++ mPvsStat.frames;
-	  }
-	  
-	}
-  
-  glFinish();
-
-  
-  cout << endl << flush;
+	mPvsStat.Reset();
+
+	SetupProjection(GetWidth(), GetHeight());
+
+	cout << "mPvsStatFrames=" << viewPoints.size() << endl;
+
+	SimpleRayContainer::const_iterator sit, sit_end = viewPoints.end();
+
+	int i = 0;
+
+	for (sit = viewPoints.begin(); sit != sit_end; ++ sit, ++ i) 
+	{
+		//cout << "\n\nvp: " << (*sit) << endl;
+		SimpleRay sray = *sit;
+		int pvsSize = 0;
+
+		// set frame id for saving the error buffer
+		mFrame = i;
+		mViewPoint = sray.mOrigin;
+		mViewDirection = sray.mDirection;
+
+		// skip all frames which have already 0 pixel error
+		// $$ Reverted back by JB for efficiency
+		if (mPvsErrorBuffer[i].mError > 0.0f) 
+		{
+			// compute the pixel error
+			float error = GetPixelError(pvsSize);
+
+			mPvsErrorBuffer[i].mError = error;
+			mPvsErrorBuffer[i].mPvsSize = pvsSize;
+
+			int pixelError = (int)mPvsErrorBuffer[i].mError * GetWidth() * GetHeight();
+
+			if (0 && (pixelError > 0) && (pvsSize > 0)) 
+			{
+				cout << "!err: " << i << "," << mViewPoint << "," << mViewDirection << " " << mPvsErrorBuffer[i].mError * GetWidth() * GetHeight() << endl;
+			}
+		}
+
+		const float err = mPvsErrorBuffer[i].mError;
+
+		// hack:
+		// do not account for the case that no PVS is rendered - hack for 08 rebuttal GVS evaluation
+		// drop the first frame (for some reason, the first frame yields wrong pixel error)
+		
+		if ((mFrame > 0) && (err >= 0.0f) && (err < (1.0f - 1e-6f)) && (pvsSize > 0)) 
+		{
+			if (err > mPvsStat.maxError)
+			{
+				mPvsStat.maxError = err;
+
+				cout << "new max error: " << mPvsStat.maxError * GetWidth()*GetHeight()  << endl;
+			}
+
+			mPvsStat.sumError += err;
+			mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize;
+
+			if (err == 0.0f)
+				++ mPvsStat.errorFreeFrames;
+
+			// $$ JB
+			// moved it back here not to count frames with negative err (backfacing triangle)
+			++ mPvsStat.frames;
+		}
+
+	}
+
+	glFinish();
+
+
+	cout << endl << flush;
 }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.cpp	(revision 2655)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.cpp	(revision 2662)
@@ -85,4 +85,6 @@
 #ifdef USE_HAVRAN_RAYCASTER 
   return mKtbtree->ExportBinTree(filename);
+#else
+	return false;
 #endif
 }
@@ -92,5 +94,7 @@
 {
 #ifdef USE_HAVRAN_RAYCASTER 
-  return mKtbtree->ImportBinTree(filename, objects);
+	return mKtbtree->ImportBinTree(filename, objects);
+#else
+	return false;
 #endif
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor05.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor05.vcproj	(revision 2660)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor05.vcproj	(revision 2662)
@@ -100,5 +100,5 @@
 			Name="Release|Win32"
 			OutputDirectory="..\bin\$(ConfigurationName)"
-			IntermediateDirectory="$(SolutionDir)\obj05\$(ConfigurationName)"
+			IntermediateDirectory="..\obj05\$(ConfigurationName)"
 			ConfigurationType="1"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2648)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2662)
@@ -846,42 +846,47 @@
 		{
 			mViewCells.push_back((*vit)->first);
+
+			if (mViewCells.size() >= mMaxViewCells)
+				break;
 		}
-
-		return;
-	}
-
-	while ((int)mViewCells.size() < mMaxViewCells)
-    {
-		if (0)
+	}
+	else
+	{
+		while ((int)mViewCells.size() < mMaxViewCells)
 		{
-			mViewCells.push_back(mViewCellsManager->GetViewCell((int)mViewCells.size()));
-			continue;
-		}
-		
-		// HACK
-		const int tries = 10000;
-		int i = 0;
-
-		for (i = 0; i < tries; ++ i)
-		{
-			const int idx = (int)RandomValue(0.0f, (float)mViewCellsManager->GetNumViewCells() - 0.5f);
-	
-			ViewCell *viewCell = mViewCellsManager->GetViewCell(idx);
-
-			if (!viewCell->Mailed())
+			if (0)
 			{
-				viewCell->Mail();
+				mViewCells.push_back(mViewCellsManager->GetViewCell((int)mViewCells.size()));
+				continue;
+			}
+
+			// HACK
+			const int tries = 10000;
+			int i = 0;
+
+			for (i = 0; i < tries; ++ i)
+			{
+				const int idx = (int)RandomValue(0.0f, (float)mViewCellsManager->GetNumViewCells() - 0.5f);
+
+				ViewCell *viewCell = mViewCellsManager->GetViewCell(idx);
+
+				if (!viewCell->Mailed())
+				{
+					viewCell->Mail();
+					break;
+				}
+
+				mViewCells.push_back(viewCell);
+			}
+
+			if (i == tries)
+			{
+				cerr << "big error! no view cell found" << endl;
 				break;
 			}
-
-			mViewCells.push_back(viewCell);
 		}
-
-		if (i == tries)
-		{
-			cerr << "big error! no view cell found" << endl;
-			return;
-		}
-	}
+	}
+
+	cout << "\ncomputing list of " << mViewCells.size() << " view cells" << endl;
 }
 
@@ -1114,13 +1119,4 @@
 		cout << "finished view cell construction" << endl;
 	}
-#if 0
-	else
-	{	
-		//-- test successful view cells loading by exporting them again
-		VssRayContainer dummies;
-		mViewCellsManager->Visualize(mObjects, dummies);
-		mViewCellsManager->ExportViewCells("test.xml.gz", mViewCellsManager->GetExportPvs(), mObjects);
-	}
-#endif
 
 	if (mPerViewCell)
