Index: GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp	(revision 1288)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp	(revision 1291)
@@ -1264,6 +1264,4 @@
 
 
-#if 0
-
 float OspTree::EvalRenderCostDecrease(const AxisAlignedPlane &candidatePlane,
 									  const OspTraversalData &tData,
@@ -1274,195 +1272,5 @@
 
 	// probability that view point lies in back / front node
-	float pOverall = 0;//data.mProbability; // todo matt§: value ok?
-	float pFront = 0;
-	float pBack = 0;
-	float pFrontAndBack = 0;
-
-	const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume();
-
-	Intersectable::NewMail(3);
-	
-	KdLeaf *leaf = tData.mNode;
-	const int totalPvs = (int)leaf->mObjects.size();
-	
-	RayInfoContainer frontRays, backRays;
-	ClassifyRays(*tData.mRays, leaf, candidatePlane, frontRays, backRays);
-
-	ViewCellContainer touchedViewCells;
-	
-	// sum up volume seen from the objects of left and right children
-	// => the volume is the weight for the render cost equation
-	ViewCell::NewMail(3);
-
-	RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end();
-
-	for (rit = tData.mRays->begin(); rit < rit_end; ++ rit)
-	{
-		VssRay *ray = (*rit).mRay;
-
-		// add volume to volumes of left and / or right children
-		// if one of the ray end points is inside
-		const int classification = ClassifyRay(ray, leaf, candidatePlane);
-
-		ViewCellContainer viewCells;
-		mVspTree->GetViewCells(*ray, viewCells);
-			
-		ViewCellContainer::const_iterator vit, vit_end = viewCells.end();
-
-		// traverse through view cells and classify them according
-		// to them being seen from to back / front / front and back node
-		for (vit = viewCells.begin(); vit != vit_end; ++ vit)
-		{
-			ViewCell *vc = *vit;
-
-			// if not previously mailed
-			if (!vc->Mailed() && !vc->Mailed(1) && !vc->Mailed(2))
-			{
-				touchedViewCells.push_back(vc);
-			}
-
-			// classify / mail the view cell
-			MailViewCell(vc, classification);	
-		}
-	}
-
-	// evaluate view cells volume contribution 
-	// with respect to the mail box classification
-	ViewCellContainer::const_iterator vit, vit_end = touchedViewCells.end();
-
-	for (vit = touchedViewCells.begin(); vit != vit_end; ++ vit)
-	{
-		AddViewCellVolumeContri(*vit, pFront, pBack, pFrontAndBack);
-	}
-
-	//////////////////////////////////////////////
-	//
-	// evaluate contribution of objects which are part of other kd nodes
-	// which are seen by the same view cell
-	// These contributions cannot be reduced by splitting, because
-	// the object would still be part of the pvs
-
-	float additionalFrontRenderCost = 0;
-	float additionalBackRenderCost = 0;
-	
-	MailablePvsData::NewMail();
-
-	for (rit = tData.mRays->begin(); rit != tData.mRays->end(); ++ rit)
-	{
-		VssRay *ray = (*rit).mRay;
-
-		ViewCellContainer viewCells;
-		mVspTree->GetViewCells(*ray, viewCells);
-
-		ViewCellContainer::const_iterator vit, vit_end = viewCells.end();
-
-		// traverse through view cells
-		for (vit = viewCells.begin(); vit != vit_end; ++ vit)
-		{
-			ViewCell *viewCell = *vit;
-
-			// for a view cell:
-			// if object is also in the kd pvs entries from other kd leaves,
-			// render cost cannot be reduced for this view cell
-			// => the render cost was falsly reduced, add them again
-
-			if (ray->mTerminationObject)
-			{	
-				Intersectable *obj = ray->mTerminationObject;
-				
-				const bool renderCostWrong = 
-					ViewCellHasMultipleReferences(obj, viewCell, true);
-			
-				// if there is already an entry of this object in the view cell pvs 
-				if (renderCostWrong)
-				{
-					// view cell was counted only for front or back => correct tjos
-					if (viewCell->Mailed(1) && obj->Mailed())
-					{
-						additionalFrontRenderCost += viewCell->GetVolume();
-					}
-					else if (viewCell->Mailed() && obj->Mailed(1))
-					{
-						additionalBackRenderCost += viewCell->GetVolume();
-					}
-				}
-			}
-	
-			if (ray->mOriginObject)
-			{
-				Intersectable *obj = ray->mOriginObject;
-
-				const bool renderCostWrong = 
-					ViewCellHasMultipleReferences(obj, viewCell, true);
-				// if there is already an entry of this object in the view cell pvs 
-				if (renderCostWrong)
-				{
-					if (viewCell->Mailed(1) && obj->Mailed())
-					{
-						additionalFrontRenderCost += viewCell->GetVolume();
-					}
-					else if (viewCell->Mailed() && obj->Mailed(1))
-					{
-						additionalBackRenderCost += viewCell->GetVolume();
-					}
-				}
-			}
-		}
-	}
-
-	/////////////////////////////
-
-
-	// these are non-overlapping sets
-	pOverall = pFront + pBack + pFrontAndBack;
-
-
-	//-- pvs rendering heuristics
-
-	const float oldRenderCost = pOverall * totalPvs;
-	
-	// sum up the terms: 
-	// the view cells seeing
-	// a) the left node are weighted by the #left node objects
-	// b) the right node are weighted by the #right node objects
-	// c) both nodes are weighted by the #parent node objects
-	const float newRenderCost = pvsFront * pFront + pvsBack * pBack + totalPvs * pFrontAndBack
-		+ additionalFrontRenderCost + additionalBackRenderCost;
-
-	// normalize volume with view space volume
-	const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol;
-
-	Debug << "\n(((( eval render cost decrease ))))" << endl
-		  << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl 
-		  << "back p: " << pBack / viewSpaceVol << " front p " << pFront / viewSpaceVol 
-		  << " front and back p " << pFrontAndBack / viewSpaceVol << " p: " << tData.mProbability / viewSpaceVol << endl
-		  << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl
-		  << "render cost decrease: " << renderCostDecrease << endl
-		  << "additional front " << additionalFrontRenderCost / viewSpaceVol 
-		  << " additional back " << additionalBackRenderCost  / viewSpaceVol << endl;
-
-	if (oldRenderCost < newRenderCost * 0.99)
-		Debug <<"error!!"<<endl;
-
-	//if ((((pOverall - tData.mProbability) / viewSpaceVol) > 0.00001))
-	//	Debug << "ERROR!!"<<endl;
-
-	normalizedOldRenderCost = oldRenderCost / viewSpaceVol;
-
-		
-	return renderCostDecrease;
-}
-
-#else
-
-float OspTree::EvalRenderCostDecrease(const AxisAlignedPlane &candidatePlane,
-									  const OspTraversalData &tData,
-									  float &normalizedOldRenderCost) const
-{
-	float pvsFront = 0;
-	float pvsBack = 0;
-
-	// probability that view point lies in back / front node
-	float pOverall = 0;//data.mProbability; // todo matt§: value ok?
+	float pOverall = 0;
 	float pFront = 0;
 	float pBack = 0;
@@ -1504,5 +1312,4 @@
 	}
 
