Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/egsr_test_script
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/egsr_test_script	(revision 667)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/egsr_test_script	(revision 668)
@@ -3,6 +3,6 @@
 
 #SCENE=soda5
-SCENE=soda
-#SCENE=atlanta
+#SCENE=soda
+SCENE=atlanta
 #SCENE=vienna
 
@@ -22,10 +22,38 @@
 METHOD=vspbsp
 
-$PROGRAM $ENVIRONMENT \
--view_cells_type=vspBspTree \
--view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \
--view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \
--vsp_bsp_subdivision_stats=$LOG_PREFIX-$METHOD-subdivisionStats.log \
--view_cells_post_process_merge=true \
+echo "$SCENE $METHOD"
+
+
+$PROGRAM $ENVIRONMENT \
+-view_cells_type=vspBspTree \
+-view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \
+-view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \
+-vsp_bsp_subdivision_stats=$LOG_PREFIX-$METHOD-subdivisionStats.log \
+-view_cells_post_process_merge=true \
+-view_cells_filename=$LOG_PREFIX-$METHOD-viewCells.x3d
+
+mv debug.log $LOG_PREFIX-$METHOD-debug.log
+
+
+
+################################################################
+#           vspbsptree (only subdivision)                      #
+################################################################
+
+#
+# only view space subdivision, no merge
+#
+
+
+METHOD=onlysubdiv
+
+echo "$SCENE $METHOD"
+
+$PROGRAM $ENVIRONMENT \
+-view_cells_type=vspBspTree \
+-view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \
+-view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \
+-vsp_bsp_subdivision_stats=$LOG_PREFIX-$METHOD-subdivisionStats.log \
+-view_cells_post_process_merge=false \
 -view_cells_filename=$LOG_PREFIX-$METHOD-viewCells.x3d
 
@@ -44,4 +72,6 @@
 METHOD=bsp
 
+echo "$SCENE $METHOD"
+
 $PROGRAM $ENVIRONMENT \
 -view_cells_type=bspTree \
@@ -65,4 +95,6 @@
 
 METHOD=nirenstein
+
+echo "$SCENE $METHOD"
 
 $PROGRAM $ENVIRONMENT \
@@ -98,4 +130,6 @@
 METHOD=kd
 
+echo "$SCENE $METHOD"
+
 $PROGRAM $ENVIRONMENT \
 -view_cells_type=vspBspTree \
@@ -126,4 +160,6 @@
 METHOD=octree
 
+echo "$SCENE $METHOD"
+
 $PROGRAM $ENVIRONMENT \
 -view_cells_type=vspBspTree \
@@ -145,5 +181,4 @@
 
 
-
 #
 #  for internal testing only
@@ -153,27 +188,4 @@
 
 ################################################################
-#           vspbsptree (only subdivision)                      #
-################################################################
-
-#
-# only view space subdivision, no merge
-#
-
-
-METHOD=onlysubdiv
-
-$PROGRAM $ENVIRONMENT \
--view_cells_type=vspBspTree \
--view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \
--view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \
--vsp_bsp_subdivision_stats=$LOG_PREFIX-$METHOD-subdivisionStats.log \
--view_cells_post_process_merge=false \
--view_cells_filename=$LOG_PREFIX-$METHOD-viewCells.x3d
-
-mv debug.log $LOG_PREFIX-$METHOD-debug.log
-
-
-
-################################################################
 #             vspbsptree - few samples                         #
 ################################################################
@@ -184,4 +196,6 @@
 
 METHOD=vsp-many-samples
+
+echo "$SCENE $METHOD"
 
 $PROGRAM $ENVIRONMENT \
@@ -208,4 +222,6 @@
 METHOD=vsp-good-merge
 
+echo "$SCENE $METHOD"
+
 $PROGRAM $ENVIRONMENT \
 -view_cells_type=vspBspTree \
@@ -231,4 +247,6 @@
 
 METHOD=vsp-many-samples
+
+echo "$SCENE $METHOD"
 
 $PROGRAM $ENVIRONMENT \
@@ -255,4 +273,6 @@
 METHOD=vsp-many-samples-no-split-queue
 
