Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/gi_final.sh
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/gi_final.sh	(revision 2309)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/gi_final.sh	(revision 2350)
@@ -7,19 +7,20 @@
 TARGET=release
 
-PROGRAM=../bin/$TARGET/Preprocessor.exe
+PROGRAM=../bin/$TARGET/Preprocessor2.exe
+#PROGRAM=../bin/$TARGET/Preprocessor_old.exe
+#PROGRAM=../bin/$TARGET/Preprocessor_itl.exe
 
 EXT=obj
-#SCENE=vienna_cropped
-#SCENE_PATH=../data/vienna
+SCENE=vienna_cropped
+SCENE_PATH=../data/vienna
 
 #SCENE=arena-high-lods
 #SCENE_PATH=../data/Arena
 
-SCENE=PompeiiOne
-SCENE_PATH=../data/Pompeii
+SCENE=soda
+SCENE_PATH=../data/soda
 
 ENVIRONMENT=gi_final.env
-
-LOG_PREFIX=../scripts/tests/gi/$SCENE-speed
+LOG_PREFIX=../scripts/tests/gi/$SCENE-test
 
 echo "starting $TARGET mode for $SCENE scene ($PROGRAM)"
@@ -29,9 +30,8 @@
 #######################################################
 
-USE_HEUR=true
- METHOD=int
- echo "$SCENE $METHOD"
+USE_HEUR=false
+METHOD=int-$USE_HEUR
 
-
+echo "$SCENE $METHOD"
 $PROGRAM $ENVIRONMENT \
   -scene_filename=$SCENE_FILENAME \
@@ -40,4 +40,6 @@
   -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \
   -view_cells_filename=$LOG_PREFIX-$METHOD-viewcells.xml.gz \
+  -view_cells_triangle_weight=1.0 \
+  -view_cells_object_weight=0.0 \
   -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \
   -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \
@@ -46,80 +48,32 @@
   -hierarchy_construction_min_avg_rays_per_object=0 \
   -hierarchy_construction_max_avg_rays_per_object=0 \
-  -bvh_use_sah=false \
+  -bvh_use_sah=true \
   -vsp_use_cost_heuristics=$USE_HEUR
 
 sh movefiles.sh $LOG_PREFIX-$METHOD
 
-#######################################################
 
-USE_HEUR=true
- METHOD=int-2
- echo "$SCENE $METHOD"
-
-
-$PROGRAM $ENVIRONMENT \
-  -scene_filename=$SCENE_FILENAME \
-  -view_cells_sampling_type=object_directional \
-  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \
-  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \
-  -view_cells_filename=$LOG_PREFIX-$METHOD-viewcells.xml.gz \
-  -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \
-  -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \
-  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \
-  -hierarchy_construction_type=2 \
-  -hierarchy_construction_min_avg_rays_per_object=1 \
-  -hierarchy_construction_max_avg_rays_per_object=10 \
-  -bvh_use_sah=false \
-  -vsp_use_cost_heuristics=$USE_HEUR
-
-sh movefiles.sh $LOG_PREFIX-$METHOD
 
 #######################################################
 
 NODES=60000
-#NODES=5000
-USE_HEUR=true
-#USE_HEUR=false
-  
-METHOD=seq-$NODES
-echo "$SCENE $METHOD"
+USE_HEUR=false
+METHOD=seq-$NODES-$USE_HEUR
+ 
+#echo "$SCENE $METHOD"
+# $PROGRAM $ENVIRONMENT \
+ -scene_filename=$SCENE_FILENAME \
+ -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \
+ -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \
+ -view_cells_filename=$LOG_PREFIX-$METHOD-viewcells.xml.gz \
+ -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \
+ -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \
+ -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \
+ -hierarchy_construction_type=0 \
+ -view_cells_triangle_weight=1.0 \
+ -view_cells_object_weight=50.0 \
+ -vsp_use_cost_heuristics=$USE_HEUR \
+ -bvh_term_max_leaves=$NODES
 
-$PROGRAM $ENVIRONMENT \
-  -scene_filename=$SCENE_FILENAME \
-  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \
-  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \
-  -view_cells_filename=$LOG_PREFIX-$METHOD-viewcells.xml.gz \
-  -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \
-  -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \
-  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \
-  -hierarchy_construction_type=0 \
-  -hierarchy_construction_consider_memory=false \
-  -vsp_use_cost_heuristics=$USE_HEUR \
-  -bvh_term_max_leaves=$NODES
+#sh movefiles.sh $LOG_PREFIX-$METHOD
 
