Index: /trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h	(revision 592)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h	(revision 599)
@@ -353,4 +353,11 @@
 
 	
+  
+  void CollectViewCells(const int n) {
+	mNumMergedViewCells = n;
+	mViewCells.clear();
+	CollectViewCells();
+  }
+
 
 protected:
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp	(revision 591)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp	(revision 599)
@@ -1545,4 +1545,8 @@
 				   "false");
 	
+	RegisterOption("Preprocessor.quitOnFinish",
+				   optBool,
+				   "quitOnFinish",
+				   "true");
 
 	/**************************************************************************************/
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp	(revision 577)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp	(revision 599)
@@ -28,4 +28,6 @@
   
   environment->GetBoolValue("Preprocessor.useGlDebugger", mUseGlDebugger);
+  environment->GetBoolValue("Preprocessor.quitOnFinish", mQuitOnFinish);
+
 }
 
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/default.env
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/default.env	(revision 576)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/default.env	(revision 599)
@@ -13,7 +13,7 @@
 #;../data/vienna/vienna-plane.x3d
 # filename ../data/vienna/viewcells-25-sel.x3d
-filename ../data/atlanta/atlanta2.x3d
+#filename ../data/atlanta/atlanta2.x3d
 #filename ../data/soda/soda.dat
-# filename ../data/soda/soda5.dat
+filename ../data/soda/soda5.dat
 }
 
@@ -27,4 +27,5 @@
 	detectEmptyViewSpace false
 	pvsRenderErrorSamples 10000
+	quitOnFinish false
 }
 
@@ -72,6 +73,6 @@
 RssPreprocessor {
 	samplesPerPass 500000
-	initialSamples 2000000
-	vssSamples 20000000
+	initialSamples 100
+	vssSamples 100
 	vssSamplesPerPass 1000000
 	useImportanceSampling true
@@ -166,6 +167,17 @@
 
 ViewCells {
-	loadFromFile true
+	# samples used for view cell construction
+	Construction {
+		samples 600000
+		samplesPerPass 200000
+	}
+
+	#number of active view cells
+	active 10000
+	maxStaticMemory	40
+
 	exportToFile false
+	loadFromFile false
+
 	#type kdTree
 	#type vspKdTree
@@ -177,28 +189,39 @@
 	height 5.0
 	maxViewCells 100000
+
 	#percentage of total visible objects where pvs is considered invalid
-	maxPvsRatio 0.05
+	maxPvsRatio 1.0
 		
-	delayedConstruction true
-		
-		
+	pruneEmptyViewCells false
+	processOnlyValidViewCells false
+	
 	PostProcess {
 		# how much samples are used for post processing
-		samples 200000
+		samples 300000
+		renderCostWeight 1.0
+		maxCostRatio 0.1
+		minViewCells 1
+		avgCostMaxDeviation 0.8
+		maxMergesPerPass 500 
+		useRaysForMerge false
+		refine false
+		compress false
+		merge true
 	}
 
 	Visualization {
 		# how much samples we use for visualization
-		samples 5000
+		samples 100000
 		#colorCode PVS
 		#colorCode MergedLeaves
 		#colorCode MergedTreeDiff
 		colorCode Random
-		exportRays false
-		exportGeometry false
-	}
-	
-#	filename ../data/soda/viewcells_soda5-2.xml
-	filename ../data/atlanta/viewcells_atlanta2.xml
+		exportRays true
+		exportGeometry true
+		exportMergedViewCells true
+		useCuttingPlane true
+		cuttingPlaneAxis 1
+	}
+	
 #	filename ../data/atlanta/atlanta_viewcells_large.x3d
 #	filename ../data/vienna/viewcells-25-sel.x3d
@@ -206,6 +229,5 @@
 #	filename ../data/vienna/viewcells-large-sel.x3d
 #	filename ../scripts/viewcells_vienna.xml
-
-
+	filename ../scripts/viewcells_atlanta.xml
 }
 
@@ -217,4 +239,5 @@
 	moveSpeed 0.0001
 }
+
 
 
@@ -257,9 +280,11 @@
 
 
+
 VspBspTree {
 	Construction {
-		samples 500000
+		samples 300000
 		epsilon 0.005
 		randomize false
+		renderCostWeight 1.0
 	}
 
@@ -270,13 +295,16 @@
 	# balanced rays        = 512
 	# pvs                  = 1024
-
+	
 	splitPlaneStrategy 1024
 	
 	# maximal candidates for split planes
-	maxPolyCandidates 100
-	maxRayCandidates 100
+	maxPolyCandidates 0
+
 	
 	# maximal tested rays for split cost heuristics
-	maxTests 2000
+	maxTests 10000
+	
+	maxTotalMemory	50
+	maxStaticMemory	50
 	
 	# factors for evaluating split plane costs
@@ -287,24 +315,31 @@
 	}
 	
