Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 2560)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 2584)
@@ -125,5 +125,5 @@
 				OptimizeForProcessor="2"
 				OptimizeForWindowsApplication="TRUE"
-				AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(CG_INC_PATH)&quot;;Timer;..\src\sparsehash\src\google\sparsehash;..\src\sparsehash\src\windows;..\src\sparsehash\src\google;..\src\sparsehash\src;..\src\ootl\;..\src\ootl\src\;..\src\ootl\src\cpp;..\src\ootl\src\cpp\include\;..\src\ootl\src\include\ootl;..\src\ootl\src\include\ootl\sandbox;..\src\ootl\src\cpp\include\ootl\mswin"
+				AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(CG_INC_PATH)&quot;;Timer;..\src\sparsehash\src\google\sparsehash;..\src\sparsehash\src\windows;..\src\sparsehash\src\google;..\src\sparsehash\src;..\src\ootl\;..\src\ootl\src\;..\src\ootl\src\cpp;..\src\ootl\src\cpp\include\;..\src\ootl\src\include\ootl;..\src\ootl\src\include\ootl\sandbox;..\src\ootl\src\cpp\include\ootl\mswin;..\src\havran"
 				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GTP_INTERNAL;USE_QT;USE_VERBOSE_PVS;USE_CG"
 				StringPooling="TRUE"
@@ -1053,8 +1053,8 @@
 			</File>
 			<File
+				RelativePath=".\sparsehash\src\windows\hash_fun.h">
+			</File>
+			<File
 				RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h">
-			</File>
-			<File
-				RelativePath=".\sparsehash\src\windows\hash_fun.h">
 			</File>
 			<File
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.cpp	(revision 2581)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.cpp	(revision 2584)
@@ -23,6 +23,5 @@
 
 
-void LogWriter::Write(//ofstream &myfile, 
-					  const int numSamples, const ViewCellInfoContainer &infos)
+void LogWriter::Write(const int numSamples, const ViewCellContainer &viewCells)
 {
 	ofstream myfile;
@@ -32,40 +31,13 @@
 		myfile.open(mFilename.c_str());
 
-	ViewCellInfoContainer::const_iterator vit, vit_end = infos.end();
+	ViewCellContainer::const_iterator vit, vit_end =viewCells.end();
 
 	myfile << numSamples << endl;
 
-	for (vit = infos.begin(); vit != vit_end; ++ vit)
+	for (vit = viewCells.begin(); vit != vit_end; ++ vit)
 	{
-		myfile << (*vit).mPiercingRays << " " << (*vit).mPvsSize << endl;
-		//myfile << (*vit);
-		//ViewCell *vc = *vit;
-		//myfile << "vc: " << vc->GetPvs().GetSize() << " " << vc->GetNumPiercingRays();
+		myfile << (*vit)->GetNumPiercingRays() << " " << (*vit)->GetPvs().GetSize() << endl;
 	}
 }
 
