source: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h @ 1884

Revision 1884, 6.8 KB checked in by bittner, 18 years ago (diff)

temporary version, rss preprocessor not functional

RevLine 
[372]1#ifndef _Preprocessor_H__
2#define _Preprocessor_H__
3
4#include <string>
5using namespace std;
6#include "Containers.h"
7#include "Mesh.h"
8#include "KdTree.h"
9
[492]10
[860]11namespace GtpVisibilityPreprocessor {
[1867]12  class PreprocessorThread;
13 
[409]14class RenderSimulator;
[372]15class SceneGraph;
[429]16class Exporter;
[439]17class ViewCellsManager;
[445]18class BspTree;
[1006]19class VspOspTree;
[445]20class VspBspTree;
[468]21class RenderSimulator;
[490]22struct VssRayContainer;
[1020]23class SamplingStrategy;
[496]24class GlRendererBuffer;
[1022]25class VspTree;
[1279]26class HierarchyManager;
[1264]27class BvHierarchy;
[1221]28class Intersectable;
[1287]29class VssRay;
[1520]30class RayCaster;
[490]31
[1520]32
[372]33/** Namespace for the external visibility preprocessor
34
35    This namespace includes all classes which are created by the VUT (Vienna University
36    of Technology) for the External Visibility Preprocessor of the GTP (GameTools Project)
37    (www.gametools.org).
38*/
39 
[1145]40/** Main class of the visibility preprocessor. Responsible for loading and
41    saving of the input and output files. Initiates construction of the kD-tree,
42    viewcell loading/generation and the visibility computation itself.
43*/
[1521]44class Preprocessor
[1145]45{
[1520]46        friend class RayCaster;
47        friend class IntelRayCaster;
48        friend class InternalRayCaster;
[1564]49
[372]50public:
51        /** Default constructor initialising e.g., KD tree and BSP tree.
52        */
53        Preprocessor();
54
[1520]55        virtual ~Preprocessor();
[372]56
[1564]57        /** Load the input scene.
58        @param filename file to load
59        @return true on success
60        */
61        virtual bool LoadScene(const string filename);
[372]62
[1564]63        /** Export all preprocessed data in a XML format understandable by the
64        PreprocessingInterface of the GtpVisibilityPreprocessor Module.
65        The file can be compressed depending on the environement settings.
66        @return true on successful export
67        */
68        virtual bool ExportPreprocessedData(const string filename);
[871]69
[1564]70        /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction
71        is driven by the environment settings, which also sais which of the three types of
72        entities should be used to drive the heuristical construction (only occluders by default)
73        */
74        virtual bool BuildKdTree();
[871]75
[1564]76        /** Compute visibility method. This method has to be reimplemented by the actual
77        Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor,
78        GlobalSamplingpreprocessor)
79        */
80        virtual bool ComputeVisibility() = 0;
[1292]81
[1564]82        /** Post Process the computed visibility. By default applys the visibility filter
83        (if specified in the environment and export the preprocessed data */
84        virtual bool PostProcessVisibility();
[1292]85
[1564]86        /** View cells are either loaded or prepared for generation, according to the chosen environment
87        object. Important evironment options are, e.g, the view cell type.
88        Should be done after scene loading (i.e., some options are based on scene type).
89        */
90        bool PrepareViewCells();
[1020]91
[1564]92        /** Construct viewcells from the scratch
93        */
94        bool ConstructViewCells();
95
96        /** Returns the specified sample strategy, NULL if no valid strategy.
97        */
[1884]98        SamplingStrategy *GenerateSamplingStrategy(const int strategyId);
[1564]99
100        /** Export preprocessor data.
101        */
[1695]102        bool Export(const string filename, const bool scene, const bool kdtree); 
[372]103
[1564]104        virtual void KdTreeStatistics(ostream &s);
105        virtual void BspTreeStatistics(ostream &s);
[490]106
[1564]107        /** Loads samples from file.
108        @param samples returns the stored sample rays
109        @param objects needed to associate the objects ids
110        @returns true if samples were loaded successfully
111        */
112        bool LoadSamples(VssRayContainer &samples,
[1695]113                                         ObjectContainer &objects) const;
[508]114
[1564]115        /** Exports samples to file.
116        @returns true if samples were written successfully
117        */
118        bool ExportSamples(const VssRayContainer &samples) const;
[1197]119
[1564]120        bool LoadKdTree(const string filename);
121        bool ExportKdTree(const string filename);
[1381]122
[1786]123        virtual int
[1867]124        GenerateRays(const int number,
125                                 SamplingStrategy &strategy,
126                                 SimpleRayContainer &rays);
[1786]127
[1867]128  virtual int GenerateRays(const int number,
129                                                   const int raysType,
130                                                   SimpleRayContainer &rays);
[1786]131
132        bool GenerateRayBundle(SimpleRayContainer &rayBundle,
133                const SimpleRay &mainRay,
134                const int number,
135                const int shuffleType) const;
136
137        virtual void CastRays(SimpleRayContainer &rays,
[1867]138                                                  VssRayContainer &vssRays,
139                                                  const bool castDoubleRays,
140                                                  const bool pruneInvalidRays = true);
[1786]141
[1564]142        /** Returns a view cells manager of the given name.
143        */
144        ViewCellsManager *CreateViewCellsManager(const char *name);
[1221]145
[1564]146        GlRendererBuffer *GetRenderer();
[492]147
[1564]148        bool InitRayCast(const string externKdTree, const string internKdTree);
[409]149
[1786]150        bool ExportObj(const string filename, const ObjectContainer &objects);
[429]151
[1786]152        Intersectable *GetParentObject(const int index) const;
153Vector3 GetParentNormal(const int index) const;
[1564]154        ////////////////////////////////////////////////
[538]155
[1564]156        /// scene graph loaded from file
157        SceneGraph *mSceneGraph;
[599]158
[1564]159        /// raw array of objects
160        ObjectContainer mObjects;
[658]161
[1564]162        /// kD-tree organizing the scene graph (occluders + occludees) + viewcells
163        KdTree *mKdTree;
164        /// View space partition bsp tree
165        VspBspTree *mVspBspTree;
166        /// BSP tree representing the viewcells
167        BspTree *mBspTree;
[878]168
[1564]169        /// list of all loaded occluders
170        ObjectContainer mOccluders;
171        /// list of all loaded occludees
172        ObjectContainer mOccludees;
[1221]173
[1251]174
[1564]175        ViewCellsManager *mViewCellsManager;
176
177        /// greedy optimized hierarchy for both objects and view cells
178        VspOspTree *mVspOspTree;
179
180        bool mUseGlRenderer;
181        bool mUseGlDebugger;
182
183        bool mLoadViewCells;
184
185        bool mDetectEmptyViewSpace;
186
187        bool mQuitOnFinish;
188        bool mLoadMeshes;
189        bool mComputeVisibility;
190
191        bool mExportVisibility;
192        string mVisibilityFileName;
193
194        bool mApplyVisibilityFilter;
195        bool mApplyVisibilitySpatialFilter;
196
197        float mVisibilityFilterWidth;
198
199        int mPass;
[1723]200 
201    bool mDelayVisibilityComputation;
202        bool mStopComputation;
[1613]203 
[1695]204        bool mExportObj;
205
[1786]206        ofstream mStats;
[1771]207
[1785]208  GlRendererBuffer *renderer;
209
[1867]210  void SetThread(PreprocessorThread *t) {
211        mThread = t;
212  }
213
214  PreprocessorThread *GetThread() const {
215        return mThread;
216  }
217
[492]218protected:
219
[1658]220        bool LoadBinaryObj(const string filename,
221                                           SceneGraphNode *root,
222                                           vector<FaceParentInfo> *parents);
223
224        bool ExportBinaryObj(const string filename, SceneGraphNode *root);
225
[1520]226        void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction) const;
[1251]227
[1520]228        void EvalPvsStat();
[492]229
[1786]230        virtual void EvalViewCellHistogram();
[1771]231
[1520]232        /////////////////////////
233
[1564]234        RayCaster *mRayCaster;
235        /// samples used for construction of the BSP view cells tree.
236        int mBspConstructionSamples;
237        /// samples used for construction of the VSP OSP tree.
238        int mVspOspConstructionSamples;
[1786]239        /// Simulates rendering of the scene.
[1564]240        RenderSimulator *mRenderSimulator;
[1520]241
[1564]242        vector<FaceParentInfo> mFaceParents;
[492]243
[1564]244
[1723]245        /// if box around view space should be used
246        bool mUseViewSpaceBox;
[1867]247
248  PreprocessorThread *mThread;
[372]249};
250
[1867]251  extern Preprocessor *preprocessor;
[372]252
[860]253}
254
[372]255#endif
Note: See TracBrowser for help on using the repository browser.