Index: /trunk/VUT/GtpVisibility/include/DummyPreprocessingManager.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/DummyPreprocessingManager.h	(revision 65)
+++ /trunk/VUT/GtpVisibility/include/DummyPreprocessingManager.h	(revision 65)
@@ -0,0 +1,61 @@
+#ifndef _VisibilityDummyPreprocessingManager_H__
+#define _VisibilityDummyPreprocessingManager_H__
+
+#include "PreprocessingManager.h"
+
+
+namespace GtpVisibility {
+  
+  /**
+     Implements a dummy interface to the external visibility preprocessing.
+  */
+class DummyPreprocessingManager : public PreprocessingManager
+{
+public:
+
+
+  /** Constructor taking a scene traverser for a specific type of
+      hierarchyInterface as argument. 
+  */
+  DummyPreprocessingManager( HierarchyInterface *hierarchyInterface );
+  
+  
+  /** 
+      Export the scene for visibility preprocessing. Exports the hierarchyInterface including
+      its bounding boxes + mesh data for occluders. The viewcell data will either be
+      supplied directly to the visibility preprocessing standalone module
+  */
+  virtual bool ExportScene(const string filename);
+  
+  
+  /** 
+      Load preprocessed visibility information
+  */
+  virtual bool LoadPreprocessedData(const string filename);
+  
+  
+protected:
+
+  /** 
+      Find viewcells intersecting a spherical neighborhood of a point.
+      Returns false if no viewcell was found.
+    */
+  virtual bool LocateViewCellIds(const Vector3 &center,
+				 const float radius,
+				 vector<int> *viewCellIds
+				 );
+
+
+  /**
+     Add a PVS of the given viewcell to the already evaluated PVS by computing
+     a union with visibleNodes and visibleMeshes. Returns the number of added entries.
+  */
+  virtual int AddViewCellPVS(const int cellID,
+			     InfoContainer<NodeInfo> *visibleNodes,
+			     InfoContainer<MeshInfo> *visibleMeshes );
+
+};
+
+};
+
+#endif // VisibilityPreprocessingManager
Index: /trunk/VUT/GtpVisibility/include/VisibilityVector3.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/VisibilityVector3.h	(revision 65)
+++ /trunk/VUT/GtpVisibility/include/VisibilityVector3.h	(revision 65)
@@ -0,0 +1,13 @@
+#ifndef _VisibilityVector3_H__
+#define _VisibilityVector3_H__
+
+#include "OgreVector3.h"
+
+namespace GtpVisibility {
+  /** Vector3 class currently uses the native Ogre vector when compiled with the Ogre platform */
+  typedef Ogre::Vector3 Vector3;
+}
+
+
+
+#endif
Index: /trunk/VUT/GtpVisibility/include/HierarchyInterface.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/HierarchyInterface.h	(revision 59)
+++ /trunk/VUT/GtpVisibility/include/HierarchyInterface.h	(revision 65)
@@ -41,4 +41,10 @@
 	*/
 	void SetSceneRoot(HierarchyNode *root);
