Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp	(revision 944)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp	(revision 971)
@@ -9,7 +9,6 @@
 VisibilityEnvironment::VisibilityEnvironment()
 {
-	// load debug stream
+	// HACK: loading debug stream should not happen here
 	GtpVisibilityPreprocessor::Debug.open("debug.log");
-
 	// load environment
 	mEnvironment = new GtpVisibilityPreprocessor::Environment();	 
@@ -22,17 +21,5 @@
 //-----------------------------------------------------------------------
 bool VisibilityEnvironment::LoadEnvironment(string filename)
-{	
-	//-- parse filename into c-style argument list
-	/*char argc = 2;
-	char *argv[2];
-	argv[0] = "";
-	
-	char fname[200];
-	sprintf(fname, "%s", filename.c_str());
-	argv[1] = fname;
-
-	GtpVisibilityPreprocessor::Debug << "loading environment from: " << argv[1] << endl;
-	return GtpVisibilityPreprocessor::environment->Parse(argc, argv, false);
-*/
+{		
 	//-- parse environment
 	return mEnvironment->ReadEnvFile(filename.c_str());
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 955)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 971)
@@ -1033,4 +1033,15 @@
 		mVisibilityManager->GetVisibilityEnvironment()->GetPreprocessorEnvironment();
 
+	if (!env)
+	{
+	std::stringstream d;
+		d << "here454 error loading view cells: no view cells environment " << endl;
+		LogManager::getSingleton().logMessage(d.str());
+	}
+
+	std::stringstream d;
+	d << "filename999: " << filename.c_str();
+	LogManager::getSingleton().logMessage(d.str());
+
 	// load the view cells assigning the found objects to the pvss
 	mViewCellsManager = 
@@ -1040,5 +1051,5 @@
 	{
 		std::stringstream d;
-		d << "error loading view cells" << endl;
+		d << "here344 error loading view cells: no view cells manager " << endl;
 		LogManager::getSingleton().logMessage(d.str());
 	}
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp	(revision 938)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp	(revision 971)
@@ -49,5 +49,4 @@
 	// load visibility environment
 	visEnv = new GtpVisibility::VisibilityEnvironment();
-	//visEnv->LoadEnvironment("simple.env");
 	visManager = new GtpVisibility::VisibilityManager(visEnv);
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj	(revision 931)
+++ /GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj	(revision 971)
@@ -183,4 +183,16 @@
 			</File>
 			<File
+				RelativePath="..\src\GzBinFileInputStream.cpp">
+			</File>
+			<File
+				RelativePath="..\src\GzBinFileInputStream.h">
+			</File>
+			<File
+				RelativePath="..\src\GzFileInputSource.cpp">
+			</File>
+			<File
+				RelativePath="..\src\GzFileInputSource.h">
+			</File>
+			<File
 				RelativePath="..\src\gzstream.cpp">
 			</File>
Index: /GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env	(revision 955)
+++ /GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env	(revision 971)
@@ -261,5 +261,5 @@
 #	filename ../data/vienna/viewcells-large-sel.x3d
 #	filename ../scripts/viewcells_vienna.xml
-	filename D:/svn/gametools/GTP/trunk/Lib/Vis/Preprocessing/scripts/vienna-visibility.xml
+	filename E:/svn/gametools/GTP/trunk/Lib/Vis/Preprocessing/scripts/vienna-visibility.xml
 }
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h	(revision 955)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h	(revision 971)
@@ -327,6 +327,9 @@
 	/** Writes tree to output stream
 	*/
-	//bool Export(ogzstream &stream);
+#if ZIPPED_VIEWCELLS
+	bool Export(ogzstream &stream);
+#else
 	bool Export(ofstream &stream);
+#endif
 
 	/** Casts beam, i.e. a 5D frustum of rays, into tree.
@@ -696,6 +699,9 @@
 		@note: should be implemented as visitor.
 	*/
+#if ZIPPED_VIEWCELLS
+	void ExportNode(BspNode *node, ogzstream &stream);
+#else
 	void ExportNode(BspNode *node, ofstream &stream);
