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

Revision 1942, 7.0 KB checked in by bittner, 18 years ago (diff)

tmp commit

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