Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.cpp	(revision 2576)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.cpp	(revision 2576)
@@ -0,0 +1,49 @@
+#include "LogWriter.h"
+#include "ViewCellsManager.h"
+
+
+namespace GtpVisibilityPreprocessor 
+{
+
+
+void LogWriter::SetFilename(const std::string &filename)
+{
+	mFilename = filename;
+}
+
+
+void LogWriter::Write(ofstream &myfile, const int numSamples, const ViewCellInfoContainer &infos)
+{
+	ViewCellInfoContainer::const_iterator vit, vit_end = infos.end();
+
+	for (vit = infos.begin(); vit != vit_end; ++ vit)
+	{
+		myfile << (*vit).mPiercingRays;
+		//ViewCell *vc = *vit;
+		//myfile << "vc: " << vc->GetPvs().GetSize() << " " << vc->GetNumPiercingRays();
+	}
+}
+
+
+void LogWriter::Write(const ViewCellHistoryContainer &hist)
+{
+	ofstream myfile;
+
+	//char filename[64]; 
+	//sprintf(filename, "%s %06d", mFilename.c_str(), numSamples);
+	//myfile.open(filename);
+	myfile.open(mFilename.c_str());
+
+	ViewCellHistoryContainer::const_iterator vit, vit_end = hist.end();
+
+	// number of samples
+	//myfile << "samples: " << numSamples << endl;
+	myfile << (int)hist.size() << endl;
+
+	for (vit = hist.begin(); vit != vit_end; ++ vit)
+	{
+		Write(myfile, (*vit).first, *(*vit).second);
+	}
+}
+
+}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2572)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2576)
@@ -1,6 +1,6 @@
+#include "glInterface.h"
+#include "QtGlRenderer.h"
 #include "Mesh.h"
-#include "glInterface.h"
 #include "OcclusionQuery.h"
-#include "QtGlRenderer.h"
 #include "ViewCellsManager.h"
 #include "SceneGraph.h"
@@ -1245,6 +1245,58 @@
 #endif
 
-void
-QtGlRendererWidget::RenderViewCells()
+
+
+void QtGlRendererWidget::ComputeMaxValues(const ViewCellContainer &viewCells,
+										  int &maxPvs, 
+										  int &maxPiercingRays, 
+										  float &maxRelativeRays, 
+										  float &maxRcCost)
+{
+	maxPvs = -1;
+	maxPiercingRays = 1; // not zero for savety
+	maxRelativeRays = Limits::Small; // not zero for savety
+	maxRcCost = Limits::Small;
+
+	for (size_t i = 0; i < viewCells.size(); ++ i) 
+	{
+		ViewCell *vc = viewCells[i];
+
+		if (mShowPvsSizes) // pvs size
+		{
+			//const int p = vc->GetPvs().CountObjectsInPvs();
+			const int p = vc->GetPvs().GetSize();
+			if (p > maxPvs)
+				maxPvs = p;
+		}
+		else if (mShowPiercingRays) // relative number of rays
+		{
+			const int piercingRays = vc->GetNumPiercingRays();
+
+			if (piercingRays > maxPiercingRays)
+				maxPiercingRays = piercingRays;
+		} 
+		else if (mShowWeightedRays)
+		{
+			const int piercingRays = vc->GetNumPiercingRays();
+
+			const float relativeArea = 
+				vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea();
+
+			if ((float)piercingRays / relativeArea > maxRelativeRays)
+				maxRelativeRays = (float)piercingRays / relativeArea;
+		}
+		else if (mShowWeightedCost)
+		{
+			const float rcCost = ComputeRenderCost(vc);
+			mViewCellsManager->UpdateScalarPvsCost(vc, rcCost);
+
+			if (rcCost > maxRcCost)
+				maxRcCost = rcCost;
+		}
+	}
+}
+
+
+void QtGlRendererWidget::RenderViewCells()
 {
 	mUseFalseColors = true;
@@ -1272,46 +1324,9 @@
 	ViewCellContainer &viewcells = mViewCellsManager->GetViewCells();
 	
-	int maxPvs = -1;
-	int maxPiercingRays = 1; // not zero for savety
-	float maxRelativeRays = Limits::Small; // not zero for savety
-	float maxRcCost = Limits::Small;
-
-	for (i = 0; i < viewcells.size(); ++ i) 
-	{
-		ViewCell *vc = viewcells[i];
-
-		if (mShowPvsSizes) // pvs size
-		{
-			//const int p = vc->GetPvs().CountObjectsInPvs();
-			const int p = vc->GetPvs().GetSize();
-			if (p > maxPvs)
-				maxPvs = p;
-		}
-		else if (mShowPiercingRays) // relative number of rays
-		{
-			const int piercingRays = vc->GetNumPiercingRays();
-
-			if (piercingRays > maxPiercingRays)
-				maxPiercingRays = piercingRays;
-		} 
-		else if (mShowWeightedRays)
-		{
-			const int piercingRays = vc->GetNumPiercingRays();
-
-			const float relativeArea = 
-				vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea();
-
-			if ((float)piercingRays / relativeArea > maxRelativeRays)
-				maxRelativeRays = (float)piercingRays / relativeArea;
-		}
-		else if (mShowWeightedCost)
-		{
-			const float rcCost = ComputeRenderCost(vc);
-			mViewCellsManager->UpdateScalarPvsCost(vc, rcCost);
-
-			if (rcCost > maxRcCost)
-				maxRcCost = rcCost;
-		}
-	}
+	int maxPvs, maxPiercingRays;
+	float maxRelativeRays, maxRcCost;
+
+	ComputeMaxValues(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost);
+
 
 	if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays && !mShowWeightedCost)
