Index: GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp	(revision 1404)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp	(revision 1419)
@@ -125,8 +125,24 @@
 	  const Vector3 a = (*ri)->GetOrigin();
 	  const Vector3 b = (*ri)->mTerminationObject ? (*ri)->GetTermination() : a + 1000 * Normalize((*ri)->GetDir());
-	  //const Vector3 b = (*ri)->GetTermination(); // matt: change back!!
-
-	  stream << a.x << " " << a.y << " " << a.z << " ,";
-	  stream << b.x << " " << b.y << " " << b.z << " ,\n";
+	  
+	  bool isnan = false;
+
+	  if ((a[0] != a[0]) || (a[1] != a[1]) || (a[2] != a[2]))
+	  {
+		  cout << "error a"<<endl;
+		  isnan = true;
+	  }
+
+	  if ((b[0] != b[0]) || (b[1] != b[1]) || (b[2] != b[2]))
+	  {
+		  cout << "error b"<<endl;
+		  isnan = true;
+	  }
+
+	  if (!isnan)
+	  {
+		stream << a.x << " " << a.y << " " << a.z << " ,";
+		stream << b.x << " " << b.y << " " << b.z << " ,\n";
+	  }
   }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp	(revision 1418)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp	(revision 1419)
@@ -255,4 +255,5 @@
 			{
 				TriangleIntersectable *ti = new TriangleIntersectable(*tit);
+				cout << "t: " << (*tit) << endl;
 				mCurrentNode->mGeometry.push_back(ti);
 			}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 1418)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 1419)
@@ -214,4 +214,10 @@
 		const bool isTermination) const;
 
+	friend ostream &operator<<(ostream &s, const HierarchyManager &hm) 
+	{
+		hm.mHierarchyStats.Print(s);
+		return s;
+	} 
+
 protected:
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp	(revision 1418)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp	(revision 1419)
@@ -67,4 +67,10 @@
 	mVertices.push_back(tri.mVertices[2]);
 
+	VertexContainer::iterator it, it_end = mVertices.end();
+
+	for (it = mVertices.begin(); it != it_end;  ++ it)
+	{
+		cout << (*it) << " ";
+	}cout<<endl<<endl;
 	//cout << "poly n: " << GetNormal() << " t normal: " << tri.GetNormal() << endl;
 }
@@ -584,5 +590,7 @@
 	const int n = (int)mesh.mVertices.size();
 
-    //-- add the vertices
+	/////////////
+    //-- add the vertices to the mesh
+
     VertexContainer::const_iterator vit, vit_end = poly.mVertices.end();
 	for (vit = poly.mVertices.begin(); vit != vit_end; ++ vit)
@@ -602,9 +610,9 @@
 
 	// add indices of triangle strip
-	for (int i = 0; i < (int)indices.size(); i += 3)
-	{
-		Face *face = new Face(n + indices[i], 
-							  n + indices[i + 1], 
-							  n + indices[i + 2]);
+	for (int i = n; i < (int)indices.size() + n; i += 3)
+	{
+		Face *face = new Face(indices[i], 
+							  indices[i + 1], 
+							  indices[i + 2]);
 		mesh.AddFace(face);
 	}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1418)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1419)
@@ -380,6 +380,5 @@
 
 
-	////////////////////////////////////////////////
-	//
+	//////////////////////
 	//-- Cast some more sampling after initial construction.
 	//-- The additional rays can be used to gain
@@ -444,5 +443,4 @@
 
 	////////////////////
-	//
 	//-- post processing of the initial construction
 	//-- We can bottom-up merge the view cells in this step
@@ -4796,6 +4794,6 @@
 
 	// print subdivision statistics
-	Debug << endl << endl;
-	mHierarchyManager->PrintHierarchyStatistics(Debug);
+	Debug << endl << endl << mHierarchyManager << endl;
+	//mHierarchyManager->PrintHierarchyStatistics(Debug);
 
 	if (0)
@@ -5157,6 +5155,5 @@
 	cout << "visualization using " << (int)rays.size() << " samples" << endl;
 	Debug << "visualization using " << (int)rays.size() << " samples" << endl;
-	Debug << "\nOutput view cells: " << endl;
-
+	
 	const bool sortedViewCells = false;
 
@@ -5169,4 +5166,6 @@
 	int limit = min(leafOut, (int)mViewCells.size());
 	int raysOut = 0;
+
+	cout << "\nOutput of " << limit << " view cells: " << endl;
 
 	///////////////