-sh movefiles.sh $LOG_PREFIX-$METHOD
-
-
-#######################################################
-
-NODES=10000
-USE_HEUR=true
-#USE_HEUR=false
-  
-METHOD=seq-$NODES
-echo "$SCENE $METHOD"
-
-$PROGRAM $ENVIRONMENT \
-  -scene_filename=$SCENE_FILENAME \
-  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \
-  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \
-  -view_cells_filename=$LOG_PREFIX-$METHOD-viewcells.xml.gz \
-  -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \
-  -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \
-  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \
-  -hierarchy_construction_type=0 \
-  -hierarchy_construction_consider_memory=false \
-  -vsp_use_cost_heuristics=$USE_HEUR \
-  -bvh_term_max_leaves=$NODES
-
-sh movefiles.sh $LOG_PREFIX-$METHOD
Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/gi_final.env
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/gi_final.env	(revision 2255)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/gi_final.env	(revision 2350)
@@ -173,14 +173,12 @@
 	}
 
-	#showVisualization true
-	showVisualization false
+	showVisualization true
+	#showVisualization false
 	#evaluateViewCells false
 	evaluateViewCells true
 	
 	Evaluation {
-		samples         100000000
-		samplesForStats 100000000
-		#samples          10000000
-		#samplesForStats  10000000
+		samples         6000000
+		samplesForStats 2000000
 
 		samplesPerPass  500000
@@ -233,4 +231,5 @@
 	Construction {		
 		renderCostDecreaseWeight 0.999
+#		renderCostDecreaseWeight 1.0
 	}
 
@@ -265,5 +264,5 @@
 	Construction {
 
-		samples 6000000
+		samples 100000
 
 		# type 0 = sequential computation, 1 = interleaved, 2 = gradient
@@ -280,5 +279,4 @@
 		# minimal steps of same type: for interleaved, this is only valid for the first few splits
 		minStepsOfSameType 100
-		#maxStepsOfSameType 3000
 		maxStepsOfSameType 900
 
@@ -288,9 +286,8 @@
 	Termination {
 		# maximal number of leaves
-		maxLeaves 300000
-#		maxLeaves 6000
+		maxLeaves 10000
 		# maximal memory in MB
 #		maxMemory 4
-		maxMemory 35
+		maxMemory 25
 		# minimum ratio of global cost decrease
 		minGlobalCostRatio -1
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 2347)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 2350)
@@ -693,8 +693,5 @@
 		AssociateViewCellsWithObjects(*tData.mSampledObjects);
 
-		EvalSubdivisionCandidate2(*frontCandidate, true, false);
-		cout << "\nfc2: " << frontCandidate->GetPriority() << endl;
 		EvalSubdivisionCandidate(*frontCandidate, true, false);
-		cout << "fc1: " << frontCandidate->GetPriority() << endl;
 		EvalSubdivisionCandidate(*backCandidate, true, false);
 
@@ -789,5 +786,5 @@
 
 
-void BvHierarchy::EvalSubdivisionCandidate2(BvhSubdivisionCandidate &splitCandidate, 
+void BvHierarchy::EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitCandidate, 
 										   const bool computeSplitPlane,
 										   const bool preprocessViewCells)
@@ -890,6 +887,4 @@
 	}
 
-	//cout << "pvol: " << parentVol << " front: " << volFront << " back: " << volBack << " diff: " <<  parentVol - volFront - volBack << endl;
-	
 
 	/////////////////////
@@ -936,6 +931,4 @@
 	const int backTri = (int)splitCandidate.mBackObjects.size();
 	
-	if (totalTri - frontTri - backTri != 0)
-		cout << "big error!!!" << endl;
 
 	// compute render cost decrease in the view cells which can see the object
@@ -980,26 +973,5 @@
 		oldRenderCost += oldRc * vc->GetVolume() / viewSpaceVol;
 		newRenderCost += newRc * vc->GetVolume() / viewSpaceVol;
-		//cout << "old rc=" << oldRenderCost << " new rc " << newRenderCost << endl;
-	}
-
-
-	const float dummyFrontVol = EvalViewCellsVolume(splitCandidate.mSampledFrontObjects) / viewSpaceVol;
-	const float dummyBackVol = EvalViewCellsVolume(splitCandidate.mSampledBackObjects) / viewSpaceVol;
-	const float dummyParentVol = EvalViewCellsVolume(leaf->mObjects) / viewSpaceVol;
-
-	const int dummyNumFrontViewCells = CountViewCells(splitCandidate.mSampledFrontObjects);
-	const int dummyNumBackViewCells = CountViewCells(splitCandidate.mSampledBackObjects);
-	const int dummyPvs = CountViewCells(*tData.mSampledObjects);
-	
-	const int dummyPvsEntriesIncr = - dummyPvs + dummyNumFrontViewCells + dummyNumBackViewCells;
-
-	const float relfrontCost = dummyFrontVol * (float)splitCandidate.mFrontObjects.size();
-	const float relBackCost =  dummyBackVol * (float)splitCandidate.mBackObjects.size();
-	const float relParentCost = dummyParentVol * (float)leaf->mObjects.size();
-
-	// compute global decrease in render cost
-	const float dummyNewRenderCost = relfrontCost + relBackCost;
-	const float dummyRenderCostDecr = relParentCost - dummyNewRenderCost;
-
+	}
 
 
@@ -1011,140 +983,8 @@
 	splitCandidate.SetRenderCostDecrease(renderCostDecr);
 	
