Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2695)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2696)
@@ -11,6 +11,8 @@
 echo "starting $TARGET version"
 
-SCENE=../data/vienna/vienna_cropped.obj
-#SCENE=../data/vienna/city_full.obj
+#SCENE=../data/vienna/vienna_cropped.obj
+#SCENE=../data/roofs2.obj
+#SCENE=../data/vienna/city_full_hp.obj
+SCENE=../data/vienna/vienna_rep.obj
 
 VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz 
@@ -36,5 +38,5 @@
 -gvs_initial_samples=16 \
 -gvs_max_viewcells=20 \
--gvs_min_contribution=100 \
+-gvs_min_contribution=50 \
 -gvs_per_viewcell=true \
 -gvs_stats=$LOG_PREFIX-gvsStats.log \
Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/demo1.env
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/demo1.env	(revision 2689)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/demo1.env	(revision 2696)
@@ -53,5 +53,5 @@
 	useGlRenderer true
 	useGlDebugger false
-# 0 = INTERNAL 		1 = MLRT
+# 0 = INTERNAL 1 = MLRT
 	rayCastMethod 1
 	
Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna	(revision 2695)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna	(revision 2696)
@@ -9,5 +9,7 @@
 
 #SCENE=../data/vienna/vienna_cropped.obj
-SCENE=../data/vienna/city_full.obj
+#SCENE=../data/vienna/city_full.obj
+#SCENE=../data/vienna/city_full_hp.obj
+SCENE=../data/vienna/vienna_rep.obj
 
 VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 2695)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 2696)
@@ -1248,7 +1248,5 @@
 							   const ObjectContainer &objects);
 
-	/** Sets a view space boundary.
-	*/
-	virtual void SetViewSpaceBox(const AxisAlignedBox3 &box);
+	
 
 #if TEST_PACKETS
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2695)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2696)
@@ -254,4 +254,5 @@
 		{
 			Triangle3 tri = static_cast<TriangleIntersectable *>(obj)->GetItem();
+			//tri.mVertices[0] *= 10; tri.mVertices[1] *= 10; tri.mVertices[2] *= 10;
 
 			samplesOut.write(reinterpret_cast<char *>(tri.mVertices + 0), sizeof(Vector3));
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2695)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2696)
@@ -290,5 +290,5 @@
 
 	// some error happened
-	if (1)//pixelCount > pixelThres) 
+	if (pixelCount > pixelThres) 
 	{
 		cout << "f " << mFrame << " id " << viewcell->GetId() << " pvs " << pvsSize 
@@ -313,37 +313,38 @@
 			im.save(qstr, "PNG");
 
-#if 1
-			///////////
-			//-- output computed pvs
-			
-			//mUseFalseColors = false;
-			mUseFalseColors = true;
-			glPushAttrib(GL_CURRENT_BIT);
-			glColor3f(0, 1, 0);
-
-			glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-
-			KdNode::NewMail2();
-			Intersectable::NewMail();
-
-			++ mCurrentFrame;
-
-			// render pvs once
-			//RenderPvs(pvs);
-			RenderTrianglePvs();
-
-			glFlush();
-
-			mUseFalseColors = false;
-
-			im = toImage();
-			sprintf(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount);
-			str = mSnapPrefix + filename;
-			qstr = str.c_str();
-			im.save(qstr, "PNG");
-
-			glPopAttrib();
-#endif
+			if (0)
+			{
+				///////////
+				//-- output computed pvs
+
+				//mUseFalseColors = false;
+				mUseFalseColors = true;
+				glPushAttrib(GL_CURRENT_BIT);
+				glColor3f(0, 1, 0);
+
+				glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+				glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+				KdNode::NewMail2();
+				Intersectable::NewMail();
+
+				++ mCurrentFrame;
+
+				// render pvs once
+				//RenderPvs(pvs);
+				RenderTrianglePvs();
+
+				glFlush();
+
+				mUseFalseColors = false;
+
+				im = toImage();
+				sprintf(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount);
+				str = mSnapPrefix + filename;
+				qstr = str.c_str();
+				im.save(qstr, "PNG");
+
+				glPopAttrib();
+			}
 		}
 	}