@@ -1338,7 +1353,5 @@
 	else
 	{
-		//glDisable(GL_CULL_FACE);
-		//glCullFace(GL_BACK);
-
+		// transparency	
 		if (!mUseTransparency)
 		{
@@ -1365,46 +1378,11 @@
 		}
 
-		for (i = 0; i < viewcells.size(); ++ i) 
-		{
-			RgbColor c;
-            ViewCell *vc = viewcells[i];
-			
-			float importance;
-
-			if (mShowPiercingRays)
-			{
-				importance = mTransferFunction *
-					((float)vc->GetNumPiercingRays() / (float)maxPiercingRays);
-			}
-			else if (mShowWeightedRays) // relative number of rays
-			{
-				float relativeArea = vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea();
-
-				if (relativeArea < Limits::Small)
-					relativeArea = Limits::Small;
-
-				importance = mTransferFunction * ((float)vc->GetNumPiercingRays() / relativeArea) / maxRelativeRays;
-			}
-			else if (mShowPvsSizes) // pvs size
-			{
-				importance = mTransferFunction *
-					((float)vc->GetPvs().GetSize() / (float)maxPvs);
-			} // weighted render cost
-			else if (mShowWeightedCost)
-			{
-				const float rcCost = mTransferFunction * ComputeRenderCost(vc);
-				importance = rcCost / maxRcCost;
-			}
-
-			// c = RgbColor(importance, 1.0f - importance, 0.0f);
-			c = RainbowColorMapping(importance);
-
-			glColor4f(c.r, c.g, c.b, 1.0f - mTransparency);
-
-			if (!mHideByCost || (mHidingCost < importance)) 
-			{
-				RenderViewCell(vc);
-			}
-		}
+		ViewCellInfoContainer *infos1 = mCurrentInfos[mCurrentSamples];
+		ViewCellInfoContainer *infos2 = mCompareInfos[mCurrentSamples];
+
+		if (mAssignImportanceByRelativeValue)
+			AssignImportanceByRelativeValue(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost);
+		else
+			AssignColorByComparison(viewcells, *infos1, *infos2);
 
 		glEnable(GL_DEPTH_TEST);	
@@ -1423,29 +1401,96 @@
 
 
-
-/*********************************************************************/
-/*                   QtGlDebuggerWidget implementation               */
-/*********************************************************************/
-
-
-QtGlDebuggerWidget::QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent)
-: QGLWidget(QGLFormat(QGL::SampleBuffers), parent), mRenderBuffer(buf)
-{
-	// create the pbuffer
-	//pbuffer = new QGLPixelBuffer(QSize(512, 512), format(), this);
-	timerId = startTimer(20);
-	setWindowTitle(("OpenGL pbuffers"));
-}
-
-
-QtGlDebuggerWidget::~QtGlDebuggerWidget()
-{
-	mRenderBuffer->releaseFromDynamicTexture();
-	glDeleteTextures(1, &dynamicTexture);
-
-	DEL_PTR(mRenderBuffer);
-}
-
-
+void QtGlRendererWidget::AssignImportanceByRelativeValue(const ViewCellContainer &viewCells,
+														 int &maxPvs, 
+														 int &maxPiercingRays, 
+														 float &maxRelativeRays, 
+														 float &maxRcCost)
+{
+	for (size_t i = 0; i < viewCells.size(); ++ i) 
+	{
+		RgbColor c;
+		ViewCell *vc = viewCells[i];
+
+		float importance;
+
+		if (mShowPiercingRays)
+		{
+			importance = mTransferFunction *
+				((float)vc->GetNumPiercingRays() / (float)maxPiercingRays);
+		}
+		else if (mShowWeightedRays) // relative number of rays
+		{
+			float relativeArea = vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea();
+
+			if (relativeArea < Limits::Small)
+				relativeArea = Limits::Small;
+
+			importance = mTransferFunction * ((float)vc->GetNumPiercingRays() / relativeArea) / maxRelativeRays;
+		}
+		else if (mShowPvsSizes) // pvs size
+		{
+			importance = mTransferFunction *
+				((float)vc->GetPvs().GetSize() / (float)maxPvs);
+		} // weighted render cost
+		else if (mShowWeightedCost)
+		{
+			const float rcCost = mTransferFunction * ComputeRenderCost(vc);
+			importance = rcCost / maxRcCost;
+		}
+
+		// c = RgbColor(importance, 1.0f - importance, 0.0f);
+		c = RainbowColorMapping(importance);
+
+		glColor4f(c.r, c.g, c.b, 1.0f - mTransparency);
+
+		if (!mHideByCost || (mHidingCost < importance)) 
+		{
+			RenderViewCell(vc);
+		}
+	}
+}
+
+
+void QtGlRendererWidget::AssignColorByComparison(const ViewCellContainer &viewcells,
+												 const ViewCellInfoContainer &infos1, 
+												 const ViewCellInfoContainer &infos2)
+{
+
+	const float maxRatio = 2;
+	const float minRatio = 0.5;
+
+	const float scale = 1.0f / (maxRatio - minRatio);
+
+	for (size_t i = 0; i < viewcells.size(); ++ i) 
+	{
+		RgbColor c;
+		ViewCell *vc = viewcells[i];
+
+		ViewCellInfo vc1Info = infos1[i];
+		ViewCellInfo vc2Info = infos2[i];
+
+		const float vcRatio = vc1Info.mPiercingRays / vc2Info.mPiercingRays + Limits::Small;
+
+		const float importance = (vcRatio - minRatio) * scale;
+
+		// c = RgbColor(importance, 1.0f - importance, 0.0f);
+		c = RainbowColorMapping(importance);
+
+		glColor4f(c.r, c.g, c.b, 1.0f);
+
+		if (1)//!mHideByCost || (mHidingCost < importance)) 
+		{
+			RenderViewCell(vc);
+		}
+	}
+}
+
+
+
+/**********************************************************************/
+/*              QtRendererControlWidget implementation                */
+/**********************************************************************/
+
+#if 1
 QGroupBox *QtRendererControlWidget::CreateVisualizationPanel(QWidget *parent)
 {
@@ -1527,4 +1572,5 @@
 }
 