+  /** Get the root of the scene hierarchy.
+      @return the hierarchy root
+  */
+  HierarchyNode *GetSceneRoot() const {
+    return mSceneRoot;
+  }
 	/** Sets the scene root and initialises this scene traverser for a traversal.
 		@param root current scene root
Index: /trunk/VUT/GtpVisibility/include/QueryManager.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/QueryManager.h	(revision 59)
+++ /trunk/VUT/GtpVisibility/include/QueryManager.h	(revision 65)
@@ -2,74 +2,93 @@
 #define _VisibilityQueryManager_H__
 
+#include <vector>
+
 #include "VisibilityInfo.h"
+#include "VisibilityVector3.h"
+#include "VisibilityCamera.h"
+#include "VisibilityRay.h"
 
+namespace GtpVisibility {
+  
+/** This abstract class defines interface for a specific visibility query
+    algorithm. The interface supports two from point visibility queries and
+    the ray shooting query. The output of the queries consists of list of
+    visible meshes and hierarchy nodes. The from point queries will be implemented
+    either with item bufferring or based purelly on occlusion queries. Note that
+    the actuall implementation can also exploit the
+    output of the visibility preprocessor.
+*/
+  class QueryManager
+  {
+  public:
+    /** Constructor taking a hierarchy interface as an argument. This allows to operate
+	onm different hierarchy types, while reusing the implementation of the query methods.
+     */
+    QueryManager( HierarchyInterface *hierarchyInterface );
+    
+    /** 
+	Computes restricted visibility from point by using an explicit camera to execute
+	the visibility query.
+	@param camera The camera to be used
 
-/** This abstract class defining interface for a specific visibility query
-    algorithm. The algorithm is either used to render the scene with false colors
-    and query visibility of scene nodes and polygons */
-*/
-class VisibilityQueryManager
-{
-public:
-  /** Constructor taking a scene traverser for a specific type of hierarchy as argument. 
-   */
-	VisibilityQueryManager( GtpVisibility::SceneTraverser *sceneTraverser );
+	@param visibleNodes Pointer to the container where visible nodes should be added.
+	This set is formed of visible leafs or fully visible interior nodes.
+	If NULL no visible nodes are not evaluated.
 
+	@param visibleGeometry Pointer to the container where visible meshes should be added.
+	If NULL no visible meshes are not evaluated.
+
+	@param relativeVisibility If true the visibility member for
+	NodeInfo and MeshInfo represent relative visibility; i.e. the number of visible
+	pixels divided by the the number of projected pixels.
+
+	@return true if the corresponding PVS exists.
+    */
+    virtual void
+    ComputeCameraVisibility(const Camera &camera,
+			    InfoContainer<NodeInfo> *visibleNodes,
+			    InfoContainer<MeshInfo> *visibleGeometry,
+			    bool relativeVisibility = false
+			    ) = 0;
+    
+    /** 
+	Uses the specified point to execute the visibility query in all directions. 
+	@sa ComputeCameraVisibility()
+    */
+    virtual void
+    ComputeFromPointVisibility(const Vector3 &point,
+			       InfoContainer<NodeInfo> *visibleNodes,
+			       InfoContainer<MeshInfo> *visibleGeometry,
+			       bool relativeVisibility = false
+			       ) = 0;
+    
   /** 
-      Uses explicit camera to execute the visibility query
+      Ray shooting intreface: finds an intersection with objects in the scene.
+
+      @param ray The given input ray (assuming the ray direction is normalized)
+
+      @param visibleMeshes List of meshes intersecting the ray
+
+      @param isGlobalLine If false only first intersection with opaque object is returned.
+      Otherwise all intersections of the ray with the scene are found.
+
+      @return true if there is any intersection. 
   */
-  virtual void
-  ComputeFromPointVisibility(const Camera &camera,
-			     VisibilityContainer<NodeVisibilityInfo> *visibleNodes,
-			     VisibilityContainer<MeshVisibilityInfo> *visibleGeometry ) = 0;
-  
-  /** 
-      Uses the specified point to execute the visibility query in all directions
-  */
-  virtual void
-  ComputeFromPointVisibility(const Vector3D &point,
-			     VisibilityContainer<NodeVisibilityInfo> *visibleNodes,
-			     VisibilityContainer<MeshVisibilityInfo> *visibleGeometry ) = 0;
-  
-  /** 
-      Ray shooting intreface: finds an intersection with the first opaque
-      object in the scene if globalLine = false, otherwise finds all intersections
-      with the scene. 
-  */
-  virtual void
-  ShootRay(const Ray &ray,
-	   VisibilityContainer<NodeVisibilityInfo> *visibleNodes,
-	   VisibilityContainer<MeshVisibilityInfo> *visibleMeshes,
-	   bool isGlobalLine = false
-	   ) = 0;
-  
-  
-  /** 
-      Preprocessing interface: PVS for a given point found using PVS of the corresponding viewcell
-  */
-  virtual int
-  GetFromPointPVS(const Vector3D &point,
-		  VisibilityContainer<NodeVisibilityInfo> *visibleNodes,
-		  VisibilityContainer<MeshVisibilityInfo> *visibleMeshes ) = 0;
-  
-  /** 
-      Preprocessing interface: PVS for a given sphere using union of cell based PVS
-  */
-  virtual int
-  GetFromSpherePVS(const Vector3D &center,
-		   const float radius,
-		   VisibilityContainer<NodeVisibilityInfo> *visibleNodes,
-		   VisibilityContainer<MeshVisibilityInfo> *visibleMeshes ) = 0;
-  
+    virtual bool
+    ShootRay(const Ray &ray,
+	     std::vector<Mesh *> *visibleMeshes,
+	     bool isGlobalLine = false
+	     );
   
   /** Sets the scene traverser.
-      @remark the scene traverser is dependent on the type of hierarchy the scene consists of.
+      @remark the scene traverser depends on the type of hierarchyInterface the scene consists of.
   */
-  void setSceneTraverser( GtpVisibility::SceneTraverser *sceneTraverser );
+  void SetSceneTraverser(HierarchyInterface *hierarchyInterface );
 
 protected:
-	GtpVisibility::SceneTraverser *mSceneTraverser;
+    HierarchyInterface *mHierarchyInterface;
   
-  VisibilityPreprocessingInterface *mPreprocessingManager;
+};
+
 };
 
