Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2661)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2663)
@@ -30,5 +30,5 @@
 -gvs_samples_per_pass=50000 \
 -gvs_initial_samples=16 \
--gvs_max_viewcells=20 \
+-gvs_max_viewcells=4 \
 -gvs_min_contribution=50 \
 -gvs_per_viewcell=true \
Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna	(revision 2596)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna	(revision 2663)
@@ -7,4 +7,6 @@
 
 SCENE=../data/vienna/vienna_cropped.obj
+SCENE=../data/vienna/city_full.obj
+#SCENE=../data/vienna/city_full3.obj
 #VIEWCELLS=../data/vienna/vienna_cropped-seq-3000-false-20-viewcells.xml.gz
 VIEWCELLS=../data/vienna/vienna_cropped-57000-viewcells.xml.gz
Index: GTP/trunk/Lib/Vis/Preprocessing/src/OcclusionQuery.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/OcclusionQuery.cpp	(revision 2629)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/OcclusionQuery.cpp	(revision 2663)
@@ -12,14 +12,16 @@
 #endif
 
-#ifdef _WIN32
+//#ifdef _WIN32
 // This Macro does not compile under LINUX
-#define _ARBGL
-#endif
+//#define _ARBGL
+//#endif
+
 
 using namespace std;
 
-namespace GtpVisibilityPreprocessor {
-
-bool OcclusionQuery::sUseArbQueries = true;
+namespace GtpVisibilityPreprocessor 
+{
+
+const static bool sUseArbQueries = true;
 
 
@@ -27,24 +29,26 @@
 {
 	GLuint id;
-
-	if (sUseArbQueries)
-	{
-#ifdef _ARBGL
-	  // VH
-	  glGenQueriesARB(1, &id);
+	
+	if (sUseArbQueries)
+	{
+#ifdef _WIN32
+		// VH
+		glGenQueriesARB(1, &id);
 #endif
 	}
 	else
 	{		
-#ifdef _ARBGL
-	  // VH
+#ifdef _WIN32
+		// VH
 		glGenOcclusionQueriesNV(1, &id);
 #endif
 	}
 }
+
 
 OcclusionQuery::OcclusionQuery(const unsigned int idx):
 mId(idx)
-{}
+{
+}
 
 
@@ -53,6 +57,6 @@
 	if (sUseArbQueries)
 	{
-#ifdef _ARBGL
-	  // VH
+#ifdef _WIN32
+		// VH
 		glDeleteQueriesARB(1, &mId);
 #endif
@@ -60,6 +64,6 @@
 	else
 	{
-#ifdef _ARBGL
-	  // VH
+#ifdef _WIN32
+		// VH
 		glDeleteOcclusionQueriesNV(1, &mId);
 #endif
@@ -67,11 +71,13 @@
 	
 }
-//-----------------------------------------------------------------------
+
+
 void OcclusionQuery::BeginQuery()
 {
 	if (sUseArbQueries)
 	{
-#ifdef _ARBGL
-	  // VH
+#ifdef _WIN32
+		// VH
+		cout << "issuing arb query" << endl;
 		glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mId);
 #endif
@@ -79,17 +85,20 @@
 	else
 	{
-#ifdef _ARBGL
-	  // VH
+#ifdef _WIN32
+		// VH
+		cout << "issuing nv query" << endl;
 		glBeginOcclusionQueryNV(mId);
 #endif
 	}
 }
-//-----------------------------------------------------------------------
+
+
 void OcclusionQuery::EndQuery()
 {
 	if (sUseArbQueries)
 	{
-#ifdef _ARBGL
-	  // VH
+#ifdef _WIN32
+		// VH
+		cout << "ending query" << endl;
 		glEndQueryARB(GL_SAMPLES_PASSED_ARB);
 #endif
@@ -97,6 +106,6 @@
 	else
 	{
-#ifdef _ARBGL
-	  // VH
+#ifdef _WIN32
+		// VH
 		glEndOcclusionQueryNV();	
 #endif
@@ -110,28 +119,25 @@
 }
 
+
 bool OcclusionQuery::ResultAvailable() const
 {
-	GLuint available;
-
-	if (sUseArbQueries)
-	{
-#ifdef _ARBGL
-	  // VH
-		//GLint available;
-		glGetQueryObjectuivARB(mId,
-							   GL_QUERY_RESULT_AVAILABLE_ARB,
-				       &available);
+	GLuint available = GL_TRUE;
+
+	if (sUseArbQueries)
+	{
+#ifdef _WIN32
+		// VH
+		glGetQueryObjectuivARB(mId, GL_QUERY_RESULT_AVAILABLE_ARB, &available);
 #endif		
-		return available == GL_TRUE;
-	}
-	else
-	{
-#ifdef _ARBGL
+	}
+	else
+	{
+#ifdef _WIN32
 	  // VH
 	  glGetOcclusionQueryuivNV(mId, GL_PIXEL_COUNT_AVAILABLE_NV, &available);
 #endif
-		return available == GL_TRUE;
-	}
-
+	}
+
+	return available == GL_TRUE;
 }
 
@@ -139,26 +145,27 @@
 unsigned int OcclusionQuery::GetQueryResult() const
 {
-	GLuint sampleCount;
-
-	if (sUseArbQueries)
-	{
-#ifdef _ARBGL
-	  // VH
+	GLuint sampleCount = 1;
+
+	if (sUseArbQueries)
+	{
+#ifdef _WIN32
+		// VH
 		glGetQueryObjectuivARB(mId, GL_QUERY_RESULT_ARB, &sampleCount);
 #endif
-		return sampleCount;
 	}
 	else
 	{	
-#ifdef _ARBGL
-	  // VH
+#ifdef _WIN32
+		// VH
 		glGetOcclusionQueryuivNV(mId, GL_PIXEL_COUNT_NV, &sampleCount);
 #endif		
-		return sampleCount;
 	}	
-}
-
-
-void OcclusionQuery::GenQueries(std::vector<OcclusionQuery * > &queries, const int numQueries)
+	
+	return sampleCount;
+}
+
+
+void OcclusionQuery::GenQueries(std::vector<OcclusionQuery * > &queries, 
+								int numQueries)
 {
 	if ((int)queries.size() < numQueries)
@@ -170,14 +177,16 @@
 		if (sUseArbQueries)
 		{
-#ifdef _ARBGL
-	  // VH
+#ifdef _WIN32
+			// VH
 			glGenQueriesARB(n, (unsigned int *)newQueries);
+			cout << "creating " << n << " arb queries" <<  endl;
 #endif
 		}
 		else
 		{
-#ifdef _ARBGL
-	  // VH		  
-		  glGenOcclusionQueriesNV(n, (unsigned int *)newQueries);
+#ifdef _WIN32
+			// VH		  
+			glGenOcclusionQueriesNV(n, (unsigned int *)newQueries);
+			cout << "creating " << n << " nv queries" <<  endl;
 #endif		  
 		}
@@ -192,3 +201,5 @@
 	}
 }
+
+
 } // namespace
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2662)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2663)
@@ -101,28 +101,12 @@
 QtGlRendererBuffer::RenderPvs(const ObjectPvs &pvs)
 {
-#if TEST_PVS_RENDERING 
-
-  // Render PVS
-  ObjectPvsIterator it = pvs.GetIterator();
-  
-  Intersectable::NewMail();
-  mCurrentFrame++;
-  while (it.HasMoreEntries()) 
-	{
-	  RenderIntersectable(it.Next());
-	}
-
-#else
-  
-  PreparePvs(pvs);
-
-  int offset = (int)mObjects.size() * 3;
-  char *arrayPtr = mUseVbos ? NULL : (char *)mData;
-
-  glVertexPointer(3, GL_FLOAT, 0, (char *)arrayPtr);
-  glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3));
-  glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices);
-  
-#endif
+	PreparePvs(pvs);
+
+	int offset = (int)mObjects.size() * 3;
+	char *arrayPtr = mUseVbos ? NULL : (char *)mData;
+
+	glVertexPointer(3, GL_FLOAT, 0, (char *)arrayPtr);
+	glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3));
+	glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices);
 }
 
