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();