-/*
-void LogWriter::Write(const ViewCellHistoryContainer &hist)
-{
-	//ofstream myfile;
-	//char filename[64]; 
-	//sprintf(filename, "%s %06d", mFilename.c_str(), numSamples);
-	//myfile.open(filename);
-	if (!mFile.is_open())
-		mFile.open(mFilename.c_str());
-
-	ViewCellHistoryContainer::const_iterator vit, vit_end = hist.end();
-
-	// number of samples
-	//myfile << "samples: " << numSamples << endl;
-	mFile << (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 2581)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2584)
@@ -846,6 +846,4 @@
 	mRenderVisibilityEstimates = false;
 
-	mHistRecorded = false;
-
 	mHideByCost = false;
 	mUseTransparency = false;
@@ -885,17 +883,14 @@
 	mShowRays = false;
 
-	mNextSamples = SAMPLES_INCR;
 	mControlWidget = new QtRendererControlWidget(NULL);
 
 	connect(mControlWidget, SIGNAL(SetViewCellGranularity(int)), this, SLOT(SetViewCellGranularity(int)));
-	connect(mControlWidget,
-		SIGNAL(SetTransferFunction(int)),
-		this,
-		SLOT(SetTransferFunction(int)));
+	connect(mControlWidget,	SIGNAL(SetTransferFunction(int)), this,	SLOT(SetTransferFunction(int)));
+
 	connect(mControlWidget, SIGNAL(UpdateAllPvs()), this, SLOT(UpdateAllPvs()));
 	connect(mControlWidget, SIGNAL(ComputeVisibility()), this, SLOT(ComputeVisibility()));
 	connect(mControlWidget, SIGNAL(StopComputation()), this, SLOT(StopComputation()));
-	connect(mControlWidget, SIGNAL(SetRandomViewPoint()), this,
-		SLOT(SetRandomViewPoint()));
+	connect(mControlWidget, SIGNAL(SetRandomViewPoint()), this,	SLOT(SetRandomViewPoint()));
+	connect(mControlWidget, SIGNAL(StoreStatistics(void)), this, SLOT(StoreStatistics(void)));
 
 	connect(mControlWidget, SIGNAL(SetSceneCut(int)), this, SLOT(SetSceneCut(int)));
@@ -965,6 +960,23 @@
 QtGlRendererWidget::SetRandomViewPoint()
 {
-	cerr<<"stop computation called!\n"<<endl;
+	cerr<<"setting random view point!\n"<<endl;
 	mViewCellsManager->GetViewPoint(mViewPoint);
+	updateGL();
+}
+
+
+void QtGlRendererWidget::StoreStatistics()
+{
+	cerr<<"storing statistics!\n"<<endl;
+	const int currentSamples = mViewCellsManager->GetPreprocessor()->mCurrentSamples;
+
+	cout<<"**********************************************" << endl;
+	cout << "reached " << currentSamples << " samples " << " => writing file" << endl;
+		
+	LogWriter writer;
+	writer.SetFilename("compare.log");
+	writer.Write(currentSamples, mViewCellsManager->GetViewCells());
+	cout << "finished writing file" << endl;
+	mCompareInfo.clear();
 	updateGL();
 }
@@ -1306,23 +1318,4 @@
 
 
-
-void QtGlRendererWidget::FillNewContainer(const ViewCellContainer &viewCells, ViewCellInfoContainer &infos)
-{
-	ViewCellContainer::const_iterator vit, vit_end = viewCells.end();
-
-	for (vit = viewCells.begin(); vit != vit_end; ++ vit)
-	{
-        ViewCell *vc = *vit;
-		ViewCellInfo info;
-
-		info.mPiercingRays = vc->GetNumPiercingRays();
-
-		infos.push_back(info);
-		//myfile << "vc: " << vc->GetPvs().GetSize() << " " << vc->GetNumPiercingRays();
-	}
-}
-
-
-
 void QtGlRendererWidget::RenderViewCells()
 {
@@ -1347,30 +1340,6 @@
 	}
 
-	mNextSamples = 200000;
-
 	ViewCellContainer &viewcells = mViewCellsManager->GetViewCells();
-	const int currentSamples = mViewCellsManager->GetPreprocessor()->mCurrentSamples;
-	//cout << "current samples: " << currentSamples << endl;
-
-	if (!mHistRecorded && (currentSamples > mNextSamples))
-	{
-		mHistRecorded = true;
-
-		//mNextSamples += SAMPLES_INCR;
-		cout<<"************************************************" << endl;
-		cout << "reached " << currentSamples << " samples " << " => writing file" << endl;
-		//ViewCellInfoContainer newContainer;
-
-		mCurrentInfo.clear();
-		FillNewContainer(viewcells, mCurrentInfo);
-		//mCurrentHist[mNextSamples] = newContainer;
-		
-		LogWriter writer;
-		writer.SetFilename("compare.log");
-		writer.Write(mNextSamples, mCurrentInfo);
-
-		cout << "finished writing file" << endl;
-	}
-
+	
 	int maxPvs, maxPiercingRays;
 	float maxRelativeRays, maxRcCost;
@@ -1428,17 +1397,17 @@
 		}
 
-		if (!mShowComparison)//mAssignImportanceByRelativeValue)
+		if (!mShowComparison)
 			AssignImportanceByRelativeValue(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost);
 		else
 		{
-			mCurrentInfo.clear();
-			FillNewContainer(viewcells, mCurrentInfo);
-
-			//ViewCellInfoContainer *infos1 = mCurrentHist[mNextSamples];
-			//ViewCellInfoContainer *infos2 = mCompareHist[mNextSamples];
-
-			//AssignColorByComparison(viewcells, *infos1, *infos2);
-			AssignColorByComparison(viewcells, //mCurrentInfo, 
-				mCompareInfo);
+			if (mCompareInfo.empty())
+			{
+				LogReader reader;
+				reader.SetFilename("compare.log");
+				int samples;
+				reader.Read(samples, mCompareInfo);
+			}
+
+			AssignColorByComparison(viewcells, mCompareInfo);
 		}
 
@@ -1513,7 +1482,15 @@
 												 const ViewCellInfoContainer &compareInfo)
 {
-
-	const float maxRatio = 1.0f;
-	const float minRatio = 0.5f;
+	//cout << "comparing " << viewcells.size() << " view cells to " << compareInfo.size() << " values" << endl;
+
+	if (viewcells.size() > compareInfo.size())
+	{
+		cerr << "loaded size (" << compareInfo.size() << ") does not fit to view cells size (" << viewcells.size() << ")" << endl;
+		return;
+	}
+
+	//const float maxRatio = 1.0f;
+	const float maxRatio = 2.0f;
+	const float minRatio = 0.0f;
 
 	const float scale = 1.0f / (maxRatio - minRatio);
@@ -1527,7 +1504,19 @@
 		ViewCellInfo vc2Info = compareInfo[i];
 
-		const float vcRatio = vc->GetNumPiercingRays() / vc2Info.mPiercingRays + Limits::Small;
+		//const float vcRatio = vc->GetNumPiercingRays() / vc2Info.mPiercingRays + Limits::Small;
+		float vcRatio = 1.0f;//maxRatio;
+		
+		if (vc2Info.mPvsSize > Limits::Small) 
+			vcRatio = (float)vc->GetPvs().GetSize() / vc2Info.mPvsSize;
+
+		// truncate here
+		if (vcRatio > maxRatio) vcRatio = 1.0f;
 
 		const float importance = (vcRatio - minRatio) * scale;
+	
+		if (i < 20)
+		{
+			cout << "pvs1: " << vc->GetPvs().GetSize() << " pvs2: " << compareInfo[i].mPvsSize << " importance: " << importance << endl;
+		}
 
 		// c = RgbColor(importance, 1.0f - importance, 0.0f);
@@ -1744,13 +1733,10 @@
 
 	myBox->setLayout(vh);
-
 	vl->addWidget(myBox, 0, 0);
 
 	QGroupBox *groupBox = CreateVisualizationPanel(hbox);
-
 	vh->addWidget(groupBox, 0, 0);
 
 	QGroupBox *groupBox2 = CreateRenderCostPanel(hbox);
-
 	vh->addWidget(groupBox2, 0, 0);
 
@@ -1900,5 +1886,5 @@
 
 
-	vbox = new QGroupBox("PVS Errors", this);
+	/*vbox = new QGroupBox("PVS Errors", this);
 	layout()->addWidget(vbox);
 
@@ -1916,7 +1902,15 @@
 	button = new QPushButton("Set Random View Point", vbox);
 	vbox->layout()->addWidget(button);
-	connect(button, SIGNAL(clicked()), SLOT(SetRandomViewPoint()));
-
-
+	connect(button, SIGNAL(clicked()), SLOT(SetRandomViewPoint()));*/
+
+	button = new QPushButton("Store statistics", vbox);
+	vbox->layout()->addWidget(button);
+	connect(button, SIGNAL(clicked()), SIGNAL(StoreStatistics()));
+
+	/*cb = new QCheckBox("Stats", vbox);
+	vbox->layout()->addWidget(cb);
+	cb->setChecked(false);
+	connect(cb, SIGNAL(toggled(bool)), SIGNAL(StoreStatistics()));
+*/
 	if (0) 
 	{
@@ -1940,4 +1934,5 @@
 	}
 	
