Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1768)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1769)
@@ -986,4 +986,6 @@
 	case SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION:
 		return new ReverseObjectBasedDistribution(*this);
+	case SamplingStrategy::VIEWCELL_BORDER_BASED_DISTRIBUTION:
+		return new ViewCellBorderBasedDistribution(*this);
 	//case OBJECTS_INTERIOR_DISTRIBUTION:
 	//	return new ObjectsInteriorDistribution(*this);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h	(revision 1763)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h	(revision 1769)
@@ -28,5 +28,6 @@
 		 OBJECT_DIRECTION_BASED_DISTRIBUTION,
 		 OBJECTS_INTERIOR_DISTRIBUTION,
-		 REVERSE_OBJECT_BASED_DISTRIBUTION
+		 REVERSE_OBJECT_BASED_DISTRIBUTION,
+		 VIEWCELL_BORDER_BASED_DISTRIBUTION
 	 };
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1768)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1769)
@@ -551,8 +551,15 @@
 	
 	/////////////////
-	//-- Finally, we do some visualization
+	//-- Show some visualizations
 
 	if (mShowVisualization)
 	{
+		cout << "************************\n*********************\n";
+		if (0)
+		{
+			strategies.clear();
+			strategies.push_back(SamplingStrategy::VIEWCELL_BORDER_BASED_DISTRIBUTION);
+		}
+
 		///////////////
 		//-- visualization rays, e.g., to show some samples in the scene
@@ -5501,7 +5508,17 @@
 	int leafOut;
 	Environment::GetSingleton()->GetIntValue("ViewCells.Visualization.maxOutput", leafOut);
+
+	const bool sortViewCells = false;
+	const bool exportPvs = true;
+	const bool exportRays = true;
 	const int raysOut = 100;
 
-	ExportSingleViewCells(objects, leafOut, false, true, false, raysOut, "");
+	ExportSingleViewCells(objects, 
+						  leafOut, 
+						  sortViewCells, 
+						  exportPvs, 
+						  exportRays, 
+						  raysOut, 
+						  "");
 }
 
@@ -5943,5 +5960,5 @@
 	strategies.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION);
 	strategies.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION);
-
+//strategies.push_back(SamplingStrategy::VIEWCELL_BORDER_BASED_DISTRIBUTION);
 	cout << "reseting pvs ... ";
 		
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp	(revision 1768)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp	(revision 1769)
@@ -802,6 +802,7 @@
 
 	// get random edge of face (hack: this is not uniform in the edges!
-	const int edgeIdx = (int)RandomValue(0.0f, face->mVertexIndices.size() - 0.5f);
-
+	const int edgeIdx = (int)RandomValue(0.0f, (float)face->mVertexIndices.size() - 0.5f);
+
+	//cout << "idx = " << edgeIdx << " s: " << face->mVertexIndices.size() << endl;
 	const int vertexIdxA = face->mVertexIndices[edgeIdx];
 	const int vertexIdxB = face->mVertexIndices[(edgeIdx + 1) % (int)face->mVertexIndices.size()];
@@ -815,4 +816,5 @@
 	point = a * w + b * (1.0f - w);
 
+	//cout << "va " << a << " vb " << b << "p " << point << endl;
 	// hack: set normal of face as normal
 	normal = mMesh->GetFacePlane(faceIdx).mNormal;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 1768)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 1769)
@@ -199,5 +199,4 @@
 	Vector3 normal, normal2;
 	
-	//cout << "y";
 	const int vcIdx = (int)RandomValue(0, (float)viewCells.size() - 0.5f);
 	const int objIdx = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f);
@@ -206,4 +205,7 @@
 	ViewCell *viewCell = viewCells[vcIdx];
 
+	//cout << "vc: " << vcIdx << endl;
+	//cout << "obj: " << objIdx << endl;
+
 	object->GetRandomSurfacePoint(point, normal);
 	viewCell->GetRandomEdgePoint(origin, normal2);
@@ -214,5 +216,5 @@
 	const float c = Magnitude(direction);
 
-	if ((c <= Limits::Small) || (DotProd(direction, normal) < 0))
+	if ((c <= Limits::Small) /*|| (DotProd(direction, normal) < 0)*/)
 	{
 		return false;
@@ -224,5 +226,7 @@
 	direction *= 1.0f / c;
 	ray = SimpleRay(origin, direction, pdf);
-	
+
+	//cout << "ray: " << ray.mOrigin << " " << ray.mDirection << endl;
+
 	return true;
 }
@@ -258,4 +262,5 @@
 	return true;
 }
+
 #endif
 }
