Index: GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 2001)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 2002)
@@ -158,5 +158,6 @@
 
   float pContributingRays = contributingRays/(float)vssRays.size();
-  float importance = 1.0f/(pContributingRays + 1e-5);
+  //  float importance = 1.0f/(pContributingRays + 1e-5);
+  float importance = 1.0f;
   // set this values for last contributingRays
   int index = mBufferStart - 1;
@@ -566,4 +567,6 @@
 	mRays[index].ResetReverseMutation();
 	mRays[index].mMutations++;
+	mRays[index].mUnsuccessfulMutations++;
+
 	return true;
   }
@@ -616,5 +619,5 @@
   // optimal for Vienna 0.5f
   
-  float radiusExtension = 0.5f;
+  float radiusExtension = 0.1f;
   //  + mRays[index].mMutations/50.0f;
   
@@ -672,4 +675,6 @@
   if (GenerateMutationCandidate(index, sray, object, box)) {
     mRays[index].mMutations++;
+	mRays[index].mUnsuccessfulMutations++;
+
 	return true;
   }
@@ -738,4 +743,5 @@
   sray = mutationCandidates[id];
   mRays[index].mMutations++;
+  mRays[index].mUnsuccessfulMutations++;
 
   return true;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/run_test2
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2001)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2002)
@@ -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"
@@ -14,7 +14,7 @@
 #VIEWCELLS=../data/PowerPlant/power_plant_viewcells1.xml
 
-#SCENE=../data/soda/soda.dat
+#SCENE=../data/soda/soda5.dat
+#VIEWCELLS=../data/soda/soda-viewcells-5000.xml
 #VIEWCELLS=../data/soda/soda5-viewcells.xml
