Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1006)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1020)
@@ -8,5 +8,5 @@
 #include "ViewCellBsp.h"
 #include "KdTree.h"
-//#include "VspOspTree.h"
+#include "VspOspTree.h"
 #include "Exporter.h"
 #include "VspBspTree.h"
@@ -104,4 +104,5 @@
 
 	
+	// sampling type for view cells construction samples
 	if (strcmp(buf, "box") == 0)
 	{
@@ -112,5 +113,13 @@
 		mSamplingType = Preprocessor::DIRECTION_BASED_DISTRIBUTION;
 	}
-	else 
+	else if (strcmp(buf, "interior") == 0)
+	{
+		mSamplingType = Preprocessor::OBJECTS_INTERIOR_DISTRIBUTION;
+	}
+	else if (strcmp(buf, "object_directional") == 0)
+	{
+		mSamplingType = Preprocessor::OBJECT_DIRECTION_BASED_DISTRIBUTION;
+	}
+	else
 	{
 		Debug << "error! wrong sampling type" << endl;
@@ -118,4 +127,5 @@
 	}
 
+	// sampling type for evaluation samples
 	Environment::GetSingleton()->GetStringValue("ViewCells.Evaluation.samplingType", buf);
 	
@@ -128,5 +138,13 @@
 		mEvaluationSamplingType = Preprocessor::DIRECTION_BASED_DISTRIBUTION;
 	}
-	else 
+	else if (strcmp(buf, "object_directional") == 0)
+	{
+		mEvaluationSamplingType = Preprocessor::OBJECT_DIRECTION_BASED_DISTRIBUTION;
+	}
+	else if (strcmp(buf, "interior") == 0)
+	{
+		mEvaluationSamplingType = Preprocessor::OBJECTS_INTERIOR_DISTRIBUTION;
+	}
+	else
 	{
 		Debug << "error! wrong sampling type" << endl;
@@ -201,9 +219,10 @@
 ViewCellsManager::~ViewCellsManager()
 {
-	//DEL_PTR(mRenderer);
-
+	// HACK: if view cells tree does not 
+	// take care of view cells, we have to do it
+	// question: rather create view cells resource manager?
 	if (!ViewCellsTreeConstructed())
 		CLEAR_CONTAINER(mViewCells);
-	//else
+	
 	DEL_PTR(mViewCellsTree);
 }
@@ -855,8 +874,6 @@
 	Debug << "view cell stats prefix: " << statsPrefix << endl;
 
-	
 	// should directional sampling be used?
 	bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION);
-
 
 	cout << "reseting pvs ... ";
@@ -1366,7 +1383,5 @@
 	ViewCellContainer::const_iterator it, it_end = mViewCells.end();
 
-
 	//-- compute expected value
-
 	totalRenderCost = 0;
 	totalPvs = 0;
@@ -2480,6 +2495,5 @@
 	if (1) // export final view cells
 	{
-		mColorCode = 1;
-
+		mColorCode = 1; // hack color code
 		Exporter *exporter = Exporter::GetExporter("final_view_cells.x3d");
 	
@@ -2494,7 +2508,9 @@
 
 			//exporter->SetFilled();
-			bool b = mUseClipPlaneForViz;
+			const bool b = mUseClipPlaneForViz;
 			mUseClipPlaneForViz = false;
+
 			ExportViewCellsForViz(exporter);
+			
 			mUseClipPlaneForViz = b;
 			delete exporter;
@@ -3101,4 +3117,5 @@
 }
 
+
 int KdViewCellsManager::PostProcess(const ObjectContainer &objects,
 									const VssRayContainer &rays)
@@ -3106,4 +3123,5 @@
 	return 0;
 }
+
 
 void KdViewCellsManager::Visualize(const ObjectContainer &objects,
@@ -3956,5 +3974,5 @@
 		mColorCode = 1;
 	
-		Exporter *exporter = Exporter::GetExporter("final_view_cells.x3d");
+		Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl");
 		
 		if (exporter)
@@ -3976,5 +3994,5 @@
 
 			// export rays
-			if (mExportRays)
+			if (1 && mExportRays)
 			{
 				exporter->ExportRays(visRays, RgbColor(0, 1, 0));
@@ -3982,11 +4000,14 @@
 
 			//exporter->SetFilled();
+
 			// HACK: export without clip plane
 			const bool b = mUseClipPlaneForViz;
 			mUseClipPlaneForViz = false;
+
 			ExportViewCellsForViz(exporter);
+			
 			mUseClipPlaneForViz = b;
-		
 			delete exporter;
+
 			cout << "finished" << endl;
 		}
@@ -4107,5 +4128,6 @@
 										  const VssRayContainer &rays)
 {
-	const int leafOut = 20;
+	int leafOut;
+	Environment::GetSingleton()->GetIntValue("ViewCells.Visualization.maxOutput", leafOut);
 
 	ViewCell::NewMail();
@@ -4116,6 +4138,4 @@
 
 	const bool sortViewCells = true;
-	
-
 	// sort view cells to visualize the largest view cells
 	if (sortViewCells)
@@ -4145,5 +4165,5 @@
 
 		//bspLeaves[j]->Mail();
-		char s[64]; sprintf(s, "bsp-pvs%04d.x3d", i);
+		char s[64]; sprintf(s, "bsp-pvs%04d.wrl", i);
 		Exporter *exporter = Exporter::GetExporter(s);
 		
@@ -4151,5 +4171,5 @@
 
 		//-- export the sample rays
-		if (1 || mExportRays)
+		if (mExportRays)
 		{
 			// output rays stored with the view cells during subdivision
@@ -4219,4 +4239,5 @@
 		
 
+		//-- export view cell geometry
 		exporter->SetWireframe();
 
@@ -4228,4 +4249,5 @@
 	
 		exporter->SetFilled();
+
 
 		//-- export pvs
@@ -4314,5 +4336,6 @@
 	case 1: // pvs
 		{
-			importance = (float)mViewCellsTree->GetPvsSize(vc) / (float)mCurrentViewCellsStats.maxPvs;
+			if (mCurrentViewCellsStats.maxPvs)
+				importance = (float)mViewCellsTree->GetPvsSize(vc) / (float)mCurrentViewCellsStats.maxPvs;
 		}
 		break;
@@ -4469,5 +4492,4 @@
 			if (i != j)
 			{
-
 				BspLeaf *leaf2 =dynamic_cast<BspViewCell *>(leaves[j])->mLeaf;
 				