-	//void ExportNode(BspNode *node, ogzstream &stream);
+#endif
 
 	/** Returns estimated memory usage of tree.
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 955)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 971)
@@ -1945,7 +1945,9 @@
 }
 
-
+#if ZIPPED_VIEWCELLS
+bool ViewCellsTree::Export(ogzstream &stream, const bool exportPvs)
+#else
 bool ViewCellsTree::Export(ofstream &stream, const bool exportPvs)
-//bool ViewCellsTree::Export(ogzstream &stream, const bool exportPvs)
+#endif
 {
 	// export recursivly all view cells from the root
@@ -1983,7 +1985,9 @@
 }
 
-
-//void ViewCellsTree::ExportPvs(ViewCell *viewCell, ogzstream &stream)
+#if ZIPPED_VIEWCELLS
+void ViewCellsTree::ExportPvs(ViewCell *viewCell, ogzstream &stream)
+#else
 void ViewCellsTree::ExportPvs(ViewCell *viewCell, ofstream &stream)
+#endif
 {
 	ObjectPvsMap::iterator it, it_end = viewCell->GetPvs().mEntries.end();
@@ -1995,7 +1999,9 @@
 }
 
-
+#if ZIPPED_VIEWCELLS
+void ViewCellsTree::ExportViewCell(ViewCell *viewCell, ogzstream &stream, const bool exportPvs)
+#else
 void ViewCellsTree::ExportViewCell(ViewCell *viewCell, ofstream &stream, const bool exportPvs)
-//void ViewCellsTree::ExportViewCell(ViewCell *viewCell, ogzstream &stream, const bool exportPvs)
+#endif
 {
 	if (viewCell->IsLeaf())
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp	(revision 870)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp	(revision 971)
@@ -14,5 +14,5 @@
 #include <xercesc/parsers/SAXParser.hpp>
 #include <xercesc/util/OutOfMemoryException.hpp>
-
+#include <xercesc/util/BinFileInputStream.hpp>
 // ---------------------------------------------------------------------------
 //  Includes
@@ -32,4 +32,5 @@
 namespace GtpVisibilityPreprocessor {
 
+float X3dParser::DEFAULT_VIEWCELL_HEIGHT = 5.0f;
 
 // ---------------------------------------------------------------------------
@@ -537,4 +538,11 @@
 }
 
+/*************************************************************************/
+/*                     X3dParser implementation                          */
+/*******************+*****************************************************/
+
+X3dParser::X3dParser():
+mViewCellHeight(DEFAULT_VIEWCELL_HEIGHT) 
+{}
 
 bool
@@ -916,4 +924,6 @@
       {
 	const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis();
+	//GzBinFileInputStream str(filename.c_str());
+	
 	parser->parse(filename.c_str());
 	const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis();
@@ -960,3 +970,6 @@
 }
 
-}
+
+
+
+}
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp	(revision 955)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp	(revision 971)
@@ -3844,7 +3844,9 @@
 }
 
-
+#if ZIPPED_VIEWCELLS
+bool VspBspTree::Export(ogzstream &stream)
+#else
 bool VspBspTree::Export(ofstream &stream)
-//bool VspBspTree::Export(ogzstream &stream)
+#endif
 {
 	ExportNode(mRoot, stream);
@@ -3853,7 +3855,9 @@
 }
 
-
+#if ZIPPED_VIEWCELLS
+void VspBspTree::ExportNode(BspNode *node, ogzstream &stream)
+#else
 void VspBspTree::ExportNode(BspNode *node, ofstream &stream)
-//void VspBspTree::ExportNode(BspNode *node, ogzstream &stream)
+#endif
 {
 	if (node->IsLeaf())
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 938)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 971)
@@ -804,5 +804,5 @@
 bool
 Environment::ReadEnvFile(const char *envFilename)
