Index: GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 1287)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 1292)
@@ -130,5 +130,5 @@
 			<Tool
 				Name="VCCLCompilerTool"
-				Optimization="3"
+				Optimization="2"
 				GlobalOptimizations="FALSE"
 				FavorSizeOrSpeed="1"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.icproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.icproj	(revision 1283)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.icproj	(revision 1292)
@@ -115,11 +115,11 @@
 			<Tool 
 				Name="CppCmplrTool"
-				Optimization="1000"
-				GlobalOptimizations="1"
+				Optimization="2"
+				GlobalOptimizations="0"
 				InlineFunctionExpansion="0"
-				EnableIntrinsicFunctions="1"
+				EnableIntrinsicFunctions="0"
 				FavorSizeOrSpeed="1"
-				OmitFramePointers="1"
-				EnableFiberSafeOptimizations="1"
+				OmitFramePointers="0"
+				EnableFiberSafeOptimizations="0"
 				OptimizeForProcessor="3"
 				OptimizeForWindowsApplication="1"
@@ -135,7 +135,5 @@
 				WarningLevel="2"
 				Detect64BitPortabilityProblems="1"
-				DebugInformationFormat="3"
-				UseProcExt="4"
-				Parallelization="1"/>
+				DebugInformationFormat="3"/>
 			<Tool 
 				Name="LinkerTool"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1291)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1292)
@@ -24,4 +24,7 @@
 #include "ArchModeler2MLRT.hxx"
 #endif
+
+#define DEBUG_RAYCAST 0
+
 
 namespace GtpVisibilityPreprocessor {
@@ -454,4 +457,21 @@
 }
 
+  
+bool
+Preprocessor::ConstructViewCells()
+{
+  // if not already loaded, construct view cells from file
+  if (!mLoadViewCells) {
+	mViewCellsManager->SetViewSpaceBox(mKdTree->GetBox());
+	
+	// construct view cells using it's own set of samples
+	mViewCellsManager->Construct(this);
+	
+	//-- several visualizations and statistics
+	Debug << "view cells construction finished: " << endl;
+	mViewCellsManager->PrintStatistics(Debug);
+  }
+  return true;
+}
 
 HierarchyManager *Preprocessor::CreateHierarchyManager(const char *name)
@@ -834,48 +854,55 @@
 
 	Vector3 pointA, pointB;
-	
-	Intersectable *objectA = 
-		CastIntelSingleRay(viewPoint, direction, pointA, box);
-	
-	// cast ray into other direction
-	Intersectable *objectB = 
-		CastIntelSingleRay(viewPoint, -direction, pointB, box);
-
-	const bool validSample = (objectA != objectB);
-	
-	if (validSample) 
-	{	
-		if (objectA) 
-		{
-			vssRay = new VssRay(pointB,
-								pointA,
-								objectB,
-								objectA,
-								mPass,
-								probability
-								);
-
-			vssRays.push_back(vssRay);
-			hits ++;
-		}
-
-		if (objectB) 
-		{
-			vssRay = new VssRay(pointA,
-								pointB,
-								objectA,
-								objectB,
-								mPass,
-								probability
-								);
-
-			vssRays.push_back(vssRay);
-			hits ++;
-		}
-		//Debug << "intel ray: " << *vssRay << endl;
-	}
-
-	//cout << "a";
-	return hits;
+	Vector3 normalA, normalB;
+	Intersectable *objectA = NULL, *objectB = NULL;
+	float dist;
+	
+	int hittriangle;
+	double normal[3];
+	hittriangle = mlrtaIntersectAS(&viewPoint.x,
+								   &direction.x,
+								   normal,
+								   dist);
+	if (hittriangle !=-1 ) {
+	  if (hittriangle >= mFaceParents.size())
+		cerr<<"Warning: traingle index out of range! "<<hittriangle<<endl;
+	  else {
+		objectA = mFaceParents[hittriangle].mObject;
+		normalA = Vector3(normal[0], normal[1], normal[2]);
+		// Get the normal of that face
+		//		Mesh *mesh = ((MeshInstance *)objectA)->GetMesh();
+		//		normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal;
+		//-rays[index+i].mDirection; // $$ temporary
+		pointA = viewPoint + direction*dist;
+	  }
+	}
+
+	Vector3 dir = -direction;
+	hittriangle = mlrtaIntersectAS(&viewPoint.x,
+								   &dir.x,
+								   normal,
+								   dist);
+	if (hittriangle !=-1 ) {
+	  if (hittriangle >= mFaceParents.size())
+		cerr<<"Warning: traingle index out of range! "<<hittriangle<<endl;
+	  else {
+		objectB = mFaceParents[hittriangle].mObject;
+		normalB = Vector3(normal[0], normal[1], normal[2]);
+		// Get the normal of that face
+		//		Mesh *mesh = ((MeshInstance *)objectB)->GetMesh();
+		//		normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal;
+		//-rays[index+i].mDirection; // $$ temporary
+		pointB = viewPoint + dir*dist;
+	}
+	}
+
+	return ProcessRay(viewPoint,
+					  direction,
+					  objectA, pointA, normalA,
+					  objectB, pointB, normalB,
+					  probability,
+					  vssRays,
+					  box
+					  );
 }
 
