Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 2582)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 2583)
@@ -28,5 +28,5 @@
 
   // VH - commened out !!!!! 8/1/2008
-  // #define SORT_RAY_ENTRIES 1
+#define SORT_RAY_ENTRIES 1
 
 // use avg ray contribution as importance
@@ -278,26 +278,4 @@
 {
 #if 0
-  Vector3 v;
-  // mutate the termination
-  if (d.DrivingAxis() == 0)
-	v = Vector3(0, r[2]-0.5f, r[3]-0.5f);
-  else
-	if (d.DrivingAxis() == 1)
-	  v = Vector3(r[2]-0.5f, 0, r[3]-0.5f);
-	else
-	  v = Vector3(r[2]-0.5f, r[3]-0.5f, 0);
-  
-  //   Vector3 nv;
-  
-  //   if (Magnitude(v) > Limits::Small)
-  // 	nv = Normalize(v);
-  //   else
-  // 	nv = v;
-  
-  //  v = nv*size + v*size;
-
-  return v*(4.0f*radius);
-#endif
-#if 0
   return (U*(vr2.xx - 0.5f) + V*(vr2.yy - 0.5f))*(4.0f*radius);
 #endif
@@ -388,11 +366,13 @@
 	preprocessor->mRayCaster->CastRaysPacket4(box.Min(),
 											  box.Max(),
-											  origs, dirs,
+											  origs,
+											  dirs,
 											  hit_triangles,
 											  dist);       
 	
 	for (i=0; i < packetSize; i++) {
+	  //cout<<hit_triangles[i]<<endl;
 	  if (hit_triangles[i] == -1) {
-	    // break on first passing ray
+		// break on first passing ray
 	    break;
 	  }
@@ -771,6 +751,6 @@
   Environment::GetSingleton()->GetIntValue("Preprocessor.rayCastMethod",
 										   rayCaster);
-  useEnhancedFeatures = (rayCaster ==
-						 RayCaster::INTEL_RAYCASTER);
+  useEnhancedFeatures = (rayCaster !=
+						 RayCaster::INTERNAL_RAYCASTER);
 #else
   useEnhancedFeatures = false;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/run_test2
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2582)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2583)
@@ -3,5 +3,5 @@
 
 #COMMAND="./release/preprocessor.exe -preprocessor_quit_on_finish+"
-COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer+ -preprocessor_evaluate_filter- -samples_per_evaluation=5000000 -samples_per_pass=500000 -total_samples=6000000"
+COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish- -preprocessor_use_gl_renderer+ -preprocessor_evaluate_filter- -samples_per_evaluation=5000000 -samples_per_pass=500000 -total_samples=20000000"
 
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h	(revision 2582)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h	(revision 2583)
@@ -2,8 +2,12 @@
 #define _RayCaster_H__
 
+
 #include "Containers.h"
 #include <string>
+#include <iostream>
 #include "Vector3.h"
 #include "VssRay.h"
+
+using namespace std;
 
 //
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2582)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2583)
@@ -1,2 +1,3 @@
+
 #include "SceneGraph.h"
 #include "Exporter.h"
@@ -20,7 +21,5 @@
 #include "VssRay.h"
 #include "IntelRayCaster.h"
-#if TODO
 #include "HavranRayCaster.h"
-#endif
 #include "InternalRayCaster.h"
 #include "GlobalLinesRenderer.h"
@@ -415,7 +414,9 @@
 
 	vector<FaceParentInfo> *fi = 
-	  ((rayCastMethod == RayCaster::INTEL_RAYCASTER) && mLoadMeshes) ?
+	  ((rayCastMethod == RayCaster::INTEL_RAYCASTER ||
+		rayCastMethod == RayCaster::HAVRAN_RAYCASTER
+		) && mLoadMeshes) ?
 	  &mFaceParents : NULL;
