Index: /GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.h	(revision 1996)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.h	(revision 2076)
@@ -51,4 +51,19 @@
 							const bool pruneInvalidRays = true);
 
+  	virtual void CastRays16(
+							SimpleRayContainer &rays, 
+							const int offset,
+							VssRayContainer &vssRays,
+							const AxisAlignedBox3 &sbox,
+							const bool castDoubleRay,
+							const bool pruneInvalidRays = true);
+
+    virtual void CastRays(
+						  SimpleRayContainer &rays,
+						  VssRayContainer &vssRays,
+						  const AxisAlignedBox3 &sbox,
+						  const bool castDoubleRay,
+						  const bool pruneInvalidRays = true);
+
 protected:
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 2071)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 2076)
@@ -11,4 +11,5 @@
 #include "Exporter.h"
 #include "Environment.h"
+#include "RayCaster.h"
 
 #ifdef GTP_INTERNAL
@@ -540,7 +541,8 @@
 	// use direction based distribution
 	Vector3 origin, direction;
-	static HaltonSequence halton;
-	
-	halton.GetNext(5, rr);
+
+	for (int i=0; i < 5; i++)
+	  rr[i] = RandomValue(0,1);
+	
 	mPreprocessor.mViewCellsManager->GetViewPoint(origin,
 												  Vector3(rr[0], rr[1], rr[2]));
@@ -683,4 +685,5 @@
   } else {
 	mRays[index].mHalton.GetNext(4, rr);
+
 	// fuzzy random mutation
 	origin += ComputeOriginMutation(*ray, U, V,
@@ -751,10 +754,32 @@
 											 mMutationRadiusTermination);
   
-  Environment::GetSingleton()->GetBoolValue("Mutation.useReverseSamples",
-											mUseReverseSamples);
-  
-  Environment::GetSingleton()->GetFloatValue("Mutation.reverseSamplesDistance",
-											 mReverseSamplesDistance);
-  
+  bool useEnhancedFeatures;
+
+#ifdef GTP_INTERNAL
+  int rayCaster;
+  Environment::GetSingleton()->GetIntValue("Mutation.radiusTermination",
+										   rayCaster);
+  useEnhancedFeatures = (rayCaster ==
+						 RayCaster::INTEL_RAYCASTER);
+#else
+  useEnhancedFeatures = false;
+#endif
+  
+  if (useEnhancedFeatures) {
+	Environment::GetSingleton()->GetBoolValue("Mutation.useReverseSamples",
+											  mUseReverseSamples);
+	
+	Environment::GetSingleton()->GetFloatValue("Mutation.reverseSamplesDistance",
+
+											   mReverseSamplesDistance);
+
+	Environment::GetSingleton()->GetFloatValue("Mutation.silhouetteProb",
+											   mSilhouetteProb);
+
+  } else {
+	mUseReverseSamples = false;
+	mReverseSamplesDistance = 1e20f;
+	mSilhouetteProb = 0.0f;
+  }
   
   Environment::GetSingleton()->GetBoolValue("Mutation.useSilhouetteSamples",
@@ -764,8 +789,5 @@
 										   mSilhouetteSearchSteps);
   
-  Environment::GetSingleton()->GetFloatValue("Mutation.silhouetteProb",
-											 mSilhouetteProb);
-
-
+  
   Environment::GetSingleton()->GetBoolValue("Mutation.usePassImportance",
 											mUsePassImportance);
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/run_test2
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2060)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2076)
@@ -1,7 +1,7 @@
-#!/bin/sh
+#!sh
 
 
 #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=1000000 -total_samples=100000000"
+COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -samples_per_evaluation=5000000 -samples_per_pass=1000000 -total_samples=100000000"
 
 
@@ -31,15 +31,12 @@
 
 SCENE=../data/vienna/vienna_cropped.obj
-#VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz
-VIEWCELLS=../data/vienna/vienna-seq-viewcells-20000.xml.gz
+VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz
+#VIEWCELLS=../data/vienna/vienna-seq-viewcells-20000.xml.gz
 
-<<<<<<< .mine
-PREFIX=../work/plots/osp-vienna2-1e5
-=======
+
 # SCENE=../data/Pompeii/PompeiiTen.obj
 # VIEWCELLS=../data/Pompeii/pompeii_big-seq-viewcells.xml.gz
->>>>>>> .r2051
 
