Index: /trunk/VUT/GtpVisibilityPreprocessor/src/Makefile
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/Makefile	(revision 446)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/Makefile	(revision 450)
@@ -1,5 +1,5 @@
 #############################################################################
 # Makefile for building: preprocessor
-# Generated by qmake (1.07a) (Qt 3.3.2) on: Sun Dec 04 20:05:51 2005
+# Generated by qmake (1.07a) (Qt 3.3.2) on: Mon Dec 05 09:51:45 2005
 # Project:  preprocessor.pro
 # Template: app
@@ -80,5 +80,7 @@
 		RayInfo.cpp \
 		RssTree.cpp \
-		RssPreprocessor.cpp
+		RssPreprocessor.cpp \
+		ViewCellsManager.cpp \
+		VspBspTree.cpp
 OBJECTS =	Preprocessor.obj \
 		SamplingPreprocessor.obj \
@@ -118,5 +120,7 @@
 		RayInfo.obj \
 		RssTree.obj \
-		RssPreprocessor.obj
+		RssPreprocessor.obj \
+		ViewCellsManager.obj \
+		VspBspTree.obj
 FORMS =	
 UICDECLS =	
@@ -218,4 +222,6 @@
 	-$(DEL_FILE) RssTree.obj
 	-$(DEL_FILE) RssPreprocessor.obj
+	-$(DEL_FILE) ViewCellsManager.obj
+	-$(DEL_FILE) VspBspTree.obj
 	-$(DEL_FILE) preprocessor.pdb
 	-$(DEL_FILE) preprocessor.ilk
@@ -241,5 +247,8 @@
 		ViewCell.h \
 		Environment.h \
-		RenderSimulator.h \
+		ViewCellsManager.h \
+		ViewCellBsp.h \
+		VspBspTree.h \
+		VspKdTree.h \
 		Containers.h \
 		AxisAlignedBox3.h \
@@ -255,6 +264,4 @@
 		Mesh.h \
 		KdTree.h \
-		ViewCellBsp.h \
-		VspKdTree.h \
 		Intersectable.h \
 		Pvs.h \
@@ -273,4 +280,5 @@
 		Polygon3.h \
 		ViewCell.h \
+		ViewCellsManager.h \
 		RenderSimulator.h \
 		Containers.h \
@@ -286,11 +294,8 @@
 		VssRay.h \
 		Mesh.h \
-		ViewCellBsp.h \
-		VspKdTree.h \
-		Intersectable.h \
-		Material.h \
-		Statistics.h \
-		RayInfo.h \
-		Exporter.h \
+		Intersectable.h \
+		Material.h \
+		Exporter.h \
+		Statistics.h \
 		
 
@@ -301,21 +306,14 @@
 		Mesh.h \
 		KdTree.h \
-		ViewCellBsp.h \
-		ViewCell.h \
-		VspKdTree.h \
-		Intersectable.h \
-		Plane3.h \
-		Matrix4x4.h \
-		AxisAlignedBox3.h \
-		Material.h \
-		Pvs.h \
-		Rectangle3.h \
-		Vector3.h \
-		common.h \
-		Ray.h \
-		Polygon3.h \
-		Statistics.h \
-		VssRay.h \
-		RayInfo.h \
+		Intersectable.h \
+		Plane3.h \
+		Matrix4x4.h \
+		AxisAlignedBox3.h \
+		Material.h \
+		Pvs.h \
+		Rectangle3.h \
+		Vector3.h \
+		common.h \
+		Ray.h \
 		
 
@@ -479,19 +477,14 @@
 		Mesh.h \
 		KdTree.h \
-		ViewCellBsp.h \
-		VspKdTree.h \
-		Intersectable.h \
-		Plane3.h \
-		Matrix4x4.h \
-		AxisAlignedBox3.h \
-		Material.h \
-		Pvs.h \
-		Rectangle3.h \
-		Vector3.h \
-		common.h \
-		Ray.h \
-		Polygon3.h \
-		Statistics.h \
-		RayInfo.h \
+		Intersectable.h \
+		Plane3.h \
+		Matrix4x4.h \
+		AxisAlignedBox3.h \
+		Material.h \
+		Pvs.h \
+		Rectangle3.h \
+		Vector3.h \
+		common.h \
+		Ray.h \
 		
 
@@ -550,5 +543,5 @@
 		SceneGraph.h \
 		Triangle3.h \
-		ViewCell.h \
+		ViewCellsManager.h \
 		Parser.h \
 		Containers.h \
@@ -563,4 +556,5 @@
 		common.h \
 		Ray.h \