@@ -909,24 +936,31 @@
 
 	if (hittriangle == -1)
-	{
+	  {
 		static Ray ray;
 		SetupRay(ray, viewPoint, direction);
-
+		
 		float tmin = 0, tmax;
 		if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax)
-		{
+		  {
 			tPoint = ray.Extrap(tmax);
-		}
-
+		  }
+		
 		return NULL;
-	}
-	else
-	{
+	  }
+	else {
+	  if (hittriangle >= mFaceParents.size()) {
+		cerr<<"Warning: traingle index out of range! "<<hittriangle<<endl;
+		return NULL;
+	  }
+	  else {
+		
 		tPoint[0] = pforg[0] + pfdir[0] * dist;
 		tPoint[1] = pforg[1] + pfdir[1] * dist;
 		tPoint[2] = pforg[2] + pfdir[2] * dist;
-
+		
 		return mFaceParents[hittriangle].mObject;
-	}
+	  }
+	}
+	
 }
 
@@ -1050,8 +1084,10 @@
 {
   int hits=0;
-
+#if DEBUG_RAYCAST
+  Debug<<"PR ";
+#endif
   if (objectA == NULL && objectB == NULL)
 	return 0;
-
+  
   AxisAlignedBox3 sbox = box;
   sbox.Enlarge(Vector3(-Limits::Small));
@@ -1123,5 +1159,6 @@
 	}
   }
-  
+
+
   return hits;
 }
@@ -1135,5 +1172,8 @@
   int i;
   int num = 16;