-PREFIX=../work/plots/osp-FILTER-1e5
+PREFIX=../work/plots/osp-TEST-1e5
 
 #SCENE=../data/atlanta/atlanta2.x3d
@@ -49,5 +46,4 @@
 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
 -rss_distributions=mutation+object_direction+spatial \
--view_cells_filter_width=1.0 \
 -view_cells_use_kd_pvs+ -af_use_kd_pvs- \
 -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4a.xml \
@@ -55,58 +51,56 @@
 -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4a.hlog
 
-<<<<<<< .mine
-# $COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
-# -preprocessor_visibility_file=$PREFIX-r-reference.xml \
-# -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-reference.log \
-# -preprocessor_histogram_file=$PREFIX-r-reference.hlog
-=======
-$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
--rss_distributions=mutation+object_direction+spatial \
--view_cells_filter_width=0.0 \
--view_cells_use_kd_pvs+ -af_use_kd_pvs- \
--preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4b.xml \
--preprocessor_stats=$PREFIX-i-mixed-b1-n4b.log \
--preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4b.hlog
->>>>>>> .r2051
+# # $COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+# # -preprocessor_visibility_file=$PREFIX-r-reference.xml \
+# # -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-reference.log \
+# # -preprocessor_histogram_file=$PREFIX-r-reference.hlog
 
-$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
--rss_distributions=mutation+object_direction+spatial \
--view_cells_filter_width=1.0 \
--view_cells_use_kd_pvs+ -af_use_kd_pvs+ \
--preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4c.xml \
--preprocessor_stats=$PREFIX-i-mixed-b1-n4c.log \
--preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4c.hlog
+# $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+# -rss_distributions=mutation+object_direction+spatial \
+# -view_cells_filter_width=0.0 \
+# -view_cells_use_kd_pvs+ -af_use_kd_pvs- \
+# -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4b.xml \
+# -preprocessor_stats=$PREFIX-i-mixed-b1-n4b.log \
+# -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4b.hlog
+
+# $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+# -rss_distributions=mutation+object_direction+spatial \
+# -view_cells_filter_width=1.0 \
+# -view_cells_use_kd_pvs+ -af_use_kd_pvs+ \
+# -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4c.xml \
+# -preprocessor_stats=$PREFIX-i-mixed-b1-n4c.log \
+# -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4c.hlog
+
+# # $COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+# # -preprocessor_visibility_file=$PREFIX-r-reference.xml \
+# # -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-reference.log \
+# # -preprocessor_histogram_file=$PREFIX-r-reference.hlog
+
+# # $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+# #  -rss_distributions=direction -view_cells_filter_max_size=1 \
+# #  -preprocessor_visibility_file=$PREFIX-r-reference-global.xml \
+# #  -preprocessor_stats=$PREFIX-r-reference-global.log \
+# #  -preprocessor_histogram_file=$PREFIX-r-reference-global.hlog
+
+
+# $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+# -rss_distributions=mutation+object_direction+spatial -view_cells_filter_max_size=1 \
+# -view_cells_use_kd_pvs- -af_use_kd_pvs- \
+# -preprocessor_visibility_file=$PREFIX-i-mixed-bvh-n4k.xml \
+# -preprocessor_stats=$PREFIX-i-mixed-bvh-n4k.log \
+# -preprocessor_histogram_file=$PREFIX-i-mixed-bvh-n4k.hlog
 
 # $COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
-# -preprocessor_visibility_file=$PREFIX-r-reference.xml \
-# -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-reference.log \
-# -preprocessor_histogram_file=$PREFIX-r-reference.hlog
+# -view_cells_use_kd_pvs- -af_use_kd_pvs- \
+# -preprocessor_visibility_file=$PREFIX-r-bvh-reference.xml \
+# -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-bvh-reference.log \
+# -preprocessor_histogram_file=$PREFIX-r-bvh-reference.hlog
 
 # $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+# -view_cells_use_kd_pvs- -af_use_kd_pvs- \
 #  -rss_distributions=direction -view_cells_filter_max_size=1 \