@@ -136,7 +120,6 @@
 	float pErrorPixels = -1.0f;
 
-
 	mUseFalseColors = false;
-	unsigned int pixelCount;
+	unsigned int pixelCount = 0;
 
 
@@ -153,11 +136,7 @@
 	if (!evaluateFilter) 
 		pvs = viewcell->GetPvs();
-	else {
-
-		mViewCellsManager->ApplyFilter2(viewcell,
-			false,
-			mViewCellsManager->GetFilterWidth(),
-			pvs);
-	}
+	else 
+		mViewCellsManager->ApplyFilter2(viewcell, false, mViewCellsManager->GetFilterWidth(), pvs);
+
 
 	mUseForcedColors = true;
@@ -168,4 +147,7 @@
 	glColor3f(0,1,0);
 
+	glDepthFunc(GL_LESS);
+	glDepthMask(GL_TRUE);
+	glEnable(GL_DEPTH_TEST);
 
 	glStencilFunc(GL_EQUAL, 0x0, 0x1);
@@ -182,5 +164,5 @@
 
 
-	OcclusionQuery *query = mOcclusionQueries[0];
+	OcclusionQuery *query = mOcclusionQueries[1];
 
 	Intersectable::NewMail();
@@ -193,9 +175,12 @@
 	glDisable(GL_STENCIL_TEST); 
 
