Index: GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.h	(revision 1925)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.h	(revision 1972)
@@ -44,5 +44,5 @@
 						const bool pruneInvalidRays = true);
 
-	virtual void CastRays16(const int i,
+	virtual void CastRays16(
 							SimpleRayContainer &rays, 
 							VssRayContainer &vssRays,
Index: GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.h	(revision 1824)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.h	(revision 1972)
@@ -36,26 +36,25 @@
 
 	virtual int CastRay(
-	const SimpleRay &simpleRay,
-        VssRayContainer &vssRays,
-		const AxisAlignedBox3 &box,
-		const bool castDoubleRay,
-		const bool pruneInvalidRays = true
-		);
+						const SimpleRay &simpleRay,
+						VssRayContainer &vssRays,
+						const AxisAlignedBox3 &box,
+						const bool castDoubleRay,
+						const bool pruneInvalidRays = true
+						);
 
-	 virtual void CastRays16(
-		 const int i,
-		 SimpleRayContainer &rays, 
-		 VssRayContainer &vssRays,
-		 const AxisAlignedBox3 &sbox,
-		 const bool castDoubleRay,
-		 const bool pruneInvalidRays = true
-		 );
+	 virtual void CastRays16(SimpleRayContainer &rays, 
+							 VssRayContainer &vssRays,
+							 const AxisAlignedBox3 &sbox,
+							 const bool castDoubleRay,
+							 const bool pruneInvalidRays = true
+							 );
 
 	virtual int
-	CastGlobalRay(const SimpleRay &simpleRay,
-								VssRayContainer &vssRays,
-								const AxisAlignedBox3 &box,
-								const bool pruneInvalidRays
-								);
+	CastGlobalRay(
+				  const SimpleRay &simpleRay,
+				  VssRayContainer &vssRays,
+				  const AxisAlignedBox3 &box,
+				  const bool pruneInvalidRays
+				  );
 
 protected:
Index: GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 1949)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 1972)
@@ -194,5 +194,5 @@
 				OptimizeForWindowsApplication="TRUE"
 				AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(QTDIR)\include\Qt&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include&quot;;QtInterface"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;USE_QT;TRY_GLOBAL_LINES"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;USE_QT"
 				RuntimeLibrary="2"
 				RuntimeTypeInfo="TRUE"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h	(revision 1942)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h	(revision 1972)
@@ -45,5 +45,4 @@
 	VssRay *CastRay(const SimpleRay &simpleRay,
 					const AxisAlignedBox3 &box);
-					//const bool castDoubleRay);
 
 	virtual int CastRay(const SimpleRay &simpleRay,
@@ -54,5 +53,5 @@
 						) = 0;
 
-	 virtual void CastRays16(const int i,
+	 virtual void CastRays16(
 							 SimpleRayContainer &rays,
 							 VssRayContainer &vssRays,
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1970)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1972)
@@ -1151,49 +1151,67 @@
 	const long t1 = GetTime();
 
-	for (int i = 0; i < (int)rays.size();)
-	{
-		// HACK: does not really go together with the 16 ray bundles
-		if (rays[i].mDistribution == SamplingStrategy::HW_GLOBAL_LINES_DISTRIBUTION)
-		{
-			mGlobalLinesRenderer->CastGlobalLines(rays[i], vssRays);
-			i ++;
+	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;
+		// HACK: global lines must be treated special
+		if (ray.mDistribution == SamplingStrategy::HW_GLOBAL_LINES_DISTRIBUTION)
+		{
+			mGlobalLinesRenderer->CastGlobalLines(ray, vssRays);
 			continue;
 		}
 
-		if (i + 16 < (int)rays.size()) 
+		rayBucket.push_back(ray);
+
+		// 16 rays gathered => do ray casting
+		if ((int)rayBucket.size() >= 16)
 		{
 			mRayCaster->CastRays16(
-								   i,
-								   rays,				
+								   rayBucket,				
 								   vssRays,
 								   mViewCellsManager->GetViewSpaceBox(),
 								   castDoubleRays,
 								   pruneInvalidRays);
-			i += 16;
-		}
-		else 
+
+			rayBucket.clear();
+		}
+	
+		if ((int)rays.size() > 10000 && i % 10000 == 0)
+			cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r";
+	}
+    
+	// cast rest of rays
+	SimpleRayContainer::const_iterator sit, sit_end = rayBucket.end();
+
+	for (sit = rayBucket.begin(); sit != sit_end; ++ sit)
+	{
+		SimpleRay ray = *sit;
+		// HACK: global lines must be treated special
+		if (ray.mDistribution == SamplingStrategy::HW_GLOBAL_LINES_DISTRIBUTION)
+		{
+			mGlobalLinesRenderer->CastGlobalLines(ray, vssRays);
+		}
+		else
 		{
 			mRayCaster->CastRay(
-								rays[i],
+								ray,
 								vssRays,
 								mViewCellsManager->GetViewSpaceBox(),
 								castDoubleRays,
 								pruneInvalidRays);
-			++ i;
-		}
-
-		if (rays.size() > 10000 && i % 10000 == 0)
-		  cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r";
-	}
-
-	if (rays.size() > 10000) 
+		}
+	}
+
+	if ((int)rays.size() > 10000) 
 	{
 		cout << endl;
-
-		long t2 = GetTime();
+        long t2 = GetTime();
 
 #if SHOW_RAYCAST_TIMING
 		if (castDoubleRays)
-            cout << 2 * 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;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp	(revision 1969)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp	(revision 1972)
@@ -183,5 +183,5 @@
   
   lastPos = event->pos();
-updateGL();
+  updateGL();
 }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp	(revision 1971)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp	(revision 1972)
