Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj	(revision 1288)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj	(revision 1521)
@@ -194,4 +194,5 @@
 				RuntimeTypeInfo="TRUE"
 				UsePrecompiledHeader="0"
+				BrowseInformation="1"
 				WarningLevel="3"
 				Detect64BitPortabilityProblems="TRUE"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h	(revision 1500)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h	(revision 1521)
@@ -72,5 +72,5 @@
 		b) if triangle was found reverse sampling
 	*/
-	bool HandleRay(VssRay &ray);
+	bool HandleRay(VssRay *ray);
 
 	/** The adaptive border sampling step. It aims to find neighbouring 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h	(revision 1520)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h	(revision 1521)
@@ -31,7 +31,16 @@
 	RayCaster(const Preprocessor &preprocessor);
 
-	virtual ~RayCaster() = 0;
+	virtual ~RayCaster();
 
 	virtual int Type() const = 0;
+
+	/** Wrapper for casting single ray.
+	*/
+	VssRay *CastSingleRay(
+		const Vector3 &viewPoint,
+		const Vector3 &direction,
+		const float probability,
+        const AxisAlignedBox3 &box
+		);
 
 	virtual int CastRay(
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1520)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1521)
@@ -193,6 +193,12 @@
 }
 
-int
-SplitFilenames(const string str, vector<string> &filenames)
+
+GlRendererBuffer *Preprocessor::GetRenderer() 
+{ 
+	return renderer;
+}
+
+
+static int SplitFilenames(const string str, vector<string> &filenames)
 {
 	int pos = 0;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 1520)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 1521)
@@ -225,4 +225,5 @@
 				RuntimeTypeInfo="TRUE"
 				UsePrecompiledHeader="0"
+				BrowseInformation="1"
 				WarningLevel="2"
 				Detect64BitPortabilityProblems="TRUE"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp	(revision 1486)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp	(revision 1521)
@@ -14,7 +14,6 @@
 #include "GlRenderer.h"
 #include "Intersectable.h"
-#ifdef GTP_INTERNAL
-#include "ArchModeler2MLRT.hxx"
-#endif
+#include "RayCaster.h"
+
 
 namespace GtpVisibilityPreprocessor {
@@ -488,5 +487,5 @@
 			Vector3 direction = GetDirection(viewpoint, &mViewSpaceBox);
 
-			sampleContributions = CastRay(viewpoint, direction, 1, mVssRays, mViewSpaceBox);
+			sampleContributions = mRayCaster->CastRay(viewpoint, direction, 1, mVssRays, mViewSpaceBox, true);
 
 			if (sampleContributions) {
@@ -617,5 +616,7 @@
 
 	for (int i=0; i < rays.size(); i++)
-	  CastRay(rays[i].mOrigin, rays[i].mDirection, 1, vssRays, mViewSpaceBox);
+	{
+		mRayCaster->CastRay(rays[i].mOrigin, rays[i].mDirection, 1, vssRays, mViewSpaceBox, true);
+	}
 
 	vssTree->AddRays(vssRays);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 1520)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 1521)
@@ -42,8 +42,6 @@
     viewcell loading/generation and the visibility computation itself.
 */
-// matt: remove qt dependencies
-class Preprocessor// : public QObject 
+class Preprocessor
 {
-  //Q_OBJECT
 	friend class RayCaster;
 	friend class IntelRayCaster;
@@ -64,6 +62,6 @@
   
   /** Export all preprocessed data in a XML format understandable by the
-      PreprocessingInterface of the GtpVisibilityPreprocessor Module. The file can be compressed depending
-      on the environement settings.
+      PreprocessingInterface of the GtpVisibilityPreprocessor Module. 
+	  The file can be compressed depending on the environement settings.
       @return true on successful export
   */
@@ -100,11 +98,9 @@
   SamplingStrategy *GenerateSamplingStrategy(const int strategyId) const;
 
-  bool
-  Export( const string filename,
-	  const bool scene,
-	  const bool kdtree,
-	  const bool bsptree
-	  );
-  
+  bool Export(
+		const string filename, 
+		const bool scene, 
+		const bool kdtree, 
+		const bool bsptree);  
   
   virtual void KdTreeStatistics(ostream &s);
@@ -151,17 +147,9 @@
   HierarchyManager *CreateHierarchyManager(const char *name);
    
-  GlRendererBuffer *GetRenderer() { return renderer;}
+  GlRendererBuffer *GetRenderer();
 
   bool InitRayCast(const string externKdTree, const string internKdTree);
 
-  int CastRay(
-	  const Vector3 &viewPoint,
-	  const Vector3 &direction,
-	  const float probability,
-	  VssRayContainer &vssRays,
-	  const AxisAlignedBox3 &box
-	  );
-
-  
+   
   ////////////////////////////////////////////////
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp	(revision 1520)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp	(revision 1521)
@@ -37,6 +37,5 @@
 							VssRayContainer &vssRays,
 							const AxisAlignedBox3 &box,
-							const bool castDoubleRay,
-							const int pass
+							const bool castDoubleRay
 							)
 {
@@ -113,6 +112,5 @@
 								VssRayContainer &vssRays,
 								const AxisAlignedBox3 &sbox,
-								const bool castDoubleRay,
-								const int pass)
+								const bool castDoubleRay)
 {
 	int i;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 1520)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 1521)