@@ -5234,5 +5233,6 @@
 				//-- export objects seen from the rays
 				Intersectable::NewMail();
-                VssRayContainer::const_iterator vcit, vcit_end = vcRays.end();
+				
+				VssRayContainer::const_iterator vcit, vcit_end = vcRays.end();
 				for (vcit = vcRays.begin(); vcit != vcit_end; ++ vcit)
 				{
@@ -5244,5 +5244,5 @@
 					{
 						obj->Mail();
-					//	exporter->ExportIntersectable(obj);
+						exporter->ExportIntersectable(obj);
 					}
 				}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp	(revision 1418)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp	(revision 1419)
@@ -293,4 +293,7 @@
 	}
 	
+	//cout << "describe:\n" << dummyMesh << endl;
+	//dummyMesh.CheckMesh();
+
 	ExportMesh(&dummyMesh);
 	CLEAR_CONTAINER(polys);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h	(revision 1418)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h	(revision 1419)
@@ -210,5 +210,10 @@
   Vector3 GetNormal(const int idx) const;
 
-  virtual ostream &Describe(ostream &s) {
+  // $$ matt temp
+  bool CheckMesh() const;
+
+  void Print(ostream &app) const;
+
+  virtual ostream &Describe(ostream &s) const {
 	return s<<"Mesh #vertices="<<(int)mVertices.size()<<" #faces="<<(int)mFaces.size();
   }
@@ -219,5 +224,6 @@
   friend Mesh *CreateMeshFromBox(const AxisAlignedBox3 &box);
 
- 
+  friend ostream& operator<< (ostream &s, const Vector3 &A);
+
 protected:
 
@@ -225,4 +231,13 @@
   int mId;
 };
+
+
+// Overload << operator for C++-style output
+inline ostream&
+operator<< (ostream &s, const Mesh &A)
+{
+	A.Print(s);
+	return s;
+}
 
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/PlyParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/PlyParser.cpp	(revision 1379)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/PlyParser.cpp	(revision 1419)
@@ -182,6 +182,6 @@
 		 meshProxy.IndexVertices();
 	   
-	   Mesh *mesh = new Mesh(meshProxy.mVertices.size(),
-							 meshProxy.mFaces.size());
+	   Mesh *mesh = new Mesh((int)meshProxy.mVertices.size(),
+							 (int)meshProxy.mFaces.size());
 	   
 	   
@@ -210,5 +210,5 @@
    for (int k  = 0; k < flist[i]->nverts; k++) {
 	 Vertex *v = vlist[flist[i]->verts[k]];
-	 vc.push_back(meshProxy.mVertices.size());
+	 vc.push_back((int)meshProxy.mVertices.size());
 	 meshProxy.mVertices.push_back(Vector3(v->x, v->y, v->z));
    }
@@ -222,6 +222,6 @@
 	 meshProxy.IndexVertices();
 
-   Mesh *mesh = new Mesh(meshProxy.mVertices.size(),
-						 meshProxy.mFaces.size());
+   Mesh *mesh = new Mesh((int)meshProxy.mVertices.size(),
+						 (int)meshProxy.mFaces.size());
 
    mesh->mVertices = meshProxy.mVertices;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp	(revision 1418)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp	(revision 1419)
@@ -499,4 +499,46 @@
 }
 
+
+bool Mesh::CheckMesh() const
+{
+	VertexContainer::const_iterator vit, vit_end = mVertices.end();
+
+	for (vit = mVertices.begin(); vit != vit_end; ++ vit)
+	{
+		for (int i = 0; i < 3; ++ i)
+		{
+			const float x = (*vit)[i];
+			if (x != x) // nan
+			//if (isnan((*vit)[i]))
+			{
+				cout << "warning: vertex is ill defined" << endl;
+				return false;
+			}
+		}
+	}
+	return true;
+}
+
+
+void Mesh::Print(ostream &app) const
+{
+	VertexContainer::const_iterator vit, vit_end = mVertices.end();
+
+	for (vit = mVertices.begin(); vit != vit_end; ++ vit)
+	{
+		app << (*vit) << " ";
+	}
+	app << endl;
+
+	/*FaceContainer::const_iterator fit, fit_end = mVertices.end();
+
+	for (vit = mVertices.begin(); vit != vit_end; ++ vit)
+	{
+		app << (*vit);
+	}
+	app << endl;*/
+}
+
+
 void
 Mesh::Cleanup()