-
+	
 	if (files == 1) 
 	{
@@ -1047,57 +1048,61 @@
 bool Preprocessor::LoadInternKdTree(const string &internKdTree)
 {
-	bool mUseKdTree = true;
-
-	if (!mUseKdTree) {
-	  // create just a dummy KdTree
-	  mKdTree = new KdTree;
-	  return true;
-	}
-
-	int rayCastMethod;
-	Environment::GetSingleton()->
-	  GetIntValue("Preprocessor.rayCastMethod", rayCastMethod);
-
-	if (rayCastMethod == 2) {
-	  //HavranRayCaster *hr =
-	  //  dynamic_cast<HavranRayCaster*>(mRayCaster);
-#if TODO
-	  HavranRayCaster *hr =
-	    reinterpret_cast<HavranRayCaster*>(mRayCaster);
-	  hr->Build(this->mObjects);
-#endif
-	  return true;
-	}	
-
-	// always try to load the kd tree
-	cout << "loading kd tree file " << internKdTree << " ... " << endl;
-
-	if (!LoadKdTree(internKdTree)) {
-		cout << "error loading kd tree with filename " 
-			<< internKdTree << ", rebuilding it instead ... " << endl;
-		// build new kd tree from scene geometry
-		BuildKdTree();
-
-		// export kd tree?
-		const long startTime = GetTime();
-		cout << "exporting kd tree ... ";
-
-		if (!ExportKdTree(internKdTree))
-		{
-			cout << " error exporting kd tree with filename " 
-				<< internKdTree << endl;
-		}
-		else
-		{
-			cout << "finished in " 
-				<< TimeDiff(startTime, GetTime()) * 1e-3 
-				<< " secs" << endl;
-		}
-	}
-
-	KdTreeStatistics(cout);
-	cout << mKdTree->GetBox() << endl;
-
+  bool mUseKdTree = true;
+
+
+  int rayCastMethod;
+  Environment::GetSingleton()->
+	GetIntValue("Preprocessor.rayCastMethod", rayCastMethod);
+
+  if (rayCastMethod == 2) {
+	//HavranRayCaster *hr =
+	//  dynamic_cast<HavranRayCaster*>(mRayCaster);
+	HavranRayCaster *hr =
+	  reinterpret_cast<HavranRayCaster*>(mRayCaster);
+	hr->Build(this->mObjects);
+	// $$ do not exit here, so that the "internal" kD-tree used 
+	// other puroposes can be loaded
+	//	return true;
+  }
+
+  
+  if (!mUseKdTree) {
+	// create just a dummy KdTree
+	mKdTree = new KdTree;
 	return true;
+  }
+  
+  
+  
+  // always try to load the kd tree
+  cout << "loading kd tree file " << internKdTree << " ... " << endl;
+  
+  if (!LoadKdTree(internKdTree)) {
+	cout << "error loading kd tree with filename " 
+		 << internKdTree << ", rebuilding it instead ... " << endl;
+	// build new kd tree from scene geometry
+	BuildKdTree();
+	
+	// export kd tree?
+	const long startTime = GetTime();
+	cout << "exporting kd tree ... ";
+	
+	if (!ExportKdTree(internKdTree))
+	  {
+		cout << " error exporting kd tree with filename " 
+			 << internKdTree << endl;
+	  }
+	else
+	  {
+		cout << "finished in " 
+			 << TimeDiff(startTime, GetTime()) * 1e-3 
+			 << " secs" << endl;
+	  }
+  }
+  
+  KdTreeStatistics(cout);
+  cout << mKdTree->GetBox() << endl;
+  
+  return true;
 }
 
@@ -1154,8 +1159,6 @@
 	if (rayCastMethod == 2) 
 	{
-#if TODO
-		cout << "ray cast method: havran" << endl;
+	  cout << "ray cast method: havran" << endl <<flush;
 	  mRayCaster = new HavranRayCaster(*this);
-#endif
 	}
 	
@@ -1206,5 +1209,5 @@
 	cout << "reserving " << reserveRays << " rays " << endl;
 	mRayCaster->ReserveVssRayPool(reserveRays);
-	
+	cout<<"done."<<endl<<flush;
 	return true;
 }
@@ -1223,5 +1226,5 @@
 
 	// !!!!!!!!!!!!!!!! VH no sorting
-	if (0 &&
+	if (
 	    rays.size() > 10000)
 	{
@@ -1263,6 +1266,9 @@
 #endif
 	}
-	// cerr<<"Determining PVS objects"<<endl;
+
+	cerr<<"Determining PVS objects"<<endl;
 	DeterminePvsObjects(vssRays);
+	cerr<<"done."<<endl;
+
 }
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/default.env
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 2582)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 2583)
@@ -40,5 +40,5 @@
 	totalSamples 250000000
 #	totalSamples 2000000
-	samplesPerPass 1000000
+	samplesPerPass 500000
 	samplesPerEvaluation 5000000
 
@@ -53,5 +53,5 @@
 	useGlDebugger false
 # 0 = INTERNAL 	1 = MLRT 2 = HAVRAN
-	rayCastMethod 1
+	rayCastMethod 2
 	
 #	type sampling
@@ -106,5 +106,5 @@
 #	distributions rss+spatial+object_direction
 #	distributions rss+object_direction+spatial+object+direction
-	distributions mutation+spatial+object_direction+filter_based
+	distributions mutation+spatial+object_direction
 #	distributions rss+object_direction
 #	distributions object_direction
@@ -202,5 +202,5 @@
 	importRandomViewCells false
 