+	//connect(button, SIGNAL(clicked(void)), SLOT(StoreStatistics(void)));
 	//mHidingCost = 0.1f;
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.h	(revision 2580)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.h	(revision 2584)
@@ -23,12 +23,9 @@
 	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);
+	void Write(const int numSamples, const ViewCellContainer &viewcells);
+	
 
 protected:
 
-	//std::ofstream mFile;
 	std::string mFilename;
 };
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2581)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2584)
@@ -105,4 +105,5 @@
   void StopComputation();
   void SetRandomViewPoint();
+  void StoreStatistics();
   void UpdateAllPvs();
   void SetViewCellGranularity(int);
@@ -185,10 +186,4 @@
 	bool mShowWeightedTriangles;
 
-	/// the current number of samples
-	//int mCurrentSamples;
-	/// the next number of samples where we record the data
-	int mNextSamples;
-	bool mHistRecorded;
-
 	// some statistics
 	int mPvsSize;
@@ -198,6 +193,4 @@
 	unsigned int mIndexBufferSize;
 
-	//bool mAssignImportanceByRelativeValue;
-
 	Vector3 mDummyViewPoint;
 
@@ -206,10 +199,4 @@
 	QtPreprocessorThread *mPreprocessorThread;
 
-	int mCurrentSamples;
-
-	//ViewCellHistoryContainer mCurrentHist;
-	//ViewCellHistoryContainer mCompareHist;
-
-	ViewCellInfoContainer mCurrentInfo;
 	ViewCellInfoContainer mCompareInfo;
 
