Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.sh
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.sh	(revision 2625)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.sh	(revision 2633)
@@ -17,4 +17,7 @@
 SCENE=arena-high-lods
 SCENE_PATH=../data/Arena
+
+SCENE=PompeiiTen
+SCENE_PATH=../data/pompeii
 
 
@@ -37,5 +40,5 @@
 SAMPLES=1000000
 
-METHOD=$VIEWCELLS-viewcells.xml.gz
+METHOD=$VIEWCELLS
  
 echo "$SCENE $METHOD"
Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/demo1.env
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/demo1.env	(revision 2621)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/demo1.env	(revision 2633)
@@ -170,5 +170,5 @@
 
 KdTree {
-	pvsArea   8e-4
+	pvsArea   3e-5
 	sahUseFaces false
 	Termination {
Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_arena.sh
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_arena.sh	(revision 2601)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_arena.sh	(revision 2633)
@@ -12,4 +12,6 @@
 SCENE=../data/Arena/arena-high-lods.obj
 VIEWCELLS=../data/Arena/arena-high-lods-57000-viewcells.xml.gz
+VIEWCELLS=../data/Arena/arena-high-lods-10000-viewcells.xml.gz
+VIEWCELLS=../data/Arena/arena-high-lods-5000-viewcells.xml.gz
 
 LOG_PREFIX=../scripts/tests/sig2008
@@ -29,5 +31,5 @@
 -gvs_initial_samples=16 \
 -gvs_max_viewcells=200 \
--gvs_min_contribution=50 \
+-gvs_min_contribution=200 \
 -gvs_per_viewcell=true \
 -view_cells_filename=$VIEWCELLS \
Index: GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 2598)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 2633)
@@ -145,5 +145,5 @@
 				OptimizeForWindowsApplication="TRUE"
 				AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(QTDIR)\include\Qt&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include&quot;;QtInterface;..\src\sparsehash\src\;..\src\ootl\src\include\ootl;..\src\ootl\src\include\ootl\sandbox;$(NOINHERIT)"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;USE_QT;USE_CG;USE_VERBOSE_PVS;QT_OPENGL_LIB;QT_DLL"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;USE_QT;USE_CG;USE_HASH_PVS;QT_OPENGL_LIB;QT_DLL"
 				StringPooling="TRUE"
 				MinimalRebuild="TRUE"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HashPvs.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HashPvs.h	(revision 2530)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HashPvs.h	(revision 2633)
@@ -150,18 +150,21 @@
 
 	inline int GetSamples() const	{ return mSamples; }
-	}
 
 	void MergeInPlace(const HashPvs<T, S> &a)
 	{
-		cerr << "hashpvs: mergeinplace not implemented yet" << endl;
+		std::cerr << "hashpvs: mergeinplace not implemented yet" << std::endl;
 	}
 
 	inline bool RequiresResortLog() const {	return false; }
 
-	void Reserve(const int n) { // not necessary }
+	void Reserve(const int n) 
+	{ // not necessary 
+	}
 
 	/** Sort pvs entries assume that the pvs contains unique entries
 	*/
-	void SimpleSort() {	// not necessary }
+	void SimpleSort() 
+	{	// not necessary 
+	}
 
 	int SubtractPvs(const HashPvs<T, S> &pvs)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 2621)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 2633)
@@ -126,5 +126,5 @@
 				OptimizeForWindowsApplication="TRUE"
 				AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(CG_INC_PATH)&quot;;Timer;..\src\sparsehash\src\google\sparsehash;..\src\sparsehash\src\windows;..\src\sparsehash\src\google;..\src\sparsehash\src;..\src\ootl\;..\src\ootl\src\;..\src\ootl\src\cpp;..\src\ootl\src\cpp\include\;..\src\ootl\src\include\ootl;..\src\ootl\src\include\ootl\sandbox;..\src\ootl\src\cpp\include\ootl\mswin;..\src\havran"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GTP_INTERNAL;USE_QT;USE_VERBOSE_PVS;USE_CG"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GTP_INTERNAL;USE_QT;USE_HASH_PVS;USE_CG"
 				StringPooling="TRUE"
 				MinimalRebuild="TRUE"