-	useKdPvs true
+	useKdPvs false
 	useKdPvsAfterFiltering true
 	# samples used for view cell construction
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2575)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2583)
@@ -687,5 +687,6 @@
 
 
-Intersectable *ViewCellsManager::GetIntersectable(const VssRay &ray, const bool isTermination) const
+Intersectable *ViewCellsManager::GetIntersectable(const VssRay &ray,
+												  const bool isTermination) const
 {
 	if (mUseKdPvs)
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/common.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/common.h	(revision 2582)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/common.h	(revision 2583)
@@ -29,5 +29,8 @@
 
   
-
+#if defined(_MSC_VER)
+// define __SSE__ macro as it is not defined under MSVC
+#define __SSE__
+#endif
 
 // This constant should be used for the length of the array char for filenames
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.cpp	(revision 2582)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.cpp	(revision 2583)
@@ -70,9 +70,9 @@
 // ray shooting is computed !
 void HavranRayCaster::CastRaysPacket4(Vector3 &boxmax,
-				      Vector3 &boxmin,
-				      Vector3 origin4[],
-				      Vector3 direction4[],
-				      int     result4[],
-				      float   dist4[])
+									  Vector3 &boxmin,
+									  Vector3 origin4[],
+									  Vector3 direction4[],
+									  int     result4[],
+									  float   dist4[])
 {
 #ifdef USE_HAVRAN_RAYCASTER 
@@ -81,6 +81,6 @@
     raypack.SetLoc(i, origin4[i]);
     raypack.SetDir(i, direction4[i]);
-  }  
-
+  }
+  
   // The same operations for packets of rays, if implemented by
   // a particular ASDS, otherwise it is emulated by decomposition
@@ -93,7 +93,8 @@
     Intersectable* intersectable;
     if ( (intersectable = raypack.GetObject(i)) )
-      result4[i] = (int)intersectable;
-  }
-    
+	  // $$JB this is very hacky - > should be replaced with fetching the index of the triangle
+	  result4[i] = (int)intersectable;
+  }
+  
   return;
 #endif
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2582)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2583)
@@ -1,5 +1,5 @@
 #############################################################################
 # Makefile for building: preprocessor
-# Generated by qmake (2.00a) (Qt 4.1.2) on: st 9. I 11:11:49 2008
+# Generated by qmake (2.00a) (Qt 4.1.2) on: st 9. I 13:30:43 2008
 # Project:  preprocessor.pro
 # Template: app
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 2575)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 2583)
@@ -14,5 +14,5 @@
 
 RayCaster::RayCaster(const Preprocessor &preprocessor):
-mPreprocessor(preprocessor)
+  mVssRayPool(), mPreprocessor(preprocessor)
 {
 }
@@ -270,10 +270,10 @@
 int
 RayCaster::ProcessRay(const SimpleRay &simpleRay,
-		      Intersection &hitA,
-		      Intersection &hitB,
-		      VssRayContainer &vssRays,
-		      const AxisAlignedBox3 &box,
-		      const bool castDoubleRay,
-		      const bool pruneInvalidRays)
+					  Intersection &hitA,
+					  Intersection &hitB,
+					  VssRayContainer &vssRays,
+					  const AxisAlignedBox3 &box,
+					  const bool castDoubleRay,
+					  const bool pruneInvalidRays)
 {
   int hits = 0;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/havran/raypack.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/havran/raypack.h	(revision 2582)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/havran/raypack.h	(revision 2583)
@@ -22,7 +22,5 @@
 #include "Vector3.h"
   
-// $$JB __SSE__ macro not define in _WIN32
-//#ifdef __SSE__
-#if 1
+#ifdef __SSE__
 
 // System headers for SSE
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/havran/ktbtrav.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/havran/ktbtrav.h	(revision 2582)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/havran/ktbtrav.h	(revision 2583)
@@ -311,7 +311,6 @@
   }
   // $$JB correction
-  virtual int FindNearestI_16oneDir(SimpleRayContainer &rays, int offset) {
-	return 0;
-  }
+  virtual int FindNearestI_16oneDir(SimpleRayContainer &rays, int offset);
+
   int PrecomputeData(SimpleRayContainer &rays);
   void ReverseRay(const int indexA);
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/havran/ktbftrav.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/havran/ktbftrav.cpp	(revision 2582)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/havran/ktbftrav.cpp	(revision 2583)
@@ -990,4 +990,5 @@
       results[i].tdist;
   } // for i
+  return 0;
 }
 #endif
@@ -1338,8 +1339,12 @@
 CKTBTraversal::FindNearestI(RayPacket2x2 &rp, Vector3 &boxmin, Vector3 &boxmax)
 {
+
   static AxisAlignedBox3 localbox;
   localbox.SetMin(boxmin);
   localbox.SetMax(boxmax);
 
+#define USE_SIMPLE_VERSION 1
+
+#if !USE_SIMPLE_VERSION
   int m1 = _mm_movemask_ps(rp.dx4);
   if ((m1 == 0)||(m1 == 15)) {
@@ -1514,5 +1519,5 @@
     return;
   }}}
-
+#endif
   // Trace ray by ray
   SimpleRay ray;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro	(revision 2582)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro	(revision 2583)
@@ -85,5 +85,5 @@
 CONFIG(qt) {
 win32:LIBS += cg.lib cgGL.lib
-#DEFINES += USE_QT
+DEFINES += USE_QT
 }
 