-#VIEWCELLS=../data/soda/soda-viewcells-5000.xml
 #VIEWCELLS=../data/soda/soda5-viewcells-single.xml
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/OcclusionQuery.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/OcclusionQuery.cpp	(revision 1785)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/OcclusionQuery.cpp	(revision 2002)
@@ -8,5 +8,5 @@
 namespace GtpVisibilityPreprocessor {
 
-bool OcclusionQuery::sUseArbQueries = false;
+bool OcclusionQuery::sUseArbQueries = true;
 
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2001)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2002)
@@ -1150,5 +1150,6 @@
   if (1) {
 	VssRayContainer tmpRays;
-	for (int i=0; i < 200; i++) {
+	int m = 50000;
+	for (int i=m; i < m+20; i++) {
 	  tmpRays.push_back(new VssRay(rays[i].mOrigin,
 								   rays[i].mOrigin + 100.0f*rays[i].mDirection,
@@ -1330,4 +1331,38 @@
 }
 
+bool
+Preprocessor::ExportRayAnimation(const char *filename,
+								 const vector<VssRayContainer> &vssRays
+								 )
+{
+  cout<<"Exporting vss rays..."<<endl<<flush;
+	
+  Exporter *exporter = NULL;
+  exporter = Exporter::GetExporter(filename);
+  if (0) {
+	exporter->SetWireframe();
+	exporter->ExportKdTree(*mKdTree);
+  }
+  exporter->SetFilled();
+  // $$JB temporarily do not export the scene
+  if (1)
+	exporter->ExportScene(mSceneGraph->GetRoot());
+  exporter->SetWireframe();
+
+  if (1) {
+	exporter->SetForcedMaterial(RgbColor(1,0,1));
+	exporter->ExportBox(mViewCellsManager->GetViewSpaceBox());
+	exporter->ResetForcedMaterial();
+  }
+  
+  exporter->ExportRaySets(vssRays, RgbColor(1, 0, 0));
+	
+  delete exporter;
+
+  cout<<"done."<<endl<<flush;
+
+  return true;
+}
+
 void
 Preprocessor::ComputeRenderError()
@@ -1346,4 +1381,5 @@
 	mStats <<
 	  "#AvgPvsRenderError\n" <<renderer->mPvsStat.GetAvgError()<<endl<<
+	  "#AvgPixelError\n" <<renderer->GetAvgPixelError()<<endl<<
 	  "#MaxPvsRenderError\n" <<renderer->mPvsStat.GetMaxError()<<endl<<
 	  "#ErrorFreeFrames\n" <<renderer->mPvsStat.GetErrorFreeFrames()<<endl<<
Index: GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp	(revision 1966)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp	(revision 2002)
@@ -165,37 +165,4 @@
 
 
-bool
-RssPreprocessor::ExportRayAnimation(const char *filename,
-									const vector<VssRayContainer> &vssRays
-									)
-{
-  cout<<"Exporting vss rays..."<<endl<<flush;
-	
-  Exporter *exporter = NULL;
-  exporter = Exporter::GetExporter(filename);
-  if (0) {
-	exporter->SetWireframe();
-	exporter->ExportKdTree(*mKdTree);
-  }
-  exporter->SetFilled();
-  // $$JB temporarily do not export the scene
-  if (1)
-	exporter->ExportScene(mSceneGraph->GetRoot());
-  exporter->SetWireframe();
-
-  if (1) {
-	exporter->SetForcedMaterial(RgbColor(1,0,1));
-	exporter->ExportBox(mViewCellsManager->GetViewSpaceBox());
-	exporter->ResetForcedMaterial();
-  }
-  
-  exporter->ExportRaySets(vssRays, RgbColor(1, 0, 0));
-	
-  delete exporter;
-
-  cout<<"done."<<endl<<flush;
-
-  return true;
-}
 
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 1997)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2002)
@@ -83,5 +83,5 @@
 
 
-
+// reimplemented here so that we can snap the error windows
 float
 QtGlRendererBuffer::GetPixelError(int &pvsSize)
@@ -96,52 +96,9 @@
   unsigned int pixelCount;
 
-  //static int query = -1;
-  //if (query == -1)
-  //	  glGenOcclusionQueriesNV(1, (unsigned int *)&query);
-
-  OcclusionQuery query;
 
   ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint);
   if (viewcell == NULL)
 	return 0.0f;
-
-  if (mDetectEmptyViewSpace) {
-	// now check whether any backfacing polygon would pass the depth test
-	SetupCamera();
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-	glEnable( GL_CULL_FACE );
-	glCullFace(GL_BACK);
-
-	cout<<"RS ";
-	RenderScene();
-	
-	glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
-	glDepthMask(GL_FALSE);
-	glDisable( GL_CULL_FACE );
-
-	query.BeginQuery();
-	
-	cout<<"RS ";
-	RenderScene();
-	cout<<"RS3 ";
-	
-	query.EndQuery();
-	
-	// at this point, if possible, go and do some other computation
-	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-	glDepthMask(GL_TRUE);
-	glEnable( GL_CULL_FACE );
-	
-	// reenable other state
-	pixelCount = query.GetQueryResult();
-	cout<<"RS4 ";
-	
-	if (pixelCount > 0)
-	  return -1.0f; // backfacing polygon found -> not a valid viewspace sample
-
-  } else
-	glDisable( GL_CULL_FACE );
-	
-
+  
   //  ViewCell *viewcell = NULL;
   
@@ -182,6 +139,8 @@
   
   mUseFalseColors = true;
-  
-  query.BeginQuery();
+
+  OcclusionQuery *query = mOcclusionQueries[0];
+
+  query->BeginQuery();
   
   SetupCamera();
@@ -189,15 +148,18 @@
   RenderScene();
   
-  query.EndQuery();
-  
+  query->EndQuery();
   
   // reenable other state
-  pixelCount = query.GetQueryResult();
-  
+  //  int wait=0;
+  //  while (!query.ResultAvailable()) {
+  //  	wait++;
+  //  }
+
+  pixelCount = query->GetQueryResult();
   
   pErrorPixels = ((float)pixelCount)/(GetWidth()*GetHeight());
-
-  
-  if (mSnapErrorFrames && pErrorPixels > 0.001f) {
+  
+  
+  if (mSnapErrorFrames && pErrorPixels > 0.01f) {
 	
 	char filename[256];
Index: GTP/trunk/Lib/Vis/Preprocessing/src/default.env
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 1989)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 2002)
@@ -39,8 +39,12 @@
 Preprocessor {
 	totalSamples 250000000
+#	totalSamples 2000000
 	samplesPerPass 1000000
+	samplesPerEvaluation 5000000
+
+
 #	initialSamples 2000000
-	samplesPerEvaluation 5000000
-
+
+	exportObj false
 	delayVisibilityComputation false
 	# stored sample rays
@@ -57,6 +61,6 @@
 #	type render
 	detectEmptyViewSpace true
-	pvsRenderErrorSamples 0
-#	pvsRenderErrorSamples 1000
+#	pvsRenderErrorSamples 0
+	pvsRenderErrorSamples 5000
 	quitOnFinish false
 	computeVisibility true
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2001)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2002)
@@ -129,4 +129,9 @@
 			   );
 
