Index: GTP/trunk/Lib/Vis/Preprocessing/src/run_test2
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2006)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2008)
@@ -2,5 +2,5 @@
 
 #COMMAND="./release/preprocessor.exe -preprocessor_quit_on_finish+"
-COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter+"
+COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer+ -preprocessor_evaluate_filter-"
 
 #SCENE="../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d"
@@ -49,7 +49,7 @@
 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
  -rss_distributions=mutation+object_direction+spatial -view_cells_filter_max_size=1 \
- -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4g.xml \
- -preprocessor_stats=$PREFIX-i-mixed-b1-n4g.log \
- -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4g.hlog
+ -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4h.xml \
+ -preprocessor_stats=$PREFIX-i-mixed-b1-n4h.log \
+ -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4h.hlog
 
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 2006)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 2008)
@@ -1910,6 +1910,7 @@
 					"false");   
 
-   RegisterOption("Preprocessor.Export.rays", optBool, "export_rays=", "false");
-	RegisterOption("Preprocessor.Export.numRays", optInt, "export_num_rays=", "5000");
+   RegisterOption("Preprocessor.Export.rays", optBool, "export_rays", "false");
+   RegisterOption("Preprocessor.Export.animation", optBool, "export_animation", "false");
+   RegisterOption("Preprocessor.Export.numRays", optInt, "export_num_rays=", "5000");
    
 	/*************************************************************************/
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2005)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2008)
@@ -167,6 +167,6 @@
 
 	Environment::GetSingleton()->GetBoolValue("Preprocessor.Export.rays", mExportRays);
+	Environment::GetSingleton()->GetBoolValue("Preprocessor.Export.animation", mExportAnimation);
 	Environment::GetSingleton()->GetIntValue("Preprocessor.Export.numRays", mExportNumRays);
-
 
 	Environment::GetSingleton()->GetIntValue("Preprocessor.samplesPerPass", mSamplesPerPass);
@@ -1201,9 +1201,9 @@
   const long t1 = GetTime();
 
-#if 0
+#if 1
   mRayCaster->SortRays(rays);
   cout<<"Rays sorted in "<<TimeDiff(t1, GetTime())<<" s."<<endl;
 
-  if (1) {
+  if (0) {
 	VssRayContainer tmpRays;
 	int m = 50000;
@@ -1403,5 +1403,5 @@
   exporter->SetFilled();
   // $$JB temporarily do not export the scene
-  if (1)
+  if (0)
 	exporter->ExportScene(mSceneGraph->GetRoot());
   exporter->SetWireframe();
@@ -1439,4 +1439,5 @@
 	  "#AvgPvsRenderError\n" <<renderer->mPvsStat.GetAvgError()<<endl<<
 	  "#AvgPixelError\n" <<renderer->GetAvgPixelError()<<endl<<
+	  "#MaxPixelError\n" <<renderer->GetMaxPixelError()<<endl<<
 	  "#MaxPvsRenderError\n" <<renderer->mPvsStat.GetMaxError()<<endl<<
 	  "#ErrorFreeFrames\n" <<renderer->mPvsStat.GetErrorFreeFrames()<<endl<<
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2002)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2008)
@@ -120,7 +120,10 @@
   
   SetupCamera();
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
   glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE);
-  
+
+
+  glStencilFunc(GL_EQUAL, 0x0, 0x1);
+  glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); 
   
   // 	// Render PVS
@@ -137,4 +140,5 @@
   //	glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
   glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+  glEnable(GL_STENCIL_TEST); 
   
   mUseFalseColors = true;
@@ -142,4 +146,5 @@
   OcclusionQuery *query = mOcclusionQueries[0];
 
+  
   query->BeginQuery();
   
@@ -149,5 +154,5 @@
   
   query->EndQuery();
-  
+  glDisable(GL_STENCIL_TEST); 
   // reenable other state
   //  int wait=0;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/default.env
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 2006)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 2008)
@@ -62,5 +62,5 @@
 	detectEmptyViewSpace true
 #	pvsRenderErrorSamples 0
-	pvsRenderErrorSamples 5000
+	pvsRenderErrorSamples 10000
 	quitOnFinish false
 	computeVisibility true