-#  -preprocessor_visibility_file=$PREFIX-r-reference-global.xml \
-#  -preprocessor_stats=$PREFIX-r-reference-global.log \
-#  -preprocessor_histogram_file=$PREFIX-r-reference-global.hlog
-
-
-$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
--rss_distributions=mutation+object_direction+spatial -view_cells_filter_max_size=1 \
--view_cells_use_kd_pvs- -af_use_kd_pvs- \
--preprocessor_visibility_file=$PREFIX-i-mixed-bvh-n4k.xml \
--preprocessor_stats=$PREFIX-i-mixed-bvh-n4k.log \
--preprocessor_histogram_file=$PREFIX-i-mixed-bvh-n4k.hlog
-
-$COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
--view_cells_use_kd_pvs- -af_use_kd_pvs- \
--preprocessor_visibility_file=$PREFIX-r-bvh-reference.xml \
--view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-bvh-reference.log \
--preprocessor_histogram_file=$PREFIX-r-bvh-reference.hlog
-
-$COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
--view_cells_use_kd_pvs- -af_use_kd_pvs- \
- -rss_distributions=direction -view_cells_filter_max_size=1 \
- -preprocessor_visibility_file=$PREFIX-r-bvh-reference-global.xml \
- -preprocessor_stats=$PREFIX-r-bvh-reference-global.log \
- -preprocessor_histogram_file=$PREFIX-r-bvh-reference-global.hlog
+#  -preprocessor_visibility_file=$PREFIX-r-bvh-reference-global.xml \
+#  -preprocessor_stats=$PREFIX-r-bvh-reference-global.log \
+#  -preprocessor_histogram_file=$PREFIX-r-bvh-reference-global.hlog
 
 
@@ -116,34 +110,34 @@
 #############
 #############
-#############
+# #############
 
 
 
-# $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
-#  -rss_distributions=mutation+object_direction+spatial -view_cells_filter_max_size=1 \
-#  -view_cells_use_kd_pvs- -af_use_kd_pvs- \
-#  -preprocessor_visibility_file=$PREFIX-i-mixed-bvh-n4i.xml \
-#  -preprocessor_stats=$PREFIX-i-mixed-bvh-n4i.log \
-#  -preprocessor_histogram_file=$PREFIX-i-mixed-bvh-n4i.hlog
+# # $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+# #  -rss_distributions=mutation+object_direction+spatial -view_cells_filter_max_size=1 \
+# #  -view_cells_use_kd_pvs- -af_use_kd_pvs- \
+# #  -preprocessor_visibility_file=$PREFIX-i-mixed-bvh-n4i.xml \
+# #  -preprocessor_stats=$PREFIX-i-mixed-bvh-n4i.log \
+# #  -preprocessor_histogram_file=$PREFIX-i-mixed-bvh-n4i.hlog
 
 
 
-#$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
-# -rss_distributions=mutation+object_direction+spatial -view_cells_filter_max_size=1 \
-# -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4i.xml \
-# -preprocessor_stats=$PREFIX-i-mixed-b1-n4i.log \
-# -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4i.hlog
+# #$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+# # -rss_distributions=mutation+object_direction+spatial -view_cells_filter_max_size=1 \
+# # -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4i.xml \
+# # -preprocessor_stats=$PREFIX-i-mixed-b1-n4i.log \
+# # -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4i.hlog
 
 
-# e - no origin mutation, silh. tm Q=2, reverse samples
-# f - no origin, q=2, no reverse samples
-# g - gaussian origin, q=2, reverse samples
+# # e - no origin mutation, silh. tm Q=2, reverse samples
+# # f - no origin, q=2, no reverse samples
+# # g - gaussian origin, q=2, reverse samples
 
-# g, h contain pvs error estimations...
+# # g, h contain pvs error estimations...
 
-# $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
-# -rss_distributions=rss+object_direction+spatial+object+direction -view_cells_filter_max_size=1 \
-# -preprocessor_stats=$PREFIX-i-mixed-b1-n2.log \
-# -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n2.hlog
+# # $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+# # -rss_distributions=rss+object_direction+spatial+object+direction -view_cells_filter_max_size=1 \
+# # -preprocessor_stats=$PREFIX-i-mixed-b1-n2.log \
+# # -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n2.hlog
 
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Halton.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Halton.h	(revision 1894)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Halton.h	(revision 2076)
@@ -10,4 +10,5 @@
   //  float r = 1 - prev - 1e-10f;
   float r = 1.0f - prev;
+  //float r = 1.0f - prev;
   if (baseRec < r)
 	return prev + baseRec;
@@ -17,11 +18,11 @@
 	hh = h;
 	h *= baseRec;