@@ -1074,8 +1074,8 @@
 			</File>
 			<File
+				RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h">
+			</File>
+			<File
 				RelativePath=".\sparsehash\src\windows\hash_fun.h">
-			</File>
-			<File
-				RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h">
 			</File>
 			<File
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2627)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2633)
@@ -304,4 +304,17 @@
 	GlRenderer::InitGL();
 
+	GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0};
+    GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0};
+    GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0};
+    GLfloat light_position[] =  //{278.0f, 548.8f,279.0f, 1.0f };
+    { 0.f,0.f,0.f,1.0f };
+
+    /*glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
+    glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
+    glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
+    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
+*/
+    glEnable(GL_LIGHT0); 
+
 	GLfloat mat_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f};
 	
@@ -311,10 +324,10 @@
 	GLfloat mat_shininess[] = {1.0f};
 
-	GLfloat light_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f};
+/*	GLfloat light_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f};
 	GLfloat light_diffuse[] = {0.4f, 0.4f, 0.4f, 1.0f};
 	GLfloat light_specular[] = {0.3f, 0.3f, 0.3f, 1.0f};
 
 	GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f};
-
+*/
 
 	// default Material
@@ -329,16 +342,16 @@
 	glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
 
-	glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
+	/*glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
 	glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
 	glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
-
-	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+*/
+	//glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
 
 	glEnable(GL_LIGHTING);
 	glEnable(GL_LIGHT0);
-	glEnable(GL_LIGHT1);
+//	glEnable(GL_LIGHT1);
 
 	// set position of the light
-	GLfloat infinite_light[] = {  1.0, 0.8, 1.0, 0.0  };
+	/*GLfloat infinite_light[] = {  1.0, 0.8, 1.0, 0.0  };
 	glLightfv (GL_LIGHT0, GL_POSITION, infinite_light);
 
@@ -346,4 +359,6 @@
 	GLfloat infinite_light2[] = {  -0.3, 1.5, 1.0, 0.0  };
 	glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2);
+*/
+	glLightfv (GL_LIGHT0, GL_POSITION, light_position);
 
 	glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
@@ -351,5 +366,5 @@
 	glEnable(GL_COLOR_MATERIAL);
 
-	glShadeModel(GL_FLAT);
+	glShadeModel(GL_SMOOTH);
 }
 
@@ -392,23 +407,5 @@
 void QtGlRendererWidget::_RenderPvs()
 {
-
-#if TEST_PVS_RENDERING
-  
-  ObjectPvsIterator it = mPvsCache.mPvs.GetIterator();
-
-  int pvsSize = mPvsCache.mPvs.GetSize();
-
-  Intersectable::NewMail();
-  mCurrentFrame++;
-  while (it.HasMoreEntries()) 
-	{
-	  RenderIntersectable(it.Next());
-	}
-
-  
-  return;
-#endif
-  
-  mUseFalseColors = false;
+	mUseFalseColors = false;
 
 	int offset = (int)mObjects.size() * 3;
@@ -436,5 +433,5 @@
 
 
-void QtGlRendererWidget::PreparePvs()
+void QtGlRendererWidget::PreparePvs2(const ObjectPvs &pvs)
 {
 	int indexBufferSize = 0;
@@ -443,9 +440,11 @@
 	//Intersectable::NewMail();
 
-	mPvsSize = mPvsCache.mPvs.GetSize();
+	mPvsSize = pvs.GetSize();
+
 #if DYNAMIC_OBJECTS_HACK
 	mDynamicObjects.clear();
 #endif
-	ObjectPvsIterator it = mPvsCache.mPvs.GetIterator();
+
+	ObjectPvsIterator it = pvs.GetIterator();
 
 	while (it.HasMoreEntries()) 
@@ -492,5 +491,4 @@
 
 	EnableDrawArrays();
-
 	//Intersectable::NewMail();
 	
@@ -505,4 +503,5 @@
 	if (viewcell) 
 	{
+#if 1
 		// copy the pvs so that it can be filtered ...
 		if (PvsChanged(viewcell)) 
@@ -524,5 +523,5 @@
 				//mPvsCache.mPvs = pvs;
 				//mMutex.unlock();
-				cout << "pvs size: " << mPvsCache.mPvs.GetSize() << endl;
+				//cout << "pvs size: " << mPvsCache.mPvs.GetSize() << endl;
 			}
 			else
@@ -530,10 +529,14 @@
 				mPvsCache.mPvs = viewcell->GetPvs();
 			}
-
-			/// update the indices for rendering
-			PreparePvs();
-
+			
+			// update the indices for rendering
+			PreparePvs2(mPvsCache.mPvs);
+			
 			emit PvsUpdated();
 		}