-  
+
+#if DEBUG_RAYCAST
+  Debug<<"C16 "<<flush;
+#endif
   if (mRayCastMethod == INTEL_RAYCASTER) {
 #ifdef GTP_INTERNAL
@@ -1144,8 +1184,8 @@
   int backward_hit_triangles[16];
   float backward_dist[16];
-  
+
+
   Vector3 min = sbox.Min();
   Vector3 max = sbox.Max();
-  
   for (i=0; i < num; i++) {
 	mlrtaStoreRayAS16(&rays[index + i].mOrigin.x,
@@ -1161,5 +1201,5 @@
 
   for (i=0; i < num; i++) {
-	Vector3 dir = -rays[index+i].mDirection;
+	Vector3 dir = -rays[index + i].mDirection;
 	mlrtaStoreRayAS16(&rays[index+i].mOrigin.x,
 					  &dir.x,
@@ -1174,27 +1214,39 @@
   
 
+
   for (i=0; i < num; i++) {
 	Intersectable *objectA = NULL, *objectB = NULL;
 	Vector3 pointA, pointB;
 	Vector3 normalA, normalB;
+
+
+  
 	if (forward_hit_triangles[i] !=-1 ) {
-	  objectA = mFaceParents[forward_hit_triangles[i]].mObject;
-	  // Get the normal of that face
-	  Mesh *mesh = ((MeshInstance *)objectA)->GetMesh();
-	  normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal;
-	  //-rays[index+i].mDirection; // $$ temporary
-	  pointA = rays[index+i].Extrap(forward_dist[i]);
+	  if (forward_hit_triangles[i] >= mFaceParents.size())
+		cerr<<"Warning: traingle index out of range! "<<forward_hit_triangles[i]<<endl;
+	  else {
+		objectA = mFaceParents[forward_hit_triangles[i]].mObject;
+		// Get the normal of that face
+		Mesh *mesh = ((MeshInstance *)objectA)->GetMesh();
+		normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal;
+		//-rays[index+i].mDirection; // $$ temporary
+		pointA = rays[index+i].Extrap(forward_dist[i]);
+	  }
 	}
 	
 	if (backward_hit_triangles[i]!=-1) {
-	  objectB = mFaceParents[backward_hit_triangles[i]].mObject;
-	  Mesh *mesh = ((MeshInstance *)objectB)->GetMesh();
-
-	  normalB = mesh->GetFacePlane(mFaceParents[backward_hit_triangles[i]].mFaceIndex).mNormal;
-	  
-	  //	  normalB = rays[index+i].mDirection; // $$ temporary
-	  pointB = rays[index+i].Extrap(-backward_dist[i]);
-	}
-	
+	  if (backward_hit_triangles[i] >= mFaceParents.size())
+		cerr<<"Warning: traingle index out of range! "<<backward_hit_triangles[i]<<endl;
+	  else {
+		objectB = mFaceParents[backward_hit_triangles[i]].mObject;
+		Mesh *mesh = ((MeshInstance *)objectB)->GetMesh();
+		
+		normalB = mesh->GetFacePlane(mFaceParents[backward_hit_triangles[i]].mFaceIndex).mNormal;
+		
+		//	  normalB = rays[index+i].mDirection; // $$ temporary
+		pointB = rays[index+i].Extrap(-backward_dist[i]);
+	  }
+	}
+
 	ProcessRay(rays[index+i].mOrigin,
 			   rays[index+i].mDirection,
@@ -1207,4 +1259,5 @@
   }
 #endif
+  
   } else {
 
@@ -1217,5 +1270,7 @@
 	}
   }
-  
+#if DEBUG_RAYCAST
+  Debug<<"C16F\n"<<flush;
+#endif
 }
 
@@ -1236,4 +1291,5 @@
 	  i += 16;
 	} else {
+
 	  CastRay(rays[i].mOrigin,
 			  rays[i].mDirection,
@@ -1241,4 +1297,5 @@
 			  vssRays,
 			  mViewCellsManager->GetViewSpaceBox());
+
 	  i++;
 	}
@@ -1252,14 +1309,69 @@
 }
 
-
-int Preprocessor::CastRay(
-						  const Vector3 &viewPoint,
-						  const Vector3 &direction,
-						  const float probability,
-						  VssRayContainer &vssRays,
-						  const AxisAlignedBox3 &box
-						  )
-{
-	switch (mRayCastMethod)
+Intersectable *
+Preprocessor::CastSimpleRay(
+							const Vector3 &viewPoint,
+							const Vector3 &direction,
+							const AxisAlignedBox3 &box,
+							Vector3 &point,
+							Vector3 &normal
+							)
+{
+  Intersectable *result = NULL;
+  switch (mRayCastMethod)
+	{
+	case INTEL_RAYCASTER: {
+	  float dist;
+	  int hittriangle;
+	  double n[3];
+	  hittriangle = mlrtaIntersectAS(&viewPoint.x,
+									 &direction.x,
+									 n,
+									 dist);
+	  if (hittriangle !=-1 ) {
+		if (hittriangle >= mFaceParents.size())
+		  cerr<<"Warning: traingle index out of range! "<<hittriangle<<endl;
+		else {
+		  result = mFaceParents[hittriangle].mObject;
+		  normal = Vector3(n[0], n[1], n[2]);
+		  point = viewPoint + direction*dist;
+		}
+	  }
+	  break;
+	}
+	case INTERNAL_RAYCASTER:
+	default: {
+	  static Ray ray;
+	  
+	  ray.intersections.clear();
+	  // do not store anything else then intersections at the ray
+	  ray.Init(viewPoint, direction, Ray::LOCAL_RAY);
+	  
+	  ray.mFlags &= ~Ray::CULL_BACKFACES;
+	  
+	  if (mKdTree->CastRay(ray)) {
+		result = ray.intersections[0].mObject;
+		point = ray.Extrap(ray.intersections[0].mT);
+		normal = ray.intersections[0].mNormal;
+	  }
+	  break;
+	}
+	}
+  return result;
+}
+
+int
+Preprocessor::CastRay(
+					  const Vector3 &viewPoint,
+					  const Vector3 &direction,
+					  const float probability,
+					  VssRayContainer &vssRays,
+					  const AxisAlignedBox3 &box
+					  )
+{
+#if DEBUG_RAYCAST
+  Debug<<"CR "<<flush;
+#endif
+  switch (mRayCastMethod)
 	{
 	case INTEL_RAYCASTER:
@@ -1269,4 +1381,7 @@
 		return CastInternalRay(viewPoint, direction, probability, vssRays, box);
 	}
+#if DEBUG_RAYCAST
+  Debug<<"CRF "<<flush;
+#endif	
 }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 1287)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 1292)