-{
+{Debug << "here222 " << envFilename << endl;
   char buff[MaxStringLength], name[MaxStringLength];
   char *s, *t;
@@ -817,5 +817,5 @@
     return false;
   }
-  
+
   name[0] = '\0';
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GzBinFileInputStream.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GzBinFileInputStream.h	(revision 971)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GzBinFileInputStream.h	(revision 971)
@@ -0,0 +1,136 @@
+/*
+ * Copyright 1999-2000,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * $Log: GzBinFileInputStream.hpp,v $
+ * Revision 1.7  2004/09/08 13:56:21  peiyongz
+ * Apache License Version 2.0
+ *
+ * Revision 1.6  2004/01/29 11:48:46  cargilld
+ * Code cleanup changes to get rid of various compiler diagnostic messages.
+ *
+ * Revision 1.5  2003/12/17 13:58:02  cargilld
+ * Platform update for memory management so that the static memory manager (one
+ * used to call Initialize) is only for static data.
+ *
+ * Revision 1.4  2003/06/03 18:12:29  knoaman
+ * Add default value for memory manager argument.
+ *
+ * Revision 1.3  2003/05/16 03:11:22  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
+ * Revision 1.2  2002/11/04 15:22:03  tng
+ * C++ Namespace Support.
+ *
+ * Revision 1.1.1.1  2002/02/01 22:22:09  peiyongz
+ * sane_include
+ *
+ * Revision 1.3  2000/02/24 20:05:23  abagchi
+ * Swat for removing Log from API docs
+ *
+ * Revision 1.2  2000/02/06 07:48:01  rahulj
+ * Year 2K copyright swat.
+ *
+ * Revision 1.1.1.1  1999/11/09 01:04:00  twl
+ * Initial checkin
+ *
+ * Revision 1.3  1999/11/08 20:45:03  rahul
+ * Swat for adding in Product name and CVS comment log variable.
+ *
+ */
+
+#if !defined(GZBINFILEINPUTSTREAM_HPP)
+#define GZBINFILEINPUTSTREAM_HPP
+
+#include <xercesc/util/BinInputStream.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
+#include "gzstream.h"
+
+XERCES_CPP_NAMESPACE_BEGIN
+//0699/15227486
+class /*XMLUTIL_EXPORT*/ GzBinFileInputStream : public BinInputStream
+{
+public :
+    // -----------------------------------------------------------------------
+    //  Constructors and Destructor
+    // -----------------------------------------------------------------------
+    GzBinFileInputStream
+    (
+        const   XMLCh* const    fileName
+        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
+    );
+
+    GzBinFileInputStream
+    (
+        const   char* const     fileName
+        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
+    );
+
+ 
+    virtual ~GzBinFileInputStream();
+
+
+    // -----------------------------------------------------------------------
+    //  Getter methods
+    // -----------------------------------------------------------------------
+    bool getIsOpen() const;
+    unsigned int getSize() const;
+    void reset();
+
+
+    // -----------------------------------------------------------------------
+    //  Implementation of the input stream interface
+    // -----------------------------------------------------------------------
+    virtual unsigned int curPos() const;
+
+    virtual unsigned int readBytes
+    (
+                XMLByte* const      toFill
+        , const unsigned int        maxToRead
+    );
+
+	igzstream mStream;
+
+private :
+    // -----------------------------------------------------------------------
+    //  Unimplemented constructors and operators
+    // -----------------------------------------------------------------------
+    GzBinFileInputStream(const GzBinFileInputStream&);
+    GzBinFileInputStream& operator=(const GzBinFileInputStream&);   
+
+    // -----------------------------------------------------------------------
+    //  Private data members
+    //
+    //  fSource
+    //      The source file that we represent. The FileHandle type is defined
+    //      per platform.
+    // -----------------------------------------------------------------------
+    FileHandle              fSource;
+    MemoryManager* const    fMemoryManager;
+};
+
+
+// ---------------------------------------------------------------------------
+//  GzBinFileInputStream: Getter methods
+// ---------------------------------------------------------------------------
+inline bool GzBinFileInputStream::getIsOpen() const
+{
+    return (fSource != 0);
+}
+
+XERCES_CPP_NAMESPACE_END
+
+#endif
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h	(revision 955)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h	(revision 971)
@@ -7,8 +7,6 @@
 #include "Statistics.h"
 #include "Material.h"
-//#include "bzip2stream.hpp"
 #include "gzstream.h"
 
-//class ogzstream;
 
 namespace GtpVisibilityPreprocessor {
@@ -440,6 +438,9 @@
 	/** Exports view cells to file.
 	*/
+#if ZIPPED_VIEWCELLS
+	bool Export(ogzstream &stream, const bool exportPvs = false);
+#else
 	bool Export(ofstream &stream, const bool exportPvs = false);
-    //bool Export(ogzstream &stream, const bool exportPvs = false);
+#endif
 
 	/** Export statistics of this view cell tree.
@@ -545,12 +546,17 @@
 		NOTE: should be in exporter!!
 	*/
-	void ExportViewCell(ViewCell *viewCell, ofstream &stream, const bool exportPvs);
-	//void ExportViewCell(ViewCell *viewCell, ogzstream &stream, const bool exportPvs);
+#if ZIPPED_VIEWCELLS
+	void ExportViewCell(ViewCell *viewCell, ogzstream &stream, const bool exportPvs);
+#else
+	void ExportViewCell(ViewCell *viewCell, ofstream &stream, const bool exportPvs);	
+#endif
 
 	/** Exports pvs of a view cell.
 	*/
+#if ZIPPED_VIEWCELLS
+	void ExportPvs(ViewCell *viewCell, ogzstream &stream);
+#else
 	void ExportPvs(ViewCell *viewCell, ofstream &stream);
-	//void ExportPvs(ViewCell *viewCell, ogzstream &stream);
-
+#endif
 
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GzBinFileInputStream.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GzBinFileInputStream.cpp	(revision 971)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GzBinFileInputStream.cpp	(revision 971)
@@ -0,0 +1,141 @@
+/*
+ * Copyright 1999-2000,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * $Log: GzBinFileInputStream.cpp,v $
+ * Revision 1.5  2004/09/08 13:56:21  peiyongz
+ * Apache License Version 2.0
+ *
+ * Revision 1.4  2003/12/17 13:58:02  cargilld
+ * Platform update for memory management so that the static memory manager (one
+ * used to call Initialize) is only for static data.
+ *
+ * Revision 1.3  2003/05/16 03:11:22  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
+ * Revision 1.2  2002/11/04 15:22:03  tng
+ * C++ Namespace Support.
+ *
+ * Revision 1.1.1.1  2002/02/01 22:22:09  peiyongz
+ * sane_include
+ *
+ * Revision 1.3  2000/03/02 19:54:38  roddey
+ * This checkin includes many changes done while waiting for the
+ * 1.1.0 code to be finished. I can't list them all here, but a list is
+ * available elsewhere.
+ *
+ * Revision 1.2  2000/02/06 07:48:01  rahulj
+ * Year 2K copyright swat.
+ *
+ * Revision 1.1.1.1  1999/11/09 01:03:59  twl
+ * Initial checkin
+ *
+ * Revision 1.4  1999/11/08 20:56:55  droddey
+ * If the main xml entity does not exist, we need to get the error handling for that
+ * inside the main XMLScanner::scanDocument() try block so that it gets reported
+ * in the normal way. We have to add a little extra safety code because, when this
+ * happens, there is no reader on the reader stack to get position ino from.
+ *
+ * Revision 1.3  1999/11/08 20:45:03  rahul
+ * Swat for adding in Product name and CVS comment log variable.
+ *
+ */
+
+
+// ---------------------------------------------------------------------------
+//  Includes
+// ---------------------------------------------------------------------------
+#include <xercesc/util/BinFileInputStream.hpp>
+#include <xercesc/util/Janitor.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
+#include <xercesc/util/XMLExceptMsgs.hpp>
+#include <xercesc/util/XMLString.hpp>
+
+#include "GzBinFileInputStream.h"
+
+XERCES_CPP_NAMESPACE_BEGIN
+
+// ---------------------------------------------------------------------------
+//  GzBinFileInputStream: Constructors and Destructor
+// ---------------------------------------------------------------------------
+GzBinFileInputStream::GzBinFileInputStream(const XMLCh* const fileName
+                                       , MemoryManager* const manager) :
+
+    //fSource(0) , 
+fMemoryManager(manager)
+{
+	// Try to open the file
+    //fSource = XMLPlatformUtils::openFile((unsignedfileName, manager);
+	char *myFileName = XMLString::transcode(fileName);
+	mStream.open(myFileName);
+}
+
+GzBinFileInputStream::GzBinFileInputStream(const char* const fileName,
+										   MemoryManager* const manager) :
+fMemoryManager(manager)
+{
+    // Try to open the file
+	mStream.open(fileName);
+}
+
+
+GzBinFileInputStream::~GzBinFileInputStream()
+{
+   mStream.close();
+}
+
+
+// ---------------------------------------------------------------------------
+//  GzBinFileInputStream: Getter methods
+// ---------------------------------------------------------------------------
+unsigned int GzBinFileInputStream::getSize() const
+{
+	// todo
+    return 0;
+}
+
+
+// ---------------------------------------------------------------------------
+//  GzBinFileInputStream: Stream management methods
+// ---------------------------------------------------------------------------
+void GzBinFileInputStream::reset()
+{
+	// todo
+}
+
+
+// ---------------------------------------------------------------------------
+//  GzBinFileInputStream: Implementation of the input stream interface
+// ---------------------------------------------------------------------------
+unsigned int GzBinFileInputStream::curPos() const
+{
+    return XMLPlatformUtils::curFilePos(fSource, fMemoryManager);
+}
+
+unsigned int
+GzBinFileInputStream::readBytes(          XMLByte* const  toFill
+                                , const unsigned int    maxToRead)
+{
+    //
+    //  Read up to the maximum bytes requested. We return the number
+    //  actually read.
+    //
+    //return XMLPlatformUtils::readFileBuffer(fSource, maxToRead, toFill, fMemoryManager);
+	mStream.getline((char *)toFill, maxToRead);
+	return mStream.gcount();
+}
+
+XERCES_CPP_NAMESPACE_END
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GzFileInputSource.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GzFileInputSource.h	(revision 971)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GzFileInputSource.h	(revision 971)
@@ -0,0 +1,201 @@
+/*
+ * Copyright 1999-2000,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * $Log: LocalFileInputSource.hpp,v $
+ * Revision 1.6  2004/09/08 13:55:57  peiyongz
+ * Apache License Version 2.0
+ *
+ * Revision 1.5  2004/01/29 11:46:29  cargilld
+ * Code cleanup changes to get rid of various compiler diagnostic messages.
+ *
+ * Revision 1.4  2003/12/01 23:23:25  neilg
+ * fix for bug 25118; thanks to Jeroen Witmond
+ *
+ * Revision 1.3  2003/05/16 21:36:55  knoaman
+ * Memory manager implementation: Modify constructors to pass in the memory manager.
+ *
+ * Revision 1.2  2002/11/04 15:00:21  tng
+ * C++ Namespace Support.
+ *
+ * Revision 1.1.1.1  2002/02/01 22:21:50  peiyongz
+ * sane_include
+ *
+ * Revision 1.7  2001/10/13 04:21:53  jasons
+ * This patch resolves bug #2409: undocumented XMLException in LocalFileInputSource::new()
+ *
+ * Revision 1.6  2000/12/14 18:49:53  tng
+ * Fix API document generation warning: "Warning: end of member group without matching begin"
+ *
+ * Revision 1.5  2000/02/24 20:00:22  abagchi
+ * Swat for removing Log from API docs
+ *
+ * Revision 1.4  2000/02/15 23:59:06  roddey
+ * More updated documentation of Framework classes.
+ *
+ * Revision 1.3  2000/02/15 01:21:30  roddey
+ * Some initial documentation improvements. More to come...
+ *
+ * Revision 1.2  2000/02/06 07:47:46  rahulj
+ * Year 2K copyright swat.
+ *
+ * Revision 1.1  2000/01/12 18:58:06  roddey
+ * Putting this back with the correct lower case extension.
+ *
+ * Revision 1.1  2000/01/12 00:13:26  roddey
+ * These were moved from internal/ to framework/, which was something that should have
+ * happened long ago. They are really framework type of classes.
+ *
+ * Revision 1.1.1.1  1999/11/09 01:08:10  twl
+ * Initial checkin
+ *
+ * Revision 1.2  1999/11/08 20:44:43  rahul
+ * Swat for adding in Product name and CVS comment log variable.
+ *
+ */
+
+
+#if !defined(GZFILEINPUTSOURCE_H)
+#define GZFILEINPUTSOURCE_H
+
+//#include <xercesc/sax/InputSource.hpp>
+#include <xercesc/framework/LocalFileInputSource.hpp>
+
+XERCES_CPP_NAMESPACE_BEGIN
+
+class BinInputStream;
+
+/**
+ *  This class is a derivative of the standard InputSource class. It provides
+ *  for the parser access to data which is referenced via a local file path,
+ *  as apposed to remote file or URL. This is the most efficacious mechanism
+ *  by which local files can be parsed, since the parse knows that it refers
+ *  to a local file and will make no other attempts to interpret the passed
+ *  path.
+ *
+ *  The path provided can either be a fully qualified path or a relative path.
+ *  If relative, it will be completed either relative to a passed base path
+ *  or relative to the current working directory of the process.
+ *
+ *  As with all InputSource derivatives. The primary objective of an input
+ *  source is to create an input stream via which the parser can spool in
+ *  data from the referenced source.
+ */
+class /*XMLPARSER_EXPORT*/ GzFileInputSource: public LocalFileInputSource
+{
+public :
+    // -----------------------------------------------------------------------
+    //  Constructors and Destructor
+    // -----------------------------------------------------------------------
+
+    /** @name Constructors */
+    //@{
+
+    /**
+      * A local file input source requires a path to the file to load. This
+      * can be provided either as a fully qualified path, a path relative to
+      * the current working directly, or a path relative to a provided base
+      * path.
+      *
+      * The completed path will become the system id of this input source.
+      * The constructors don't take any public id for local files, but you
+      * still set them via the parent class' setPublicId() method of course.
+      *
+      * This constructor takes an explicit base path and a possibly relative
+      * path. If the relative path is seen to be fully qualified, it is used
+      * as is. Otherwise, it is made relative to the passed base path.
+      *
+      * @param  basePath    The base path from which the passed relative path
+      *                     will be based, if the relative part is indeed
+      *                     relative.
+      *
+      * @param  relativePath    The relative part of the path. It can actually
+      *                         be fully qualified, in which case it is taken
+      *                         as is.
+      *
+      * @param  manager    Pointer to the memory manager to be used to
+      *                    allocate objects.
+      *
+      * @exception XMLException If the path is relative and doesn't properly
+      *            resolve to a file.
+      */
+    GzFileInputSource
+    (
+        const   XMLCh* const   basePath
+        , const XMLCh* const   relativePath
+        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
+    );
+
+    /**
+      * This constructor takes a single parameter which is the fully qualified
+      * or relative path. If it is fully qualified, it is taken as is. If it is
+      * relative, then it is completed relative to the current working directory
+      * (or the equivalent on the local host machine.)
+      *
+      * The completed path will become the system id of this input source.
+      * The constructors don't take any public id for local files, but you
+      * still set them via the parent class' setPublicId() method of course.
+      *
+      * @param  filePath    The relative or fully qualified path.
+      *
+      * @param  manager     Pointer to the memory manager to be used to
+      *                     allocate objects.
+      *
+      * @exception XMLException If the path is relative and doesn't properly
+      *            resolve to a file.
+      */
+    GzFileInputSource
+    (
+        const   XMLCh* const   filePath
+        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
+    );
+    //@}
+
+    /** @name Destructor */
+    //@{
+    ~GzFileInputSource();
+    //@}
+
+
+    // -----------------------------------------------------------------------
+    //  Virtual input source interface
+    // -----------------------------------------------------------------------
+
+    /** @name Virtual methods */
+    //@{
+
+    /**
+    * This method will return a binary input stream derivative that will
+    * parse from the local file indicatedby the system id.
+    *
+    * @return A dynamically allocated binary input stream derivative that
+    *         can parse from the file indicated by the system id.
+    */
+    virtual BinInputStream* makeStream() const;
+
+    //@}
+private:
+    // -----------------------------------------------------------------------
+    //  Unimplemented constructors and operators
+    // -----------------------------------------------------------------------
+    GzFileInputSource(const GzFileInputSource&);
+    GzFileInputSource& operator=(const GzFileInputSource&);
+
+};
+
+XERCES_CPP_NAMESPACE_END
+
+#endif
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 955)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 971)
@@ -30,4 +30,5 @@
 #include "VspKdTree.h"
 #include "ViewCellsManager.h"