+#else
+		PreparePvs2(viewcell->GetPvs());
+		emit PvsUpdated();
+#endif
 
 
@@ -898,5 +901,5 @@
 									   )
 									   :
-GlRendererWidget(sceneGraph, viewcells, tree), QGLWidget(parent, shareWidget, f)
+GlRendererWidget(sceneGraph, viewcells, tree), QGLWidget(QGLFormat(QGL::SampleBuffers), parent, shareWidget, f)
 {
 	mPreprocessorThread = NULL;
@@ -910,4 +913,5 @@
 	mRenderFilter = true;
 	mRenderVisibilityEstimates = false;
+	//mRenderVisibilityEstimates = true;
 
 	mUseRandomColorPerPvsObject = false;
@@ -918,6 +922,4 @@
 	mTransferFunction = 1.0f;
 	mIndexBufferSize = 0;
-
-	//mCurrentFrame = 0;
 
 	const int delay = 250; // in milliseconds
@@ -956,4 +958,5 @@
 	mShowRays = false;
 
+	SetSceneCut(0);
 	mControlWidget = new QtRendererControlWidget(NULL);
 
@@ -1242,4 +1245,8 @@
 	s.sprintf("PVS: %04d", mPvsSize);
 	renderText(20, 40, s, font40);
+
+/*	QFont font40; font40.setPointSize(30);
+	s.sprintf("New triangles: %04d", 100);
+	renderText(200, 40, s, font40);*/
 }
 
@@ -1362,5 +1369,5 @@
 	float renderCost = 0;
 
-#ifndef USE_BIT_PVS
+#ifdef USE_VERBOSE_PVS
 	if (mShowDistanceWeightedPvs)
 	{
@@ -1461,7 +1468,9 @@
 
 	ComputeMaxValues(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost);
+	
 	// matt: temp hack
-	maxRcCost = 200.0f;
+	//maxRcCost = 5000.0f;
 	//cout << "maxRcCost: " << maxRcCost << endl;
+
 	int i;
 
@@ -1982,5 +1991,4 @@
 
 
-
 	cb = new QCheckBox("Cut view cells", vbox);
 	vbox->layout()->addWidget(cb);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2621)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2633)
@@ -538,5 +538,5 @@
 	}
 
-	void PreparePvs();
+	void PreparePvs2(const ObjectPvs &pvs);
 
 	void _RenderPvs();
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface.vcproj	(revision 2576)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface.vcproj	(revision 2633)
@@ -165,6 +165,6 @@
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="..\..\src;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;..\..\..\..\..\..\..\NonGTP\Zlib\include;&quot;$(CG_INC_PATH)&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;QTGLRENDERER_EXPORTS;USE_VERBOSE_PVS;USE_QT;USE_CG;GTP_INTERNAL"
+				AdditionalIncludeDirectories="..\..\src;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;..\..\..\..\..\..\..\NonGTP\Zlib\include;&quot;$(CG_INC_PATH)&quot;;..\..\src\sparsehash\src;..\..\src\sparsehash\src\google;..\..\src\sparsehash\src\windows;..\..\src\sparsehash\src\google\sparsehash"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;QTGLRENDERER_EXPORTS;USE_HASH_PVS;USE_QT;USE_CG;GTP_INTERNAL"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2625)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2633)
@@ -273,4 +273,6 @@
 
 
+	int mGenericStats;
+
 protected:
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2627)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2633)
@@ -2406,5 +2406,5 @@
 
 	const int numTriangles = kdObj->ComputeNumTriangles();