@@ -115,10 +115,10 @@
 				Name="VCCLCompilerTool"
 				Optimization="2"
-				GlobalOptimizations="TRUE"
+				GlobalOptimizations="FALSE"
 				InlineFunctionExpansion="0"
-				EnableIntrinsicFunctions="TRUE"
+				EnableIntrinsicFunctions="FALSE"
 				FavorSizeOrSpeed="1"
-				OmitFramePointers="TRUE"
-				EnableFiberSafeOptimizations="TRUE"
+				OmitFramePointers="FALSE"
+				EnableFiberSafeOptimizations="FALSE"
 				OptimizeForProcessor="3"
 				OptimizeForWindowsApplication="TRUE"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp	(revision 1283)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp	(revision 1292)
@@ -503,4 +503,6 @@
   
   long startTime = GetTime();
+  long lastTime;
+  float totalTime;
   
   int totalSamples = 0;
@@ -602,9 +604,13 @@
 	mViewCellsManager->ComputeSampleContributions(mVssRays, true, false);
 	cout<<"done.\n"<<flush;
+
+	long time = GetTime();
+	totalTime = TimeDiff(startTime, time)*1e-3;
+	lastTime = time;
 	
 	mStats <<
 	  "#Pass\n" <<mPass<<endl<<
 	  "#RssPass\n" <<rssPass<<endl<<
-	  "#Time\n" << TimeDiff(startTime, GetTime())*1e-3<<endl<<
+	  "#Time\n" << totalTime <<endl<<
 	  "#TotalSamples\n" <<totalSamples<<endl<<
 	  "#RssSamples\n" <<rssSamples<<endl;
@@ -748,5 +754,5 @@
 	  
 	  // now evaluate the ratios for the next pass
-#define TIMES 0
+#define TIMES 1
 
 #if TIMES
@@ -800,4 +806,8 @@
 																		   mInitialSamples)<<"%\n";
 	
+
+	long time = GetTime();
+	totalTime += TimeDiff(lastTime, time);
+	lastTime = time;
 	
 	mStats <<
Index: GTP/trunk/Lib/Vis/Preprocessing/src/default.env
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 1283)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 1292)
@@ -56,4 +56,7 @@
 }
 
+ObjParser {
+	meshGrouping 500
+}
 
 RenderSampler {
@@ -104,5 +107,5 @@
 
 SamplingPreprocessor {
-	totalSamples 30000000
+	totalSamples 10000000
 	samplesPerPass 1000000
 }
@@ -112,5 +115,5 @@
 	initialSamples 1000000
 	vssSamples 10000000
-	vssSamplesPerPass 500000
+	vssSamplesPerPass 1000000
 	useImportanceSampling true
 
@@ -192,7 +195,8 @@
 }
 
+
 MeshKdTree {
 	Termination {
-		minCost 32
+		minCost 150
 		maxDepth 18
 		maxCostRatio 0.9
@@ -221,5 +225,5 @@
 
 	#number of active view cells
-	active 5000
+	active 1000
 	maxStaticMemory	200
 
@@ -234,5 +238,5 @@
 	
 	height 5.0
-	maxViewCells 5000
+	maxViewCells 1000
 
 	#percentage of total visible objects where pvs is considered invalid
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 1288)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 1292)
@@ -87,5 +87,9 @@
   */
   bool PrepareViewCells();
-  
+
+  /** Construct viewcells (if not already loaded) */
+  bool
+  ConstructViewCells();
+
   /** Returns the specified sample strategy, NULL if no valid strategy.
   */
