Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjReader.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjReader.h	(revision 2111)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjReader.h	(revision 2112)
@@ -6,4 +6,5 @@
 #include <vector>
 #include <Ogre.h>
+#include "Containers.h"
 /*#include "ObjNode.h"
 #include "ObjMeshData.h"
@@ -18,5 +19,5 @@
 }
 
-typedef std::vector<GtpVisibilityPreprocessor::Triangle3 *> TriangleContainer;
+//typedef std::vector<GtpVisibilityPreprocessor::Triangle3 *> TriangleContainer;
 
 class __declspec(dllexport) ObjReader
@@ -27,5 +28,5 @@
 
 	bool LoadFile(const std::string &filename,
-				  TriangleContainer &triangles) const;
+				  GtpVisibilityPreprocessor::ObjectContainer &objects) const;
 	
 	const std::vector<Ogre::Entity *> &GetObjects() const;
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj	(revision 2111)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj	(revision 2112)
@@ -341,12 +341,12 @@
 				RelativePath="..\src\ObjReader.cpp">
 			</File>
-		</Filter>
-		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl;inc;xsd"
-			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
-			<File
-				RelativePath="..\include\ObjReader.h">
-			</File>
+			<Filter
+				Name="Header Files"
+				Filter="h;hpp;hxx;hm;inl;inc;xsd"
+				UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+				<File
+					RelativePath="..\include\ObjReader.h">
+				</File>
+			</Filter>
 		</Filter>
 	</Files>
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.cpp	(revision 2111)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.cpp	(revision 2112)
@@ -2,8 +2,10 @@
 #include "gzstream.h"
 #include "Triangle3.h"
+#include "IntersectableWrapper.h"
 
 
 ObjReader::ObjReader()
 {}
+
 
 ObjReader::~ObjReader()
@@ -12,5 +14,5 @@
 
 bool ObjReader::LoadFile(const string &filename,
-						 TriangleContainer &triangles) const
+						 GtpVisibilityPreprocessor::ObjectContainer &objects) const
 {
 	igzstream samplesIn(filename.c_str());
@@ -23,16 +25,15 @@
 
 	samplesIn.read(reinterpret_cast<char *>(&numTriangles), sizeof(int));
-	triangles.reserve(numTriangles);
+	objects.reserve(numTriangles);
 	
 	while (1)
 	{
-		GtpVisibilityPreprocessor::Triangle3 *tri = 
-			new GtpVisibilityPreprocessor::Triangle3();
+		GtpVisibilityPreprocessor::Triangle3 tri;
 		
-		samplesIn.read(reinterpret_cast<char *>((*tri).mVertices + 0), 
+		samplesIn.read(reinterpret_cast<char *>(tri.mVertices + 0), 
 					   sizeof(GtpVisibilityPreprocessor::Vector3));
-		samplesIn.read(reinterpret_cast<char *>((*tri).mVertices + 1), 
+		samplesIn.read(reinterpret_cast<char *>(tri.mVertices + 1), 
 					   sizeof(GtpVisibilityPreprocessor::Vector3));
-		samplesIn.read(reinterpret_cast<char *>((*tri).mVertices + 2), 
+		samplesIn.read(reinterpret_cast<char *>(tri.mVertices + 2), 
 					   sizeof(GtpVisibilityPreprocessor::Vector3));
 
@@ -41,5 +42,7 @@
 			break;
 
-		triangles.push_back(tri);
+		GtpVisibilityPreprocessor::TriangleIntersectable *obj = 
+			new GtpVisibilityPreprocessor::TriangleIntersectable(tri);
+		objects.push_back(obj);
 	}
 	
@@ -56,5 +59,8 @@
 #if TODO
 
-Ogre::Entity *IVReader::createEntity(Ogre::SceneManager* sceneMgr, std::string name, ObjMeshData *mData, Ogre::Vector3 *translation)
+Ogre::Entity *IVReader::createEntity(Ogre::SceneManager* sceneMgr, 
+									 std::string name, 
+									 ObjMeshData *mData, 
+									 Ogre::Vector3 *translation)
 {
 	using namespace Ogre;
@@ -72,8 +78,4 @@
 
 		if (translation != NULL) *translation = data->boundingBox->getCenter();
-
-//		data->collapse();
-//		delete data;
-
 
 		addMeshToList(meshName, loader);
@@ -101,233 +103,3 @@
 
 
-void IVReader::buildTree(Ogre::SceneManager* sceneMgr, Ogre::SceneNode *sceneNodeRoot)
-{
-	using namespace Ogre;
-	if (root == NULL) return;
-
-	std::string s = intToStr(treeCnt) + "/" + fileName + "/Root";
-	SceneNode *actualSceneNode = sceneNodeRoot->createChildSceneNode(s);
-	s = "/"; s = s + fileName + "/RootMaterial";
-	
-	Material* pMaterial = NULL;
-	if ((pMaterial = (Material *) MaterialManager::getSingleton().getByName(s).getPointer()) == NULL)
-	{
-		pMaterial = (Material *)MaterialManager::getSingleton().create(s, "General").getPointer();
-	}
-	pMaterial->load();
-
-	nodeCnt = 1; matCnt = 1;
-	
-
-	buildTree(sceneMgr, actualSceneNode, root, NULL, pMaterial);	
-	treeCnt++; 
-
-
-	std::string message = "Tree of "; message = message + fileName + " built (" + intToStr(nodeCnt) + " Nodes)";
-	if (IVLog != NULL) IVLog->logMessage(message);
-
-}
-
-void IVReader::buildTree(Ogre::SceneManager* sceneMgr,  
-						 Ogre::SceneNode *sceneNodeRoot, 
-						 ObjNode *IVReaderoot, ObjMeshData *mData, 
-						 Ogre::Material *material)
-{
-	using namespace Ogre;
-
-	Material *newMaterial = NULL;
-
-	bool meshDataCreated = false;
-	if (mData == NULL)
-	{
-		mData = new ObjMeshData();
-		meshDataCreated = true;
-	}
-
-	ObjType t; int i;
-	
-	ObjNode *help = IVReaderoot->getNextChildNode(true);
-	while (help != NULL)
-	{	
-		if (strcmp(help->getName(), "USE") == 0)
-		{
-			char *defLabel = (char *) help->getField("label", &t, &i);
-			if (t == IV_STRING) 
-			{
-				help = defList->getDef(defLabel);
-			}
-		}
-		if ((strcmp(help->getName(), "Separator") == 0) || (strcmp(help->getName(), "TransformSeparator") == 0)) 
-		{
-/*			std::string s = sceneNodeRoot->getName() + "/Sep" + intToStr(nodeCnt);
-			nodeCnt++;
-			SceneNode *actualSceneNode = sceneNodeRoot->createChildSceneNode(s);
-			buildTree(sceneMgr, actualSceneNode, help, mData, actualMaterial);
-*/
-			if (newMaterial == NULL) newMaterial = material;
-			buildTree(sceneMgr, sceneNodeRoot, help, mData, newMaterial);
-		}
-
-		if (strcmp(help->getName(), "Texture2") == 0)
-		{
-			char *textureFileName = (char *) help->getField("filename", &t, &i);
-			if (t == IV_STRING) 
-			{  
-				std::string s = sceneNodeRoot->getName().substr(sceneNodeRoot->getName().find('/',0), sceneNodeRoot->getName().length()) + "/Material" + intToStr(matCnt);
-				matCnt++;
-				if ((newMaterial = (Material *) MaterialManager::getSingleton().getByName(s).getPointer()) == NULL)
-				{
-					newMaterial = (Material *)MaterialManager::getSingleton().create(s, "General").getPointer();
-					newMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(textureFileName);
-				}
-				newMaterial->load();
-				newMaterial->reload();
-			}
-		}
-// can be included
-		if (strcmp(help->getName(), "Material") == 0)
-		{
-			Real *ambientColor = (Real *) help->getField("ambientColor", &t, &i);
-			if ((i != 3) || (t != IV_REAL)) ambientColor = NULL;
-			Real *diffuseColor = (Real *) help->getField("diffuseColor", &t, &i);
-			if ((i != 3) || (t != IV_REAL)) diffuseColor = NULL;
-			Real *specularColor = (Real *) help->getField("specularColor", &t, &i);
-			if ((i != 3) || (t != IV_REAL)) specularColor = NULL;
-			Real *emissiveColor = (Real *) help->getField("emissiveColor", &t, &i);
-			if ((i != 3) || (t != IV_REAL)) emissiveColor = NULL;
-			Real *shininess = (Real *) help->getField("shininess", &t, &i);
-			if ((i != 1) || (t != IV_REAL)) shininess = NULL;
-			Real *transparency = (Real *) help->getField("transparency", &t, &i);
-			if ((i != 1) || (t != IV_REAL)) transparency = NULL;
-
-			if (newMaterial == NULL)
-			{
-				std::string s = sceneNodeRoot->getName().substr(sceneNodeRoot->getName().find('/',0), sceneNodeRoot->getName().length()) + "/Material" + intToStr(matCnt);
-				matCnt++;
-				if ((newMaterial = (Material *) MaterialManager::getSingleton().getByName(s).getPointer()) == NULL)
-				{
-					if (material == NULL) newMaterial = (Material *)MaterialManager::getSingleton().create(s, "General").getPointer();
-					else newMaterial = material->clone(s).getPointer();
-
-					Real alpha = 1.f;
-					if (transparency != NULL) alpha = 1.f - transparency[0];
-					if (ambientColor != NULL) newMaterial->setAmbient(ambientColor[0], ambientColor[1], ambientColor[2]);
-					if (diffuseColor != NULL) newMaterial->setDiffuse(diffuseColor[0], diffuseColor[1], diffuseColor[2], alpha);
-					if (specularColor != NULL) newMaterial->setSpecular(specularColor[0], specularColor[1], specularColor[2], alpha);
-					if (emissiveColor != NULL) newMaterial->setSelfIllumination(emissiveColor[0], emissiveColor[1], emissiveColor[2]);
-					if (shininess != NULL) newMaterial->setShininess(shininess[0]);
-					
-//					if (material->getTechnique(0)->getPass(0)->getNumTextureUnitStates() > 0)							
-//					{
-//						newMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->getTextureName());
-//					}
-				}
-				newMaterial->load();
-				newMaterial->reload();
-			}
-			else
-			{
-				Real alpha = 1.f;
-				if (transparency != NULL) alpha = 1.f - transparency[0];
-				if (ambientColor != NULL) newMaterial->setAmbient(ambientColor[0], ambientColor[1], ambientColor[2]);
-				if (diffuseColor != NULL) newMaterial->setDiffuse(diffuseColor[0], diffuseColor[1], diffuseColor[2], alpha);
-				if (specularColor != NULL) newMaterial->setSpecular(specularColor[0], specularColor[1], specularColor[2], alpha);
-				if (emissiveColor != NULL) newMaterial->setSelfIllumination(emissiveColor[0], emissiveColor[1], emissiveColor[2]);
-				if (shininess != NULL) newMaterial->setShininess(shininess[0]);
-				newMaterial->load();
-			}
-		}
-
-		if (strcmp(help->getName(), "Coordinate3") == 0)
-		{
-			mData->vertices = (Real *) help->getField("point", &t, &mData->vcnt);
-			if ((t != IV_REAL) && (t != IV_INT)) mData->vertices = NULL;
-		}
-		if (strcmp(help->getName(), "Normal") == 0)
-		{
-			mData->normals = (Real *) help->getField("vector", &t, &mData->ncnt);
-			if ((t != IV_REAL) && (t != IV_INT)) mData->normals = NULL;
-		}
-		if (strcmp(help->getName(), "TextureCoordinate2") == 0)
-		{
-			mData->texCoords = (Real *) help->getField("point", &t, &mData->tcnt);
-			if ((t != IV_REAL) && (t != IV_INT)) mData->texCoords = NULL;
-		}
-
-		if (strcmp(help->getName(), "IndexedFaceSet") == 0)
-		{
-			std::string s = sceneNodeRoot->getName() + "/IFS" + intToStr(nodeCnt);
-			nodeCnt++;
-			SceneNode *triangleStripSceneNode = sceneNodeRoot->createChildSceneNode(s);
-
-			mData->indices = (Real *) help->getField("coordIndex", &t, &mData->icnt);
-			if (t != IV_INT) mData->indices = NULL;
-
-			mData->normalIndices = (Real *) help->getField("normalIndex", &t, &mData->nicnt);
-			if (t != IV_INT) mData->normalIndices = NULL;
-		
-			mData->texCoordIndices = (Real *) help->getField("textureCoordIndex", &t, &mData->ticnt);
-			if (t != IV_INT) mData->texCoordIndices = NULL;
-		
-
-			mData->roType = IV_ROT_FACE_SET;		
-	
-			Vector3 translation = Vector3(0,0,0);
-			Entity *pEntity = createEntity(sceneMgr, s, mData, &translation);
-			if (newMaterial == NULL) newMaterial = material;
-			if (newMaterial != NULL) pEntity->setMaterialName(newMaterial->getName());
-				
-			triangleStripSceneNode->attachObject(pEntity);
-			triangleStripSceneNode->translate(translation);		
-
-		}
-
-
-		if (strcmp(help->getName(), "IndexedTriangleStripSet") == 0)
-		{
-			std::string s = sceneNodeRoot->getName() + "/ITS" + intToStr(nodeCnt);
-			nodeCnt++;
-			SceneNode *triangleStripSceneNode = sceneNodeRoot->createChildSceneNode(s);
-		
-			mData->indices = (Real *) help->getField("coordIndex", &t, &mData->icnt);
-			if (t != IV_INT) mData->indices = NULL;
-
-			mData->normalIndices = (Real *) help->getField("normalIndex", &t, &mData->nicnt);
-			if (t != IV_INT) mData->normalIndices = NULL;
-
-			mData->texCoordIndices = (Real *) help->getField("textureCoordIndex", &t, &mData->ticnt);
-			if (t != IV_INT) mData->texCoordIndices = NULL;
-
-			ObjNode *n = help->getNextChildNode(true);
-			while ((n != NULL) && (strcmp(help->getName(), "VertexProperty") == 0))
-			{
-				n = help->getNextChildNode();
-			}
-			if (n != NULL)
-			{
-				mData->vertices = (Real *) n->getField("vertex", &t, &mData->vcnt);
-				if ((t != IV_REAL) && (t != IV_INT)) mData->vertices = NULL;
-
-				mData->normals = (Real *) n->getField("normal", &t, &mData->ncnt);
-				if ((t != IV_REAL) && (t != IV_INT)) mData->normals = NULL;
-				mData->texCoords = (Real *) n->getField("texCoord", &t, &mData->tcnt);
-				if ((t != IV_REAL) && (t != IV_INT)) mData->texCoords = NULL;
-			}
-
-			mData->roType = IV_ROT_TRIANGLE_STRIP;		
-
-			Vector3 translation = Vector3(0,0,0);
-			Entity *pEntity = createEntity(sceneMgr, s, mData, &translation);
-			if (newMaterial == NULL) newMaterial = material;
-			if (newMaterial != NULL) pEntity->setMaterialName(newMaterial->getName());
-				
-			triangleStripSceneNode->attachObject(pEntity);
-			triangleStripSceneNode->translate(translation);		
-
-		}
-
-		help = IVReaderoot->getNextChildNode();
-	}
-	if (meshDataCreated) if (mData != NULL) delete mData;
-}
 #endif
