Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2575)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2580)
@@ -20,5 +20,7 @@
 #include "VssRay.h"
 #include "IntelRayCaster.h"
+#if TODO
 #include "HavranRayCaster.h"
+#endif
 #include "InternalRayCaster.h"
 #include "GlobalLinesRenderer.h"
@@ -1059,7 +1061,9 @@
 	  //HavranRayCaster *hr =
 	  //  dynamic_cast<HavranRayCaster*>(mRayCaster);
+#if TODO
 	  HavranRayCaster *hr =
 	    reinterpret_cast<HavranRayCaster*>(mRayCaster);
 	  hr->Build(this->mObjects);
+#endif
 	  return true;
 	}	
@@ -1149,6 +1153,8 @@
 	if (rayCastMethod == 2) 
 	{
-	  cout << "ray cast method: havran" << endl;
+#if TODO
+		cout << "ray cast method: havran" << endl;
 	  mRayCaster = new HavranRayCaster(*this);
+#endif
 	}
 	
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 2580)
@@ -7,4 +7,14 @@
 
 
+LogWriter::LogWriter()
+{
+}
+
+
+LogWriter::LogWriter(const std::string &filename): mFilename(filename)
+{
+}
+
+
 void LogWriter::SetFilename(const std::string &filename)
 {
@@ -13,6 +23,13 @@
 
 
-void LogWriter::Write(ofstream &myfile, const int numSamples, const ViewCellInfoContainer &infos)
+void LogWriter::Write(//ofstream &myfile, 
+					  const int numSamples, const ViewCellInfoContainer &infos)
 {
+	ofstream myfile;
+	myfile.open(mFilename.c_str());
+
+	if (!myfile.is_open())
+		myfile.open(mFilename.c_str());
+
 	ViewCellInfoContainer::const_iterator vit, vit_end = infos.end();
 
@@ -25,13 +42,13 @@
 }
 
-
+/*
 void LogWriter::Write(const ViewCellHistoryContainer &hist)
 {
-	ofstream myfile;
-
+	//ofstream myfile;
 	//char filename[64]; 
 	//sprintf(filename, "%s %06d", mFilename.c_str(), numSamples);
 	//myfile.open(filename);
-	myfile.open(mFilename.c_str());
+	if (!mFile.is_open())
+		mFile.open(mFilename.c_str());
 
 	ViewCellHistoryContainer::const_iterator vit, vit_end = hist.end();
@@ -39,5 +56,5 @@
 	// number of samples
 	//myfile << "samples: " << numSamples << endl;
-	myfile << (int)hist.size() << endl;
+	mFile << (int)hist.size() << endl;
 
 	for (vit = hist.begin(); vit != vit_end; ++ vit)
@@ -47,3 +64,5 @@
 }
 
+*/
+
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2577)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2580)
@@ -16,4 +16,5 @@
 #include "Material.h"
 #include "IntersectableWrapper.h"
+#include "LogWriter.h"
 
 
@@ -44,4 +45,5 @@
 QtGlDebuggerWidget *debuggerWidget = NULL;
 
+const static int SAMPLES_INCR = 2000000;
 
 static inline bool ilt(Intersectable *obj1, Intersectable *obj2)
@@ -860,10 +862,12 @@
 	mUseFilter = tmp;
 
-	Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilitySpatialFilter",
-		tmp );
+	Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilitySpatialFilter", tmp );
 	mUseSpatialFilter = tmp;
+
+	//mLogWriter = new LogWriter("myfile.out");
 
 	mShowRenderCost = false;
 	mShowPvsSizes = false;
+	mShowComparison = false;
 	mShowPiercingRays = false;
 	mShowWeightedRays = false;
@@ -879,4 +883,5 @@
 	mShowRays = false;
 
+	mNextSamples = SAMPLES_INCR;
 	mControlWidget = new QtRendererControlWidget(NULL);
 
@@ -904,4 +909,5 @@
 	connect(mControlWidget, SIGNAL(SetUseTransparency(bool)), this, SLOT(SetUseTransparency(bool)));
 	connect(mControlWidget, SIGNAL(SetShowPvsSizes(bool)), this, SLOT(SetShowPvsSizes(bool)));