+  bool
+  ExportRayAnimation(const char *filename,
+					 const vector<VssRayContainer> &vssRays
+					 );
+
 	virtual int
 		GenerateRays(const int number,
Index: GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.h	(revision 1931)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.h	(revision 2002)
@@ -71,8 +71,4 @@
 
 
-  bool
-  ExportRayAnimation(const char *filename,
-					 const vector<VssRayContainer> &vssRays
-					 );
 
   void
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 1997)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2002)
@@ -89,6 +89,6 @@
   mUseForcedColors = false;
   mRenderBoxes = false;
-  //mUseGlLists = true;
-  mUseGlLists = false;
+  mUseGlLists = true;
+  //mUseGlLists = false;
 
   Environment::GetSingleton()->GetIntValue("Preprocessor.pvsRenderErrorSamples", mPvsStatFrames);
@@ -328,4 +328,6 @@
   
   glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
+  
+  OcclusionQuery::GenQueries(mOcclusionQueries, 10);
 }
 
@@ -363,7 +365,31 @@
 {
   ObjectContainer::const_iterator oi = mObjects.begin();
-
   for (; oi != mObjects.end(); oi++)
 	RenderIntersectable(*oi);
+}
+
+void
+GlRenderer::_RenderSceneTriangles()
+{
+  glBegin(GL_TRIANGLES);
+
+  ObjectContainer::const_iterator oi = mObjects.begin();
+  for (; oi != mObjects.end(); oi++) {
+	
+	if ((*oi)->Type() == Intersectable::TRIANGLE_INTERSECTABLE) {
+	  TriangleIntersectable *object = (TriangleIntersectable *)*oi;
+	  Triangle3 &t = object->GetItem();
+	  
+	  Vector3 normal = t.GetNormal();
+	  glNormal3f(normal.x, normal.y, normal.z);
+	  glVertex3f(t.mVertices[0].x, t.mVertices[0].y, t.mVertices[0].z);
+	  glVertex3f(t.mVertices[1].x, t.mVertices[1].y, t.mVertices[1].z);
+	  glVertex3f(t.mVertices[2].x, t.mVertices[2].y, t.mVertices[2].z);
+	  
+	}
+  }
+
+  glEnd();
+  
 }
 
@@ -377,5 +403,5 @@
 	  glList = glGenLists(1);
 	  glNewList(glList, GL_COMPILE);
-	  _RenderScene();
+	  _RenderSceneTriangles();
 	  glEndList();
 	}
@@ -383,5 +409,5 @@
 	glCallList(glList);
   } else
-	_RenderScene();
+	_RenderSceneTriangles();
 	
   
@@ -826,4 +852,5 @@
 	mPvsErrorBuffer[i].mError = 1.0f;
   }
+  mPvsStat.maxError = 0.0f;
 }
 
@@ -1270,5 +1297,4 @@
   halton.Reset();
 
-
   SetupProjection(GetWidth(), GetHeight());
 
@@ -1281,4 +1307,15 @@
 	RandomViewPoint();
 
+ 	if (mPvsErrorBuffer[i].mError == 1.0f) {
+	  // check if the view point is valid
+	  if (!ValidViewPoint())
+		mPvsErrorBuffer[i].mError = -1.0f;
+
+	  // manualy corrected view point
+	  if (mFrame == 5105)
+		mPvsErrorBuffer[i].mError = -1.0f;
+	}
+	
+	
 	// atlanta problematic frames: 325 525 691 1543
 #if 0
@@ -1293,8 +1330,7 @@
 #endif
 	
-	if (mPvsErrorBuffer[i].mError > 0.0f) {
+ 	if (mPvsErrorBuffer[i].mError > 0.0f) {
 	  int pvsSize;
-
-
+	  
 	  float error = GetPixelError(pvsSize);
 	  mPvsErrorBuffer[i].mError = error;
@@ -1303,5 +1339,4 @@
 	  //	  emit UpdatePvsErrorItem(i,
 	  //							  mPvsErrorBuffer[i]);
-
 	  cout<<"("<<i<<","<<mPvsErrorBuffer[i].mError<<")";
 	  //	  swapBuffers();
@@ -1321,181 +1356,62 @@
 	}
   }
-
+  
   glFinish();
   cout<<endl<<flush;