@@ -456,6 +456,8 @@
 	const int layers = ApplyDepthPeeling(rays);
 
-	const float rays_per_sec = rays.size() / TimeDiff(startTime, GetTime()) * 1e-3;
-	cout << "cast " << rays.size() << " samples in " << layers << " layers in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs (" << rays_per_sec << " rays/sec)" << endl;
+	const float rays_per_sec = (float)rays.size() / (TimeDiff(startTime, GetTime()) * 1e-3f);
+	cout << "cast " << rays.size() << " samples in " << layers << " layers in " 
+		 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs (" << rays_per_sec << " rays/sec)" << endl;
+
 	return layers;
 }
@@ -852,4 +854,5 @@
 void GlobalLinesRenderer::Visualize(const VssRayContainer &vssRays)
 {
+	cout << "exporting visualization ... ";
 	Exporter *exporter = Exporter::GetExporter("globalLines.wrl");
 	
@@ -877,10 +880,10 @@
 		}
 
-		if (ray->mPass == 4)
+		//if (ray->mPass == 4)
 			outRays.push_back(ray);
 	}	
 
-	exporter->ExportRays(outRays);
-
+	//exporter->ExportRays(outRays);
+	cout << "finished" << endl;
 	delete exporter;
 }
@@ -1030,6 +1033,6 @@
 	}
 
-	Debug << "time spent in rendering: " << renderTime << endl;
-	Debug << "time spent in buffer: " << bufferTime << endl;
+	Debug << "time spent in rendering: " << renderTime * 1e-3f << endl;
+	Debug << "time spent in buffer: " << bufferTime * 1e-3f << endl;
 	
 	PrintGLerror("endpeeling");
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1966)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1972)
@@ -5829,5 +5829,5 @@
 
 		const long starttime = GetTime();
-		cout << "exporting final view cells (after initial construction + post process) ... ";
+		cout << "exporting final view cells (after initial construction + post process) ... " << endl;
 
 		// matt: hack for clamping scene
@@ -5835,5 +5835,5 @@
 		bbox.Scale(scale);
 
-		if (0 && mExportRays)
+		if (1 && mExportRays)
 		{	
 			exporter->ExportRays(visRays, RgbColor(0, 1, 0));
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 1971)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 1972)
@@ -85,6 +85,6 @@
   mUseForcedColors = false;
   mRenderBoxes = false;
-  //mUseGlLists = true;
-  mUseGlLists = false;
+  mUseGlLists = true;
+  //mUseGlLists = false;
 
   Environment::GetSingleton()->GetIntValue("Preprocessor.pvsRenderErrorSamples", mPvsStatFrames);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp	(revision 1960)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp	(revision 1972)
