Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 1779)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 1784)
@@ -2489,5 +2489,5 @@
 					"true");
 	
-	RegisterOption("BvHierarchy.Construction.useInitialSubdivisio",
+	RegisterOption("BvHierarchy.Construction.useInitialSubdivision",
 					optBool,
 					"bvh_construction_use_initial_subdivision=",
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1779)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1784)
@@ -297,5 +297,6 @@
 	Environment::GetSingleton()->GetBoolValue("BvHierarchy.Construction.useInitialSubdivision", mApplyInitialPartition);
 	
-	mApplyInitialPartition = true;
+	mInitialObjectsSize = 50;
+
 	//mMemoryConst = (float)(sizeof(VspLeaf) + sizeof(VspViewCell));
 	//mMemoryConst = (float)sizeof(BvhLeaf);
@@ -574,11 +575,11 @@
 	{
 		const bool sufficientSamples = 
-			splitCandidate.mParentData.mNumRays > mMinRaysForVisibility;
+				splitCandidate.mParentData.mNumRays > mMinRaysForVisibility;
 
 		const bool useVisibiliyBasedHeuristics = 
-			!mUseSah &&
-			(mHierarchyManager->GetViewSpaceSubdivisionType() == 
-			HierarchyManager::KD_BASED_VIEWSPACE_SUBDIV) &&
-			sufficientSamples;
+					mUseSah &&
+					(mHierarchyManager->GetViewSpaceSubdivisionType() == 
+					HierarchyManager::KD_BASED_VIEWSPACE_SUBDIV) &&
+					sufficientSamples;
 
 		// compute best object partition
@@ -1369,5 +1370,5 @@
 
 	const int numRays = CollectViewCells(tData.mNode->mObjects, viewCells, true, true);
-	//cout << "here4 " << numRays << endl;
+	//cout << "number of rays: " << numRays << endl;
 
 	ViewCellContainer::const_iterator vit, vit_end = viewCells.end();
@@ -1456,11 +1457,7 @@
 	if (mIsInitialSubdivision)
 	{
-		ApplyInititialSplit(tData, 
-							frontObjects, 
-							backObjects);
-
+		ApplyInitialSplit(tData, frontObjects, backObjects);
 		return 0;
 	}
-	
 
 	ObjectContainer nFrontObjects[3];
@@ -2120,5 +2117,5 @@
 	// only rays intersecting objects in node are interesting
 	const int nRays = AssociateObjectsWithRays(sampleRays);
-	//Debug << "using " << nRays << " of " << (int)sampleRays.size() << " rays" << endl;
+	//cout << "using " << nRays << " of " << (int)sampleRays.size() << " rays" << endl;
 
 	// create bvh traversal data
@@ -2149,4 +2146,5 @@
 	if (mApplyInitialPartition)
 	{
+		cout << "§§§§§§§§here41 "<<oSubdivisionCandidate->mParentData.mSortedObjects[3]->size()<<endl;
 		ApplyInitialSubdivision(oSubdivisionCandidate, tQueue);		
 	}
@@ -2191,5 +2189,4 @@
 
 	*(tData.mSortedObjects[3]) = objects;
-
 	stable_sort(tData.mSortedObjects[3]->begin(), tData.mSortedObjects[3]->end(), smallerSize);
 }
@@ -2211,5 +2208,5 @@
 	}
 
