Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2565)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2566)
@@ -865,4 +865,6 @@
 	mShowPvsSizes = false;
 	mShowPiercingRays = false;
+	mShowWeightedRays = false;
+
 	mSpatialFilterSize = 0.01;
 	mPvsSize = 0;
@@ -902,10 +904,9 @@
 	connect(mControlWidget, SIGNAL(SetRenderBoxes(bool)), this, SLOT(SetRenderBoxes(bool)));
 	connect(mControlWidget, SIGNAL(SetRenderFilter(bool)), this, SLOT(SetRenderFilter(bool)));
-	connect(mControlWidget, SIGNAL(SetRenderVisibilityEstimates(bool)),
-		this, SLOT(SetRenderVisibilityEstimates(bool)));
+	connect(mControlWidget, SIGNAL(SetRenderVisibilityEstimates(bool)), this, SLOT(SetRenderVisibilityEstimates(bool)));
 	connect(mControlWidget, SIGNAL(SetUseFilter(bool)), this, SLOT(SetUseFilter(bool)));
-	connect(mControlWidget, SIGNAL(SetUseSpatialFilter(bool)),
-		this, SLOT(SetUseSpatialFilter(bool)));
+	connect(mControlWidget, SIGNAL(SetUseSpatialFilter(bool)), this, SLOT(SetUseSpatialFilter(bool)));
 	connect(mControlWidget, SIGNAL(SetShowPiercingRays(bool)), this, SLOT(SetShowPiercingRays(bool)));
+	connect(mControlWidget, SIGNAL(SetShowWeightedRays(bool)), this, SLOT(SetShowWeightedRays(bool)));
 
 	connect(mControlWidget,
@@ -1198,5 +1199,6 @@
 	ViewCellContainer &viewcells = mViewCellsManager->GetViewCells();
 	int maxPvs = -1;
-	int maxPiercingRays = 1; // for savety
+	int maxPiercingRays = 1; // not zero for savety
+	float maxRelativeRays = Limits::Small; // not zero for savety
 
 	for (i = 0; i < viewcells.size(); ++ i) 
@@ -1213,7 +1215,12 @@
 		if (piercingRays > maxPiercingRays)
 			maxPiercingRays = piercingRays;
-	}
-
-	if (!mShowPvsSizes && !mShowPiercingRays)
+
+		const float relativeArea = vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea();
+
+		if ((float)piercingRays / relativeArea > maxRelativeRays)
+			maxRelativeRays = (float)piercingRays / relativeArea;
+	}
+
+	if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays)
 	{
 		for (i = 0; i < viewcells.size(); ++ i) 
@@ -1260,6 +1267,6 @@
 			{
 				ViewCell *vc = viewcells[i];
-				const Vector3 dummyViewPoint(0.0, 0.0, 1.0);
-				const float dist = SqrDistance(dummyViewPoint, vc->GetBox().Center());
+
+				const float dist = SqrDistance(mDummyViewPoint, vc->GetBox().Center());
 
 				vc->SetDistance(dist);
@@ -1269,8 +1276,7 @@
 		}
 
-		RgbColor c;
-
-        for (i = 0; i < viewcells.size(); ++ i) 
+		for (i = 0; i < viewcells.size(); ++ i) 
 		{
+			RgbColor c;
             ViewCell *vc = viewcells[i];
 			
@@ -1283,11 +1289,19 @@
 					((float)vc->GetNumPiercingRays() / (float)maxPiercingRays);
 			}
-			else
+			else if (mShowWeightedRays) // relative number of rays
+			{
+				// importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs);
+				float relativeArea = vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea();
+
+				if (relativeArea < Limits::Small)
+					relativeArea = Limits::Small;
+
+				importance = mTransferFunction * ((float)vc->GetNumPiercingRays() / relativeArea) / maxRelativeRays;
+			}
+			else // pvs size
 			{
 				//importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs);
 				importance = mTransferFunction *
 					((float)vc->GetPvs().GetSize() / (float)maxPvs);
-				// c = RgbColor(importance, 1.0f - importance, 0.0f);
-				c = RainbowColorMapping(5.0f * importance);
 			}
 
@@ -1452,5 +1466,5 @@
 
 
-	QRadioButton *rb1, *rb2, *rb3;
+	QRadioButton *rb1, *rb2, *rb3, *rb4;
 
 	// Create a check box to be in the group box
@@ -1468,4 +1482,9 @@
 	rb3 = new QRadioButton("wireframe", hbox);
 	rb3->setText("wireframe");
+	
+	rb4 = new QRadioButton("weighted rays", hbox);
+	rb4->setText("weighted rays");
+	connect(rb4, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedRays(bool)));
+
 	//vl->addWidget(rb2);
 	//connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowPvsSizes(bool)));