+	connect(mControlWidget, SIGNAL(SetShowComparison(bool)), this, SLOT(SetShowComparison(bool)));
 	connect(mControlWidget, SIGNAL(SetTopView(bool)), this, SLOT(SetTopView(bool)));
 	connect(mControlWidget, SIGNAL(SetCutViewCells(bool)), this, SLOT(SetCutViewCells(bool)));
@@ -1341,17 +1347,27 @@
 	int i;
 
-	mRecordHist = false;
-	//mRecordHist = true;
+	//mRecordHist = false;
+	mRecordHist = true;
+	mNextSamples = 2000000;
 
 	ViewCellContainer &viewcells = mViewCellsManager->GetViewCells();
-	
-	if (mRecordHist && (mSamples > mNextSamples))
-	{
-		mNextSamples += 2000000;
-
-		ViewCellInfoContainer *newContainer = new ViewCellInfoContainer();
-
-		FillNewContainer(viewcells, *newContainer);
-		mCurrentHist[mNextSamples] = newContainer;
+	const int currentSamples = mViewCellsManager->GetPreprocessor()->mCurrentSamples;
+	//cout << "current samples: " << currentSamples << endl;
+
+	if (mRecordHist && (currentSamples > mNextSamples))
+	{
+		//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;
 	}
 
@@ -1410,13 +1426,18 @@
 		}
 
-		if (mAssignImportanceByRelativeValue)
+		if (!mShowComparison)//mAssignImportanceByRelativeValue)
 			AssignImportanceByRelativeValue(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost);
 		else
 		{
-			ViewCellInfoContainer *infos1 = mCurrentHist[mCurrentSamples];
-			ViewCellInfoContainer *infos2 = mCompareHist[mCurrentSamples];
-			AssignColorByComparison(viewcells, *infos1, *infos2);
-		}
-
+			mCurrentInfo.clear();
+			FillNewContainer(viewcells, mCurrentInfo);
+
+			//ViewCellInfoContainer *infos1 = mCurrentHist[mNextSamples];
+			//ViewCellInfoContainer *infos2 = mCompareHist[mNextSamples];
+
+			//AssignColorByComparison(viewcells, *infos1, *infos2);
+			AssignColorByComparison(viewcells, //mCurrentInfo, 
+				mCompareInfo);
+		}
 
 		glEnable(GL_DEPTH_TEST);	
@@ -1487,10 +1508,10 @@
 
 void QtGlRendererWidget::AssignColorByComparison(const ViewCellContainer &viewcells,
-												 const ViewCellInfoContainer &infos1, 
-												 const ViewCellInfoContainer &infos2)
-{
-
-	const float maxRatio = 2;
-	const float minRatio = 0.5;
+												 //const ViewCellInfoContainer &infos1, 
+												 const ViewCellInfoContainer &compareInfo)
+{
+
+	const float maxRatio = 1.0f;
+	const float minRatio = 0.5f;
 
 	const float scale = 1.0f / (maxRatio - minRatio);
@@ -1501,8 +1522,8 @@
 		ViewCell *vc = viewcells[i];
 
-		ViewCellInfo vc1Info = infos1[i];
-		ViewCellInfo vc2Info = infos2[i];
-
-		const float vcRatio = vc1Info.mPiercingRays / vc2Info.mPiercingRays + Limits::Small;
+		//ViewCellInfo vc1Info = infos1[i];
+		ViewCellInfo vc2Info = compareInfo[i];
+
+		const float vcRatio = vc->GetNumPiercingRays() / vc2Info.mPiercingRays + Limits::Small;
 
 		const float importance = (vcRatio - minRatio) * scale;
@@ -1526,5 +1547,5 @@
 /**********************************************************************/
 
-#if 1
+
 QGroupBox *QtRendererControlWidget::CreateVisualizationPanel(QWidget *parent)
 {
@@ -1707,4 +1728,9 @@
 	cb->setChecked(false);
 	connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowRays(bool)));