-  } while (h >= r);
+  } while (h > r);
   return prev + hh + h - 1.0f;
 }
 
 template<int T>
-class Halton {
-  float _invBases[T];
+struct Halton {
+  static float _invBases[T];
   float _prev[T];
   
@@ -32,6 +33,6 @@
 	  _prev[i] = 0;
   }
-  
-  Halton() {
+
+  Halton(const bool initializeBases) {
 	for (int i=0; i < T; i++) {
 	  int base = FindPrime(i+1);
@@ -40,4 +41,7 @@
 	  _invBases[i] = 1.0f/base;
 	}
+  }
+
+  Halton() {
 	Reset();
   }
@@ -53,5 +57,5 @@
 };
 
-class Halton2 {
+struct Halton2 {
   static float _invBases[2];
   float _prev[2];
@@ -97,5 +101,6 @@
 }
 
-/**
+  
+  /**
  * Find the nth prime number.
  * @param index the ordinal position in the sequence
@@ -133,13 +138,27 @@
 
   void
-  GetNext(const int dimensions, float *p)
-  {
-	for (int i=0; i < dimensions; i++)
-	  p[i] = (float)GetNumber(i+1);
-	GenerateNext();
-  }
+  GetNext(const int dimensions, float *p);
   
   void GenerateNext() {
 	index++;
+  }
+  
+  double GetNumber(const int dimension)  {
+	int base = FindPrime(dimension);
+	if(base == 1) {
+	  base++;  //The first dimension uses base 2.
+	} 
+	
+	int _p1 = base;
+	float _ip1 = 1.0f/base;
+	float p, u=0.0f;
+    int kk, a;
+	
+    // the first coordinate
+    for (p = _ip1, kk = index ; kk ;  p *= _ip1, kk /= _p1)   
+      if ((a = kk % _p1))
+		u += a * p;
+	
+	return u;
   }
   
@@ -150,5 +169,5 @@
    */
 
-  double GetNumber(const int dimension)  {
+  double GetNumberOld(const int dimension)  {
 	int base = FindPrime(dimension);
 	if(base == 1) {
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h	(revision 2072)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h	(revision 2076)
@@ -60,4 +60,10 @@
 							const bool pruneInvalidRays = true) = 0;
 
+  virtual void CastRays(
+						SimpleRayContainer &rays,
+						VssRayContainer &vssRays,
+						const AxisAlignedBox3 &sbox,
+						const bool castDoubleRay,
+						const bool pruneInvalidRays = true);
 	/*virtual void CastRaysEye4(SimpleRayContainer &rays,
 							  VssRayContainer &vssRays,
@@ -68,5 +74,4 @@
 	virtual void
 	SortRays(SimpleRayContainer &rays);
-
 
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 2069)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 2076)
@@ -1292,5 +1292,5 @@
    RegisterOption("Mutation.reverseSamplesDistance",
 				  optFloat,
-				  "mutation_reverse_samples_distance",
+				  "mutation_reverse_samples_distance=",
 				  "3.0");
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2072)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2076)
@@ -135,5 +135,6 @@
 mStopComputation(false),
 mThread(NULL),
-mGlobalLinesRenderer(NULL)
+mGlobalLinesRenderer(NULL),
+mUseHwGlobalLines(false)
 {
 	Environment::GetSingleton()->GetBoolValue("Preprocessor.useGlRenderer", mUseGlRenderer);
@@ -651,7 +652,10 @@
 	  return false;
 	
+	
 	mViewCellsManager->ApplyFilter(mKdTree,
-								   mApplyVisibilityFilter ? mVisibilityFilterWidth : -1.0f,
-								   mApplyVisibilitySpatialFilter ? mVisibilityFilterWidth : -1.0f);
+								   mApplyVisibilityFilter ?
+								   mVisibilityFilterWidth : -1.0f,
+								   mApplyVisibilitySpatialFilter ?
+								   mVisibilityFilterWidth : -1.0f);
 	cout << "done." << endl;
   }
@@ -1280,33 +1284,73 @@
 	}
 
-	SimpleRayContainer::const_iterator rit, rit_end = rays.end();
-
-	SimpleRayContainer rayBucket;
-	int i = 0;
-
-	for (rit = rays.begin(); rit != rit_end; ++ rit, ++ i)
-	{
-		SimpleRay ray = *rit;
+
+	if (mUseHwGlobalLines) 
+	  CastRaysWithHwGlobalLines(
+								rays,
+								vssRays,
+								castDoubleRays,
+								pruneInvalidRays
+								);
+	else
+	  mRayCaster->CastRays(
+						 rays,				
+						 vssRays,
+						 mViewCellsManager->GetViewSpaceBox(),
+						 castDoubleRays,
+						 pruneInvalidRays);
+  
+	if ((int)rays.size() > 10000) 
+	{
+		cout << endl;
+        long t2 = GetTime();
+
+#if SHOW_RAYCAST_TIMING
+		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;
+#endif
+	}
+
+	DeterminePvsObjects(vssRays);
+}
+
+
+  
+void
+Preprocessor::CastRaysWithHwGlobalLines(
+										SimpleRayContainer &rays,
+									  VssRayContainer &vssRays,
+									  const bool castDoubleRays,
+									  const bool pruneInvalidRays
+									  )
+{
+  SimpleRayContainer::const_iterator rit, rit_end = rays.end();
+  SimpleRayContainer rayBucket;
+  int i = 0;
+  for (rit = rays.begin(); rit != rit_end; ++ rit, ++ i)
+	{
+	  SimpleRay ray = *rit;
 #ifdef USE_CG
 		// HACK: global lines must be treated special
-		if (ray.mDistribution == SamplingStrategy::HW_GLOBAL_LINES_DISTRIBUTION)
-		{
-			mGlobalLinesRenderer->CastGlobalLines(ray, vssRays);
-			continue;
+	  if (ray.mDistribution == SamplingStrategy::HW_GLOBAL_LINES_DISTRIBUTION)
+		{
+		  mGlobalLinesRenderer->CastGlobalLines(ray, vssRays);
+		  continue;
 		}
 #endif
-		rayBucket.push_back(ray);
-
-		// 16 rays gathered => do ray casting
-		if ((int)rayBucket.size() >= 16)
-		{
-			mRayCaster->CastRays16(
-								   rayBucket,				
-								   vssRays,
-								   mViewCellsManager->GetViewSpaceBox(),
-								   castDoubleRays,
-								   pruneInvalidRays);
-
-			rayBucket.clear();
+	  rayBucket.push_back(ray);
+	  
+	  // 16 rays gathered => do ray casting
+	  if ((int)rayBucket.size() >= 16)
+		{
+		  mRayCaster->CastRays16(
+								 rayBucket,				
+								 vssRays,
+								 mViewCellsManager->GetViewSpaceBox(),
+								 castDoubleRays,
+								 pruneInvalidRays);
+		  
+		  rayBucket.clear();
 		}
 	
@@ -1340,33 +1384,4 @@
 	}
 
-	int m = 850000;
-
-	if (0 && (int)rays.size() > m + 50) {
-	  VssRayContainer tmpRays;
-	  	  
-	  for (int i=m; i < m+20; i++) {
-		  if (vssRays[i])
-		  {cout<<"e";
-		tmpRays.push_back(vssRays[i]);
-		  }
-		  else cout <<"d";
-	  }
-	  ExportRays("sorted_rays2.x3d", tmpRays, 200);
-	}
-
-	if ((int)rays.size() > 10000) 
-	{
-		cout << endl;
-        long t2 = GetTime();
-
-#if SHOW_RAYCAST_TIMING
-		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;
-#endif
-	}
-
-	DeterminePvsObjects(vssRays);
 }
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2048)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2076)
@@ -150,4 +150,12 @@
 						  const bool pruneInvalidRays = true);
 
+  virtual void
+  CastRaysWithHwGlobalLines(
+							SimpleRayContainer &rays,
+							VssRayContainer &vssRays,
+							const bool castDoubleRays,
+							const bool pruneInvalidRays
+							);
+
 	/** Compute pixel error of the current PVS solution by sampling given number of viewpoints .
 	*/
@@ -212,5 +220,5 @@
 	bool mUseGlRenderer;
 	bool mUseGlDebugger;
-
+  bool mUseHwGlobalLines;
 	bool mLoadViewCells;
 
@@ -248,4 +256,6 @@
 	int mSamplesPerEvaluation;
 
+  	RayCaster *mRayCaster;
+
 protected:
 
@@ -266,5 +276,4 @@
 	GlobalLinesRenderer *mGlobalLinesRenderer;
 
-	RayCaster *mRayCaster;
 	/// samples used for construction of the BSP view cells tree.
 	int mBspConstructionSamples;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h	(revision 2000)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h	(revision 2076)
@@ -249,8 +249,5 @@
 public:
  
-  HwGlobalLinesDistribution(Preprocessor &preprocessor):
-	SamplingStrategy(preprocessor) {
-	//mType = HW_GLOBAL_LINES_DISTRIBUTION;
-  }
+  HwGlobalLinesDistribution(Preprocessor &preprocessor);
   
 private:
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp	(revision 2017)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp	(revision 2076)
@@ -109,5 +109,5 @@
 
 void IntelRayCaster::CastRays16(
-								SimpleRayContainer &rays, 
+								SimpleRayContainer &rays,
 								VssRayContainer &vssRays,
 								const AxisAlignedBox3 &sbox,
@@ -115,55 +115,66 @@
 								const bool pruneInvalidRays)
 {
-	int i;
-	const int num = 16;
-	
-#if DEBUG_RAYCAST
-	Debug<<"C16 "<<flush;
-	static int counter=0;
-	Debug<<counter++<<endl;
-#endif
-
-	static int forward_hit_triangles[16];
-	static float forward_dist[16];
-
-	static int backward_hit_triangles[16];
-	static float backward_dist[16];
-
-	
-	Vector3 min = mPreprocessor.mSceneGraph->GetBox().Min();
-	Vector3 max = mPreprocessor.mSceneGraph->GetBox().Max();
-
-	for (i=0; i < num; i++) {
-#if DEBUG_RAYCAST
-	  if (counter == 43964) {
-		Debug<<rays[i].mOrigin<<" "<<rays[i].mDirection<<endl;
-	  }
-#endif
-	  mlrtaStoreRayAS16(&rays[i].mOrigin.x,
-						&rays[i].mDirection.x,
+  CastRays16(rays, 0, vssRays, sbox, castDoubleRay, pruneInvalidRays);
+}
+
+void IntelRayCaster::CastRays16(
+								SimpleRayContainer &rays,
+								const int offset,
+								VssRayContainer &vssRays,
+								const AxisAlignedBox3 &sbox,
+								const bool castDoubleRay,
+								const bool pruneInvalidRays)
+{
+  int i, k;
+  const int num = 16;
+  
+#if DEBUG_RAYCAST
+  Debug<<"C16 "<<flush;
+  static int counter=0;
+  Debug<<counter++<<endl;
+#endif
+  
+  static int forward_hit_triangles[16];
+  static float forward_dist[16];
+  
+  static int backward_hit_triangles[16];
+  static float backward_dist[16];
+  
+  
+  Vector3 min = mPreprocessor.mSceneGraph->GetBox().Min();
+  Vector3 max = mPreprocessor.mSceneGraph->GetBox().Max();
+
+  for (k=offset, i=0; i < num; i++, k++) {
+#if DEBUG_RAYCAST
+	if (counter == 43964) {
+	  Debug<<rays[k].mOrigin<<" "<<rays[k].mDirection<<endl;
+	}
+#endif
+	mlrtaStoreRayAS16(&rays[k].mOrigin.x,
+					  &rays[k].mDirection.x,
+					  i);
+  }
+  
+#if DEBUG_RAYCAST
+  Debug<<"TA\n"<<flush;
+#endif
+  
+  mlrtaTraverseGroupAS16(&min.x,
+						 &max.x,
+						 forward_hit_triangles,
+						 forward_dist);
+  
+#if DEBUG_RAYCAST
+  Debug<<"TAB\n"<<flush;
+#endif
+
+  if (castDoubleRay) {
+	for (k=offset, i=0; i < num; i++, k++)  {
+	  Vector3 dir = -rays[k].mDirection;
+	  mlrtaStoreRayAS16(&rays[k].mOrigin.x,
+						&dir.x,
 						i);
 	}
-
-#if DEBUG_RAYCAST
-	Debug<<"TA\n"<<flush;
-#endif
-
-	mlrtaTraverseGroupAS16(&min.x,
-						   &max.x,
-						   forward_hit_triangles,
-						   forward_dist);
-
-#if DEBUG_RAYCAST
-	Debug<<"TAB\n"<<flush;
-#endif
-
-	if (castDoubleRay) {
-	  for (i=0; i < num; i++)  {
-		Vector3 dir = -rays[i].mDirection;
-		mlrtaStoreRayAS16(&rays[i].mOrigin.x,
-						  &dir.x,
-						  i);
-	  }
-	  
+	
 #if DEBUG_RAYCAST
 	  Debug<<"TB\n"<<flush;
@@ -179,8 +190,8 @@
 	Debug<<"BBB\n"<<flush;
 #endif
-
-	for (i=0; i < num; i++) 
+	
+	for (i=0, k=offset; i < num; i++, k++) 
 	{
-		Intersection hitA(rays[i].mOrigin), hitB(rays[i].mOrigin);
+		Intersection hitA(rays[k].mOrigin), hitB(rays[k].mOrigin);
 
 #if DEBUG_RAYCAST
@@ -197,5 +208,5 @@
 
 			//-rays[index+i].mDirection; // $$ temporary
-			hitA.mPoint = rays[i].Extrap(forward_dist[i]);
+			hitA.mPoint = rays[k].Extrap(forward_dist[i]);
 		}
 	
@@ -214,5 +225,5 @@
 
 				// normalB = rays[i].mDirection; // $$ temporary
-				hitB.mPoint = rays[i].Extrap(-backward_dist[i]);
+				hitB.mPoint = rays[k].Extrap(-backward_dist[i]);
 			}
 		}
@@ -222,5 +233,6 @@
 #endif
 
-		ProcessRay(rays[i],
+#if 1
+		ProcessRay(rays[k],
 				   hitA,
 				   hitB,
@@ -230,4 +242,5 @@
 				   pruneInvalidRays
 				   );
+#endif
 	}
 
@@ -237,5 +250,32 @@
 }
 
-}
-
-#endif
+
+
+void
+IntelRayCaster::CastRays(
+						 SimpleRayContainer &rays,
+						 VssRayContainer &vssRays,
+						 const AxisAlignedBox3 &sbox,
+						 const bool castDoubleRay,
+						 const bool pruneInvalidRays )
+{
+  cout<<"INTEL"<<endl;
+
+  int buckets = rays.size()/16;
+  int offset = 0;
+  
+  for (int i=0; i < buckets; i++, offset+=16) {
+	CastRays16(rays, offset, vssRays, sbox, castDoubleRay, pruneInvalidRays);
+
+	if ((int)rays.size() > 100000 && i % (100000/16) == 0)
+	  cout<<"\r"<<offset<<"/"<<(int)rays.size()<<"\r";
+  }
+
+  for (; offset < rays.size(); offset++)
+  	CastRay(rays[offset], vssRays, sbox, castDoubleRay, pruneInvalidRays);
+
+}
+
+}
+
+#endif
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2060)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2076)
@@ -1,5 +1,5 @@
 #############################################################################
 # Makefile for building: preprocessor
-# Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 25. I 14:38:54 2007
+# Generated by qmake (2.00a) (Qt 4.1.2) on: pá 2. II 13:23:45 2007
 # Project:  preprocessor.pro
 # Template: app
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.h	(revision 2060)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.h	(revision 2076)
@@ -47,4 +47,5 @@
 	short mMutations;
 	short mUnsuccessfulMutations;
+	//	Halton<4> mHalton;
 	HaltonSequence mHalton;
 	float mImportance;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Halton.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Halton.cpp	(revision 863)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Halton.cpp	(revision 2076)
@@ -1,11 +1,38 @@
-
 #include "Halton.h"
+#include "PerfTimer.h"
 
 namespace GtpVisibilityPreprocessor {
 
+PerfTimer haltonTimer;
+
 // global halton generator
 
-Halton2 halton2;
-float Halton2::_invBases[2];
+  Halton2 halton2;
+  float Halton2::_invBases[2];
+
+  float Halton<1>::_invBases[1];
+  float Halton<2>::_invBases[2];
+  float Halton<3>::_invBases[3];
+  float Halton<4>::_invBases[4];
+  float Halton<5>::_invBases[5];
+  float Halton<6>::_invBases[6];
+  
+
+  Halton<1> dummmyHalton1(true);
+  Halton<2> dummmyHalton2(true);
+  Halton<3> dummmyHalton3(true);
+  Halton<4> dummmyHalton4(true);
+  Halton<5> dummmyHalton5(true);
+  Halton<6> dummmyHalton6(true);
+  
+void
+HaltonSequence::GetNext(const int dimensions, float *p)
+{
+  haltonTimer.Entry();
+  for (int i=0; i < dimensions; i++)
+	p[i] = (float)GetNumber(i+1);
+  GenerateNext();
+  haltonTimer.Exit();
+}
 
 }
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 2070)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 2076)
@@ -356,3 +356,25 @@
 }
 