@@ -1478,5 +1497,6 @@
 	vbox2->addWidget(rb1);
 	vbox2->addWidget(rb2);
-	rb2->setChecked(true);
+	vbox2->addWidget(rb4);
+	rb3->setChecked(true);
 
 	vbox2->addStretch(1);
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.h	(revision 2562)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.h	(revision 2566)
@@ -3,5 +3,5 @@
 
 #include <QtOpenGL>
-
+#include "Vector3.h"
 
 namespace GtpVisibilityPreprocessor 
@@ -22,5 +22,5 @@
 
 	QtGlViewer(QWidget *parent,
-		QtGlRendererWidget *renderer);
+		       QtGlRendererWidget *renderer);
 
 	virtual ~QtGlViewer(){};
@@ -41,9 +41,11 @@
 	void mouseMoveEvent(QMouseEvent *event);
 
-	void keyPressEvent ( QKeyEvent * e );
+	void keyPressEvent(QKeyEvent * e);
 
 	bool mWireframe;
 
 	int timerId;
+
+	Vector3 mDummyViewPoint;
 
 private:
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2564)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2566)
@@ -115,4 +115,5 @@
   void SetShowPvsSizes(bool);
   void SetShowPiercingRays(bool);
+  void SetShowWeightedRays(bool);
   void SetTopView(bool);
   void SetCutViewCells(bool);
@@ -144,4 +145,5 @@
 	bool mShowRenderCost;
 	bool mShowPiercingRays;
+	bool mShowWeightedRays;
 	bool mShowRays;
 
@@ -163,4 +165,6 @@
 
 	unsigned int mIndexBufferSize;
+
+	Vector3 mDummyViewPoint;
 
 	QtRendererControlWidget *mControlWidget;
@@ -316,4 +320,9 @@
 	void SetShowPiercingRays(bool b) {
 		mShowPiercingRays = b;
+		updateGL();
+	}
+
+	void SetShowWeightedRays(bool b) {
+		mShowWeightedRays = b;
 		updateGL();
 	}
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp	(revision 2564)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp	(revision 2566)
@@ -55,4 +55,5 @@
 	//glDisable(GL_DEPTH_TEST);
 
+	mRenderer->mDummyViewPoint = mDummyViewPoint;
 	glColor3f(0.8f, 0.8f, 0.8f);
 	mRenderer->RenderPvs();
@@ -108,15 +109,16 @@
 	glLoadIdentity();
 
-	float m[4][4];
+	//float m[4][4];
+	Matrix4x4 m;
 
 	glLoadIdentity();
 	gluLookAt(0.0, 0.0, 1.0,  /* eye is at (0,0,30) */
-		0.0, 0.0, 0.0,      /* center is at (0,0,0) */
-		0.0, 1.0, 0.);      /* up is in positive Y direction */
-
-	build_rotmatrix(m, manipulatorLastQuat);
-	glMultMatrixf(&m[0][0]);
-
-	float s = scale*20.0f/Magnitude(mRenderer->mSceneGraph->GetBox().Diagonal());
+		      0.0, 0.0, 0.0,  /* center is at (0,0,0) */
+		      0.0, 1.0, 0.);  /* up is in positive Y direction */
+
+	build_rotmatrix(m.x, manipulatorLastQuat);
+	glMultMatrixf((float *)m.x);
+
+	float s = scale * 20.0f / Magnitude(mRenderer->mSceneGraph->GetBox().Diagonal());
 	glScalef(s, s, s);
 
@@ -124,4 +126,12 @@
 	glTranslatef(t.x, t.y, t.z);
 
+	mDummyViewPoint = -t;
+	mDummyViewPoint /= s;
+
+	//glGetFloatv(GL_MODELVIEW_MATRIX, m1);
+
+	m.Invert();
+
+	mDummyViewPoint = m * mDummyViewPoint;
 	RenderScene();
 }
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2548)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2566)
@@ -750,5 +750,5 @@
 	Vector3 origin, termination, direction; 
 
-	float radius = 0.5f * 
+	const float radius = 0.5f * 
 		Magnitude(mPreprocessor.mViewCellsManager->GetViewSpaceBox().Size());
 