+echo "$SCENE $METHOD"
+
 $PROGRAM $ENVIRONMENT \
 -view_cells_type=vspBspTree \
Index: GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp
===================================================================
--- GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp	(revision 667)
+++ GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp	(revision 668)
@@ -15,5 +15,20 @@
 	difference in percent of the weighted render cost.
 */
-bool extractRenderCost(ifstream &file, vector<float> &renderCosts)
+
+
+struct RenderStats 
+{
+	float mRenderCost;
+	float mAvgRenderCost;
+};
+
+
+typedef vector<RenderStats> StatsContainer;
+
+
+enum {NO_TAG, RENDER_COST, AVG_RENDER_COST};
+
+
+bool extractRenderStats(ifstream &file, StatsContainer &renderStats)
 {
 	if (!file.is_open())
@@ -21,8 +36,11 @@
 		
 	string buf;
-	bool isRenderCost = false;
 
+	int currentTag = NO_TAG;
+	
 	while (!(getline(file, buf)).eof())
 	{
+		//cout << "buf: " << buf << endl;
+
 		if (buf[0] == '#')
 		{
@@ -31,14 +49,39 @@
 			sscanf(buf.c_str(), "#%s", entry);
 			
-			if (strcmp(entry, "TotalRenderCost") == 0)
-				isRenderCost = true;
+			// new entry
+			if (strcmp(entry, "Pass") == 0)
+			{
+				//cout << "\nnew render stat " << endl;
+				renderStats.push_back(RenderStats());
+			}
+			else if (strcmp(entry, "TotalRenderCost") == 0)
+			{
+				currentTag = RENDER_COST;
+			}
+			else if (strcmp(entry, "AvgRenderCost") == 0)
+			{
+				currentTag = AVG_RENDER_COST;
+			}
 		}
-		else if (isRenderCost)
+		else
 		{
-			float rc;
-			sscanf(buf.c_str(), "%f", &rc);
+			float val;
+			sscanf(buf.c_str(), "%f", &val);
 			
-			renderCosts.push_back(rc);
-			isRenderCost = false;
+			switch (currentTag)
+			{
+			case RENDER_COST:
+				//cout << "render cost: " << val << endl;
+                renderStats.back().mRenderCost = val;
+				break;
+			case AVG_RENDER_COST:
+				//cout << "avg render cost: " << val << endl;
+				renderStats.back().mAvgRenderCost = val;
+				break;
+			default:
+				break;
+			}
+			
+			currentTag = NO_TAG;
 		}
 	}
@@ -47,56 +90,91 @@
 }
 