+
 	// reenable other state
-	//  int wait=0;
-	//  while (!query.ResultAvailable()) {
-	//  	wait++;
-	//  }
+	int wait = 0;
+	
+	while (0 && !query->ResultAvailable()) 
+	{
+		wait ++;
+	}
 
 
@@ -1648,9 +1633,8 @@
 												 const ViewCellInfoContainer &compareInfo)
 {
-	//cout << "comparing " << viewcells.size() << " view cells to " << compareInfo.size() << " values" << endl;
-
 	if (viewcells.size() > compareInfo.size())
 	{
-		cerr << "loaded size (" << (int)compareInfo.size() << ") does not fit to view cells size (" << (int)viewcells.size() << ")" << endl;
+		cerr << "loaded size (" << (int)compareInfo.size() 
+			 << ") does not fit to view cells size (" << (int)viewcells.size() << ")" << endl;
 		return;
 	}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2662)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2663)
@@ -435,5 +435,6 @@
 	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
 
-	OcclusionQuery::GenQueries(mOcclusionQueries, 10);
+	// create some occlusion queries
+	OcclusionQuery::GenQueries(mOcclusionQueries, 100);
 
 	SceneGraphInterior *interior = mSceneGraph->GetRoot();
@@ -1734,5 +1735,5 @@
 float GlRenderer::GetPixelError(int &pvsSize)
 {
-  return -1.0f;
+	return -1.0f;
 }
 
@@ -1951,4 +1952,5 @@
 
 		delete [] mData;
+		mData = NULL;
 	}
 
@@ -1960,26 +1962,7 @@
 {
 	glDeleteBuffersARB(1, &mVboId);
-
-/*
-	KdLeafContainer leaves;
-	mKdTree->CollectLeaves(leaves);
-
-	KdLeafContainer::const_iterator kit, kit_end = leaves.end();
-
-	for (kit = leaves.begin(); kit != kit_end; ++ kit)
-	{
-		KdLeaf *leaf = *kit;
-
-		if (leaf->mVboId == -1)
-		{
-			// delete old vbo
-			glDeleteBuffersARB(1, &leaf->mVboId);
-			leaf->mVboId = -1;
-		}
-	}
-*/
-}
-
-
-
-}
+}
+
+
+
+}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/OcclusionQuery.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/OcclusionQuery.h	(revision 1001)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/OcclusionQuery.h	(revision 2663)
@@ -23,5 +23,5 @@
 	virtual void EndQuery();
 	
-	static void GenQueries(std::vector<OcclusionQuery *> &queries, const int numQueries);
+	static void GenQueries(std::vector<OcclusionQuery *> &queries, int numQueries);
 
 	unsigned int GetQueryId() const;
@@ -31,6 +31,5 @@
 
 	OcclusionQuery(const unsigned int idx);
-	static bool sUseArbQueries;
-
+	
 	unsigned int mId;
 };
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2643)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2663)
@@ -357,5 +357,5 @@
 	unsigned int *mPixelBuffer;
 
-	static void GenQueries(const int numQueries);
+	static void GenQueries(int numQueries);
 
 	virtual void SetupProjectionForViewPoint(const Vector3 &viewPoint, 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 2660)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 2663)
@@ -511,5 +511,5 @@
 			break;
 		case PARSE_OBJECTSPACE_HIERARCHY:
-			if ((++ nObjects % 1000) == 0)
+			if ((++ nObjects % 10000) == 0)
 				cout <<"\r" << nObjects << " objects parsed\r";
 		
