Index: GTP/trunk/Lib/Vis/Preprocessing/EvalStats/stdafx.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/EvalStats/stdafx.h	(revision 656)
+++ GTP/trunk/Lib/Vis/Preprocessing/EvalStats/stdafx.h	(revision 656)
@@ -0,0 +1,12 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+
+#include <iostream>
+#include <tchar.h>
+
+// TODO: reference additional headers your program requires here
Index: GTP/trunk/Lib/Vis/Preprocessing/EvalStats/EvalStats.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/EvalStats/EvalStats.cpp	(revision 827)
+++ GTP/trunk/Lib/Vis/Preprocessing/EvalStats/EvalStats.cpp	(revision 827)
@@ -0,0 +1,325 @@
+// EvalStats.cpp : Defines the entry point for the console application.
+//
+#include "stdafx.h"
+
+#include <string>
+#include <vector>
+#include <istream>
+#include <iostream>
+#include <fstream>
+#include <math.h>
+#include <algorithm>
+
+using namespace std;
+
+/** This is a small function which takes two log files and computes the
+	difference in percent of the weighted render cost.
+*/
+
+
+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())
+		return false;
+		
+	string buf;
+
+	int currentTag = NO_TAG;
+
+	while (!(getline(file, buf)).eof())
+	{
+		//cout << "buf: " << buf << endl;
+
+		if (buf[0] == '#')
+		{
+			char entry[50];	
+
+			sscanf(buf.c_str(), "#%s", entry);
+			
+			// 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
+		{
+			float val;
+			sscanf(buf.c_str(), "%f", &val);
+			
+			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;
+		}
+	}
+
+	return true;
+}
+
+
+
+void ComputeStats(ofstream &statsOut, 
+				  const RenderStats &firstStats, 
+				  const RenderStats &currentStats, 
+				  const int index)
+{
+	float denom = firstStats.mRenderCost ? firstStats.mRenderCost : 0.000001f;
+	float costRatio = currentStats.mRenderCost / denom;
+			
+	denom = firstStats.mAvgRenderCost ? firstStats.mAvgRenderCost : 0.000001f;
+	float avgCostRatio = currentStats.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;
+			 << "#TotalRenderCostRatio\n" << costRatio << endl
+			 << "#AvgRenderCostRatio\n" << avgCostRatio << endl << endl;
+}
+
+
+inline bool vlt(const RenderStats &c1, const RenderStats &c2)
+{
+	return c1.mRenderCost > c2.mRenderCost;
+}
+
+
+// evaluate number of view cells needed for same rendercost
+void EvalNumViewCells(ofstream &outstream,
+					  const StatsContainer &firstStats, 
+					  const StatsContainer &currentStats)
+{
+	
+	const int n = min((int)firstStats.size(), (int)currentStats.size());
+	//const int n = (int)firstStats.size();
+	
+	StatsContainer::const_iterator it, it_end = currentStats.end();
+
+	int i = 0;
+
+	// currentStats would be the other (necessarily worse?) method, firstStats would be our method
+	// loop through view cells of currentStats
+	// Compare render cost with render cost of other view cell
+	// compute ratio of view cells
+	for (it = currentStats.begin(); it != it_end; ++ it, ++ i)
+	{
+		
+		const float renderCost = (*it).mRenderCost;
+    
+		// find equivalent render cost in the other stats container.
+		// don't stop until cursor is placed one element behind
+		// or end of vector is reached
+		StatsContainer::const_iterator equalCostIt = std::upper_bound(firstStats.begin(), firstStats.end(), *it, vlt);
+
+		int j = (int)(equalCostIt - firstStats.begin());
+
+		float val;
+
+		// soecial cases
+		if (j == 0)
+		{
+			val = (float)j;
+		}
+		else if (j >= n)
+		{
+			val = (float)(j - 1);
+		}
+		else 
+		// interpolate linearly. NOTE: probably big error because of steep curve
+		// => intepolate logarithmically
+		{
+#if 1
+			const float rcu = log(firstStats[j - 1].mRenderCost);
+			const float rcl = log(firstStats[j].mRenderCost);
+			const float rc = log(renderCost);
+#else
+			const float rcu = firstStats[j - 1].mRenderCost;
+			const float rcl = firstStats[j].mRenderCost;
+			const float rc = renderCost;
+#endif
+			const float factor = (rcu - rcl != 0) ?
+				(rcu - rc) / (rcu - rcl) : 1;
+
+			// view cells needed for same render cost
+			val = (float)j - 1 + factor;
+		}
+
+		// lower bound
+		//int j = max (0, i - 1);
+		//cout << "i: " << i << " j: " << j << endl;
+		float ratio = (i && val) ? (float)i / val : 1;
+
+		//cout << "ratio: " << ratio << endl;
+		outstream << "#Pass\n" << i << endl;
+		outstream << "#RenderCost\n" << renderCost << endl;
+		outstream << "#ViewCellsRatio\n" << ratio << endl << endl;	
+	}
+}
+
+
+
+
+
+// evaluate number of view cells needed for same rendercost
+int EvalSingleNumViewCells(const StatsContainer &currentStats,
+						   const float cost)
+{
+	
+	StatsContainer::const_iterator it, it_end = currentStats.end();
+
+	RenderStats dummy; dummy.mRenderCost = cost;
+	
+	// find equivalent render cost in the other stats container.
+	// don't stop until cursor is placed one element behind
+	// or end of vector is reached
+	StatsContainer::const_iterator equalCostIt = std::upper_bound(currentStats.begin(),currentStats.end(), dummy, vlt);
+
+	int j = (int)(equalCostIt - currentStats.begin());
+
+	return j;
+}
+
+
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+	vector<StatsContainer> renderStats;
+	
+	if (argc < 3)
+	{
+		cerr << "arguments missing. Usage: input1 input2 ... intputn" << endl;
+		exit(1);
+	}
+
+	vector<string> outFilenames;
+	vector<string> outFilenames2;
+	vector<string> methodnames;
+	// read input files from command line
+	for (int i = 1; i < argc; ++ i)
+	{
+		StatsContainer currentStats;
+      
+		ifstream file;
+		file.open(argv[i]);
+
+		// extract the render cost
+		cout << "extracting render cost of file " << argv[i] << endl;
+	
+		if (extractRenderStats(file, currentStats))
+		{
+			renderStats.push_back(currentStats);
+
+			// 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");
+			string outFilename2 = string(fn) + string("-reverse.log");
+			
+			outFilenames.push_back(outFilename);
+			outFilenames2.push_back(outFilename2);
+			methodnames.push_back(fn);
+
+			cout << "new filen: " << outFilename2 << endl;
+		}
+		else
+		{
+			cout << "could not open file!" << endl;
+		}
+	}
+
+	//statsOut << "rc1 size: " << (int)renderCosts1.size() << " " << (int)renderCosts2.size() << endl << endl;
+	vector<StatsContainer>::const_iterator it = renderStats.begin(), it_end = renderStats.end();
+
+	vector<string>::const_iterator sit, sit_end = outFilenames.end();
+	vector<string>::const_iterator sit2, sit2_end = outFilenames2.end();
+	vector<string>::const_iterator sit3, sit3_end = methodnames.end();
+
+
+	sit = outFilenames.begin();
+	sit2 = outFilenames2.begin();
+	sit3 = methodnames.begin();
+
+	// compare all values with this vector
+	StatsContainer &firstStats = renderStats[0];
+
+	// don't compare with itself
+	//++ it;
+	//++ sit;
+	ofstream statsOut3;
+	statsOut3.open("numviewcells.log");
+
+	for (it; it != it_end; ++ it, ++ sit, ++ sit2, ++sit3)
+	{
+		cout << "now writing output to file " << *sit << endl;
+
+		ofstream statsOut;
+		statsOut.open((*sit).c_str());
+	
+		ofstream statsOut2;
+		statsOut2.open((*sit2).c_str());
+
+		cout << "opening new file: " << (*sit2).c_str() << endl;
+		// compute size of output vector
+		const int n = min((int)firstStats.size(), (int)(*it).size());
+	
+		for (int i = 0; i < n; ++ i)
+		{
+			//cout << "rc: " << (*it)[i].mRenderCost << endl;
+			ComputeStats(statsOut, firstStats[i], (*it)[i], i);
+		}
+
+		// evaluate number of view cells needed for same rendercost
+		EvalNumViewCells(statsOut2, firstStats, (*it));
+
+		const float rendercost = 100;
+		const int j = EvalSingleNumViewCells(*it, rendercost);
+
+		statsOut3 << (*sit3).c_str() << " " << j << endl;
+
+		statsOut.close();
+		statsOut2.close();
+	}
+
+	statsOut3.close();
+
+
+
+	return 0;
+}
+
Index: GTP/trunk/Lib/Vis/Preprocessing/EvalStats/EvalStats.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/EvalStats/EvalStats.vcproj	(revision 833)
+++ GTP/trunk/Lib/Vis/Preprocessing/EvalStats/EvalStats.vcproj	(revision 833)
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="EvalStats"
+	ProjectGUID="{935D1BDD-41B0-49F1-A86C-EB49B94DDB20}"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="Debug"
+			IntermediateDirectory="Debug"
+			ConfigurationType="1"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="5"
+				UsePrecompiledHeader="3"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(OutDir)/EvalStats.exe"
+				LinkIncremental="2"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="$(OutDir)/EvalStats.pdb"
+				SubSystem="1"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
+			ConfigurationType="1"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				RuntimeLibrary="0"
+				UsePrecompiledHeader="3"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(OutDir)/EvalStats.exe"
+				LinkIncremental="1"
+				GenerateDebugInformation="TRUE"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+			<File
+				RelativePath=".\EvalStats.cpp">
+			</File>
+			<File
+				RelativePath=".\stdafx.cpp">
+				<FileConfiguration
+					Name="Debug|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"/>
+				</FileConfiguration>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+			<File
+				RelativePath=".\stdafx.h">
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+		</Filter>
+		<File
+			RelativePath=".\VTune\EvalStats.vpj">
+		</File>
+		<File
+			RelativePath=".\ReadMe.txt">
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: GTP/trunk/Lib/Vis/Preprocessing/EvalStats/stdafx.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/EvalStats/stdafx.cpp	(revision 656)
+++ GTP/trunk/Lib/Vis/Preprocessing/EvalStats/stdafx.cpp	(revision 656)
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// EvalStats.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