@@ -83,5 +83,5 @@
 	}
 	Export {
-		rays true
+		rays false
 		numRays 5000
 	}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2003)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2008)
@@ -235,4 +235,5 @@
 
 	bool mExportRays;
+	bool mExportAnimation;
 	int mExportNumRays;
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2006)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2008)
@@ -1,5 +1,5 @@
 #############################################################################
 # Makefile for building: preprocessor
-# Generated by qmake (2.00a) (Qt 4.1.2) on: ne 21. I 01:18:19 2007
+# Generated by qmake (2.00a) (Qt 4.1.2) on: ne 21. I 22:47:46 2007
 # Project:  preprocessor.pro
 # Template: app
@@ -63,5 +63,5 @@
 	$(MAKE) -f $(MAKEFILE).Debug uninstall
 
-Makefile: preprocessor.pro  C:/Qt/4.1.2/mkspecs/win32-msvc2005\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \
+Makefile: preprocessor.pro  C:/Qt/4.1.2/mkspecs/win32-msvc.net\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \
 		C:\Qt\4.1.2\mkspecs\features\qt_config.prf \
 		C:\Qt\4.1.2\mkspecs\features\exclusive_builds.prf \
Index: GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 2002)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 2008)
@@ -163,6 +163,11 @@
   int i;
 
-  // if (depth%4==0)
+  const int batchsize = 8192;
+
+  //  if (r - l < 32*batchsize)
   //  	offset = 3;
+	
+  //  if (depth%5==0)
+  //	offset = 3;
   
   for (i=offset; i < offset + 3; i++) {
@@ -174,5 +179,5 @@
   }
 
-  //  cout<<depth<<" "<<axis<<endl;
+  //  cout<<depth<<" "<<axis<<" "<<l<<" "<<r<<endl;
   
   i=l;
@@ -182,7 +187,7 @@
   //  float x = rays[(l+r)/2].GetParam(axis);
   do {
-	while(rays[i].GetParam(axis) < x && i<=j)
+	while(i<j && rays[i].GetParam(axis) < x)
 	  i++;
-	while(x <= rays[j].GetParam(axis) && i<=j)
+	while(i<j && x < rays[j].GetParam(axis))
 	  j--;
 	
@@ -193,6 +198,7 @@
 	}
   } while (i<=j);
-  
-  if (l + 4 < j ) {
+
+  
+  if (l + batchsize < j ) {
 	// set new max
 	float save = box[axis+6];
@@ -200,11 +206,18 @@
 	_SortRays(rays, l, j, depth+1, box);
 	box[axis+6] = save;
+  } else {
+	//	for (int k=0; k < 6; k++)
+	//	  cout<<k<<" "<<box[k]<<" - "<<box[k+6]<<endl;
   }
   
-  if (i + 4 < r) {
+  if (i + batchsize < r) {
 	// set new min
 	box[axis] = x;
     _SortRays(rays, i, r, depth+1, box);
+  } else {
+	//	for (int k=0; k < 6; k++)
+	//	  cout<<k<<" "<<box[k]<<" - "<<box[k+6]<<endl;
   }
+	
 }
   
Index: GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 2003)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 2008)
@@ -351,5 +351,5 @@
 			// $$matt
 			preprocessor->renderer = 
-				new QtGlRendererBuffer(512, 512,
+				new QtGlRendererBuffer(1024, 1024,
 									   preprocessor->mSceneGraph,
 									   preprocessor->mViewCellsManager,
Index: GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp	(revision 2002)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp	(revision 2008)
@@ -68,5 +68,4 @@
 
   
-  bool mExportAnimation = false;
   vector<VssRayContainer> rayBuffer;
   
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2002)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2008)
@@ -174,4 +174,8 @@
 	return mPvsStat.GetAvgError()*GetWidth()*GetHeight();
   }
+
+  virtual float GetMaxPixelError() {
+	return mPvsStat.GetMaxError()*GetWidth()*GetHeight();
+  }
   
 public:
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2004)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2008)
@@ -653,5 +653,6 @@
 					if (strcmp(curr, "mutation")==0) {
 					  // temp matt: still no mutationstrategy!
-					  //mDistributions.push_back(new MutationBasedDistribution(mPreprocessor));
+					  
+					  mDistributions.push_back(new MutationBasedDistribution(mPreprocessor));
 					}
 	