@@ -168,4 +172,13 @@
 	  );
 
+  Intersectable *
+  CastSimpleRay(
+				const Vector3 &viewPoint,
+				const Vector3 &direction,
+				const AxisAlignedBox3 &box,
+				Vector3 &point,
+				Vector3 &normal
+				);
+  
   ////////////////////////////////////////////////
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h	(revision 1291)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h	(revision 1292)
@@ -190,4 +190,5 @@
 	bool Mailed() const { return mMailbox == sMailId; }
 
+
 	static int sMailId;
 	int mMailbox;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp	(revision 1251)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp	(revision 1292)
@@ -15,5 +15,5 @@
 
 
-SamplingPreprocessor::SamplingPreprocessor(): mPass(0)
+SamplingPreprocessor::SamplingPreprocessor(): Preprocessor(), mPass(0)
 {
   // this should increase coherence of the samples
@@ -36,5 +36,4 @@
 							  )
 {
-  static Ray ray;
   AxisAlignedBox3 box = mViewCellsManager->GetViewSpaceBox();
   
@@ -43,25 +42,21 @@
   if (!sbox.IsInside(origin))
 	return 0;
-	
-  ray.intersections.clear();
-  // do not store anything else then intersections at the ray
-  ray.Init(origin, direction, Ray::LOCAL_RAY);
-
-  ray.mFlags &= ~Ray::CULL_BACKFACES;
-
-
+  
+  Vector3 point, normal;
+  Intersectable *object;
 
   // cast ray to KD tree to find intersection with other objects
-  Intersectable *objectA = NULL;
-  Vector3 pointA;
-  float bsize = Magnitude(box.Size());
-  
-  if (mKdTree->CastRay(ray)) {
-	if (!mDetectEmptyViewSpace || DotProd(ray.intersections[0].mNormal, direction) < 0) {
-	  objectA = ray.intersections[0].mObject;
-	  pointA = ray.Extrap(ray.intersections[0].mT);
-	}
-  }
-  return objectA;
+  object = CastSimpleRay(origin,
+						 direction,
+						 mKdTree->GetBox(),
+						 point,
+						 normal
+						 );
+  
+  if (mDetectEmptyViewSpace && DotProd(normal, direction) >= 0) {
+	object = NULL;
+  }
+  
+  return object;
 }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 1272)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 1292)
@@ -1,5 +1,5 @@
 #############################################################################
 # Makefile for building: preprocessor
-# Generated by qmake (2.00a) (Qt 4.1.2) on: út 22. VIII 22:47:13 2006
+# Generated by qmake (2.00a) (Qt 4.1.2) on: po 28. VIII 11:32:19 2006
 # Project:  preprocessor.pro
 # Template: app
@@ -78,7 +78,4 @@
 		C:\Qt\4.1.2\mkspecs\features\win32\stl.prf \
 		C:\Qt\4.1.2\mkspecs\features\shared.prf \
-		C:\Qt\4.1.2\mkspecs\features\qt.prf \
-		C:\Qt\4.1.2\mkspecs\features\win32\opengl.prf \
-		C:\Qt\4.1.2\mkspecs\features\moc.prf \
 		C:\Qt\4.1.2\mkspecs\features\resources.prf \
 		C:\Qt\4.1.2\mkspecs\features\uic.prf
@@ -99,7 +96,4 @@
 C:\Qt\4.1.2\mkspecs\features\win32\stl.prf:
 C:\Qt\4.1.2\mkspecs\features\shared.prf:
-C:\Qt\4.1.2\mkspecs\features\qt.prf:
-C:\Qt\4.1.2\mkspecs\features\win32\opengl.prf:
-C:\Qt\4.1.2\mkspecs\features\moc.prf:
 C:\Qt\4.1.2\mkspecs\features\resources.prf:
 C:\Qt\4.1.2\mkspecs\features\uic.prf:
@@ -116,16 +110,4 @@
 distclean: release-distclean debug-distclean FORCE
 	-$(DEL_FILE) Makefile