+		VssRay.h \
 		
 
@@ -726,4 +720,5 @@
 		VssRay.h \
 		VssTree.h \
+		ViewCellsManager.h \
 		Containers.h \
 		AxisAlignedBox3.h \
@@ -737,11 +732,8 @@
 		Preprocessor.h \
 		Mesh.h \
-		ViewCellBsp.h \
-		VspKdTree.h \
-		Intersectable.h \
-		Material.h \
-		Statistics.h \
-		RayInfo.h \
-		Exporter.h \
+		Intersectable.h \
+		Material.h \
+		Exporter.h \
+		Statistics.h \
 		
 
@@ -834,11 +826,62 @@
 		Preprocessor.h \
 		Mesh.h \
+		Intersectable.h \
+		Material.h \
+		Exporter.h \
+		Statistics.h \
+		
+
+ViewCellsManager.obj: ViewCellsManager.cpp  \
+		ViewCellsManager.h \
+		RenderSimulator.h \
+		Mesh.h \
+		Triangle3.h \
+		ViewCell.h \
+		Environment.h \
+		X3dParser.h \
 		ViewCellBsp.h \
+		KdTree.h \
 		VspKdTree.h \
-		Intersectable.h \
-		Material.h \
-		Statistics.h \
+		Exporter.h \
+		VspBspTree.h \
+		Ray.h \
+		VssRay.h \
+		Containers.h \
+		Matrix4x4.h \
+		Vector3.h \
+		common.h \
+		Statistics.h \
+		Intersectable.h \
+		Plane3.h \
+		AxisAlignedBox3.h \
+		Material.h \
+		Pvs.h \
+		Rectangle3.h \
+		Parser.h \
+		Polygon3.h \
 		RayInfo.h \
-		Exporter.h \
+		
+
+VspBspTree.obj: VspBspTree.cpp  \
+		Plane3.h \
+		VspBspTree.h \
+		Mesh.h \
+		common.h \
+		ViewCell.h \
+		Environment.h \
+		Polygon3.h \
+		Ray.h \
+		AxisAlignedBox3.h \
+		Exporter.h \
+		Vector3.h \
+		Containers.h \
+		Statistics.h \
+		VssRay.h \
+		RayInfo.h \
+		Intersectable.h \
+		Matrix4x4.h \
+		Material.h \
+		Pvs.h \
+		Rectangle3.h \
 		
 
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp	(revision 448)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp	(revision 450)
@@ -365,8 +365,8 @@
 
 #ifdef _DEBUG	
-	if (frontPolys->empty() && backPolys->empty() && (coincident.size() > 2))
-	{	for (PolygonContainer::iterator it = coincident.begin(); it != coincident.end(); ++it)
-			Debug << (*it) << " " << (*it)->GetArea() << " " << (*it)->mParent << endl ;
-		Debug << endl;}
+//  	if (frontPolys->empty() && backPolys->empty() && (coincident.size() > 2))
+//  	{	for (PolygonContainer::iterator it = coincident.begin(); it != coincident.end(); ++it)
+//  			Debug << (*it) << " " << (*it)->GetArea() << " " << (*it)->mParent << endl ;
+//  		Debug << endl;}
 #endif
 
@@ -953,7 +953,7 @@
 
 #ifdef _DEBUG
-	Debug << "totalpvs: " << pvs << " ptotal: " << pOverall
-		  << " frontpvs: " << frontPvs << " pFront: " << pFront 
-		  << " backpvs: " << backPvs << " pBack: " << pBack << endl << endl;
+//  	Debug << "totalpvs: " << pvs << " ptotal: " << pOverall
+//  		  << " frontpvs: " << frontPvs << " pFront: " << pFront 
+//  		  << " backpvs: " << backPvs << " pBack: " << pBack << endl << endl;
 #endif
 	return val;
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp	(revision 448)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp	(revision 450)
@@ -818,8 +818,8 @@
 
 #ifdef _DEBUG	
-	if (frontPolys->empty() && backPolys->empty() && (coincident.size() > 2))
-	{	for (PolygonContainer::iterator it = coincident.begin(); it != coincident.end(); ++it)
-			Debug << (*it) << " " << (*it)->GetArea() << " " << (*it)->mParent << endl ;
-		Debug << endl;}
+//  	if (frontPolys->empty() && backPolys->empty() && (coincident.size() > 2))
+//  	{	for (PolygonContainer::iterator it = coincident.begin(); it != coincident.end(); ++it)
+//  			Debug << (*it) << " " << (*it)->GetArea() << " " << (*it)->mParent << endl ;
+//  		Debug << endl;}
 #endif
 
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp	(revision 448)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp	(revision 450)
@@ -572,5 +572,4 @@
   delete rssTree;
   