+#include "GzFileInputSource.h"
 
 namespace GtpVisibilityPreprocessor {
@@ -82,5 +83,5 @@
   , mBoundingBoxConverter(bconverter)
   , mEnvironment(env)
-{
+{Debug << "here22" << endl;
 	// mObjects = objects;
 }
@@ -126,5 +127,5 @@
 	// go one up in the tree
 	if (mCurrentBspNode->GetParent())
-	{	cout << "]";
+	{	Debug << "]";
 		mCurrentBspNode = mCurrentBspNode->GetParent();
 	}
@@ -136,5 +137,5 @@
 	// go one up in the tree
 	if (mCurrentViewCell->GetParent())
-	{	cout << "]";
+	{	Debug << "]";
 		mCurrentViewCell = mCurrentViewCell->GetParent();
 	}
@@ -195,5 +196,5 @@
 	if (element == "Interior") 
 	{
-		cout << "[";
+		Debug << "[";
 		StartBspInterior(attributes);
 	}
@@ -201,5 +202,5 @@
 	if (element == "Leaf") 
 	{
-		cout << "l";
+		Debug << "l";
 		StartBspLeaf(attributes);
 	}
@@ -209,12 +210,12 @@
 void ViewCellsParseHandlers::startElement(const XMLCh* const name,
 										  AttributeList& attributes)
-{
+{	Debug << "here722" << endl;
 	StrX lname(name);
 	string element(lname.LocalForm());
-	
+
 	// decides the used view cell hierarchy
 	if (element == "ViewCells")
 	{
-		cout << "parsing view cells" << endl;
+		Debug << "parsing view cells" << endl;
 		mParseViewCells = true;
 	}
@@ -222,5 +223,5 @@
 	if (element == "Hierarchy")
 	{
-		cout << "parsing spatial hierarchy" << endl;
+		Debug << "parsing spatial hierarchy" << endl;
 		mParseViewCells = false;
 		StartHierarchy(attributes);
@@ -230,5 +231,5 @@
 	if (element == "ViewSpaceBox")
 	{
-		cout << "v";
+		Debug << "v";
 		StartViewSpaceBox(attributes);
 	}
@@ -237,5 +238,5 @@
 	if (element == "BoundingBox")
 	{
-		cout << "b";
+		Debug << "b";
 		StartBoundingBox(attributes);
 	}
@@ -263,5 +264,5 @@
 		if (element == "Interior") 
 		{
-			cout << "[";
+			Debug << "[";
 			StartViewCellInterior(attributes);
 		}
@@ -269,5 +270,5 @@
 		if (element == "Leaf") 
 		{
-			cout << "l";
+			Debug << "l";
 			StartViewCellLeaf(attributes);
 		}
@@ -719,5 +720,5 @@
     }
   
-  
+  Debug << "here2" << endl;
   //
   //  Create a SAX parser object. Then, according to what we were told on
@@ -754,6 +755,15 @@
       {
 	const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis();
+#if ZIPPED_VIEWCELLS
+	XMLCh *myFilePath = XMLString::transcode(filename.c_str());
+	
+	GzFileInputSource isource(myFilePath);
+	Debug << "here4" << endl;
+	parser->parse(isource);
+
+#else
 	parser->parse(filename.c_str());
-	//ogzstream stream; parser->parse(stream);
+#endif
+
 	const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis();
 	duration = endMillis - startMillis;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.h	(revision 863)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.h	(revision 971)
@@ -12,5 +12,6 @@
 {
 public:
-	X3dParser():Parser(), mViewCellHeight(5.0f) {}
+	
+	X3dParser();
   
 	bool ParseFile(const string filename, SceneGraphNode **root, const bool loadPolygonsAsMeshes = false);
@@ -19,4 +20,6 @@
 	/// height of a loaded view cell
 	float mViewCellHeight;
+
+	static float DEFAULT_VIEWCELL_HEIGHT;
 };
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GzFileInputSource.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GzFileInputSource.cpp	(revision 971)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GzFileInputSource.cpp	(revision 971)
@@ -0,0 +1,119 @@
+/*
+ * Copyright 1999-2000,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+// ---------------------------------------------------------------------------
+//  Includes
+// ---------------------------------------------------------------------------
+#include <xercesc/framework/LocalFileInputSource.hpp>
+#include <xercesc/util/BinFileInputStream.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
+#include <xercesc/util/XMLString.hpp>
+#include <xercesc/util/XMLUniDefs.hpp>
+
+#include "GzFileInputSource.h"
+#include "GzBinFileInputStream.h"
+
+XERCES_CPP_NAMESPACE_BEGIN
+
+/***
+ *
+ * Originated by Chris larsson
+ *
+ * Issue:
+ *
+ * There is an inconsistency in URI resolution in the case where the file itself is a 
+ * symbolic link to another path (or the path has path segment which is a symbolic
+ * link to another path). So, is the base path the directory where the symbolic link resides 
+ * or the directory where the real file resides? I'm sure one could argue either way, 
+ * but I think that having the base path be the directory where the symbolic link resides 
+ * is more intuitive. 
+ *
+ * Defining it this way would then make the behavior consistent with using an absolute 
+ * path as well as with the java behavior. 
+ *
+ * Proposal:
+ *
+ * The URI is resolved within the parser code, and is somewhat independant of the OS. 
+ * 
+ * A relative path is resolved by querying the current directory and appending the 
+ * relative part onto the returned current directory string to obtain the base URI. 
+ * An absolute path is simply used as the base URI. 
+ * Then remove all "./" and "../" path segments using an algorithm like weavepath to obtain 
+ * the resolved base URI. 
+ *
+ * When you need to access another file such as a dtd, use the resolved base URI and add on
+ * the relative URI of the dtd file. Then resolve it using the same weavepath algorithm. 
+ *
+ * Note:
+ *
+ *   Java parser behaves differently for a path containning symbolic path segment. When 
+ *   it is given an absolute path, it can locate the primary instance document, while given 
+ *   relative path, it might not.
+ *
+ *   It is because Java parser uses URI solution where "/segment/../" is required to be removed
+ *   from the resultant path if a relative URI is merged to a baseURI. While this is NOT required
+ *   for an absolute URI. 
+ *   
+ *   So if a path segment, which is symbolic link, happen to be followed by the '/../', it is 
+ *   NOT removed from the path if it is given in absolute form, and the underlying file system 
+ *   will locate the file, if in relative form, that symbolic link path segment together with 
+ *   '../' is removed from the resultant path, and the file system may NOT be able to locate 
+ *   the file, if there is a one, it is definitely not the one expected, in fact by accident.
+ *
+ *   Therefore, to keep consistent with Java parser, for now, we do not apply removeDotDotSlash()
+ *   for absolute path.
+ *  
+ ***/
+
+// ---------------------------------------------------------------------------
+//  LocalFileInputSource: Constructors and Destructor
+// ---------------------------------------------------------------------------
+GzFileInputSource::GzFileInputSource( const XMLCh* const basePath
+                             , const XMLCh* const relativePath
+                             , MemoryManager* const manager)
+    : LocalFileInputSource(basePath, relativePath, manager)
+{
+}
+
+GzFileInputSource::GzFileInputSource(const XMLCh* const filePath,
+									 MemoryManager* const manager)
+    : LocalFileInputSource(filePath, manager)
+{
+}
+
+
+GzFileInputSource::~GzFileInputSource()
+{
+}
+
+
+// ---------------------------------------------------------------------------
+//  LocalFileInputSource: InputSource interface implementation
+// ---------------------------------------------------------------------------
+BinInputStream* GzFileInputSource::makeStream() const
+{
+	GzBinFileInputStream* retStrm = new (getMemoryManager()) GzBinFileInputStream(getSystemId(), getMemoryManager());
+	if (!retStrm->getIsOpen())
+    {
+        delete retStrm;
+        return 0;
+    }
+    return retStrm;
+}
+
+XERCES_CPP_NAMESPACE_END
+
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 955)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 971)
@@ -4715,5 +4715,5 @@
 
 	ViewCellsManager *vm = NULL;
-
+Debug << "here98 " << filename << endl;
 	if (parser.ParseFile(filename, &vm, objects, bconverter, env))
 	{
@@ -4752,6 +4752,10 @@
 	cout << "exporting view cells to xml ... ";
 	
-	//ogzstream stream(filename.c_str());
+#if ZIPPED_VIEWCELLS
+	ogzstream stream(filename.c_str());
+	cout << "!!!!!!!!!!!!!!!!!!!!!!" << endl;
+#else
 	std::ofstream stream(filename.c_str());
+#endif
 
 	// for output we need unique ids for each view cell
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/X3dParserXerces.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/X3dParserXerces.h	(revision 860)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/X3dParserXerces.h	(revision 971)
@@ -20,4 +20,5 @@
 class Material;
 class ViewCellsManager;
+
 
 struct ltstr
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/common.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/common.h	(revision 865)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/common.h	(revision 971)
@@ -483,14 +483,17 @@
 }
 
-#endif
-
-
-
-
-
-
-
-
-
-
-
+// if the view cells should be exported and inported as gzstream
+#define ZIPPED_VIEWCELLS 1
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
