Index: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2643)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2648)
@@ -20,5 +20,4 @@
   
 #define GVS_DEBUG 0
-static ObjectContainer myobjects;
 
 struct VizStruct
@@ -32,5 +31,7 @@
 static const float MIN_DIST = 0.001f;
 
+static ObjectContainer myobjects;
 static vector<VizStruct> vizContainer;
+
 
 GvsPreprocessor::GvsPreprocessor(): 
@@ -78,4 +79,6 @@
 	mGvsStats.Reset();
 
+	// hack: some generic statistical values that can be read
+	// by an application using the preprocessor
 	mGenericStats = 0;
 	mGenericStats2 = 0;
@@ -105,7 +108,4 @@
 ViewCell *GvsPreprocessor::NextViewCell()
 {
-	//if (mViewCellsManager->GetNumViewCells() == mProcessedViewCells)
-	//	return false; // no more view cells
-
 	if (mProcessedViewCells == (int)mViewCells.size())
 		return NULL; // no more view cells
@@ -440,13 +440,15 @@
 
 	const int numBorderSamples = (int)vssRays.size() - numRandomRays;
+
+#if 0
 	// set flags
-	/*VssRayContainer::const_iterator rit, rit_end = vssRays.end();
+	VssRayContainer::const_iterator rit, rit_end = vssRays.end();
 	for (rit = vssRays.begin(); rit != rit_end; ++ rit, ++ i)
 		(*rit)->mFlags |= VssRay::BorderSample;
-		*/
+#endif
+
 	int castRays = (int)simpleRays.size();
 
 	VssRayContainer invalidSamples;
-
 
 	// handle rays
@@ -783,4 +785,5 @@
 	int oldContribution = mGvsStats.mTotalContribution;
 	int passSamples = 0;
+
 	mGenericStats = 0;
 	mGenericStats2 = 0;
@@ -831,9 +834,7 @@
 void GvsPreprocessor::CompileViewCellsList()
 {
+	// Receive list of view cells from view cells manager
 	ViewCellPointsList *vcPoints = mViewCellsManager->GetViewCellPointsList();
-
-	
-	int i = 0;
-
+	
 	if (!vcPoints->empty())
 	{
@@ -843,5 +844,5 @@
 
 		for (vit = vcPoints->begin(); vit != vit_end; ++ vit)
-		{//cout << i ++ << " " << (*vit)->first->GetId() << endl;
+		{
 			mViewCells.push_back((*vit)->first);
 		}
@@ -941,5 +942,4 @@
 
 
-
 void GvsPreprocessor::PerViewCellComputation()
 {
@@ -954,5 +954,5 @@
 			(*oit)->mCounter = 0;
 
-		ComputeViewCell(vc);
+        ComputeViewCell(vc);
 	}
 }
@@ -1124,20 +1124,11 @@
 #endif
 
-	mGvsStats.Stop();
-	mGvsStats.Print(mGvsStatsStream);
-
 	if (mPerViewCell)
 	{
-#if 0
+#if 1
 		// provide list of view cells to compute
 		CompileViewCellsList();
-
 		// start per view cell gvs
 		PerViewCellComputation();
-
-		if (mEvaluatePixelError)
-		{
-			ComputeRenderError();
-		}
 #else
 		PerViewCellComputation2();
@@ -1162,4 +1153,10 @@
 	{
 		ExportPreprocessedData(mVisibilityFileName);
+	}
+	
+	// compute the pixel error of this visibility solution
+	if (mEvaluatePixelError)
+	{
+		ComputeRenderError();
 	}
 
@@ -1211,20 +1208,22 @@
 {
 	app << "#ViewCells\n" << mViewCells << endl;
-	app << "#ViewCellId\n" << mViewCellId << endl;
+	app << "#Id\n" << mViewCellId << endl;
+	app << "#Time\n" << mTimePerViewCell << endl;;
+	app << "#TrianglePvs\n" << mTrianglePvs << endl;
+	app << "#ObjectPvs\n" << mPerViewCellPvs << endl;
+	app << "#PvsCost\n" << (int)mPvsCost << endl;
+
+#if 0
+	app << "#TotalPvs\n" << mTotalPvs << endl;
 	app << "#TotalTime\n" << mTotalTime << endl;
-	app << "#TimePerViewCell\n" << mTimePerViewCell << endl;;
-
 	app << "#RaysPerSec\n" << RaysPerSec() << endl;
-
-	app << "#TrianglePvs\n" << mTrianglePvs << endl;
-	app << "#TotalTrianglePvs\n" << mTotalTrianglePvs << endl;
-
-	app << "#PerViewCellPvs\n" << mPerViewCellPvs << endl;
-	app << "#TotalPvs\n" << mTotalPvs << endl;
 	
 	app << "#PerViewCellSamples\n" << mPerViewCellSamples << endl;
 	app << "#TotalSamples\n" << mTotalSamples << endl;
 	app	<< "#SamplesContri\n" << mTotalContribution << endl;
-		
+	app << "#TotalTrianglePvs\n" << mTotalTrianglePvs << endl;
+	
+#endif
+
 	//app << "#ReverseSamples\n" << mReverseSamples << endl;
 	//app << "#BorderSamples\n" << mBorderSamples << endl;
@@ -1277,13 +1276,9 @@
 	else
 	{
-		/*// add pvs
-		ObjectContainer::const_iterator it, it_end = mKdPvs.end();
-
-		for (it = mKdPvs.begin(); it != it_end; ++ it)
-			mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f);
-		*/
 		mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize();
-
-		cout << "pvs cost: " << mCurrentViewCell->GetPvs().EvalPvsCost() << " pvs tri: " << mGenericStats2 << endl;
+		mGvsStats.mPvsCost = mCurrentViewCell->GetPvs().EvalPvsCost();
+
+		cout << "id: " << mCurrentViewCell->GetId() << " pvs cost: " 
+			 << mGvsStats.mPvsCost << " pvs tri: " << mTrianglePvs.size() << endl;
 	}
 
@@ -1293,6 +1288,4 @@
 
 	mGvsStats.mViewCells = mProcessedViewCells;//mPass;
-
-
 	mGvsStats.mTotalPvs += mGvsStats.mPerViewCellPvs;
 	mGvsStats.mTotalSamples += mGvsStats.mPerViewCellSamples;