-	float pseudoOldRenderCost = parentVol * (float)leaf->mObjects.size() / viewSpaceVol;
-
-	//cout << "cor. entries: " << dummyPvsEntriesIncr << " entries: " << frontAndBackViewCells << endl;
-	cout << "\nv1: " << renderCostDecr << " " << pseudoOldRenderCost << " " << newRenderCost << endl;
-	cout << "v2: " << dummyRenderCostDecr << " " << relParentCost << " " << dummyNewRenderCost << endl;
+	const float pseudoOldRenderCost = parentVol * (float)leaf->mObjects.size() / viewSpaceVol;
 
 	// at last computed priority based on render cost reduction / memory increase
 	const float priority = EvalPriority(splitCandidate, renderCostDecr,	pseudoOldRenderCost);
-	cout << "\nfc0: " << priority << endl;
-	const float priority2 = EvalPriority(splitCandidate, dummyRenderCostDecr, relParentCost);
-	splitCandidate.SetPriority(priority2);
-
-#if STORE_VIEWCELLS_WITH_BVH
-	if (preprocessViewCells)
-		ReleaseViewCells(*splitCandidate.mParentData.mSampledObjects);
-#endif
-
-	mEvalTimer.Exit();
-}
-
-
-void BvHierarchy::EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitCandidate, 
-										   const bool computeSplitPlane,
-										   const bool preprocessViewCells)
-{
-	mPlaneTimer.Entry();
-
-#if STORE_VIEWCELLS_WITH_BVH
-	if (preprocessViewCells) // fill view cells cache
-		AssociateViewCellsWithObjects(*splitCandidate.mParentData.mSampledObjects);
-#endif
-
-	if (computeSplitPlane)
-	{
-		splitCandidate.mFrontObjects.clear();
-		splitCandidate.mBackObjects.clear();
-		splitCandidate.mSampledFrontObjects.clear();
-		splitCandidate.mSampledBackObjects.clear();
-
-		const bool sufficientSamples = 
-			splitCandidate.mParentData.mNumRays > mMinRaysForVisibility;
-
-		//if (!sufficientSamples) cout << splitCandidate.mParentData.mNumRays << " ";
-
-		const bool useVisibiliyBasedHeuristics = 
-					!mUseSah &&
-					(mHierarchyManager->GetViewSpaceSubdivisionType() == 
-					HierarchyManager::KD_BASED_VIEWSPACE_SUBDIV) &&
-					sufficientSamples;
-
-		// compute best object partition
-		const float ratio =	SelectObjectPartition(splitCandidate.mParentData, 
-												  splitCandidate.mFrontObjects, 
-												  splitCandidate.mBackObjects,
-												  useVisibiliyBasedHeuristics);
-	
-		// cost ratio violated?
-		const bool maxCostRatioViolated = mTermMaxCostRatio < ratio;
-		const int previousMisses = splitCandidate.mParentData.mMaxCostMisses;
-
-		splitCandidate.SetMaxCostMisses(maxCostRatioViolated ? 
-										previousMisses + 1 : previousMisses);
-
-		StoreSampledObjects(splitCandidate.mSampledFrontObjects, splitCandidate.mFrontObjects);
-		StoreSampledObjects(splitCandidate.mSampledBackObjects, splitCandidate.mBackObjects);
-	}
-
-	mPlaneTimer.Exit();
-
-	mEvalTimer.Entry();
-
-	const BvhTraversalData &tData = splitCandidate.mParentData;
-	BvhLeaf *leaf = tData.mNode;
-
-	// avg contribution of a ray to a pvs
-	const float pvs = (float)CountViewCells(*tData.mSampledObjects);
-	//const float avgRayContri = AvgRayContribution((int)pvs, tData.mNumRays);
-	const float avgRaysPerObject = AvgRaysPerObject((int)pvs, tData.mNumRays);
-
-	// high avg ray contri, the result is influenced by undersampling
-	splitCandidate.SetAvgRaysPerObject(avgRaysPerObject);
-	const float viewSpaceVol = GetViewSpaceVolume();
-
-	const float oldVolume = EvalViewCellsVolume(*tData.mSampledObjects) / viewSpaceVol;
-	const float oldRatio = (tData.mVolume > 0) ? oldVolume / tData.mVolume : 1;
-	const float parentVol = tData.mCorrectedVolume * oldRatio;
-
-	// this leaf is a pvs entry in all the view cells
-	// that see one of the objects.
-	splitCandidate.mVolumeFrontViewCells = EvalViewCellsVolume(splitCandidate.mSampledFrontObjects) / viewSpaceVol;
-	splitCandidate.mVolumeBackViewCells = EvalViewCellsVolume(splitCandidate.mSampledBackObjects) / viewSpaceVol;
-
-	splitCandidate.mNumFrontViewCells = CountViewCells(splitCandidate.mSampledFrontObjects);
-	splitCandidate.mNumBackViewCells = CountViewCells(splitCandidate.mSampledBackObjects);
-
-	splitCandidate.mCorrectedFrontVolume = 
-		mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeFrontViewCells, parentVol, avgRaysPerObject);
-	
-	splitCandidate.mCorrectedBackVolume = 
-		mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeBackViewCells, parentVol, avgRaysPerObject);
-
-#if 0
-	const float relfrontCost = splitCandidate.mCorrectedFrontVolume * splitCandidate.mFrontObjects.size();
-	const float relBackCost =  splitCandidate.mCorrectedBackVolume * splitCandidate.mBackObjects.size();
-	const float relParentCost = parentVol * leaf->mObjects.size();
-#else
-	const float relfrontCost = splitCandidate.mVolumeFrontViewCells * splitCandidate.mFrontObjects.size();
-	const float relBackCost =  splitCandidate.mVolumeBackViewCells * splitCandidate.mBackObjects.size();
-	const float relParentCost = oldVolume * leaf->mObjects.size();
-#endif
-	// compute global decrease in render cost
-	const float newRenderCost = relfrontCost + relBackCost;
-	const float renderCostDecr = relParentCost - newRenderCost;
-	
-	splitCandidate.SetRenderCostDecrease(renderCostDecr);
-
-	// increase in pvs entries
-	const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate, 
-												  avgRaysPerObject, 
-												  (int)pvs, 
-												  splitCandidate.mNumFrontViewCells, 
-												  splitCandidate.mNumBackViewCells);
-
-	splitCandidate.SetPvsEntriesIncr(pvsEntriesIncr);
-
-#ifdef GTP_DEBUG
-	Debug << "old render cost: " << oldRenderCost << endl;
-	Debug << "new render cost: " << newRenderCost << endl;
-	Debug << "render cost decrease: " << renderCostDecr << endl;
-#endif
-
-	float priority = EvalPriority(splitCandidate, 
-								  renderCostDecr,
-								  relParentCost);
-
-  	// compute global decrease in render cost
 	splitCandidate.SetPriority(priority);
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 2347)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 2350)
@@ -579,8 +579,4 @@
 								  const bool preprocessViewCells);
 