@@ -107,5 +107,4 @@
 
 void IntelRayCaster::CastRays16(
-								const int index,
 								SimpleRayContainer &rays, 
 								VssRayContainer &vssRays,
@@ -116,5 +115,5 @@
 	int i;
 	const int num = 16;
-
+	
 #if DEBUG_RAYCAST
 	Debug<<"C16 "<<flush;
@@ -132,6 +131,6 @@
 
 	for (i=0; i < num; i++) {
-	  mlrtaStoreRayAS16(&rays[index + i].mOrigin.x,
-						&rays[index + i].mDirection.x,
+	  mlrtaStoreRayAS16(&rays[i].mOrigin.x,
+						&rays[i].mDirection.x,
 						i);
 	}
@@ -150,6 +149,6 @@
 		for (i=0; i < num; i++) 
 		  {
-			Vector3 dir = -rays[index + i].mDirection;
-			mlrtaStoreRayAS16(&rays[index+i].mOrigin.x,
+			Vector3 dir = -rays[i].mDirection;
+			mlrtaStoreRayAS16(&rays[i].mOrigin.x,
 							  &dir.x,
 							  i);
@@ -186,5 +185,5 @@
 
 			//-rays[index+i].mDirection; // $$ temporary
-			hitA.mPoint = rays[index+i].Extrap(forward_dist[i]);
+			hitA.mPoint = rays[i].Extrap(forward_dist[i]);
 		}
 	
@@ -202,6 +201,6 @@
 				hitB.mNormal = mPreprocessor.GetParentNormal(backward_hit_triangles[i]);
 
-				// normalB = rays[index+i].mDirection; // $$ temporary
-				hitB.mPoint = rays[index+i].Extrap(-backward_dist[i]);
+				// normalB = rays[i].mDirection; // $$ temporary
+				hitB.mPoint = rays[i].Extrap(-backward_dist[i]);
 			}
 		}
@@ -211,5 +210,5 @@
 #endif
 
-		ProcessRay(rays[index + i],
+		ProcessRay(rays[i],
 				   hitA,
 				   hitB,
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp	(revision 1876)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp	(revision 1972)
@@ -64,5 +64,4 @@
 		pch = strtok(NULL, " ");
 	}
-	//if (indices.size() > 4) return NULL;
 
 	return new Face(indices); 
@@ -70,7 +69,8 @@
 
 
-static Triangle3 LoadTriangle(char *str, 
-							  const VertexContainer &vertices, 
-							  map<int, Vector3> &hashTable)
+static void LoadTriangles(char *str, 
+						  const VertexContainer &vertices, 
+						  map<int, Vector3> &hashTable,
+                          vector<Triangle3> &triangles)
 {
 	char *pch = strtok(str + 1, " ");
@@ -78,16 +78,27 @@
 	VertexIndexContainer indices;
 	
+	int i = 0;
 	while (pch != NULL)
 	{
 	   	const int index = (int)strtol(pch, NULL, 10) - 1;
+		++ i;
 				
 		// store vertex in hash table
-		hashTable[index] = vertices[index];
+		//hashTable[index] = vertices[index];
 		indices.push_back(index);
 		
 		pch = strtok(NULL, " ");
-	}
-	
-    return Triangle3(vertices[indices[0]], vertices[indices[1]], vertices[indices[2]]); 
+
+		// problem: don't know how intel ray tracer tesselates
+		if ((int)indices.size() > 2)
+		{
+			int index_2 = (int)indices.size() - 2;
+			int index_3 = (int)indices.size() - 1;
+
+			triangles.push_back(Triangle3(vertices[indices[0]], 
+										  vertices[indices[index_2]], 
+										  vertices[indices[index_3]])); 
+		}
+	}
 }
 
@@ -230,15 +241,22 @@
 				else
 				{
-					Triangle3 triangle = LoadTriangle(str, vertices, hashTable);
+					vector<Triangle3> triangles;
+					
+					LoadTriangles(str, vertices, hashTable, triangles);
 				
-					TriangleIntersectable *obj = new TriangleIntersectable(triangle);
-					root->mGeometry.push_back(obj);
-
-					// matt: we don't really need to keep an additional data structure
-					// if working with triangles => remove this
-					if (parents) 
+					vector<Triangle3>::const_iterator tit, tit_end = triangles.end();
+
+					for (tit = triangles.begin(); tit != tit_end; ++ tit)
 					{
-						FaceParentInfo info(obj, 0);
-						parents->push_back(info);
+						TriangleIntersectable *obj = new TriangleIntersectable(*tit);	
+						root->mGeometry.push_back(obj);
+
+						// matt: we don't really need to keep an additional data structure
+						// if working with triangles => remove this
+						if (0 && parents) 
+						{
+							FaceParentInfo info(obj, 0);
+							parents->push_back(info);
+						}
 					}
 				}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp	(revision 1964)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp	(revision 1972)
@@ -192,6 +192,6 @@
 }
 
-void InternalRayCaster::CastRays16(const int index,
-								   SimpleRayContainer &rays, 
+
+void InternalRayCaster::CastRays16(SimpleRayContainer &rays, 
 								   VssRayContainer &vssRays,
 								   const AxisAlignedBox3 &sbox,
@@ -199,14 +199,14 @@
 								   const bool pruneInvalidRays)
 {
-	const int num = 16;
-
 #if DEBUG_RAYCAST
 	Debug << "C16 " << flush;
 #endif
 
+	SimpleRayContainer::const_iterator sit, sit_end = rays.end();
+
 	// no acceleration for ray bundles implemented right now
-	for (int i = index; i < index + num; i++) 
+	for (sit = rays.begin(); sit != sit_end; ++ sit) 
 	{
-		CastRay(rays[i], vssRays, sbox,	castDoubleRays, pruneInvalidRays);
+		CastRay(*sit, vssRays, sbox, castDoubleRays, pruneInvalidRays);
 	}
 