+	
+	cb = new QCheckBox("Show Comparison", hbox);
+	hlayout->addWidget(cb);
+	cb->setChecked(false);
+	connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowComparison(bool)));
 
 
@@ -1943,6 +1969,4 @@
 
 
-#endif
-
 
 /*********************************************************************/
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 2580)
@@ -17,12 +17,18 @@
 class LogWriter
 {
+public:
+
+	LogWriter();
+	LogWriter(const std::string &filename);
 	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(//std::ofstream &myfile, 
+				const int numSamples, const ViewCellInfoContainer &infos);
+	//void Write(const ViewCellHistoryContainer &hist);
 
 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 2577)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2580)
@@ -41,4 +41,7 @@
 struct RenderCostSample;
 
+//class LogWriter;
+
+
 
 class QtGlRendererBuffer : public QObject, public QGLPixelBuffer, public GlRendererBuffer
@@ -124,4 +127,5 @@
   void SetShowPiercingRays(bool);
   void SetShowWeightedRays(bool);
+   void SetShowComparison(bool);
   void SetShowWeightedCost(bool);
  
@@ -163,6 +167,8 @@
 
 	bool mShowPvsSizes;
+	bool mShowComparison;
 	float mSpatialFilterSize;
 
+	//LogWriter *mLogWriter;
 	Plane3 mSceneCutPlane;
 	float mHidingCost;
@@ -180,5 +186,5 @@
 
 	/// the current number of samples
-	int mSamples;
+	//int mCurrentSamples;
 	/// the next number of samples where we record the data
 	int mNextSamples;
@@ -192,5 +198,5 @@
 	unsigned int mIndexBufferSize;
 
-	bool mAssignImportanceByRelativeValue;
+	//bool mAssignImportanceByRelativeValue;
 
 	Vector3 mDummyViewPoint;
@@ -202,13 +208,16 @@
 	int mCurrentSamples;
 
-	ViewCellHistoryContainer mCurrentHist;
-	ViewCellHistoryContainer mCompareHist;
-
+	//ViewCellHistoryContainer mCurrentHist;
+	//ViewCellHistoryContainer mCompareHist;
+
+	ViewCellInfoContainer mCurrentInfo;
+	ViewCellInfoContainer mCompareInfo;
 
 	QtGlRendererWidget(SceneGraph *sceneGraph,
-		ViewCellsManager *viewcells,
-		KdTree *tree,
-		QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0
-		);
+		               ViewCellsManager *viewcells,
+					   KdTree *tree,
+					   QWidget * parent = 0, 
+					   const QGLWidget *shareWidget = 0, 
+					   Qt::WFlags f = 0);
 
 	QtGlRendererWidget() {};
@@ -276,6 +285,6 @@
 
 	void AssignColorByComparison(const ViewCellContainer &viewcells,
-								 const ViewCellInfoContainer &info1, 
-								 const ViewCellInfoContainer &info2);
+								 //const ViewCellInfoContainer &info1, 
+								 const ViewCellInfoContainer &compareInfo);
 
 
@@ -368,4 +377,9 @@
 	void SetShowPvsSizes(bool b) {
 		mShowPvsSizes = b;
+		updateGL();
+	}
+
+	void SetShowComparison(bool b) {
+		mShowComparison = b;
 		updateGL();
 	}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.cpp	(revision 2578)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.cpp	(revision 2580)
@@ -12,15 +12,6 @@
 
 
-void LogReader::Read(ViewCellHistoryContainer &history)
+/*void LogReader::Read(ViewCellHistoryContainer &history)
 {
-	/*std::vector<int>::const_iterator it, it_end = numSamples.end();
-
-	for (it = numSamples.begin(); it != it_end; ++ it)
-	{
-		int numSamples = *it;
-
-		Read(numSamples, infos);
-		}*/
-
 	int numViewCells, numSamples;
     
@@ -49,14 +40,14 @@
 		src.close();
 	}
