Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1299)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1328)
@@ -38,5 +38,5 @@
 static void AddGeometry(SceneGraph *scene)
 {
-	scene->mRoot->UpdateBox();
+	scene->GetRoot()->UpdateBox();
 
 	AxisAlignedBox3 sceneBox = scene->GetBox();
@@ -62,5 +62,5 @@
 
 				MeshInstance *mi = new MeshInstance(mesh);
-				scene->mRoot->mGeometry.push_back(mi);
+				scene->GetRoot()->mGeometry.push_back(mi);
 			}
 		}
@@ -81,5 +81,5 @@
 
 				MeshInstance *mi = new MeshInstance(mesh);
-				scene->mRoot->mGeometry.push_back(mi);
+				scene->GetRoot()->mGeometry.push_back(mi);
 			}
 		}
@@ -100,8 +100,8 @@
 
 			MeshInstance *mi = new MeshInstance(mesh);
-			scene->mRoot->mGeometry.push_back(mi);
+			scene->GetRoot()->mGeometry.push_back(mi);
 		}
 
-		scene->mRoot->UpdateBox();
+		scene->GetRoot()->UpdateBox();
 	}
 
@@ -122,5 +122,5 @@
 
 		MeshInstance *planeMi = new MeshInstance(planeMesh);
-		scene->mRoot->mGeometry.push_back(planeMi);
+		scene->GetRoot()->mGeometry.push_back(planeMi);
 	}	
 }
@@ -136,5 +136,6 @@
 mRenderSimulator(NULL),
 mPass(0),
-mRayCastMethod(0)
+mRayCastMethod(0),
+mSceneGraph(NULL)
 {
 	Environment::GetSingleton()->GetBoolValue("Preprocessor.useGlRenderer", mUseGlRenderer);
@@ -242,18 +243,26 @@
 			  parser = new UnigraphicsParser;
 
-		cout<<filename<<endl;
+		cout << filename << endl;
+
+		SceneGraphNode *sroot = mSceneGraph->GetRoot();
 
 		if (mRayCastMethod == Preprocessor::INTEL_RAYCASTER)
-		  result = parser->ParseFile(filename, &mSceneGraph->mRoot,
-									 mLoadPolygonsAsMeshes,
-									 &mFaceParents);
+		{ cout << "here5800" << endl;
+			result = parser->ParseFile(
+				filename, 
+				&sroot,
+				mLoadPolygonsAsMeshes,
+				&mFaceParents);
+		}
 		else
-		  result = parser->ParseFile(filename, &mSceneGraph->mRoot, mLoadPolygonsAsMeshes);
-		
+		{ cout << "here776645" << endl;
+			result = parser->ParseFile(filename, &sroot, mLoadPolygonsAsMeshes);
+		}
+		 cout << "here98809845" << endl;
 		delete parser;
 
 	} else {
 		// root for different files
-		mSceneGraph->mRoot = new SceneGraphNode;
+		mSceneGraph->SetRoot(new SceneGraphNode());
 		for (int i= 0; i < filenames.size(); i++) {
 		  if (strstr(filenames[i].c_str(), ".x3d"))
@@ -266,14 +275,22 @@
 		  
 		  if (mRayCastMethod == Preprocessor::INTEL_RAYCASTER)
-			success = parser->ParseFile(filename, &node,
-										mLoadPolygonsAsMeshes,
-										&mFaceParents);
+		  { cout << "here4500" << endl;
+			  success = parser->ParseFile(
+				  filename, 
+				  &node,
+				  mLoadPolygonsAsMeshes,
+				  &mFaceParents);
+		  }
 		  else
-			success = parser->ParseFile(filename, &node, mLoadPolygonsAsMeshes);
-		  
-		  if (success) {
-			mSceneGraph->mRoot->mChildren.push_back(node);
-			// at least one file parsed
-			result = true;
+		  {
+			  cout << "here45" << endl;
+			  success = parser->ParseFile(filename, &node, mLoadPolygonsAsMeshes);
+		  }
+
+		  if (success) 
+		  { cout << "here4509999" << endl;
+			  mSceneGraph->GetRoot()->mChildren.push_back(node);
+			  // at least one file parsed
+			  result = true;
 		  }
 		  
@@ -281,27 +298,26 @@
 		}
 	}
-	
-	
+	 cout << "here8888" << endl;
+
 	if (result) 
-	  {
+	{ cout << "here199" << endl;
 		// HACK 
 		if (ADDITIONAL_GEOMETRY_HACK)
 			AddGeometry(mSceneGraph);
-		
+
 		mSceneGraph->AssignObjectIds();
-	
+ cout << "here99" << endl;
 		int intersectables, faces;
 		mSceneGraph->GetStatistics(intersectables, faces);
-        
+ cout << "here999" << endl;
 		cout<<filename<<" parsed successfully."<<endl;
 		cout<<"#NUM_OBJECTS (Total numner of objects)\n"<<intersectables<<endl;
 		cout<<"#NUM_FACES (Total numner of faces)\n"<<faces<<endl;
 		mSceneGraph->CollectObjects(&mObjects);
-		mSceneGraph->mRoot->UpdateBox();
-
+		mSceneGraph->GetRoot()->UpdateBox();
+ cout << "here9999" << endl;
 		if (0)
 		{
 			Exporter *exporter = Exporter::GetExporter("testload.x3d");
-
 			if (exporter)
 			{
@@ -311,6 +327,5 @@
 		}
 	}
-	
-	
+
 	return result;
 }
@@ -356,6 +371,7 @@
   // add mesh instances of the scene graph to the root of the tree
   KdLeaf *root = (KdLeaf *)mKdTree->GetRoot();
+  	cout << "here3.95" << endl;
   mSceneGraph->CollectObjects(&root->mObjects);
-  
+  	cout << "here3.97" << endl;
   long startTime = GetTime();
 
@@ -389,5 +405,5 @@
   if (exporter) {
     if (scene)
-      exporter->ExportScene(mSceneGraph->mRoot);
+      exporter->ExportScene(mSceneGraph->GetRoot());
 
     if (kdtree) {