-	
 	ViewCellContainer touchedViewCells;
 
@@ -1603,13 +1410,7 @@
 
 	/////////////////////////////
-
-
-	// these are non-overlapping sets
-	pOverall = pFront + pBack + pFrontAndBack;
-
-
 	//-- pvs rendering heuristics
 
-	const float oldRenderCost = rc;//pOverall * totalPvs;
+	const float oldRenderCost = rc;
 	
 	// sum up the terms: 
@@ -1618,24 +1419,13 @@
 	// b) the right node are weighted by the #right node objects
 	// c) both nodes are weighted by the #parent node objects
-	const float newRenderCost = newRc//pvsFront * pFront + pvsBack * pBack + totalPvs * pFrontAndBack
-;//		+ additionalFrontRenderCost + additionalBackRenderCost;
+	const float newRenderCost = newRc;
+
 
 	// normalize volume with view space volume
 	const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol;
 
-	Debug << "\n(((( eval render cost decrease ))))" << endl
-		  << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl 
-		  << "back p: " << pBack / viewSpaceVol << " front p " << pFront / viewSpaceVol 
-		  << " front and back p " << pFrontAndBack / viewSpaceVol << " p: " << tData.mProbability / viewSpaceVol << endl
+	Debug << "\nrender cost decrease: " << endl
 		  << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl
 		  << "render cost decrease: " << renderCostDecrease << endl;