@@ -2602,38 +2603,48 @@
 }
 
-/*
-
-int ExampleRenderThread::faceAtPosition(const QPoint &pos) 
+
+int QtGlRendererWidget::FindDynamicObject(const Vector3 &pos) 
 { 
 	// we need to lock the rendering context 
-	glw.lockGLContext(); 
+	//glw.lockGLContext(); 
+	
 	// this is the same as in every OpenGL picking example 
-	const int MaxSize = 512; 
+	const int maxSize = 512; 
+	
 	// see below for an explanation on the buffer content 
-	GLuint buffer[MaxSize]; 
+	GLuint buffer[maxSize]; 
 	GLint viewport[4];
+
 	glGetIntegerv(GL_VIEWPORT, viewport); 
-	glSelectBuffer(MaxSize, buffer); 
+	glSelectBuffer(maxSize, buffer); 
+	
 	// enter select mode 
 	glRenderMode(GL_SELECT); 
 	glInitNames(); 
 	glPushName(0); 
+	
 	glMatrixMode(GL_PROJECTION); 
 	glPushMatrix(); 
 	glLoadIdentity(); 
-	gluPickMatrix((GLdouble)pos.x(), 215 (GLdouble)(viewport[3] - pos.y()), 216 5.0, 5.0, viewport); 
-	GLfloat x = (GLfloat)viewport_size.width() / viewport_size.height(); 
+	gluPickMatrix((GLdouble)pos.x, (GLdouble)(viewport[3] - pos.y), 5.0f, 5.0f, viewport); 
+	
+	GLfloat x = (GLfloat)width() / height(); 
 	glFrustum(-x, x, -1.0, 1.0, 4.0, 15.0); 
-	draw(); 
+	
+	 glLoadName(1);
+
+	_RenderDynamicObject(mPendingDynamicObject);
+
 	glMatrixMode(GL_PROJECTION); 
 	glPopMatrix();
+
 	// finally release the rendering context again 
 	if (!glRenderMode(GL_RENDER)) 
 	{ 
-		glw.unlockGLContext(); 
+		//glw.unlockGLContext(); 
 		return -1; 
 	} 
 	
-	glw.unlockGLContext(); 
+	//glw.unlockGLContext(); 
 	
 	// Each hit takes 4 items in the buffer. 
@@ -2649,4 +2660,29 @@
 	return buffer[3]; 
 }
-*/
-}
+
+void processHits (GLint hits, GLuint buffer[])
+{
+   unsigned int i, j;
+   GLuint names, *ptr;
+
+   cout << "hits = %d" << endl;;
+   ptr = (GLuint *) buffer;
+
+   for (i = 0; i < hits; i++) 
+   {
+	   /*  for each hit  */
+	   names = *ptr;
+
+	   printf (" number of names for hit = %d\n", names); ptr++;
+	   printf("  z1 is %g;", (float) *ptr/0x7fffffff); ptr++;
+	   printf(" z2 is %g\n", (float) *ptr/0x7fffffff); ptr++;
+	   printf ("   the name is ");
+
+	   for (j = 0; j < names; j++) {     /*  for each name */
+		   printf ("%d ", *ptr); ptr++;
+	   }
+	   printf ("\n");
+   }
+}
+
+}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2695)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2696)
@@ -80,4 +80,5 @@
 	void RenderTrianglePvs();
 
+	
 public:
 
@@ -248,8 +249,8 @@
 
 #if DYNAMIC_OBJECTS_HACK
-	
+
 	SceneGraphLeaf *mPendingDynamicObject;
-
 	DynamicObjectsContainer mDynamicObjects;
+
 #endif
 
@@ -324,9 +325,10 @@
 
 	void WriteViewCellInfos();
-
 	/** Unproject x/y screen coordinates.
 	*/
 	Vector3 Unproject(int x, int y);
 	
+	int FindDynamicObject(const Vector3 &pos);
+
 
 public slots:
Index: GTP/trunk/Lib/Vis/Preprocessing/src/RandomViewCellsHandler.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/RandomViewCellsHandler.cpp	(revision 2695)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/RandomViewCellsHandler.cpp	(revision 2696)
@@ -139,6 +139,4 @@
 	AxisAlignedBox3 bbox = mViewCellsManager->GetViewSpaceBox();
 
-	cout << "old view space box: " << bbox << endl;
-
 	string buf;
 
@@ -164,16 +162,7 @@
 				sscanf(buf.c_str(), "p %f %f %f %f %f %f", &pt.x, &pt.y, &pt.z, &dir.x, &dir.y, &dir.z);
 				
-				if (1)
-				{
-					// include new point into view space box
-					if (!bbox.IsInside(pt))
-						bbox.Include(pt);
-				}
-				else
-				{
-					// other variant: clamp to box
-					bbox.ClampToBox(pt);
-				}
-
+				// other variant: clamp to box
+				bbox.ClampToBox(pt);
+				
 				SimpleRay ray(pt, dir, 0, 1);
 
@@ -194,9 +183,4 @@
 		}
 	}
-
-	// set updated view space box containing all view points
-	mViewCellsManager->SetViewSpaceBox(bbox);
-
-	cout << "new view space box: " << mViewCellsManager->GetViewSpaceBox() << endl;
 
 	return true;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h	(revision 2695)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h	(revision 2696)
@@ -354,5 +354,5 @@
 	friend class ViewCellsParseHandlers;
 	friend class HierarchyManager;
-	friend class VspOspViewCellsManager;
+	//friend class VspOspViewCellsManager;
 
 public:
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2695)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2696)
@@ -2277,17 +2277,4 @@
 
 
-void VspOspViewCellsManager::SetViewSpaceBox(const AxisAlignedBox3 &box)
-{
-	mViewSpaceBox = box;
-	mHierarchyManager->mVspTree->mBoundingBox = box;
-
-	cout << "vsp bounding box: " << box << endl;
-	// hack: create clip plane relative to new view space box
-	CreateClipPlane();
-	// the total area of the view space has changed
-	mTotalAreaValid = false;
-}
-
-
 void ViewCellsManager::CreateClipPlane()
 {
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2695)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2696)
@@ -132,4 +132,7 @@
 		mViewPoint = Vector3(1189.54, 220.087, -462.869);
 		mViewDirection = Vector3(-0.996972, -0, -0.0776569);
+
+		mViewPoint = Vector3(1199.53, 257.677, -457.145);
+		mViewDirection = Vector3(-0.71206, -0, -0.702108);
 	}
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/PvsBase.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/PvsBase.h	(revision 2582)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/PvsBase.h	(revision 2696)
@@ -304,7 +304,7 @@
 		const double LOG2E = 1.442695040f;
 
-		const float logN = log((float) Max(1, n))/LOG2E;
-		const float logS = log((float) Max(1, mLastSorted))/LOG2E;
-		const float logD = log((float) Max(1, dirtySize))/LOG2E;
+		const float logN = (float)log((float) Max(1, n))/LOG2E;
+		const float logS = (float)log((float) Max(1, mLastSorted))/LOG2E;
+		const float logD = (float)log((float) Max(1, dirtySize))/LOG2E;
 
 		if (8*(n + 2*dirtySize*logD) <
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2695)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2696)
@@ -1212,5 +1212,5 @@
 void GvsPreprocessor::ComputeViewCell()
 {
-	if (mCurrentViewCell->GetId() != 499) return;
+	//if (mCurrentViewCell->GetId() != 499) return;
 
 	// clean up
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2695)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2696)
@@ -822,5 +822,5 @@
 
 	// get point on view cell surface
-	if (1)
+	if (0)
 	{
 		//mViewCell->GetRandomEdgePoint(origin, normal);
@@ -829,5 +829,5 @@
 		// move a little bit back to avoid piercing through walls
 		// that bound the view cell
-		if (1) origin -= 0.01f * normal;
+		if (0) origin -= 0.01f * normal;
 	}
 	else