+
+
+void ComputeStats(ofstream &statsOut, 
+				  const RenderStats &firstStats, 
+				  const RenderStats &currentStats, 
+				  const int index)
+{
+	float denom = currentStats.mRenderCost ? currentStats.mRenderCost : 0.000001f;
+	float costRatio = firstStats.mRenderCost / denom;
+			
+	denom = firstStats.mAvgRenderCost ? firstStats.mAvgRenderCost : 0.000001f;
+	float avgCostRatio = firstStats.mAvgRenderCost / denom;
+
+	statsOut << "#ViewCells\n" << index + 1 << endl
+			 << "#TotalRenderCostGain\n" << 100.0f - costRatio * 100.0f << endl
+			 << "#AvgRenderCostGain\n" << 100.0f - avgCostRatio * 100.0f << endl << endl;
+}
+
+
+
 int _tmain(int argc, _TCHAR* argv[])
 {
-	vector<float> renderCosts1;
-	vector<float> renderCosts2;
+	vector<StatsContainer> renderStats;
 	
-	if (argc < 4)
+	if (argc < 3)
 	{
-		cerr << "arguments missing" << endl;
+		cerr << "arguments missing. Usage: input1 input2 ... intputn" << endl;
 		exit(1);
 	}
 
+	vector<string> outFilenames;
 
-	// read two files and the output file
+	// read input files from command line
+	for (int i = 1; i < argc; ++ i)
+	{
+		StatsContainer currentStats;
+      
+		ifstream file(argv[i]);
 
-	// read file 1
-	ifstream file1(argv[1]);
+		// extract the render cost
+		cout << "extracting render cost of file " << argv[i] << endl;
+		cout.flush();
 
-	// extract the render cost
-	cout << "extracting render cost of file " << argv[1] << endl;
-	cout.flush();
-	extractRenderCost(file1, renderCosts1);
+		extractRenderStats(file, currentStats);
+		renderStats.push_back(currentStats);
 
-	// read file 2
-    ifstream file2(argv[2]);
-	cout << "extracting render cost of file " << argv[2] << endl;
-	cout.flush();
-	extractRenderCost(file2, renderCosts2);
+		// create output file name
+		string fn = argv[i];
+		
+		string::size_type pos = fn.find(".log", 0);
+		fn.erase(pos, 4);
+		//sscanf(argv[i], "%s.log", fn);
+		string outFilename = string(fn) + string("-ratio.log");
 
-
-	cout << "writing output to file " << argv[3] << endl;
-
-	ofstream statsOut(argv[3]);
+		outFilenames.push_back(outFilename);
+	}
 
 	//statsOut << "rc1 size: " << (int)renderCosts1.size() << " " << (int)renderCosts2.size() << endl << endl;
-	int n = min((int)renderCosts1.size(), (int)renderCosts2.size());
+	vector<StatsContainer>::const_iterator it = renderStats.begin(), it_end = renderStats.end();
+	vector<string>::const_iterator sit, sit_end = outFilenames.end();
+
+	sit = outFilenames.begin();
 	
-	if (argc > 4)
+	// compare all values with this vector
+	StatsContainer &firstStats = renderStats[0];
+
+	// don't compare with itself
+	++ it;
+	++ sit;
+
+	for (it; it != it_end; ++ it)
 	{
-		char *endptr = NULL;
-			
-		int limit = strtol(argv[4], &endptr, 10);
-		
-		n = min(n, limit);
-	}
+		cout << "writing output to file " << *sit << endl;
 
-	for (int i = 0; i < n; ++ i)
-	{
-		float costRatio = renderCosts2[i] != 0 ? 
-			renderCosts1[i] / renderCosts2[i] : renderCosts1[i] / 0.0000001f;
+		ofstream statsOut((*sit).c_str());
+		++ sit;
 
-		statsOut << "#ViewCells\n" << i + 1 << endl
-				 << "#RenderCostRatio\n" << costRatio * 100.0f << endl;
+		cout << "size here" << (*it).size() << endl;
+		// compute size of output vector
+		const int n = min((int)firstStats.size(), (int)(*it).size());
+	
+		for (int i = 0; i < n; ++ i)
+		{
+			ComputeStats(statsOut, firstStats[i], (*it)[i], i);
+		}
+		cout << "here2 " << n << endl;
+		statsOut.close();
 	}
 
Index: GTP/trunk/Lib/Vis/shared/scripts/GtpVisibility.sln
===================================================================
--- GTP/trunk/Lib/Vis/shared/scripts/GtpVisibility.sln	(revision 643)
+++ GTP/trunk/Lib/Vis/shared/scripts/GtpVisibility.sln	(revision 668)
@@ -17,4 +17,8 @@
 	ProjectSection(ProjectDependencies) = postProject
 		{101A7691-74F3-48B4-96A3-CF35578F5900} = {101A7691-74F3-48B4-96A3-CF35578F5900}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EvalStats", "..\EvalStats\EvalStats.vcproj", "{935D1BDD-41B0-49F1-A86C-EB49B94DDB20}"
+	ProjectSection(ProjectDependencies) = postProject
 	EndProjectSection
 EndProject
@@ -41,4 +45,8 @@
 		{80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.Release.ActiveCfg = Release|Win32
 		{80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.Release.Build.0 = Release|Win32
+		{935D1BDD-41B0-49F1-A86C-EB49B94DDB20}.Debug.ActiveCfg = Debug|Win32
+		{935D1BDD-41B0-49F1-A86C-EB49B94DDB20}.Debug.Build.0 = Debug|Win32
+		{935D1BDD-41B0-49F1-A86C-EB49B94DDB20}.Release.ActiveCfg = Release|Win32
+		{935D1BDD-41B0-49F1-A86C-EB49B94DDB20}.Release.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
