Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1697)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1701)
@@ -88,6 +88,4 @@
 
 			Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min());
-
-			//Vector3 boxSize = sceneBox.Size() * Vector3(0.0025, 0.01, 0.0025);
 			Vector3 boxSize = sceneBox.Size() * Vector3(0.005f, 0.02f, 0.005f);
 
@@ -315,4 +313,5 @@
 	ObjectContainer::const_iterator oit, oit_end = objects.end();
 
+	//AxisAlignedBox3 bbox = mSceneGraph->GetBox(); bbox.Enlarge(30.0);
 	for (oit = objects.begin(); oit != oit_end; ++ oit)
 	{
@@ -323,7 +322,10 @@
 			Triangle3 tri = dynamic_cast<TriangleIntersectable *>(obj)->GetItem();
 
+			//if (bbox.IsInside(tri.mVertices[0]) && bbox.IsInside(tri.mVertices[1]) && bbox.IsInside(tri.mVertices[2]))
+			//{
 			samplesOut << "v " << tri.mVertices[0].x << " " << tri.mVertices[0].y << " " << tri.mVertices[0].z << endl;
 			samplesOut << "v " << tri.mVertices[1].x << " " << tri.mVertices[1].y << " " << tri.mVertices[1].z << endl;
 			samplesOut << "v " << tri.mVertices[2].x << " " << tri.mVertices[2].y << " " << tri.mVertices[2].z << endl;
+			//}
 		}
 		else
@@ -482,4 +484,6 @@
 			}
 
+			//if (!strstr(filename.c_str(), "plane")) mSceneGraph->GetRoot()->UpdateBox();
+
 			delete parser;
 		}
@@ -500,7 +504,9 @@
 		cout<<"#NUM_OBJECTS (Total numner of objects)\n"<<intersectables<<endl;
 		cout<<"#NUM_FACES (Total numner of faces)\n"<<faces<<endl;
+		
 		mObjects.reserve(intersectables);
 		mSceneGraph->CollectObjects(&mObjects);
 		mSceneGraph->GetRoot()->UpdateBox();
+
 		cout << "finished loading" << endl;
 		if (0)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1696)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1701)
@@ -286,5 +286,16 @@
 	long startTime = GetTime();
 
-	mPreprocessor->GenerateRays(samplesPerPass, sampleType, simpleRays);
+	// create one third of each type
+	int stype;
+	
+	stype = SamplingStrategy::OBJECT_BASED_DISTRIBUTION;
+	mPreprocessor->GenerateRays(samplesPerPass / 3, sampleType, simpleRays);
+	
+	stype = SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION;
+	mPreprocessor->GenerateRays(samplesPerPass / 3, sampleType, simpleRays);
+	
+	stype = SamplingStrategy::DIRECTION_BASED_DISTRIBUTION;
+	mPreprocessor->GenerateRays(samplesPerPass / 3, sampleType, simpleRays);
+
 	cout << "generated " << samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
 
@@ -1090,12 +1101,5 @@
 	case PER_TRIANGLE:
 		{//cout << "pertriangle" << endl;
-			// HACK
-			MeshInstance *mi = dynamic_cast<MeshInstance *>(obj);
-
-			// HACK: assume meshes are triangles
-			if (mi->GetMesh())
-			{
-				return (float)mi->GetMesh()->mFaces.size();
-			}
+			return (float)obj->NumberOfFaces();
 		}
 	default:
@@ -5754,8 +5758,4 @@
 	Debug << "view cell stats prefix: " << statsPrefix << endl;
 
-	// should directional sampling be used?
-	bool dirSamples = 
-		(mEvaluationSamplingType == SamplingStrategy::DIRECTION_BASED_DISTRIBUTION);
-
 	cout << "reseting pvs ... ";
 		
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp	(revision 1694)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp	(revision 1701)
@@ -234,5 +234,5 @@
 	ObjectContainer::const_iterator oit, oit_end = objects.end();
 
-	if (!exportSingleMesh)
+	if (0&&!exportSingleMesh)
 	{
 		for (oit = objects.begin(); oit != oit_end; ++ oit)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 1697)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 1701)
@@ -226,6 +226,5 @@
 		{
 			cerr << "already in obj format" << endl;
-			if (1)
-			preprocessor->ExportObj("test.obj", preprocessor->mObjects);
+			if (0) 	preprocessor->ExportObj("test.obj", preprocessor->mObjects);
 		}
 		else
@@ -233,5 +232,5 @@
 			const string objname = GetInternFilename(filename, ".obj");
 
-			//cout << "exporting scene to " << objname << endl;
+			cout << "exporting scene to " << objname << endl;
 			bool success = preprocessor->ExportObj(objname, preprocessor->mObjects);
 
@@ -246,4 +245,8 @@
 		}
 	}
+//	Exporter *exporter= Exporter::GetExporter("test1.wrl");
+//	AxisAlignedBox3 bbox = preprocessor->mKdTree->GetBox(); 
+//	bbox.Scale(Vector3(1, 1, 0.5));
+//exporter->ExportGeometry(preprocessor->mObjects);cout<<"here2"<<endl;
 
 	// parse view cells related options
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h	(revision 1697)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h	(revision 1701)
@@ -77,5 +77,5 @@
   Intersectable(): mMailbox(0), mReferences(0), mBvhLeaf(0), mVssRays(NULL) {}
 
-  virtual Intersectable::~Intersectable() {DEL_PTR(mVssRays);};
+  virtual Intersectable::~Intersectable() {DEL_PTR(mVssRays);}
 
   void SetId(const int id) { mId = id; }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1697)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1701)
@@ -457,6 +457,6 @@
 	{
 		// 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;
@@ -946,13 +946,16 @@
 	while (!splitQueue.Empty())
 	{
+		const float priority = splitQueue.Top()->GetPriority();
 		const float threshold = oldCandidate ? oldCandidate->GetPriority() : 1e20f;
+
+		// minimum slope reached
+		if ((steps >= maxSteps) || ((priority < threshold) && !(steps < minSteps)))
+		{
+			cout << "\n**************** breaking on " << priority << " smaller than " << threshold << endl;
+			break;
+		}
+		
 		SubdivisionCandidate *sc = NextSubdivisionCandidate(splitQueue); 
-		
-		const float priority = sc->GetPriority();
-		
-		//float rc = (float)sc->GetRenderCostDecrease() / (mInitialRenderCost - mHierarchyStats.mTotalCost + 1.0f);
-		//float mc = (float)sc->GetPvsEntriesIncr() / (float)mHierarchyStats.mPvsEntries;	
-		//cout << "dRc: " << sc->GetRenderCostDecrease() << " dMem: " << sc->GetPvsEntriesIncr() << " ratio1 " << rc << " ratio2 " << mc << " const: " << 1.0f - GetMemoryConst() << endl;
-
+				
 		////////
 		//-- subdivide leaf node of either type
@@ -968,13 +971,4 @@
 
 		DEL_PTR(sc);
-
-		// minimum slope reached
-		if ((steps >= maxSteps) || 
-			((priority < threshold) && !(steps < minSteps)))
-		{
-			cout << "\n**************** breaking on " << priority << " smaller than " << threshold << endl;
-			break;
-		}
-
 	}
 