-}
+}*/
 
 
-/*void LogReader::Read(const int numSamples, ViewCellInfoContainer &infos)
+void LogReader::Read(const int numSamples, ViewCellInfoContainer &infos)
 {
 	 char filename[64]; 
-	 sprintf(filename, "%s %06d", mFilename.c_str(), numSamples);
+	 //sprintf(filename, "%s %06d", mFilename.c_str(), numSamples);
 	
 	 // open file
-	 std::ifstream src(filename);
+	 std::ifstream src(mFilename.c_str());
 
 	 if (src.is_open())
@@ -65,5 +56,4 @@
 		 {
 			 ViewCellInfo info;
-
 			 src >> info.mPiercingRays;	
 
@@ -76,5 +66,5 @@
 		 src.close();
 	 }
-}*/
+}
 
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.h	(revision 2578)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.h	(revision 2580)
@@ -21,10 +21,6 @@
 
 typedef std::vector<ViewCellInfo> ViewCellInfoContainer;
-typedef std::map<int, ViewCellInfoContainer *> ViewCellHistoryContainer;
+//typedef std::map<int, ViewCellInfoContainer *> ViewCellHistoryContainer;
 
-
-/*struct ViewCellHistory;
-{
-}*/
 
 class LogReader
@@ -34,6 +30,6 @@
 	/** Reads the info for several #samples.
 	*/
-	void Read(ViewCellHistoryContainer &history);
-	/** Reads the viewcells info after specific #samples.
+	//void Read(ViewCellHistoryContainer &history);
+	/** Reads the viewcells info from disc
 	*/
 	void Read(const int numSamples, ViewCellInfoContainer &infos);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2575)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2580)
@@ -259,9 +259,11 @@
 
 	int mTotalSamples;
+	int mCurrentSamples;
+
 	int mTotalTime;
 	int mSamplesPerPass;
 	int mSamplesPerEvaluation;
-  
-  int mTotalRaysCast;
+ 
+	int mTotalRaysCast;
 
 	RayCaster *mRayCaster;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp	(revision 2574)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp	(revision 2580)
@@ -76,8 +76,10 @@
   long startTime = GetTime();
 
-  for (int i=0; i < mTotalSamples; i += mSamplesPerPass, mPass++) {
+  mCurrentSamples = 0;
+
+  for (mCurrentSamples =0; mCurrentSamples < mTotalSamples; mCurrentSamples += mSamplesPerPass, mPass++) {
 	mRayCaster->InitPass();
 	
-	cout<<"Progress :"<<i/1e6f<<"M rays, "<<(100.0f*i)/mTotalSamples<<"%"<<endl;
+	cout<<"Progress :"<<mCurrentSamples/1e6f<<"M rays, "<<(100.0f*mCurrentSamples)/mTotalSamples<<"%"<<endl;
 	
 	rays.clear();
@@ -122,5 +124,5 @@
 	mMixtureDistribution->UpdateDistributions(vssRays);
 	
-	if (i - lastEvaluation >= mSamplesPerEvaluation) {
+	if (mCurrentSamples - lastEvaluation >= mSamplesPerEvaluation) {
 	  Real time = TimeDiff(startTime, GetTime());
 	  mViewCellsManager->PrintPvsStatistics(mStats);
@@ -128,5 +130,5 @@
 		"#Pass\n" <<mPass<<endl<<
 		"#Time\n" << time <<endl<<
-		"#TotalSamples\n" <<i<<endl<<
+		"#TotalSamples\n" << mCurrentSamples <<endl<<
 		"#RssSamples\n" <<mTotalRaysCast<<endl;
 
@@ -143,5 +145,5 @@
 	  }
 	  
-	  lastEvaluation = i;
+	  lastEvaluation = mCurrentSamples;
 	  
 	  if (renderer) {
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2575)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2580)
@@ -8,5 +8,7 @@
 #include "RssTree.h"
 #include "Mutation.h"
+#if TODO
 #include "FilterBasedDistribution.h"
+#endif
 #include "DifferenceSampling.h"
 
@@ -726,5 +728,7 @@
 					} else
 					  if (strcmp(curr, "filter_based")==0) {
+#if TODO
 						mDistributions.push_back(new FilterBasedDistribution(mPreprocessor));
+#endif
 					  }
 					else if (strcmp(curr, "difference")==0) {