Index: /trunk/VUT/GtpVisibility/include/VisibilityCamera.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/VisibilityCamera.h	(revision 65)
+++ /trunk/VUT/GtpVisibility/include/VisibilityCamera.h	(revision 65)
@@ -0,0 +1,13 @@
+#ifndef _VisibilityCamera_H__
+#define _VisibilityCamera_H__
+
+#include "OgreCamera.h"
+
+namespace GtpVisibility {
+  /** Camera class currently uses the native Ogre camera when compiled with the Ogre platform */
+  typedef Ogre::Camera Camera;
+}
+
+
+
+#endif
Index: /trunk/VUT/GtpVisibility/include/VisibilityRay.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/VisibilityRay.h	(revision 65)
+++ /trunk/VUT/GtpVisibility/include/VisibilityRay.h	(revision 65)
@@ -0,0 +1,13 @@
+#ifndef _VisibilityRay_H__
+#define _VisibilityRay_H__
+
+#include "OgreRay.h"
+
+namespace GtpVisibility {
+  /** Ray class currently uses native Ogre ray when compiled with the Ogre platform */
+  typedef Ogre::Ray Ray;
+}
+
+
+
+#endif
Index: /trunk/VUT/GtpVisibility/include/VisibilityInfo.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/VisibilityInfo.h	(revision 59)
+++ /trunk/VUT/GtpVisibility/include/VisibilityInfo.h	(revision 65)
@@ -2,32 +2,50 @@
 #define _VisibilityInfo_H__
 
+#include <vector>
 
+#include "VisibilityMesh.h"
+#include "HierarchyInterface.h"
 