-#ifndef USE_BIT_PVS
+#ifdef USE_VERBOSE_PVS
 	vc->GetPvs().mStats.mDistanceWeightedTriangles += f * numTriangles; 
 	vc->GetPvs().mStats.mDistanceWeightedPvs += f ;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2622)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2633)
@@ -1780,7 +1780,5 @@
 	
 	KdNode::NewMail();
-	//Intersectable::NewMail();
-
-	
+		
 	ObjectPvsIterator it = pvs.GetIterator();
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2625)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2633)
@@ -17,5 +17,5 @@
 {
   
-#define GVS_DEBUG 1
+#define GVS_DEBUG 0
 
 struct VizStruct
@@ -37,4 +37,5 @@
 mCurrentViewCell(NULL),
 mCurrentViewPoint(Vector3(0.0f, 0.0f, 0.0f))
+//,mGenericStats(0)
 {
 	Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples);
@@ -219,4 +220,5 @@
 		return false;
 
+//	cout << "t";
 	if (0 && GVS_DEBUG)
 		mVssRays.push_back(new VssRay(*vssRay));
@@ -592,5 +594,5 @@
 
 	//CLEAR_CONTAINER(invalidSamples);
-	Debug << "generated " <<  numSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
+	//Debug << "generated " <<  numSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
 	return (int)simpleRays.size();
 }
@@ -606,7 +608,5 @@
 
 		HandleRay(ray);
-
-		//if (!HandleRay(ray));
-		//	invalidSamples.push_back(ray);
+		//if (!HandleRay(ray)) invalidSamples.push_back(ray);
 	}
 }
@@ -675,9 +675,7 @@
 
 
-//void GvsPreprocessor::VisualizeViewCell(ViewCell *vc)
 void GvsPreprocessor::VisualizeViewCell(const ObjectContainer &objects)
 {
     Intersectable::NewMail();
-
 	Material m;
 	
@@ -760,5 +758,5 @@
 	int passSamples = 0;
 
-	//if (mCurrentViewCell->GetId() != 82975 )return;
+	mGenericStats = 0;
 
 	//while (mGvsStats.mPerViewCellSamples < mTotalSamples) 
@@ -789,4 +787,6 @@
 			cout << "\nPass " << mPass << " #samples: " << mGvsStats.mPerViewCellSamples << endl;
 			cout << "contribution=" << mGvsStats.mPassContribution << " (of " << mMinContribution << ")" << endl;
+
+			//mGenericStats = GvsStats.mGvsStats.mPassContribution;
 
 			// termination criterium
@@ -964,29 +964,4 @@
 }
 
-/*
-void GvsPreprocessor::ComputeRenderError()
-{
-	cout << "computing gvs render error" << endl;
-	vector<ViewCellPoints *> *vcPoints = mViewCellsManager->GetViewCellPoints();
-
-	vector<ViewCellPoints *>::const_iterator vit, vit_end = vcPoints->end();
-
-	for (vit = vcPoints->begin(); vit != vit_end; ++ vit)
-	{
-		ViewCellPoints *vcPoints = *vit;
-		
-		renderer->EvalPvsStat(vcPoints->second);
-
-		mStats <<
-			"#ViewCell\n" << vcPoints->first->GetId() << endl <<
-			"#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 <<
-			"#AvgRenderPvs\n" << renderer->mPvsStat.GetAvgPvs() << endl;
-	}
-}
-*/
 
 void GvsPreprocessor::UpdatePvs(ViewCell *currentViewCell)
@@ -1300,6 +1275,4 @@
 	mGvsStats.mTotalTime += mGvsStats.mTimePerViewCell;
 
-	//lastTime = currentTime;
-
 	mGvsStats.Stop();
 	mGvsStats.Print(mGvsStatsStream);