-	for (int i = 0; i < 3; ++ i)
+	for (int i = 0; i < 4; ++ i)
 	{
 		frontData.mSortedObjects[i] = new ObjectContainer();
@@ -2504,25 +2501,26 @@
 
 	SplitQueue tempQueue;
-
+	tempQueue.Push(firstCandidate);
 	while (!tempQueue.Empty())
-	{
-		SubdivisionCandidate *candidate = tQueue.Top();
+	{cout << "here2"<<endl;
+		SubdivisionCandidate *candidate = tempQueue.Top();
 		tQueue.Pop();
 
 		BvhSubdivisionCandidate *bsc = 
 			dynamic_cast<BvhSubdivisionCandidate *>(candidate);
-
+		cout << "§§§§§§§§here49 "<< bsc->mParentData.mSortedObjects[3]->size()<<endl;
+cout << "here87 "<<((BvhSubdivisionCandidate *)firstCandidate)->mParentData.mNode->mObjects.size()<<endl;
 		const bool globalCriteriaMet = 
 			GlobalTerminationCriteriaMet(bsc->mParentData);
-
+cout << "here5"<<endl;
 		if (!InitialTerminationCriteriaMet(bsc->mParentData))
-		{
+		{cout << "here9"<<bsc->mParentData.mNode->mObjects.size()<<endl;
 			BvhNode *node = Subdivide(tempQueue, bsc, globalCriteriaMet);
-
+cout << "here12"<<endl;
 			// not needed anymore
 			delete bsc;
 		}
 		else // initial preprocessing  finished for this candidate
-		{
+		{cout << "here15"<<endl;
 			tQueue.Push(bsc);
 		}
@@ -2533,12 +2531,18 @@
 
 
-void BvHierarchy::ApplyInititialSplit(const BvhTraversalData &tData,
-									  ObjectContainer &frontObjects,
-                                      ObjectContainer &backObjects)
-{
+void BvHierarchy::ApplyInitialSplit(const BvhTraversalData &tData,
+									ObjectContainer &frontObjects,
+									ObjectContainer &backObjects)
+{
+	cout << "*******here54 "<<tData.mSortedObjects[3]->size()<<endl;
 	ObjectContainer *objects = tData.mSortedObjects[3];
 
 	ObjectContainer::const_iterator oit, oit_end = objects->end();
-    
+    cout<<"$$$$$$$$$$$$$$$$$$$"<<endl;
+	for (oit = objects->begin(); oit != objects->end(); ++ oit)
+	{
+		//cout << (*oit)->GetBox().SurfaceArea() << " ";
+	}
+cout<<"$$$$$$$$$$$$$$$$$$$"<<endl;
 	float maxAreaDiff = 0.0f;
 
@@ -2577,5 +2581,5 @@
 {
 	return (0
-		    || ((int)tData.mNode->mObjects.size() < mInititialObjectsSize)
+		    || ((int)tData.mNode->mObjects.size() < mInitialObjectsSize)
 			|| (tData.mNode->mObjects.back()->GetBox().SurfaceArea() < mMinInitialSurfaceArea)
 			);
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1778)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1784)
@@ -330,6 +330,10 @@
 									  ) const
 {
+	long startTime = GetTime();
+
 	SimpleRayContainer simpleRays;
-	long startTime = GetTime();
+	
+	simpleRays.reserve(samplesPerPass);
+	passSamples.reserve(samplesPerPass * 2); // always creates double rays
 
 	// create one third of each type
@@ -349,10 +353,13 @@
 	}
 
-	cout << "generated " << samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
+	cout << "generated " << samplesPerPass << " samples in " 
+		 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
 
 	startTime = GetTime();
+
 	// shoot simple ray and add it to importance samples
 	mPreprocessor->CastRays(simpleRays, passSamples, true);
-	cout << "cast " <<  samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
+	cout << "cast " <<  samplesPerPass << " samples in " 
+		 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
 
 	return (int)passSamples.size();
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1779)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1784)
@@ -903,12 +903,12 @@
 								 SplitQueue &tQueue);
 
-	void ApplyInititialSplit(const BvhTraversalData &tData,
-							 ObjectContainer &frontObjects,
-							 ObjectContainer &backObjects);
+	void ApplyInitialSplit(const BvhTraversalData &tData,
+						   ObjectContainer &frontObjects,
+						   ObjectContainer &backObjects);
 
 	bool InitialTerminationCriteriaMet(const BvhTraversalData &tData) const;
 
 	float mMinInitialSurfaceArea;
-	int mInititialObjectsSize;
+	int mInitialObjectsSize;
 
 protected:
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1779)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1784)
@@ -474,6 +474,8 @@
 	{
 		// decide upon next split type
-		const float vspPriority = viewSpaceQueue.Top() ? viewSpaceQueue.Top()->GetPriority() : -1e20f;
-		const float ospPriority = objectSpaceQueue.Top() ? objectSpaceQueue.Top()->GetPriority() : -1e20f;
+		const float vspPriority = 
+			viewSpaceQueue.Top() ? viewSpaceQueue.Top()->GetPriority() : -1e20f;
+		const float ospPriority = 
+			objectSpaceQueue.Top() ? objectSpaceQueue.Top()->GetPriority() : -1e20f;
 		
 		cout << "new decicion, vsp: " << vspPriority << ", osp: " << ospPriority << endl;
@@ -505,5 +507,6 @@
 			const int repaired = RepairQueue(dirtyVspList, viewSpaceQueue, true);
             
-			cout << "\nrepaired " << repaired << " candidates from " << (int)dirtyVspList.size() << " dirtied candidates" << endl;
+			cout << "\nrepaired " << repaired << " candidates from " 
+				 << (int)dirtyVspList.size() << " dirtied candidates" << endl;
 		}
 		else
@@ -535,5 +538,6 @@
 			const int repaired = RepairQueue(dirtyOspList, objectSpaceQueue, true);
 
-			cout << "\nrepaired " << repaired << " candidates from " << (int)dirtyOspList.size() << " dirtied candidates" << endl;
+			cout << "\nrepaired " << repaired << " candidates from " 
+				 << (int)dirtyOspList.size() << " dirtied candidates" << endl;
 		}
 	}
@@ -586,5 +590,4 @@
 		// prepare vsp tree for traversal
         mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType;
-		
 		PrepareViewSpaceSubdivision(mTQueue, sampleRays, objects);
 	}
@@ -596,5 +599,5 @@
 		PrepareObjectSpaceSubdivision(mTQueue, sampleRays, objects);
 	}
-
+	
 	// begin subdivision
 	RunConstruction(mRepairQueue, sampleRays, objects, forcedViewSpace);
@@ -2047,4 +2050,6 @@
 	
 	SubdivisionCandidate *firstVsp = mVspTree->PrepareConstruction(sampleRays, *viewSpaceRays);
+	tQueue.Push(firstVsp);
+
 	mBvHierarchy->PrepareConstruction(tQueue, sampleRays, objects);
 
@@ -2054,6 +2059,4 @@
 	firstVsp->SetPriority((float)-oldVspRoot->mTimeStamp);
 	firstBvh->SetPriority((float)-oldBvhRoot->GetTimeStamp());
-
-	tQueue.Push(firstVsp);
 	
 	ExportStats(stats, tQueue, objects);