-}
+
+void
+RayCaster::CastRays(
+					SimpleRayContainer &rays,
+					VssRayContainer &vssRays,
+					const AxisAlignedBox3 &sbox,
+					const bool castDoubleRay,
+					const bool pruneInvalidRays )
+{
+  SimpleRayContainer::const_iterator rit, rit_end = rays.end();
+  
+  for (rit = rays.begin(); rit != rit_end; ++ rit) {
+	CastRay(
+			*rit,				
+			vssRays,
+			sbox,
+			castDoubleRay,
+			pruneInvalidRays);
+  }
+  
+}
+
+}
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro	(revision 2049)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro	(revision 2076)
@@ -114,5 +114,7 @@
 Mailable.cpp \
 CombinedPreprocessor.cpp Vector2.cpp GlobalLinesRenderer.cpp \
-RenderTexture.cpp Mutation.cpp Timer/RDTSCTimer.cpp Timer/BenchTimer.cpp Timer/merror.cpp
+RenderTexture.cpp Mutation.cpp Timer/RDTSCTimer.cpp \
+Timer/BenchTimer.cpp Timer/merror.cpp \
+Intersectable.cpp
 
 SOURCES += BoostPreprocessorThread.cpp 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2072)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2076)
@@ -12,4 +12,5 @@
 namespace GtpVisibilityPreprocessor {
 
+extern PerfTimer haltonTimer;
 extern PerfTimer pvsTimer;
 extern PerfTimer viewCellCastTimer;
@@ -128,4 +129,7 @@
   sHalton.GetNext(4, r);
 
+  //  static Halton<4> halton;
+  //  halton.GetNext(r);
+  
   r[0] *= (float)mPreprocessor.mObjects.size() - 1;
   const int i = (int)r[0];
@@ -205,22 +209,4 @@
 bool SpatialBoxBasedDistribution::GenerateSample(SimpleRay &ray)
 {
-	/*
-	Vector3 origin, direction; 
-
-	mPreprocessor.mViewCellsManager->GetViewPoint(origin);
-	direction = mPreprocessor.mKdTree->GetBox().GetRandomPoint() - origin;
-	//cout << "z";
-	const float c = Magnitude(direction);
-
-	if (c <= Limits::Small) 
-	return false;
-
-	const float pdf = 1.0f;
-
-	direction *= 1.0f / c;
-	ray = SimpleRay(origin, direction, SPATIAL_BOX_BASED_DISTRIBUTION, pdf);
-
-	return true;
-	*/
 
 	Vector3 origin, direction; 
@@ -228,5 +214,7 @@
 	float r[6];
 	sHalton.GetNext(6, r);
-	mPreprocessor.mViewCellsManager->GetViewPoint(origin, Vector3(r[0], r[1], r[2]));
+	mPreprocessor.mViewCellsManager->GetViewPoint(origin, Vector3(r[0],
+																  r[1],
+																  r[2]));
 
 	direction = mPreprocessor.mKdTree->GetBox().GetRandomPoint(Vector3(r[3],
@@ -519,5 +507,9 @@
 {
   float r;
+
   sHalton.GetNext(1, &r);
+  //static Halton<1> halton;
+  //  halton.GetNext(&r);
+
   int i;
   // pickup a distribution
@@ -579,4 +571,5 @@
   cout<<"view cell cast time:"<<viewCellCastTimer.TotalTime()<<" s"<<endl;
   cout<<"pvs time:"<<pvsTimer.TotalTime()<<" s"<<endl;
+  cout<<"halton time:"<<haltonTimer.TotalTime()<<" s"<<endl;
   //  cout<<"obj time:"<<objTimer.TotalTime()<<" s"<<endl;
 #endif
@@ -710,4 +703,10 @@
 
 
+HwGlobalLinesDistribution::HwGlobalLinesDistribution(Preprocessor &preprocessor):
+  SamplingStrategy(preprocessor)
+{
+  mType = HW_GLOBAL_LINES_DISTRIBUTION;
+  preprocessor.mUseHwGlobalLines = true;
+}
 
 bool HwGlobalLinesDistribution::GenerateSample(SimpleRay &ray) 