-		  //<< "additional front " << additionalFrontRenderCost / viewSpaceVol 
-		  //<< " additional back " << additionalBackRenderCost  / viewSpaceVol << endl;
-
-	if (oldRenderCost < newRenderCost * 0.99)
-		Debug <<"error!!"<<endl;
-
-	//if ((((pOverall - tData.mProbability) / viewSpaceVol) > 0.00001))
-	//	Debug << "ERROR!!"<<endl;
 
 	normalizedOldRenderCost = oldRenderCost / viewSpaceVol;
@@ -1644,5 +1434,4 @@
 	return renderCostDecrease;
 }
-#endif
 
 
@@ -2234,37 +2023,4 @@
 	MailablePvsData::NewMail();
 	
-	/*RayInfoContainer::const_iterator rit, rit_end = rays.end();
-
-	for (rit = rays.begin(); rit < rit_end; ++ rit)
-	{
-		VssRay *ray = (*rit).mRay;
-
-		ViewCellContainer viewCells;
-		mVspTree->GetViewCells(*ray, viewCells);
-
-		ViewCellContainer::const_iterator vit, vit_end = viewCells.end();
-
-		// traverse through view cells and classify them according
-		// to them being seen from to back / front / front and back node
-		for (vit = viewCells.begin(); vit != vit_end; ++ vit)
-		{
-			ViewCell *vc = *vit;
-
-			Intersectable *obj = ray->mTerminationObject;
-			if (obj)
-			{
-				float contri;
-				AddViewCellToObjectPvs(obj, vc, contri, true);
-			}
-
-			obj = ray->mOriginObject;
-			if (obj)
-			{
-				float contri;
-				AddViewCellToObjectPvs(obj, vc, contri, true);
-			}
-		}
-	}*/
-	
 	ViewCellContainer touchedViewCells;
 	CollectTouchedViewCells(rays, touchedViewCells);
@@ -2297,48 +2053,4 @@
 {
 	MailablePvsData::NewMail();
-
-	/*RayInfoContainer::const_iterator rit, rit_end = rays.end();
-	for (rit = rays.begin(); rit < rit_end; ++ rit)
-	{
-		VssRay *ray = (*rit).mRay;
-
-		// test if intersection point with one of the objects is inside this node
-		ViewCellContainer viewCells;
-		mVspTree->GetViewCells(*ray, viewCells);
-
-		ViewCellContainer::const_iterator vit, vit_end = viewCells.end();
-
-		// traverse through view cells and classify them according
-		// to them being seen from to back / front / front and back node
-		for (vit = viewCells.begin(); vit != vit_end; ++ vit)
-		{
-			ViewCell *vc = *vit;
-			Intersectable *obj = ray->mTerminationObject;
-
-			if (obj)
-			{
-				MailablePvsData *vdata = obj->mViewCellPvs.Find(vc);
-
-				if (vdata && !vdata->Mailed())
-				{
-					vdata->Mail();
-					obj->mViewCellPvs.RemoveSample(vc, 1);
-				}
-			}
-
-			obj = ray->mOriginObject;
-
-			if (obj)
-			{
-				MailablePvsData *vdata = obj->mViewCellPvs.Find(vc);
-
-				if (vdata && !vdata->Mailed())
-				{
-					vdata->Mail();
-					obj->mViewCellPvs.RemoveSample(vc, 1);
-				}
-			}
-		}
-	}*/
 
 	ViewCellContainer touchedViewCells;