-
-}
-
+}
+
+bool
+GlRenderer::ValidViewPoint()
+{
+  if (!mDetectEmptyViewSpace)
+	return true;
+
+  OcclusionQuery *query = mOcclusionQueries[0];
+
+  // now check whether any backfacing polygon would pass the depth test
+  SetupCamera();
+  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+  glEnable( GL_CULL_FACE );
+  glCullFace(GL_BACK);
+  
+  //  cout<<"VV1 ";
+  RenderScene();
+  
+  glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+  glDepthMask(GL_FALSE);
+  glDisable( GL_CULL_FACE );
+  
+  query->BeginQuery();
+  
+  //  cout<<"VV2 ";
+  RenderScene();
+  //  cout<<"VV3 ";
+  
+  query->EndQuery();
+  
+  // at this point, if possible, go and do some other computation
+  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+  glDepthMask(GL_TRUE);
+  glEnable( GL_CULL_FACE );
+
+  //  int wait = 0;
+  //  while (!query.ResultAvailable()) {
+  //	wait++;
+  //  }
+  
+  // reenable other state
+  unsigned int pixelCount = query->GetQueryResult();
+  //  cout<<"VV4 ";
+  
+  if (pixelCount > 0)
+	return false; // backfacing polygon found -> not a valid viewspace sample
+
+  return true;
+}
 
 float
 GlRenderer::GetPixelError(int &pvsSize)
 {
-  float pErrorPixels = -1.0f;
-  
-  glReadBuffer(GL_BACK);
-  
-  //  mUseFalseColors = true;
-  
-  mUseFalseColors = false;
-  unsigned int pixelCount;
-
-  //static int query = -1;
-  //if (query == -1)
-  //	  glGenOcclusionQueriesNV(1, (unsigned int *)&query);
-
-  OcclusionQuery query;
-
-  ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint);
-  if (viewcell == NULL)
-	return 0.0f;
-
-  if (mDetectEmptyViewSpace) {
-	// now check whether any backfacing polygon would pass the depth test
-	SetupCamera();
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-	glEnable( GL_CULL_FACE );
-	glCullFace(GL_BACK);
-
-	cout<<"RS ";
-	RenderScene();
-	
-	glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
-	glDepthMask(GL_FALSE);
-	glDisable( GL_CULL_FACE );
-
-	query.BeginQuery();
-	
-	cout<<"RS ";
-	RenderScene();
-	cout<<"RS3 ";
-	
-	query.EndQuery();
-	
-	// at this point, if possible, go and do some other computation
-	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-	glDepthMask(GL_TRUE);
-	glEnable( GL_CULL_FACE );
-	
-	// reenable other state
-	pixelCount = query.GetQueryResult();
-	cout<<"RS4 ";
-	
-	if (pixelCount > 0)
-	  return -1.0f; // backfacing polygon found -> not a valid viewspace sample
-
-  } else
-	glDisable( GL_CULL_FACE );
-	
-
-  //  ViewCell *viewcell = NULL;
-  
-  //  PrVs prvs;
-  
-  //  mViewCellsManager->SetMaxFilterSize(0);
-  //  mViewCellsManager->GetPrVS(mViewPoint, prvs, mViewCellsManager->GetFilterWidth());
-  //  viewcell = prvs.mViewCell;
-  
-  ObjectPvs pvs;
-  if (1) {
-	pvs = viewcell->GetPvs();
-  } else {
-	mViewCellsManager->ApplyFilter2(viewcell,
-									false,
-									1.0f,
-									pvs);
-  }
-  
-  SetupCamera();
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-  glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE);
-  
-  
-  // 	// Render PVS
-  ObjectPvsIterator it = pvs.GetIterator();
-  
-  pvsSize = pvs.GetSize();
-  Intersectable::NewMail();
-  for (; it.HasMoreEntries(); ) {
-	ObjectPvsEntry entry = it.Next();
-	Intersectable *object = entry.mObject;
-	RenderIntersectable(object);
-  }
-  
-  //	glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
-  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-  
-  mUseFalseColors = true;
-  
-  query.BeginQuery();
-  
-  SetupCamera();
-  
-  RenderScene();
-  
-  query.EndQuery();
-  
-  
-  // reenable other state
-  pixelCount = query.GetQueryResult();
-  
-  
-  pErrorPixels = ((float)pixelCount)/(GetWidth()*GetHeight());
-
-#if 0  
-  if (mSnapErrorFrames && pErrorPixels > 0.001f) {
-	
-	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 (1) { //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);
-	SetupCamera();
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-	
-	// Render PVS
-	Intersectable::NewMail();
-
-	ObjectPvsIterator it = pvs.GetIterator();
-	for (; it.HasMoreEntries(); ) {
-	  ObjectPvsEntry entry = it.Next();
-	  Intersectable *object = entry.mObject;
-	  RenderIntersectable(object);
-	}
-	
-	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();
-  }
-#endif
-  
-  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-  
-  return pErrorPixels;
+  return -1.0f;
 }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2001)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2002)