+
 QtRendererControlWidget::QtRendererControlWidget(QWidget * parent, Qt::WFlags f):
 QWidget(parent, f)
@@ -1843,8 +1889,5 @@
 void
 QtRendererControlWidget::FocusNextPvsErrorFrame(void)
-{
-
-
-}
+{}
 
 void
@@ -1865,4 +1908,32 @@
 
 
+
+#endif
+
+
+/*********************************************************************/
+/*                   QtGlDebuggerWidget implementation               */
+/*********************************************************************/
+
+
+QtGlDebuggerWidget::QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent)
+: QGLWidget(QGLFormat(QGL::SampleBuffers), parent), mRenderBuffer(buf)
+{
+	// create the pbuffer
+	//pbuffer = new QGLPixelBuffer(QSize(512, 512), format(), this);
+	timerId = startTimer(20);
+	setWindowTitle(("OpenGL pbuffers"));
+}
+
+
+QtGlDebuggerWidget::~QtGlDebuggerWidget()
+{
+	mRenderBuffer->releaseFromDynamicTexture();
+	glDeleteTextures(1, &dynamicTexture);
+
+	DEL_PTR(mRenderBuffer);
+}
+
+
 void QtGlDebuggerWidget::initializeGL()
 {
@@ -1945,4 +2016,5 @@
 }
 