-	void EvalSubdivisionCandidate2(BvhSubdivisionCandidate &splitData,
-								  const bool computeSplitPlane,
-								  const bool preprocessViewCells);
-
 	/** Returns vector of leaves.
 	*/
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 2347)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 2350)
@@ -31,5 +31,4 @@
 #define HACK_PERFORMANCE 1
 
-#define HAS_TO_BE_REDONE 0
 
 /////////////
@@ -849,9 +848,5 @@
 	splitCandidate.mBackPvs = (float)sData.mBackObjects;
 
-#if HAS_TO_BE_REDONE
 	return (int)(splitCandidate.mCorrectedFrontPvs + splitCandidate.mCorrectedBackPvs - correctedOldPvs);
-#else
-	return sData.mFrontObjects + sData.mBackObjects - sData.mTotalObjects;
-#endif
 }
 
@@ -1627,16 +1622,8 @@
 	sc.mBackRenderCost = sData.mBackRenderCost;
 
-#if HAS_TO_BE_REDONE // undersampling evalution does not work yet
-
 	const float oldRenderCost = penaltyOld * pOverall;
 	const float newRenderCost = sc.mCorrectedFrontRenderCost * pFront + 
 								sc.mCorrectedBackRenderCost * pBack;
 
-#else
-
-	const float oldRenderCost = sData.mTotalRenderCost * pOverall;
-	const float newRenderCost = sData.mFrontRenderCost * pFront + sData.mBackRenderCost * pBack;
-
-#endif
 
 	// the normalized old render cost is needed for the priority
