Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1523)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1524)
@@ -832,6 +832,8 @@
 	else
 	{
+#ifdef GTP_INTERNAL
 		mRayCaster = new IntelRayCaster(*this, externKdTree);
 		cout << "ray cast method: intel" << endl;
+#endif
 	}
 
@@ -847,44 +849,41 @@
 					   )
 {
-	long t1 = GetTime();
+	const long t1 = GetTime();
+
+	for (int i = 0; i < (int)rays.size();)
+	{
+		if (i + 16 < (int)rays.size()) 
+		{
+			mRayCaster->CastRays16(
+				i,
+				rays,				
+				vssRays,
+				mViewCellsManager->GetViewSpaceBox(),
+				castDoubleRays);
+			i += 16;
+		}
+		else 
+		{
+			mRayCaster->CastRay(
+				rays[i].mOrigin,
+				rays[i].mDirection,
+				rays[i].mPdf,
+				vssRays,
+				mViewCellsManager->GetViewSpaceBox(),
+				castDoubleRays);
+			i ++;
+		}
+	}
+
+#if DEBUB_RAYCAST
+	long t2 = GetTime();
+	if (i % 10000 == 0)
+		cout<<".";
 
 	if (castDoubleRays)
-	{
-		for (int i = 0; i < (int)rays.size(); ) 
-		{
-			if (i + 16 < (int)rays.size()) 
-			{
-				mRayCaster->CastRays16(
-					i,
-					rays,				
-					vssRays,
-					mViewCellsManager->GetViewSpaceBox(),
-					castDoubleRays);
-				i += 16;
-			} 
-			else 
-			{
-				mRayCaster->CastRay(
-					rays[i].mOrigin,
-					rays[i].mDirection,
-					rays[i].mPdf,
-					vssRays,
-					mViewCellsManager->GetViewSpaceBox(),
-					castDoubleRays);
-				i++;
-			}
-			
-			if (i % 10000 == 0)
-				cout<<".";
-		}
-
-		long t2 = GetTime();
-
-		if (castDoubleRays)
-			cout << 2 * rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl;
-		else
-			cout << rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl;
-	}
-	
+		cout << 2 * rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl;
+	else
+		cout << rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl;
+#endif	
 }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.cpp	(revision 1500)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.cpp	(revision 1524)
@@ -75,5 +75,4 @@
 	dir = CrossProd(plane1.mNormal, plane2.mNormal);
     
-	float abs;
 	const int index = dir.DrivingAxis();
    
@@ -98,5 +97,4 @@
 
 	Normalize(dir);
-
 	return SimpleRay(point, dir);
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 1523)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 1524)
@@ -71,5 +71,6 @@
 	mViewCellsManager->ComputeSampleContribution(*vssRay, true, false);
 
-	if ((vssRay->mPvsContribution - oldContri) > 0) // new contribution
+	 // some pvs contribution for this ray?
+	if ((vssRay->mPvsContribution - oldContri) > 0)
 	{
 		//cout << "h";
@@ -94,5 +95,5 @@
 	const int indexL = (index == 0) ? 2 : index - 1;
 
-	const Vector3 a = hitTriangle.mVertices[index] - ray.GetDir();
+	const Vector3 a = hitTriangle.mVertices[index] - ray.GetOrigin();
 	const Vector3 b = hitTriangle.mVertices[indexU] - hitTriangle.mVertices[index];
 	const Vector3 c = hitTriangle.mVertices[index] - hitTriangle.mVertices[indexL];
@@ -102,6 +103,6 @@
 	const Vector3 dir1 = Normalize(CrossProd(a, b)); //N((pi-xp)×(pi+1- pi));
 	const Vector3 dir2 = Normalize(CrossProd(a, c)); // N((pi-xp)×(pi- pi-1))
-	const Vector3 dir3 = DotProd(dir1, dir2) > 0 ? // N((pi-xp)×di,i-1+di,i+1×(pi-xp))
-		Normalize(dir2 + dir1) : Normalize(CrossProd(a, dir2) + CrossProd(dir1, a)); 
+	const Vector3 dir3 = DotProd(dir2, dir1) > 0 ? // N((pi-xp)×di,i-1+di,i+1×(pi-xp))
+		Normalize(dir2 + dir1) : Normalize(CrossProd(a, dir1) + CrossProd(dir2, a)); 
 
 	// compute the new three hit points
@@ -113,7 +114,7 @@
 	const Vector3 pt3 = hitTriangle.mVertices[index] + eps * len * dir3;
 	
+	vertices.push_back(pt2);
+	vertices.push_back(pt3);
 	vertices.push_back(pt1);
-	//vertices.push_back(pt2);
-	vertices.push_back(pt3);
 }
 
@@ -196,5 +197,4 @@
 	{
 		hitTriangle = dynamic_cast<TriangleIntersectable *>(tObj)->GetItem();
-		cout << "t: " << hitTriangle << endl << endl;
 	}
 	else
@@ -217,5 +217,5 @@
 	{
 		const Vector3 rayDir = (*vit) - currentRay.GetOrigin();
-		simpleRays.push_back(SimpleRay(*vit, rayDir));
+		simpleRays.push_back(SimpleRay(currentRay.GetOrigin(), rayDir));
 	}
 
@@ -226,20 +226,22 @@
 	vizContainer.push_back(dummy);
 
-	// establish visibility
+	// cast rays to triangle vertices and determine visibility
 	VssRayContainer vssRays;
 	CastRays(simpleRays, vssRays, false);
-
+cout << "here211 " << simpleRays.size() << " " << vssRays.size() << endl;
 	// add to ray queue
 	EnqueueRays(vssRays);
-#if 0
+	const int n = (int)enlargedTriangle.size();
+	
+#if 1
     // recursivly subdivide each edge
-	for (int i = 0; i < 9; ++ i)
+	for (int i = 0; i < n; ++ i)
 	{
 		SubdivideEdge(
 			hitTriangle,
 			enlargedTriangle[i], 
-			enlargedTriangle[(i + 1) % 9], 
+			enlargedTriangle[(i + 1) % n], 
 			*vssRays[i], 
-			*vssRays[(i + 1) % 9],
+			*vssRays[(i + 1) % n],
 			currentRay);
 	}
@@ -343,5 +345,5 @@
 		castSamples += mInitialSamples;
 #endif
-		//cout << "\ncast " << castSamples << " of " << mSamplesPerPass << endl;
+		cout << "\nround finished, cast " << castSamples << " of " << mSamplesPerPass << endl;
 	}
 
@@ -417,9 +419,10 @@
 	for (vit = vizContainer.begin(); vit != vit_end; ++ vit)
 	{
-		cout << "v";
+		exporter->SetWireframe();
 		exporter->ExportPolygon((*vit).enlargedTriangle);
 		//Material m;
-		//Polygon3 poly = Polygon3((*vit).originalTriangle);
-//		exporter->ExportPolygon(&poly);
+		exporter->SetFilled();
+		Polygon3 poly = Polygon3((*vit).originalTriangle);
+		exporter->ExportPolygon(&poly);
 	}
 