+
 void QtGlDebuggerWidget::initCommon()
 {
@@ -1954,4 +2026,3 @@
 
 
-
-}
+}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.h	(revision 2576)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.h	(revision 2576)
@@ -0,0 +1,32 @@
+#ifndef __LOGWRITER_H
+#define __LOGWRITER_H
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include "common.h"
+#include "Containers.h"
+#include "LogReader.h"
+
+
+namespace GtpVisibilityPreprocessor 
+{
+
+//class ViewCellContainer;
+
+class LogWriter
+{
+	void SetFilename(const std::string &filename);
+
+	//void Write(const int numSamples, const ViewCellContainer &viewcells);
+	void Write(std::ofstream &myfile, const int numSamples, const ViewCellInfoContainer &infos);
+	void Write(const ViewCellHistoryContainer &hist);
+
+protected:
+
+	std::string mFilename;
+};
+
+}
+
+#endif
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2569)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2576)
@@ -13,4 +13,5 @@
 #include "Beam.h"
 #include "QtPreprocessorThread.h"
+#include "LogReader.h"
 
 
@@ -20,4 +21,5 @@
 
 namespace GtpVisibilityPreprocessor {
+
 
 class SceneGraph;
@@ -137,5 +139,5 @@
 
 
-class QtGlRendererWidget : public QGLWidget, public GlRendererWidget
+class QtGlRendererWidget: public QGLWidget, public GlRendererWidget
 {
 	Q_OBJECT
@@ -184,4 +186,6 @@
 	unsigned int mIndexBufferSize;
 
+	bool mAssignImportanceByRelativeValue;
+
 	Vector3 mDummyViewPoint;
 
@@ -189,4 +193,10 @@
 
 	QtPreprocessorThread *mPreprocessorThread;
+
+	int mCurrentSamples;
+
+	ViewCellHistoryContainer mCurrentInfos;
+	ViewCellHistoryContainer mCompareInfos;
+
 
 	QtGlRendererWidget(SceneGraph *sceneGraph,
@@ -201,6 +211,5 @@
 		mPreprocessorThread = t;
 	}
-	void
-		RenderRenderCost();
+	void RenderRenderCost();
 
 	virtual void SetupCamera();
@@ -245,4 +254,21 @@
 	bool PvsChanged(ViewCell *viewcell) const;
 
+	void ComputeMaxValues(const ViewCellContainer &viewCells,
+						  int &maxPvs, 
+						  int &maxPiercingRays, 
+						  float &maxRelativeRays, 
+						  float &maxRcCost);
+
+	void AssignImportanceByRelativeValue(const ViewCellContainer &viewCells,
+										 int &maxPvs, 
+										 int &maxPiercingRays, 
+										 float &maxRelativeRays, 
+										 float &maxRcCost);
+
+	void AssignColorByComparison(const ViewCellContainer &viewcells,
+								 const ViewCellInfoContainer &info1, 
+								 const ViewCellInfoContainer &info2);
+
+
 	/////////
 
@@ -411,5 +437,5 @@
 
 
-class QtGlDebuggerWidget : public QGLWidget
+class QtGlDebuggerWidget: public QGLWidget
 {
 	Q_OBJECT
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface.vcproj	(revision 2560)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface.vcproj	(revision 2576)
@@ -205,4 +205,10 @@
 			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
 			<File
+				RelativePath=".\LogReader.cpp">
+			</File>
+			<File
+				RelativePath=".\LogWriter.cpp">
+			</File>
+			<File
 				RelativePath=".\moc_QtGlRenderer.cpp">
 			</File>
@@ -224,4 +230,10 @@
 			Filter="h;hpp;hxx;hm;inl;inc;xsd"
 			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+			<File
+				RelativePath=".\LogReader.h">
+			</File>
+			<File
+				RelativePath=".\LogWriter.h">
+			</File>
 			<File
 				RelativePath=".\QtGlRenderer.h">
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/GlobalLinesRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/GlobalLinesRenderer.cpp	(revision 1940)
+++ 	(revision )
@@ -1,91 +1,0 @@
-#include "glInterface.h"
-#include "GlobalLinesRenderer.h"
-#include "common.h"
-
-#include <Cg/cg.h>
-#include <Cg/cgGL.h>
-
-#include <QtOpenGL>
-
-namespace GtpVisibilityPreprocessor {
-
-static CGcontext sCgContext = NULL;
-static CGprogram sCgDepthPeelingProgram = NULL;
-static CGprofile sCgFragmentProfile;
-
-
-static void handleCgError() 
-{
-    cerr << "Cg error: " << cgGetErrorString(cgGetError()) << endl;
-    exit(1);
-}
-
-
-GlobalLinesRenderer::GlobalLinesRenderer(QGLPixelBuffer *buffer1, QGLPixelBuffer *buffer2):
-mNewBuffer(buffer1), mOldBuffer(buffer2)
-{
-}
-
-
-GlobalLinesRenderer::~GlobalLinesRenderer()
-{
-	if (sCgDepthPeelingProgram)
-		cgDestroyProgram(sCgDepthPeelingProgram);
-	if (sCgContext)
-		cgDestroyContext(sCgContext);
-}
-
- 
-void GlobalLinesRenderer::CastGlobalLines(Beam &beam, const int samples)
-{
-	// bind pixel shader implementing the front depth buffer functionality
-	cgGLBindProgram(sCgDepthPeelingProgram);
-	cgGLEnableProfile(sCgFragmentProfile);
-
-	ApplyDepthPeeling(beam, samples);
-}
-
-
-void GlobalLinesRenderer::DrawGeometry()
-{
-}
-
-void GlobalLinesRenderer::ApplyDepthPeeling(Beam &beam, const int samples)
-{
-/*	if (rtNew->IsDoubleBuffered()) 
-		glDrawBuffer(GL_BACK);
-	
-	rtNew->BeginCapture();
-	{
-		cgGLBindProgram(passthru);
-		glColor3f(0,0.0,0.0);
-		DrawGeometry();   //just random geomerty   
-	}
-	rtNew->EndCapture();
-
-	for(int l = 0; l < mCurrentDepth; l++) 
-	{
-		// Peel another layer
-		pingpong(); // switch pointer between rendertextures
-     
-		rtNew->BeginCapture();
-		{
-			if (rtNew->IsDoubleBuffered()) 
-				glDrawBuffer(GL_BACK);
-        
-			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);         
-			
-			cgGLBindProgram(fragmentProgram);
-			cgGLSetTextureParameter(input1, rtOld->GetDepthTextureID());
-			cgGLEnableTextureParameter(input1);
-
-            glColor3f(0,0.0,0.0);
-			DrawGeometry();
-			cgGLDisableTextureParameter(input1);
-		}
-		rtNew->EndCapture();
-   }*/
-}
-
-
-}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/GlobalLinesRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/GlobalLinesRenderer.h	(revision 1940)
+++ 	(revision )
@@ -1,52 +1,0 @@
-#ifndef __GLOBALLINESRENDERER_H
-#define __GLOBALLINESRENDERER_H
-
-#include "common.h"
-#include "Containers.h"
-
-class Beam;
-class Intersectable;
-class QGLPixelBuffer;
-
-struct VssRayContainer;
-
-namespace GtpVisibilityPreprocessor {
-
-
-class __declspec(dllexport) GlobalLinesRenderer
-{
-	GlobalLinesRenderer(QGLPixelBuffer *buffer1, QGLPixelBuffer *buffer2);
-	~GlobalLinesRenderer();
-
-	void CastGlobalLines(Beam &beam, const int samples);
-
-	void InitGL();
-
-	/** Computes rays from information gained with hw sampling
-	*/
-	void ComputeRays(Intersectable *sourceObj, VssRayContainer &rays);
-
-	float GetPixelError(int &pvsSize);
-
-	int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const;
-
-private:
-
-	/** Draws the geometry for one pass.
-	*/
-	void DrawGeometry();
-
-	void ApplyDepthPeeling(Beam &beam, const int samples);
-
-	void SetupProjection(const Vector3 &viewPoint, 
-						 const Beam &beam);
-
-	QGLPixelBuffer *mNewBuffer;
-	QGLPixelBuffer *mOldBuffer;
-};
-
-
-};
-
-#endif
-