-/** Class storing the visibility information of a scene node. 
-*/
-class NodeVisibilityInfo {
-  /** pointer to the scene node */
-  SceneNode *mNode;
-  /** node visibility can either be a number of visible pixels or relative
-      number of visible pixels (if the hardware queries will provide the
-      total number of ratsterized pixels */
-  float mVisibility;
+namespace GtpVisibility {
+  
+  /** Class storing the visibility information of a scene node. 
+   */
+  class NodeInfo {
+  public:
+    NodeInfo(HierarchyNode *node,
+	     const float v):
+      mNode(node), mVisibility(v) {}
+
+  protected:
+    /** pointer to the scene node */
+    HierarchyNode *mNode;
+    /** node visibility can either be a number of visible pixels or relative
+	number of visible pixels (if the hardware queries will provide the
+	total number of ratsterized pixels */
+    float mVisibility;
+  };
+  
+  
+  /** Class storing the visibility information of a mesh. 
+   */
+  class MeshInfo {
+  public:
+    MeshInfo(Mesh *mesh,
+	     const float v):
+      mMesh(mesh), mVisibility(v) {}
+
+  protected:
+    /** pointer to the scene node */
+    Mesh *mMesh;
+    /** node visibility can either be a number of visible pixels or relative
+	number of visible pixels (if the hardware queries will provide the
+	total number of ratsterized pixels */
+    float mVisibility;
+  };
+  
+  // this define shall be replaced by template typedef
+#define InfoContainer std::vector
 };
 
 
-/** Class storing the visibility information of a mesh. 
-*/
-class MeshVisibilityInfo {
-  /** pointer to the scene node */
-  Geometry *mGeometry;
-  /** node visibility can either be a number of visible pixels or relative
-      number of visible pixels (if the hardware queries will provide the
-      total number of ratsterized pixels */
-  float mVisibility;
-};
-
-/** Default container type for visibility infos */
-temlate <typename T>
-typedef vector<T> VisibilityContainer<T>;
-
 #endif
Index: /trunk/VUT/GtpVisibility/include/VisibilityMesh.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/VisibilityMesh.h	(revision 65)
+++ /trunk/VUT/GtpVisibility/include/VisibilityMesh.h	(revision 65)
@@ -0,0 +1,12 @@
+#ifndef _VisibilityMesh_H__
+#define _VisibilityMesh_H__
+
+#include "OgreMesh.h"
+
+namespace GtpVisibility {
+  typedef Ogre::Mesh Mesh;
+}
+
+
+
+#endif
Index: /trunk/VUT/GtpVisibility/include/VisibilityAxisAlignedBox.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/VisibilityAxisAlignedBox.h	(revision 65)
+++ /trunk/VUT/GtpVisibility/include/VisibilityAxisAlignedBox.h	(revision 65)
@@ -0,0 +1,14 @@
+#ifndef _VisibilityAxisAlignedBox_H__
+#define _VisibilityAxisAlignedBox_H__
+
+#include "OgreAxisAlignedBox.h"
+
+namespace GtpVisibility {
+  /** This class currently uses the native Ogre AxisAlignedBox when
+      compiled with the Ogre platform */
+  typedef Ogre::AxisAlignedBox AxisAlignedBox;
+}
+
+
+
+#endif
Index: /trunk/VUT/GtpVisibility/include/DummyQueryManager.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/DummyQueryManager.h	(revision 65)
+++ /trunk/VUT/GtpVisibility/include/DummyQueryManager.h	(revision 65)
@@ -0,0 +1,43 @@
+#ifndef _VisibilityDummyQueryManager_H__
+#define _VisibilityDummyQueryManager_H__
+
+#include "VisibilityInfo.h"
+#include "QueryManager.h"
+
+namespace GtpVisibility {
+/** This implements dummy visibility queries. The queries return only the root of the
+    hierarchy as visible node.
+*/
+  class DummyQueryManager : public QueryManager
+  {
+  public:
+    /** Constructor taking a scene traverser for a specific type of hierarchyInterface
+	as argument. 
+    */
+    DummyQueryManager( HierarchyInterface *hierarchyInterface ):
+      QueryManager(hierarchyInterface) {}
+    
+    /**
+       @sa QueryManager::ComputeCameraVisibility()
+     */
+    virtual void
+    ComputeCameraVisibility(const Camera &camera,
+			    InfoContainer<NodeInfo> *visibleNodes,
+			    InfoContainer<MeshInfo> *visibleGeometry,
+			    bool relativeVisibility = false
+			    );
+    
+    /**
+       @sa QueryManager::ComputeFromPointVisibility()
+     */
+    virtual void
+    ComputeFromPointVisibility(const Vector3 &point,
+			       InfoContainer<NodeInfo> *visibleNodes,
+			       InfoContainer<MeshInfo> *visibleGeometry,
+			       bool relativeVisibility = false
+			       );
+    
+  };
+  
+};
+#endif // VisibilitySummyQueryManager
Index: /trunk/VUT/GtpVisibility/include/PreprocessingManager.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/PreprocessingManager.h	(revision 59)
+++ /trunk/VUT/GtpVisibility/include/PreprocessingManager.h	(revision 65)
@@ -2,87 +2,138 @@
 #define _VisibilityPreprocessingManager_H__
 
-#include "GtpVisibilitySceneTraverser.h"
-#include "GtpVisibilityInfo.h"
+#include <string>
+using namespace std;
 
+#include "HierarchyInterface.h"
+#include "VisibilityInfo.h"
+#include "VisibilityVector3.h"
 
-/** This abstract class defining interface for a specific visibility query
-    algorithm. The algorithm is either used to render the scene with false colors
-    and query visibility of scene nodes and polygons */
-*/
-class VisibilityPreprocessingInterface
-{
-public:
+namespace GtpVisibility {
+  
+  /**
+     This class defines an interface to the external visibility preprocessor.
+     It allows to export the static part of the scene to a file in the XML format
+     understood by the preprocessor. By default all the exported meshes are considered
+     as scene occluders, whereas occludees are formed by their bounding boxes,
+     and bounding boxes of the scene hierarchy.
 
+     This class also allows to import the preprocessed data with PVS
+     information for the viewcells (note that the viewcells are either generated
+     automatically by the preprocessor or loaded from a polyhedral definition stored
+     in a file (see documentation for the Preprocessor class).
+  */
+  
+  class PreprocessingManager
+  {
+  public:
+    
+    /**
+       Constructor taking a HierarchyInterface as argument.
+       The HierarchyInterface makes the PreprocessingManager independent from the actual
+       scene representation as long as it supports a required set of methods.
+     */
+    PreprocessingManager( HierarchyInterface *hierarchyInterface );
+    
 
-  /** Constructor taking a scene traverser for a specific type of hierarchy as argument. 
-   */
-	VisibilityPreprocessingInterface( GtpVisibility::SceneTraverser *sceneTraverser );
+    /**
+       Destructor which deletes all data describing static scene visibility.
+    */
+    virtual ~PreprocessingManager();
+
+    /**
+       Export the scene for visibility preprocessing. Exports the hierarchyInterface including
+       its bounding boxes + mesh data. Note that the bounding boxes can be used as occludees
+       by the extrenal preprocessor. The viewcell data will either be supplied directly to the
+       visibility preprocessing standalone module.
+
+       @param filename name of the file to export.
+       @return true if the export was succesful.
+    */
+    virtual bool ExportScene(const string filename
+			     ) = 0;
+    
+    /**
+       Load preprocessed visibility information. The loaded data is matched with the current
+       scene graph. The topology of the current scene graph has to match with the loaded data.
+       There is also geometrical check of the bounding boxes. Once loading is succesful the
+       PreprocessingManager establishes links from its internal visibility representation
+       to the scene graph: no change of this part of the scene graph is allowed; this would
+       violate the static scene assumption!
+
+       @param filename name of the file to load.
+       @return true if the loading was succesful.
+    */
+    virtual bool LoadPreprocessedData(const string filename
+				      ) = 0;
+    
+    /** 
+	Retrieve a PVS corresponding to the given spherical neighborhood of the point.
+	Typically the implementation of this method will firs locate all viewcells
+	intersecting the sphere using efficient logarithmic search enhanced with caching
+	the last query. Then it computes a union of the PVS for the found viewcells.
+
+	@param point the center point of the spherical neighborhood
+
+	@param radius the radius of the spherical neighborhood. Note that if radius==0 a
+	more efficient implementation of the method for this special case can be used.
+
+	@param visibleNodes is not NULL
+	a set of visible scene graph nodes is added to the visibleNodes container.
+	This set is formed of visible leafs or fully visible interior nodes.
+	If visibleMeshes != NULL the set of visible meshes is
+	added to the container. Returns true if the corresponding PVS exists.
+    */
+    virtual bool GetPVS(const Vector3 &point,
+			const float radius,
+			InfoContainer<NodeInfo> *visibleNodes,
+			InfoContainer<MeshInfo> *visibleMeshes );
+    
+    
   
+    /** Sets the scene traverser.
+	@remark the scene traverser is dependent on the type of hierarchyInterface the scene consists of.
+    */
+    virtual void SetSceneTraverser( HierarchyInterface *hierarchyInterface ) {
+      mSceneTraverser = hierarchyInterface;
+    }
+    
+  protected:
+    /** Get checksum of the current occluder set in the scene graph. This method is used to check
+	if the preprocessed data matches the current scene graph
+	-> $$ could be moved to VisibilitySceneTraverser */
+    long GetOccluderChecksum() const {
+      return 0;
+    }
+      
+    
+    /** Get checksum of the current occludee set in the scene graph. This method is used to check
+	if the preprocessed data matches the current scene graph
+	-> $$ could be moved to VisibilitySceneTraverser */
+    long GetOccludeeChecksum() const {
+      return 0;
+    }
+    
+    
+    /** 
+	Find viewcells intersecting a spherical neighborhood of a point.
+	Returns false if no viewcell was found.
+    */
+    virtual bool LocateViewCellIds(const Vector3 &center,
+				   const float radius,
+				   vector<int> *viewCellIds
+				   ) = 0;
+    
+    /**
+       Add a PVS of the given viewcell to the already evaluated PVS by computing
+       a union with visibleNodes and visibleMeshes. Returns the number of added entries.
+    */
+    virtual int AddViewCellPVS(const int cellID,
+			       InfoContainer<NodeInfo> *visibleNodes,
+			       InfoContainer<MeshInfo> *visibleMeshes ) = 0;
+    
+    HierarchyInterface *mSceneTraverser;
+  };
   
-  /** 
-      Export the scene for visibility preprocessing. Exports the hierarchy including
-      its bounding boxes + mesh data for occluders. The viewcell data will either be
-      supplied directly to the visibility preprocessing standalone module
-  */
-  virtual ErrorCode ExportScene(const string filename);
-  
-  
-  /** 
-      Load preprocessed visibility information
-  */
-  virtual ErrorCode LoadPreprocessedData(const string filename);
-  
-  /** 
-      Uses the specified sphere to find its PVS
-  */
-  virtual ErrorCode GetPointPVS(const Vector3D &point,
-				VisibilityContainer<NodeVisibilityInfo> *visibleNodes,
-				VisibilityContainer<MeshVisibilityInfo> *visibleMeshes ) = 0;
-  
-  /** 
-      Uses the specified sphere to find its PVS
-  */
-  virtual ErrorCode GetSpherePVS(const Vector3D &point,
-				 const float radius,
-				 VisibilityContainer<NodeVisibilityInfo> *visibleNodes,
-				 VisibilityContainer<MeshVisibilityInfo> *visibleMeshes ) = 0;
-
-  
-  
-  /** Sets the scene traverser.
-      @remark the scene traverser is dependent on the type of hierarchy the scene consists of.
-  */
-  void setSceneTraverser( GtpVisibility::SceneTraverser *sceneTraverser );
-
-protected:
-  /** Helper method for getting a scene name */
-  string GetSceneName() const;
-
-  /** Get checksum of the current occluder set in the scene graph. This method is used to check
-      if the preprocessed data matches the current scene graph
-      -> $$ could be moved to VisibilitySceneTraverser */
-  long GetOccluderChecksum() const;
-
-  /** Get checksum of the current occludee set in the scene graph. This method is used to check
-      if the preprocessed data matches the current scene graph
-      -> $$ could be moved to VisibilitySceneTraverser */
-  long GetOccludeeChecksum() const;
-
-  /** 
-      Finds a viewcell given a point in space
-  */
-  virtual ErrorCode FindViewCellId(const Vector3D &point,
-				   int *viewCellId
-				   );
-
-  /** 
-      Uses the specified viewcell to find its PVS
-  */
-  virtual ErrorCode GetViewCellPVS(const int cellID,
-				   VisibilityContainer<NodeVisibilityInfo> *visibleNodes,
-				   VisibilityContainer<MeshVisibilityInfo> *visibleMeshes ) = 0;
-
-  GtpVisibility::SceneTraverser *mSceneTraverser;
 };
 
-#endif // VisibilityPreprocessingManager
+#endif // VisibilityPreprocessingInterafce
Index: /trunk/VUT/GtpVisibility/include/VisibilityManager.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/VisibilityManager.h	(revision 59)
+++ /trunk/VUT/GtpVisibility/include/VisibilityManager.h	(revision 65)
@@ -4,4 +4,5 @@
 #include "CullingManager.h"
 #include "VisibilityEnvironment.h"
+
 
 /** This namespace includes all classes which are created by the VUT (Vienna University
@@ -12,4 +13,7 @@
 namespace GtpVisibility {
 
+  class QueryManager;
+  class PreprocessingManager;
+  
 /** This class manages all forms of visibility. It is the main
 	class of our visibility module and manages online occlusion culling,
@@ -41,7 +45,9 @@
 protected:
 	
-	CullingManager *mCullingManager;
-	VisibilityEnvironment *mVisibilityEnvironment;
-	VisibilityEnvironment::CullingManagerType mCullingManagerType;
+  CullingManager *mCullingManager;
+  QueryManager *mQueryManager;
+  PreprocessingManager *mPreprocessingManager;
+  VisibilityEnvironment *mVisibilityEnvironment;
+  VisibilityEnvironment::CullingManagerType mCullingManagerType;
 };
 } // namespace GtpVisibility
Index: /trunk/VUT/GtpVisibility/scripts/GtpVisibility.pro
===================================================================
--- /trunk/VUT/GtpVisibility/scripts/GtpVisibility.pro	(revision 65)
+++ /trunk/VUT/GtpVisibility/scripts/GtpVisibility.pro	(revision 65)
@@ -0,0 +1,31 @@
+
+TEMPLATE = app
+
+TARGET = visibility
+
+INCLUDEPATH += ../include \
+c:/stlport-4.6.2/stlport \
+D:\gametools\ogrenew\PlugIns\OctreeSceneManager\include \
+d:/gametools/ogrenew/OgreMain/include
+
+# debuc config
+CONFIG		+= console warn_on debug thread
+
+#DEFINES 	+=EXT_HASH
+# RELEASE CONFIG
+#CONFIG		+= windows warn_on thread
+
+# DEPENDPATH	= ../../include
+
+# Input
+HEADERS += 
+
+	
+SOURCES += \
+CoherentHierarchicalCullingManager.cpp  PreprocessingManager.cpp \
+CullingManager.cpp                      QueryManager.cpp \
+DummyPreprocessingManager.cpp           StopAndWaitCullingManager.cpp \
+DummyQueryManager.cpp                   VisibilityEnvironment.cpp \
+FrustumCullingManager.cpp               VisibilityManager.cpp \
+HierarchyInterface.cpp
+
Index: /trunk/VUT/GtpVisibility/src/PreprocessingManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/PreprocessingManager.cpp	(revision 65)
+++ /trunk/VUT/GtpVisibility/src/PreprocessingManager.cpp	(revision 65)
@@ -0,0 +1,28 @@
+#include "PreprocessingManager.h"
+
+namespace GtpVisibility {
+  
+  
+  bool
+  PreprocessingManager::GetPVS(
+			       const Vector3 &center,
+			       const float radius,
+			       InfoContainer<NodeInfo> *visibleNodes,
+			       InfoContainer<MeshInfo> *visibleMeshes )
+  {
+    vector<int> viewCellIds;
+    if (LocateViewCellIds(center, radius, &viewCellIds)) {
+      for (vector<int>::iterator ci = viewCellIds.begin();
+	   ci != viewCellIds.end();
+	   ci++) {
+	AddViewCellPVS(*ci,
+		       visibleNodes,
+		       visibleMeshes );
+	// remove duplicates of the PVS entries if any?
+      }
+      return true;
+    }
+    return false;
+  }
+  
+};
Index: /trunk/VUT/GtpVisibility/src/QueryManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/QueryManager.cpp	(revision 65)
+++ /trunk/VUT/GtpVisibility/src/QueryManager.cpp	(revision 65)
@@ -0,0 +1,19 @@
+#include "QueryManager.h"
+
+
+namespace GtpVisibility {
+  
+  bool
+  QueryManager::ShootRay(const Ray &ray,
+			 std::vector<Mesh *> *visibleMeshes,
+			 bool isGlobalLine
+			 )
+  {
+    // run OGRE ray shooting query
+    
+
+    return false;
+  }
+  
+  
+};
Index: /trunk/VUT/GtpVisibility/src/VisibilityManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/VisibilityManager.cpp	(revision 59)
+++ /trunk/VUT/GtpVisibility/src/VisibilityManager.cpp	(revision 65)
@@ -3,4 +3,6 @@
 #include "CoherentHierarchicalCullingManager.h"
 #include "FrustumCullingManager.h"
+#include "DummyPreprocessingManager.h"
+#include "DummyQueryManager.h"
 
 namespace GtpVisibility {
@@ -13,4 +15,8 @@
 	mCullingManagerType = VisibilityEnvironment::FRUSTUM_CULLING;
 	mCullingManager = new FrustumCullingManager(0);
+
+	mQueryManager = new DummyQueryManager(0);
+	mPreprocessingManager = new DummyPreprocessingManager(0);
+
 }
 
Index: /trunk/VUT/GtpVisibility/src/DummyPreprocessingManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/DummyPreprocessingManager.cpp	(revision 65)
+++ /trunk/VUT/GtpVisibility/src/DummyPreprocessingManager.cpp	(revision 65)
@@ -0,0 +1,55 @@
+#include "DummyPreprocessingManager.h"
+
+namespace GtpVisibility {
+
+DummyPreprocessingManager::DummyPreprocessingManager( HierarchyInterface *hierarchyInterface )
+  :PreprocessingManager(hierarchyInterface)
+{
+}
+  
+
+bool
+DummyPreprocessingManager::ExportScene(const string filename)
+{
+  ofstream s(filename.c_str());
+  s<<"#VRML 2.0 utf8"<<endl;
+  s<<"#Dummy module output"<<endl;
+  return true;
+}
+  
+
+bool
+DummyPreprocessingManager::LoadPreprocessedData(const string filename)
+{
+  // do nothing
+  return false;
+}
+
+  
+  /** 
+      Find viewcells intersecting a spherical neighborhood of a point.
+      Returns false if no viewcell was found.
+    */
+bool
+DummyPreprocessingManager::LocateViewCellIds(const Vector3 &center,
+					     const float radius,
+					     vector<int> *viewCellIds
+					     )
+{
+  return false;
+}
+  
+/** 
+    Uses the specified viewcell to find its PVS
+*/
+int
+DummyPreprocessingManager::AddViewCellPVS(const int cellID,
+					  InfoContainer<NodeInfo> *visibleNodes,
+					  InfoContainer<MeshInfo> *visibleMeshes )
+{
+  // return the root of the hierarchyInterface regardless of the cellId
+  //  visibleNodes->push_back(traverser->GetRoot());
+  return false;
+}
+
+}
Index: /trunk/VUT/GtpVisibility/src/DummyQueryManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/DummyQueryManager.cpp	(revision 65)
+++ /trunk/VUT/GtpVisibility/src/DummyQueryManager.cpp	(revision 65)
@@ -0,0 +1,44 @@
+#include "DummyQueryManager.h"
+
+
+namespace GtpVisibility {
+
+  /** 
+	Uses explicit camera to execute the visibility query
+  */
+  void
+  DummyQueryManager::ComputeCameraVisibility(const Camera &camera,
+					     InfoContainer<NodeInfo> *visibleNodes,
+					     InfoContainer<MeshInfo> *visibleGeometry,
+					     bool relativeVisibility
+					     )
+  {
+    visibleNodes->push_back(NodeInfo(mHierarchyInterface->GetSceneRoot(), 1.0f));
+    
+//      HierarchyInterface::MeshIterator *mi =
+//        hierarchyInterface->GetMeshIterator(hierarchyInterface->GetRoot());
+    
+//      for (; mi(); mi++)
+//        visibleGeometry.push_back(MeshInfo(*mi, 1.0f));
+  }
+  
+  /** 
+      Uses the specified point to execute the visibility query in all directions
+  */
+  void
+  DummyQueryManager::ComputeFromPointVisibility(const Vector3 &point,
+						InfoContainer<NodeInfo> *visibleNodes,
+						InfoContainer<MeshInfo> *visibleGeometry,
+						bool relativeVisibility
+						)
+  {
+    visibleNodes->push_back(NodeInfo(mHierarchyInterface->GetSceneRoot(), 1.0f));
+    
+//      HierarchyInterface::MeshIterator *mi =
+//        hierarchyInterface->GetMeshIterator(hierarchyInterface->GetRoot());
+    
+//      for (; mi(); mi++)
+//        visibleGeometry.push_back(MeshInfo(*mi, 1.0f));
+  }
+  
+};
Index: /trunk/VUT/work/tools/replid
===================================================================
--- /trunk/VUT/work/tools/replid	(revision 65)
+++ /trunk/VUT/work/tools/replid	(revision 65)
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+#$Id: replid,v 1.2 1999/11/06 21:23:19 bittner Exp $
+# Initially coding Jiri Bittner
+    
+if [ $# -lt 3 ]; then echo "Usage: replid strA strB file_list $1 $2"; fi
+
+STR1=$1
+STR2=$2
+
+shift
+shift
+FILES=`grep -l $STR1 $*`
+
+echo $FILES
+
+SEPARATORS='[^a-zA-Z0-9_\.]'
+BACKUPDIR="Backup"
+
+if [ ! -d $BACKUPDIR ]; then  mkdir $BACKUPDIR; fi
+
+for FILE in $FILES; do
+ echo "Replacing in $FILE"
+ cp $FILE $BACKUPDIR/$FILE
+ CMD='-e s/\('$SEPARATORS'\)'$STR1'\('$SEPARATORS'\)/\1'$STR2'\2/g -e  s/^'$STR1'\('$SEPARATORS'\)/'$STR2'\1/g  -e  s/\('$SEPARATORS'\)'$STR1'$/\1'$STR2'/g -e  s/^'$STR1'$/'$STR2'/g'
+# echo $CMD
+ sed $CMD < $BACKUPDIR/$FILE > $FILE.tmp
+ mv $FILE.tmp $FILE
+done
+
+
+
+
+
+
+
Index: /trunk/VUT/work/tools/batch_replace
===================================================================
--- /trunk/VUT/work/tools/batch_replace	(revision 65)
+++ /trunk/VUT/work/tools/batch_replace	(revision 65)
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# $Id: brepl,v 1.2 1999/11/06 21:23:19 bittner Exp $
+# Script used to globaly replace identifiers in GOLEM on 6.11. 1999
+# Initially coding Jiri Bittner
+
+# some manual changed to the code were also neccesary
+# - stats.h members of classes CIntersections and CObjects (class name collisions)
+# - hfield.h member BoundingBox
+# - world.cpp environment strings (e.g. CBSP -> BSP)
+# ...
+
+    
+FILES=$*
+
+#replid  Vector3D Vector3 $FILES
+#replid  Visibility GtpVisibility $FILES
+#replid  SceneTraverser HierarchyInterface $FILES
+replid  Visibility GtpVisibilityPreprocessor $FILES
+
+
Index: /trunk/VUT/GtpVisibilityPreprocessor/scripts/preprocessor.pro
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/scripts/preprocessor.pro	(revision 65)
+++ /trunk/VUT/GtpVisibilityPreprocessor/scripts/preprocessor.pro	(revision 65)
@@ -0,0 +1,21 @@
+
+TEMPLATE = app
+
+TARGET = preprocessor
+
+INCLUDEPATH += ../include
+
+# debuc config
+CONFIG		+= console warn_on debug thread
+
+# RELEASE CONFIG
+#CONFIG		+= windows warn_on thread
+
+# DEPENDPATH	= ../../include
+
+# Input
+HEADERS += 
+
+	
+SOURCES += Preprocessor.cpp SamplingPreprocessor.cpp ExactPreprocessor.cpp KdTree.cpp
+
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp	(revision 65)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp	(revision 65)
@@ -0,0 +1,11 @@
+#include "KdTree.h"
+
+namespace GtpVisibilityPreprocessor {
+  
+  bool
+  KdTree::Subdivide(KdNode *subtree)
+  {
+    return true;
+  }
+
+}
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp	(revision 65)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp	(revision 65)
@@ -0,0 +1,14 @@
+#include "SamplingPreprocessor.h"
+
+namespace GtpVisibilityPreprocessor {
+  
+  bool
+  SamplingPreprocessor::ComputeVisibility()
+  {
+
+    return true;
+  };
+  
+};
+
+
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp	(revision 65)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp	(revision 65)
@@ -0,0 +1,54 @@
+#include "Preprocessor.h"
+#include "SamplingPreprocessor.h"
+#include "ExactPreprocessor.h"
+
+namespace GtpVisibilityPreprocessor {
+
+  bool
+  Preprocessor::LoadViewcells(const string filename)
+  {
+
+    return true;
+  }
+
+  bool
+  Preprocessor::GenerateViewcells()
+  {
+    
+    return true;
+  }
+    
+  bool
+  Preprocessor::LoadScene(const string filename)
+  {
+    // use leaf nodes of the original spatial hiearrchy as occludees
+    
+    return true;
+  }
+
+  bool
+  Preprocessor::ExportPreprocessedData(const string filename)
+  {
+    return false;
+  }
+  
+  bool
+  Preprocessor::BuildKdTree()
+  {
+    mKdTree = new KdTree;
+    mKdTree->Subdivide(mKdTree->GetRoot());
+    return true;
+  }
+  
+};
+
+int
+main(int argc, char **argv)
+{
+  GtpVisibilityPreprocessor::Preprocessor *p = new GtpVisibilityPreprocessor::SamplingPreprocessor();
+  p->LoadScene("scene.wrl");
+  p->LoadViewcells("viewcells.wrl");
+  p->ComputeVisibility();
+  p->ExportPreprocessedData("scene.vis");
+  return 0;
+}
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/ExactPreprocessor.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/ExactPreprocessor.cpp	(revision 65)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/ExactPreprocessor.cpp	(revision 65)
@@ -0,0 +1,14 @@
+#include "ExactPreprocessor.h"
+
+namespace GtpVisibilityPreprocessor {
+  
+  bool
+  ExactPreprocessor::ComputeVisibility()
+  {
+
+    return true;
+  };
+  
+};
+
+