-#	Termination {
-#		# parameters used for autopartition
-#		minRays 		100
-#		minPolygons 		-1
-#		maxDepth		30
-#		minPvs 			2
-#		#minProbability 	0.0001
-#		minProbabilty 		0.000
-#		maxRayContribution	0.005
+	Termination {
+		# parameters used for autopartition
+		minRays 		-150
+		minPolygons 		-1
+		maxDepth		30
+		minPvs 			-10
+		#minProbability		0.0001
+		minProbability 		-1
+#		maxRayContribution	0.3
+		maxRayContribution	2.3
 #		maxCostRatio		0.9
-#		missTolerance		4
-#		#maxAccRayLength	100
+		maxCostRatio		3.9
+		missTolerance		3
+
 		
-#		maxViewCells		20000
+		maxViewCells		10000
 		
-#		# used for pvs criterium
-#		ct_div_ci 0.0
-#	}
-	
-	splitUseOnlyDrivingAxis false
+		# used for pvs criterium
+		ct_div_ci 0.0
+		
+		AxisAligned {
+			minRays 		1
+			maxRayContribution	9.9
+		}
+	}
+	
+	splitUseOnlyDrivingAxis true
 	
 	Visualization {
@@ -312,4 +347,3 @@
 		exportSplits true
 	}
-	
-}
+}
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h	(revision 577)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h	(revision 599)
@@ -156,5 +156,6 @@
   
   bool mDetectEmptyViewSpace;
-  
+
+  bool mQuitOnFinish;
 protected:
 
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h	(revision 589)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h	(revision 599)
@@ -189,4 +189,5 @@
 
   bool mTopView;
+  bool mRenderViewCells;
   
   GlRendererWidget(SceneGraph *sceneGraph,
@@ -194,9 +195,6 @@
 				   KdTree *tree,
 				   QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0
-				   ):
-	GlRenderer(sceneGraph, viewcells, tree), QGLWidget(parent, shareWidget, f)
-  {
-	mTopView = false;
-  }
+				   );
+
 
   virtual void SetupCamera();
@@ -224,4 +222,14 @@
   virtual int GetWidth() const { return width(); }
   virtual int GetHeight() const { return height(); }
+
+
+  void
+  RenderViewCells();
+
+ public slots:
+ void
+ SetViewcellGranularity(int number);
+
+
 };
 
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/PreprocessorThread.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/PreprocessorThread.cpp	(revision 576)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/PreprocessorThread.cpp	(revision 599)
@@ -13,5 +13,6 @@
 {
   mPreprocessor = p;
-  connect(this, SIGNAL(finished()), qApp, SLOT(closeAllWindows(void)));
+  if (p->mQuitOnFinish)
+	connect(this, SIGNAL(finished()), qApp, SLOT(closeAllWindows(void)));
 }
 
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp	(revision 589)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp	(revision 599)
@@ -103,12 +103,25 @@
   if (vc->GetMesh()) {
 
-	if (vc->GetValid()) 
-	  glColor3f(0,1,0);
-	else
-	  glColor3f(0,0,1);
+	if (!mUseFalseColors) {
+	  if (vc->GetValid()) 
+		glColor3f(0,1,0);
+	  else
+		glColor3f(0,0,1);
+	}
 	
 	RenderMesh(vc->GetMesh());
-  }
-}
+  } else {
+	// render viewcells in the subtree
+	if (!vc->IsLeaf()) {
+	  ViewCellInterior *vci = (ViewCellInterior *) vc;
+
+	  ViewCellContainer::iterator it = vci->mChildren.begin();
+	  for (; it != vci->mChildren.end(); ++it) {
+		RenderViewCell(*it);
+	  }
+	}
+  }
+}
+
 
 void
@@ -684,6 +697,11 @@
 GlRendererWidget::paintGL()
 {
-  RenderErrors();
-  RenderInfo();
+  if (mRenderViewCells)
+	RenderViewCells();
+  else {
+	RenderErrors();
+	RenderInfo();
+  }
+  
   mFrame++;
 }
@@ -720,4 +738,8 @@
 	updateGL();
 	break;
+  case Qt::Key_V:
+	mRenderViewCells = !mRenderViewCells;
+	updateGL();
+	break;
   default:
 	e->ignore();
@@ -727,4 +749,55 @@
 }
 
+GlRendererWidget::GlRendererWidget(SceneGraph *sceneGraph,
+								   ViewCellsManager *viewcells,
+								   KdTree *tree,
+								   QWidget * parent,
+								   const QGLWidget * shareWidget,
+								   Qt::WFlags f
+								   )
+  :
+  GlRenderer(sceneGraph, viewcells, tree), QGLWidget(parent, shareWidget, f)
+{
+  mTopView = false;
+  mRenderViewCells = false;
+
+  QSlider *slider = new QSlider(this);
+  slider->show();
+  slider->setRange(1, 10000);
+
+  connect(slider, SIGNAL(valueChanged(int)), this, SLOT(SetViewcellGranularity(int)));
+}
+
+void
+GlRendererWidget::SetViewcellGranularity(int number)
+{
+  mViewCellsManager->CollectViewCells(number);
+  updateGL();
+}
+
+void
+GlRendererWidget::RenderViewCells()
+{
+  mUseFalseColors = true;
+
+  SetupCamera();
+  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+  int i;
+  ViewCellContainer &viewcells = mViewCellsManager->GetViewCells();
+  for (i=0; i < viewcells.size(); i++) {
+	ViewCell *vc = viewcells[i];
+	Mesh *m = vc->GetMesh();
+	float r = RandomValue(0.5, 1.0);
+	float g = RandomValue(0.5, 1.0);
+	float b = RandomValue(0.5, 1.0);
+
+	glColor3f(r, g, b);
+	//SetupMaterial(m->mMaterial);
+
+	RenderViewCell(vc);
+  }
+
+}
 
 void GlRendererBuffer::SampleBeamContributions(Intersectable *sourceObject,