-
-release-mocclean: $(MAKEFILE).Release
-	$(MAKE) -f $(MAKEFILE).Release mocclean
-debug-mocclean: $(MAKEFILE).Debug
-	$(MAKE) -f $(MAKEFILE).Debug mocclean
-mocclean: release-mocclean debug-mocclean
-
-release-mocables: $(MAKEFILE).Release
-	$(MAKE) -f $(MAKEFILE).Release mocables
-debug-mocables: $(MAKEFILE).Debug
-	$(MAKE) -f $(MAKEFILE).Debug mocables
-mocables: release-mocables debug-mocables
 FORCE:
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h	(revision 1199)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h	(revision 1292)
@@ -127,5 +127,5 @@
 	because it creates the local kd tree and the bounding box.
 	*/
-  void Preprocess();
+  void Preprocess(const bool cleanup = true);
 
   /** Applies transformation to the mesh.
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1291)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1292)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 1284)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 1292)
@@ -143,4 +143,5 @@
 	MeshKdTree::ParseEnvironment();
 
+	
 	char buff[128];
 	Environment::GetSingleton()->GetStringValue("Preprocessor.type", buff);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp	(revision 1286)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp	(revision 1292)
@@ -42,5 +42,5 @@
 	};
 
-const static int nMaxFaces = 6;
+//const static int nMaxFaces = 6;
 
 
@@ -109,5 +109,7 @@
 
 	mesh->mFaces = faces;
-	mesh->Preprocess();
+
+	// can't do cleanup because coupling with kdf file for intel ray tracer
+	mesh->Preprocess(false);
 
 	/*for (int i = 0; i < faces.size(); ++ i)
@@ -161,4 +163,6 @@
 	int meshGrouping;
 	Environment::GetSingleton()->GetIntValue("ObjParser.meshGrouping", meshGrouping);
+
+	int nMaxFaces = meshGrouping;
 
 	while (fgets(str, 80, file) != NULL)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.icproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.icproj	(revision 1283)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.icproj	(revision 1292)
@@ -126,5 +126,5 @@
 			<Tool 
 				Name="CppCmplrTool"
-				Optimization="3"
+				Optimization="2"
 				GlobalOptimizations="0"
 				FavorSizeOrSpeed="1"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro	(revision 1272)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro	(revision 1292)
@@ -1,4 +1,4 @@
-#CONFIG -= qt 
-CONFIG	+= console warn_off thread release
+CONFIG -= qt debug
+CONFIG	+= console warn_off thread release mlrt
 
 TEMPLATE = app
@@ -29,4 +29,5 @@
 win32:LIBPATH += GL $$NONGTP/Xerces/xerces/lib $$NONGTP/Devil/lib \
   $$NONGTP/glut $$NONGTP/Boost/lib $$NONGTP/Zlib/lib 
+
 
 CONFIG(qt) {
@@ -64,4 +65,23 @@
 }
 
+
+CONFIG(mlrt) {
+
+CONFIG(release) {
+LIBPATH += ../MultiLevelRayTracing/RTScene/Release \
+../MultiLevelRayTracing/RTWorld/Release
+}
+
+CONFIG(debug) {
+LIBPATH += ../MultiLevelRayTracing/RTScene/Debug \
+../MultiLevelRayTracing/RTWorld/Debug
+}
+
+LIBS += RTScene.lib RTWorld.lib
+DEFINES += GTP_INTERNAL
+INCLUDEPATH += ../MultiLevelRayTracing
+}
+
+
 QMAKE_LFLAGS_CONSOLE=/NODEFAULTLIB:LIBCMT
 
@@ -91,9 +111,10 @@
 VrmlExporter.cpp PlyParser.cpp plyfile.c RenderSampler.cpp \
 GzBinFileInputStream.cpp  GzFileInputSource.cpp \
-LogManager.cpp \
+LogManager.cpp VspTree.cpp \
 SamplingStrategy.cpp KdIntersectable.cpp \
-OspTree.cpp HierarchyManager.cpp ObjParser.cpp VspTree.cpp \
+OspTree.cpp HierarchyManager.cpp ObjParser.cpp \
 BvHierarchy.cpp  \
 BoostPreprocessorThread.cpp 
+
 
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp	(revision 1287)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp	(revision 1292)
@@ -69,6 +69,7 @@
 
 void
-Mesh::Preprocess()
-{
+Mesh::Preprocess(bool cleanup)
+{
+  if (cleanup)
 	Cleanup();
  
