Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2612)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2613)
@@ -102,4 +102,6 @@
 {
 
+  MakeCurrent();
+
   float pErrorPixels = -1.0f;
 
@@ -113,7 +115,6 @@
 		return 0.0f;
 
-
 	ObjectPvs pvs;
-
+	
 	if (1) 
 		pvs = viewcell->GetPvs();
@@ -121,7 +122,10 @@
 		mViewCellsManager->ApplyFilter2(viewcell, false, 1.0f, pvs);
 
+	mUseForcedColors = true;
+
 	SetupCamera();
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
 	glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE);
+	glColor3f(0,1,0);
 
 
@@ -133,4 +137,5 @@
 
 	pvsSize = pvs.GetSize();
+	cout<<pvsSize<<endl;
 
 	Intersectable::NewMail();
@@ -140,19 +145,20 @@
 	  }
 
-
 	//glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
 	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
 	glEnable(GL_STENCIL_TEST); 
-
-	mUseFalseColors = true;
-
+	glColor3f(1,0,0);
+
+	
 	OcclusionQuery *query = mOcclusionQueries[0];
-	
+
+	//	SetupCamera();
+
+	Intersectable::NewMail();
+
 	query->BeginQuery();
 
-	SetupCamera();
-
 	RenderScene();
-
+	
 	query->EndQuery();
 	glDisable(GL_STENCIL_TEST); 
@@ -166,10 +172,12 @@
 
 	pixelCount = query->GetQueryResult();
-
+	//	cout<<"pc="<<pixelCount<<endl;
+	
 	pErrorPixels = ((float)pixelCount)/(GetWidth()*GetHeight());
 
 
-	if (mSnapErrorFrames && pErrorPixels >= 0.01f) {
+	if (mSnapErrorFrames && (0 && pErrorPixels >= 0.01f)) {
 	  glReadBuffer(GL_BACK);
+	  //glReadBuffer(GL_FRONT);
 	  
 	  char filename[256];
@@ -180,5 +188,5 @@
 	  
 	  im.save(qstr, "PNG");
-	  if (1) { //0 && mFrame == 1543) {
+	  if (0) { //0 && mFrame == 1543) {
 		int x,y;
 		int lastIndex = -1;
@@ -196,10 +204,8 @@
 	  }
 	  
-	  
 	  mUseFalseColors = false;
 	  glPushAttrib(GL_CURRENT_BIT);
 	  glColor3f(0,1,0);
 	  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-	  SetupCamera();
 	  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 	  
@@ -207,4 +213,5 @@
 	  Intersectable::NewMail();
 	  
+	  
 	  ObjectPvsIterator it = pvs.GetIterator();
 	  for (; it.HasMoreEntries(); ) 
@@ -212,4 +219,6 @@
 		  RenderIntersectable(it.Next());
 		}
+
+	  mUseForcedColors = false;
 	  
 	  im = toImage();
@@ -222,5 +231,7 @@
 	
 	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-	
+
+	DoneCurrent();
+
 	return pErrorPixels;
 }
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/default.env
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 2611)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 2613)
@@ -176,5 +176,5 @@
 		maxCostRatio 0.98
 		ct_div_ci 0.5
-		maxNodes 50000
+		maxNodes 200000
 #500000	
 	}
@@ -196,6 +196,6 @@
 	}
 
-#	splitMethod spatialMedian
-	splitMethod SAH
+	splitMethod spatialMedian
+#	splitMethod SAH
 	splitBorder 0.01
 }
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2612)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2613)
@@ -25,4 +25,7 @@
 #endif
 
+// if 1 = SAFE RENDERING OF PVS primitives without VBOs for Pvs error estimation
+#define EVAL_ERROR 0
+
 namespace GtpVisibilityPreprocessor {
 
@@ -97,4 +100,5 @@
 	Environment::GetSingleton()->GetBoolValue("Preprocessor.detectEmptyViewSpace",
 		                                      mDetectEmptyViewSpace);
+
 	mSnapErrorFrames = true;
 	mSnapPrefix = "snap/";
@@ -135,5 +139,4 @@
 {
 	Triangle3 *t = &(object->GetItem());
-
 	glBegin(GL_TRIANGLES);
 	Vector3 normal = t->GetNormal();
@@ -786,5 +789,5 @@
 	if (node->IsLeaf()) 
 	{
-#if 1
+#if !EVAL_ERROR
 		RenderKdLeaf(static_cast<KdLeaf *>(node));
 #else
@@ -1464,8 +1467,5 @@
 	  int pvsSize;
 
-	  cerr<<"GPE"<<endl;
-
 	  float error = GetPixelError(pvsSize);
-	  cerr<<"GPEd"<<endl;
 
 	  mPvsErrorBuffer[i].mError = error;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/SG08/run_test_pixel
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/SG08/run_test_pixel	(revision 2612)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/SG08/run_test_pixel	(revision 2613)
@@ -4,5 +4,5 @@
 #COMMAND="./release/preprocessor.exe -preprocessor_quit_on_finish+"
 #COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -samples_per_pass=500000 -samples_per_evaluation=10000000 -total_samples=500000000 -preprocessor_pvs_rendererror_samples=10000 -preprocessor_evaluatePixelError+"
-COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -samples_per_pass=1000000 -samples_per_evaluation=500000 -total_samples=500000000 -preprocessor_pvs_rendererror_samples=10000 -preprocessor_evaluatePixelError+ -preprocessor_detect_empty_viewspace+"
+COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -samples_per_pass=1000000 -samples_per_evaluation=10000000 -total_samples=500000000 -preprocessor_pvs_rendererror_samples=10000 -preprocessor_evaluatePixelError+ -preprocessor_detect_empty_viewspace+ -kd_pvs_area=1e-4"
 
 #SCENE="../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d"
@@ -43,5 +43,5 @@
 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
 -rss_distributions=mutation+object_direction+spatial -view_cells_filter_max_size=1 \
--view_cells_use_kd_pvs+ -af_use_kd_pvs- \
+-view_cells_use_kd_pvs+ -af_use_kd_pvs+ \
 -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4l.xml \
 -preprocessor_stats=$PREFIX-i-mixed-b1-n4l.log \
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/CHCRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/CHCRenderer.cpp	(revision 2562)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/CHCRenderer.cpp	(revision 2613)
@@ -90,5 +90,5 @@
 	Environment::GetSingleton()->GetBoolValue("Preprocessor.detectEmptyViewSpace",
 		                                      mDetectEmptyViewSpace);
-	mSnapErrorFrames = true;
+	mSnapErrorFrames = false;
 	mSnapPrefix = "snap/";
 	mUseForcedColors = false;