-
   return true;
 }
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp	(revision 448)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp	(revision 450)
@@ -58,4 +58,5 @@
 	p->KdTreeStatistics(cout);
 	
+  
 	// parse view cells related options
 	p->PrepareViewCells();
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp	(revision 449)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp	(revision 450)
@@ -12,4 +12,5 @@
 #include "VssTree.h"
 #include "VspBspTree.h"
+#include "RssTree.h"
 
 
@@ -1220,2 +1221,89 @@
 	}
 }
+
+
+bool
+X3dExporter::ExportRssTree2(const RssTree &tree,
+							const Vector3 direction
+							)
+{
+  stack<RssTreeNode *> tStack;
+  
+  
+  mUseForcedMaterial = true;
+
+  Vector3 dirParam;
+
+  dirParam.x = VssRay::GetDirParam(0, Normalize(direction));
+  dirParam.y = VssRay::GetDirParam(1, Normalize(direction));
+
+  float maxImportance = 0.0f;
+  tStack.push(tree.GetRoot());
+  while (!tStack.empty()) {
+	
+	RssTreeNode *node = tStack.top();
+    tStack.pop();
+	
+    if (!node->IsLeaf()) {
+      RssTreeInterior *interior = (RssTreeInterior *)node;
+	  if (interior->axis < 3) {
+		tStack.push(interior->front);
+		tStack.push(interior->back);
+	  } else {
+		if (dirParam[interior->axis-3] < interior->position)
+		  tStack.push(interior->back);
+		else
+		  tStack.push(interior->front);
+	  }
+    } else {
+	  RssTreeLeaf *leaf = (RssTreeLeaf *)node;
+	  if (tree.ValidLeaf(leaf)) {
+		float i = leaf->GetImportance();
+		if (i > maxImportance)
+		  maxImportance = i;
+	  }
+	}
+  }
+
+  tStack.push(tree.GetRoot());
+  while (!tStack.empty()) {
+
+	RssTreeNode *node = tStack.top();
+    tStack.pop();
+	
+			
+    if (!node->IsLeaf()) {
+      RssTreeInterior *interior = (RssTreeInterior *)node;
+	  if (interior->axis < 3) {
+		tStack.push(interior->front);
+		tStack.push(interior->back);
+	  } else {
+		if (dirParam[interior->axis-3] < interior->position)
+		  tStack.push(interior->back);
+		else
+		  tStack.push(interior->front);
+	  }
+    } else {
+	  RssTreeLeaf *leaf = (RssTreeLeaf *)node;
+	  if (tree.ValidLeaf(leaf)) {
+		AxisAlignedBox3 box;
+		box = tree.GetShrankedBBox(leaf);
+		Mesh *mesh = new Mesh;
+		AddBoxToMesh(box, mesh);
+		
+		// get 4 corners of the ray directions
+		
+		mForcedMaterial.mDiffuseColor.b = 1.0f;
+		mForcedMaterial.mDiffuseColor.r = leaf->GetImportance()/maxImportance;
+		mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r;
+		
+		ExportMesh(mesh);
+		delete mesh;
+	  }
+	}
+  }
+
+  mUseForcedMaterial = false;
+
+  return true;
+}
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/preprocessor.pro
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/preprocessor.pro	(revision 446)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/preprocessor.pro	(revision 450)
@@ -39,4 +39,5 @@
 MutualVisibility.cpp Triangle3.cpp Rectangle3.cpp Plane3.cpp Polygon3.cpp \
 ViewCell.cpp ViewCellBsp.cpp Halton.cpp VssRay.cpp VssTree.cpp VssPreprocessor.cpp \
-RenderSimulator.cpp VspKdTree.cpp RayInfo.cpp RssTree.cpp RssPreprocessor.cpp
+RenderSimulator.cpp VspKdTree.cpp RayInfo.cpp RssTree.cpp RssPreprocessor.cpp \
+ViewCellsManager.cpp VspBspTree.cpp
 
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.h
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.h	(revision 447)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.h	(revision 450)
@@ -98,7 +98,4 @@
 				);
   
-  void CastRay(const BspTree &tree, const VssRay & vssRay);
-	
-  int AddObjectSamples(Intersectable *obj, const Ray &ray);
 
   void
@@ -106,4 +103,12 @@
 			RssTree *rssTree
 			);
+
+  void
+  CastRay(const BspTree &tree, const VssRay & vssRay);
+
+  int
+  AddObjectSamples(Intersectable *obj, const Ray &ray);
+
+
 	
 };