@@ -14,4 +14,22 @@
 mPreprocessor(preprocessor)
 {
+}
+
+
+RayCaster::~RayCaster()
+{
+}
+
+
+VssRay *RayCaster::CastSingleRay(const Vector3 &viewPoint,
+								 const Vector3 &direction,
+								 const float probability,
+								 const AxisAlignedBox3 &box)
+{
+	VssRayContainer rays;
+	CastRay(viewPoint, direction, probability, rays, box, false);
+
+	if (!rays.empty())
+		return rays.back();
 }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp	(revision 1520)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp	(revision 1521)
@@ -21,6 +21,5 @@
 
 
-int InternalRayCaster::CastRay(
-							   const Vector3 &viewPoint,
+int InternalRayCaster::CastRay(const Vector3 &viewPoint,
 							   const Vector3 &direction,
 							   const float probability,
@@ -76,6 +75,5 @@
 
 
-void InternalRayCaster::CastRays16(
-								   const int index,
+void InternalRayCaster::CastRays16(const int index,
 								   SimpleRayContainer &rays, 
 								   VssRayContainer &vssRays,
@@ -83,5 +81,4 @@
 								   const bool castDoubleRays)
 {
-	int i;
 	const int num = 16;
 
@@ -91,5 +88,5 @@
 
 	// no acceleration for ray bundles implemented right now
-	for (i=index; i < index + num; i++) 
+	for (int i=index; i < index + num; i++) 
 	{
 		CastRay(rays[i].mOrigin,
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 1520)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 1521)
@@ -7,5 +7,5 @@
 #include "IntersectableWrapper.h"
 #include "Plane3.h"
-
+#include "RayCaster.h"
 
 
@@ -47,5 +47,7 @@
 	{
 		VssRay *newRay = ReverseSampling(currentRay, hitTriangle, oldRay);
-		HandleRay(*newRay);
+		if (!HandleRay(newRay))
+			delete newRay;
+
 		return true;
 	}
@@ -55,10 +57,10 @@
 
 
-bool GvsPreprocessor::HandleRay(VssRay &vssRay)
-{
-	if (mViewCellsManager->ComputeSampleContribution(vssRay, true, false))
+bool GvsPreprocessor::HandleRay(VssRay *vssRay)
+{
+	if (mViewCellsManager->ComputeSampleContribution(*vssRay, true, false))
 	{
 		//cout << "h";
-		mRayQueue.push(&vssRay);
+		mRayQueue.push(vssRay);
 		return true;
 	}
@@ -155,12 +157,14 @@
 		const Vector3 p = (p1 + p2) * 0.5f;
 		SimpleRay sray(oldRay.mOrigin, p - oldRay.mOrigin);
-		VssRay *newRay = NULL;
-		//VssRay *newRay = CastSingleRay(sray);
-		HandleRay(*newRay);
-
+	
+		VssRay *newRay = mRayCaster->CastSingleRay(sray.mOrigin, sray.mDirection, 1, mViewSpaceBox);
+		bool addedToQueue = HandleRay(newRay);
+		
 		const int s1 = SubdivideEdge(hitTriangle, p1, p, x, *newRay, oldRay);
 		const int s2 = SubdivideEdge(hitTriangle, p, p2, *newRay, y, oldRay);
-								  
-        return s1 + s2;
+		return s1 + s2;
+		
+		if (!addedToQueue)
+			delete newRay;
 	}
 }
@@ -291,5 +295,5 @@
 	for (vit = samples.begin(); vit != vit_end; ++ vit)
 	{
-		HandleRay(*(*vit));
+		HandleRay(*vit);
 	}
 }
@@ -330,4 +334,6 @@
 		
 		castSamples += AdaptiveBorderSampling(*ray);
+
+		delete ray;
 	}
 