@@ -223,8 +210,6 @@
 	QtGlRendererWidget() {};
 
-	void FillNewContainer(const ViewCellContainer &viewCells, ViewCellInfoContainer &infos);
-
-
-	void SetThread(QtPreprocessorThread *t) {
+	void SetThread(QtPreprocessorThread *t)
+	{
 		mPreprocessorThread = t;
 	}
@@ -288,4 +273,6 @@
 								 const ViewCellInfoContainer &compareInfo);
 
+	void WriteViewCellInfos();
+
 
 	/////////
@@ -300,4 +287,5 @@
 	void StopComputation();
 	void SetRandomViewPoint();
+	void StoreStatistics();
 
 	void SetRenderErrors(bool b) {
@@ -452,4 +440,6 @@
 
 	float ComputeRenderCost(ViewCell *vc);
+
+
 
 	/////////
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.cpp	(revision 2580)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.cpp	(revision 2584)
@@ -12,40 +12,8 @@
 
 
-/*void LogReader::Read(ViewCellHistoryContainer &history)
+void LogReader::Read(int &numSamples, ViewCellInfoContainer &infos)
 {
-	int numViewCells, numSamples;
-    
-	// open file
-	std::ifstream src(mFilename.c_str());
-
-	if (src.is_open())
-	{
-		src >> numViewCells;
-		src >> numSamples;
-
-		while (!src.eof())
-		{
-			ViewCellInfoContainer *infos = new ViewCellInfoContainer();
-
-			for (size_t i = 0; i << numViewCells; ++ i)
-			{
-				ViewCellInfo info;
-				src >> info.mPiercingRays;	
-				infos->push_back(info);
-			}
-
-			history[numSamples] = infos;
-		}
-
-		src.close();
-	}
-}*/
-
-
-void LogReader::Read(const int numSamples, ViewCellInfoContainer &infos)
-{
-	 char filename[64]; 
+	 //char filename[64]; 
 	 //sprintf(filename, "%s %06d", mFilename.c_str(), numSamples);
-	
 	 // open file
 	 std::ifstream src(mFilename.c_str());
@@ -53,9 +21,13 @@
 	 if (src.is_open())
 	 {
-		 while (!src.eof())
+		 src >> numSamples;
+
+		 while (1)
 		 {
 			 ViewCellInfo info;
-			 src >> info.mPiercingRays;	
-
+			 src >> info.mPiercingRays;	src >> info.mPvsSize;
+			 
+			 if (src.eof()) break;
+			 
 			 infos.push_back(info);
 		 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.h	(revision 2581)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.h	(revision 2584)
@@ -27,4 +27,5 @@
 class LogReader
 {
+public:
 	void SetFilename(const std::string &filename);
 
@@ -34,5 +35,5 @@
 	/** Reads the viewcells info from disc
 	*/
-	void Read(const int numSamples, ViewCellInfoContainer &infos);
+	void Read(int &numSamples, ViewCellInfoContainer &infos);
 
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ReverseGvs.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ReverseGvs.cpp	(revision 2582)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ReverseGvs.cpp	(revision 2584)
@@ -380,5 +380,5 @@
 	// mlrtaTraverseGroupASEye4(&box.Min().x, &box.Max().x, hit_triangles, dist);
 	assert(preprocessor->mRayCaster);
-	preprocessor->mRayCaster->CastRaysPacket4(&box.Min(), &box.Max(), origs,
+	preprocessor->mRayCaster->CastRaysPacket4(box.Min(), box.Max(), origs,
 						  dirs, hit_triangles, dist);
 	