@@ -1,5 +1,5 @@
 #############################################################################
 # Makefile for building: preprocessor
-# Generated by qmake (2.00a) (Qt 4.1.2) on: pá 19. I 15:33:39 2007
+# Generated by qmake (2.00a) (Qt 4.1.2) on: so 20. I 14:03:52 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 1996)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 2002)
@@ -163,9 +163,9 @@
   int i;
 
-  if (depth%5==0)
-  	offset = 3;
-  
-  for (i=offset; i < offset+3; i++) {
-	float diff = box[i+6] - box[i];
+  // if (depth%4==0)
+  //  	offset = 3;
+  
+  for (i=offset; i < offset + 3; i++) {
+	float diff = box[i + 6] - box[i];
 	if (diff > maxDiff) {
 	  maxDiff = diff;
@@ -184,5 +184,5 @@
 	while(rays[i].GetParam(axis) < x && i<=j)
 	  i++;
-	while(x < rays[j].GetParam(axis) && i<=j)
+	while(x <= rays[j].GetParam(axis) && i<=j)
 	  j--;
 	
@@ -194,5 +194,5 @@
   } while (i<=j);
   
-  if (l + 64 < j ) {
+  if (l + 4 < j ) {
 	// set new max
 	float save = box[axis+6];
@@ -202,5 +202,5 @@
   }
   
-  if (i + 64 < r) {
+  if (i + 4 < r) {
 	// set new min
 	box[axis] = x;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp	(revision 1984)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp	(revision 2002)
@@ -55,5 +55,5 @@
 											  buff);
   
-
+  
   mMixtureDistribution = new MixtureDistribution(*this);
   mMixtureDistribution->Construct(buff);
@@ -66,4 +66,10 @@
   mPass = 0;
   
+
+  
+  bool mExportAnimation = false;
+  vector<VssRayContainer> rayBuffer;
+  
+
   long startTime = GetTime();
   for (int i=0; i < mTotalSamples; i += mSamplesPerPass, mPass++) {
@@ -93,4 +99,10 @@
 	  ExportRays(filename, vssRays, mExportNumRays);
 
+
+	  if (mExportAnimation) {
+		rayBuffer.push_back(VssRayContainer());
+		vssRays.SelectRays(mExportNumRays, rayBuffer[rayBuffer.size()-1], true);
+	  }
+
 	  Debug<<"done."<<endl<<flush;
 	}
@@ -106,4 +118,9 @@
 		"#RssSamples\n" <<totalVssRays<<endl;
 	  lastEvaluation = i;
+
+	  if (renderer) {
+		ComputeRenderError();
+	  }
+	  
 	}
 
@@ -120,11 +137,15 @@
 	//	  CLEAR_CONTAINER(vssRays);
 
-	if (renderer) {
-	  ComputeRenderError();
-	}
 	
   }
+  
+  EvalViewCellHistogram();
 
-  EvalViewCellHistogram();
+  if (mExportAnimation && mExportRays) {
+	char filename[64];
+	sprintf(filename, "rss-rays-i.x3d");
+	//rayBuffer.resize(mPass);
+	ExportRayAnimation(filename, rayBuffer);
+  }
 
   return true;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 1997)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2002)
@@ -137,4 +137,7 @@
 
   void
+  _RenderSceneTriangles();
+
+  void
   RenderViewPoint();
 
@@ -142,4 +145,6 @@
   SetupProjection(const int w, const int h, const float angle = 70.0f);
 
+  virtual bool
+  ValidViewPoint();
   
   virtual float
@@ -166,5 +171,8 @@
   virtual void ClearErrorBuffer();
   
-
+  virtual float GetAvgPixelError() {
+	return mPvsStat.GetAvgError()*GetWidth()*GetHeight();
+  }
+  
 public:
 
