source: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h @ 2575

Revision 2575, 39.2 KB checked in by bittner, 17 years ago (diff)

big merge: preparation for havran ray caster, check if everything works

RevLine 
[440]1#ifndef _ViewCellsManager_H__
2#define _ViewCellsManager_H__
3
4#include "Ray.h"
[2105]5#include "SimpleRay.h"
[440]6#include "VssRay.h"
7#include "Containers.h"
[475]8#include "ViewCell.h"
[440]9
[2332]10#define TEST_PACKETS 0
[2176]11
[860]12namespace GtpVisibilityPreprocessor {
13
[440]14class ViewCell;
15class Intersectable;
16class RenderSimulator;
[480]17class Renderer;
[440]18class Mesh;
19struct Triangle3;
20class SimulationStatistics;
21class BspTree;
22class KdTree;
[1006]23class VspOspTree;
[440]24class VspBspTree;
25class KdNode;
26class KdLeaf;
27class AxisAlignedBox3;
[448]28class BspLeaf;
[475]29class ViewCellsStatistics;
[482]30class Exporter;
[532]31class Beam;
[570]32class Preprocessor;
[580]33class ViewCellsTree;
34class MergeCandidate;
[931]35class BoundingBoxConverter;
[1021]36class VspTree;
37class OspTree;
38class VspNode;
[1027]39class HierarchyManager;
[1259]40class BvHierarchy;
[1264]41class ViewCellsTree;
[1786]42class ViewCell;
[1903]43class MixtureDistribution;
[1047]44struct AxisAlignedPlane;
[475]45struct BspRay;
[2116]46class BspTree;
[475]47
[1903]48
[2015]49
[2116]50struct PvsFilterStatistics
51{
[1773]52        PvsFilterStatistics():
[2116]53        mAvgFilterRadius(0.0f), mLocalFilterCount(0), mGlobalFilterCount(0) {}
54       
[1761]55        float mAvgFilterRadius;
56        int mLocalFilterCount;
57        int mGlobalFilterCount;
[2116]58};
59
[1145]60/** Probably Visible Set
61*/
[697]62class PrVs
63{
64public:
[2116]65        /// root of view cells tree
66        ViewCell *mViewCell;
67        // input parameter is the render budget for the PrVs
68        float mRenderBudget;
[677]69};
70
[1786]71
72class LocalMergeNode
73{
74public:
75        virtual ~LocalMergeNode() {};
76        virtual bool IsLeaf() const = 0;
77};
78
[2017]79typedef pair<ViewCell *, SimpleRayContainer> ViewCellPoints;
[1786]80
[2571]81struct VizBuffer
82{
83        VizBuffer(): mIndex(0), mMaxSize(10000)
84        {
85        }
86
87        int GetSize() const {return (int)mVizRays.size();}
88
89        void AddRay(VssRay *ray)
90        {
91                if (mVizRays.size() < mMaxSize)
92                        mVizRays.push_back(ray);
93                else
94                        mVizRays[mIndex] = ray;
95               
96                mIndex = (mIndex + 1) % mMaxSize;
97        }
98
99        VssRayContainer &GetRays() { return mVizRays;}
100
101        VssRay *GetRay(int i) { return mVizRays[i % 100];}
102
103protected:
104
105        const int mMaxSize;
106        int mIndex;
107        VssRayContainer mVizRays;
108};
109
110
[850]111/**     Manages different higher order operations on the view cells.
[440]112*/
113class ViewCellsManager
114{
115public:
[1983]116
[2116]117        struct PerViewCellStat
118        {
119                float pvsSize;
120                float relPvsIncrease;
[1983]121        };
122
[2116]123        struct SamplesStatistics
[728]124        {
[2116]125                int mRays;
126                int mViewCells;
127                int mContributingRays;
128                int mPvsContributions;
129                void Reset()
130                {
131                        mRays = 0;
132                        mViewCells = 0;
133                        mContributingRays = 0;
134                        mPvsContributions = 0;
135                };
136        };
[1974]137
[2116]138        struct PvsStatistics
139        {
140                float minPvs;
141                float maxPvs;
142                float avgPvs;
[2205]143                float renderCost;
[2116]144                float avgPvsEntries;
145
146                float avgFilteredPvs;
147                float avgFilteredPvsEntries;
148
149                float avgFilterContribution;
150                float avgFilterRadius;
151                float avgFilterRatio;
152                float avgRelPvsIncrease;
153                float devRelPvsIncrease;
154                int viewcells;
[2224]155
156                float mem;
[2227]157                float renderCostRatio;
[1545]158        };
[1942]159 
[728]160        /// view cell container types
[1021]161        enum {BSP, KD, VSP_KD, VSP_BSP, VSP_OSP};
[466]162 
[931]163        /// render cost evaluation type
[728]164        enum {PER_OBJECT, PER_TRIANGLE};
165
[1545]166        friend class X3dViewCellsParseHandlers;
[1709]167
[1004]168        /** Default constructor.
[440]169        */
[1264]170        ViewCellsManager(ViewCellsTree *viewCellsTree);
[2539]171        /** Destructor.
172        */
[462]173        virtual ~ViewCellsManager();
[527]174        /** Constructs view cells container taking a preprocessor
[570]175                @returns the output rays (if not null)
176        */
177        int Construct(Preprocessor *preprocessor, VssRayContainer *outRays = NULL);
[527]178
[440]179        /** Constructs view cell container with a given number of samples.
180        */
[1709]181        virtual int ConstructSubdivision(const ObjectContainer &objects,
182                                                                         const VssRayContainer &rays) = 0;
[440]183
[441]184        /** Computes sample contributions of the rays to the view cells PVS.
185       
186                @param rays bundle of rays used to find intersections with view cells and
187                adding the contribution
[563]188                @param addRays true if rays should be added to the PVSs of the viewcells they
[574]189                intersect
190                @param storeViewCells true if view cells should be stored in the ray
191        */
[2332]192        virtual float ComputeSampleContributions(const VssRayContainer &rays,
193                                                     const bool addContributions,
194                                                                                         const bool storeViewCells,
195                                                                                         const bool useHitObject = false);
[440]196
[475]197        /** Computes sample contribution of a simgle ray to the view cells PVS.
198                @param ray finds intersections with view cells and holds the contribution
[1570]199                @param addSample if sample should be added to the pvs
200                 
[475]201                @returns number of sample contributions
202        */
[1159]203        virtual float ComputeSampleContribution(VssRay &ray,
[1981]204                                                                                        const bool addContributions,
[1990]205                                                                                        const bool storeViewCells,
206                                                                                        const bool useHitObject = false);
[1977]207        /** Compute sample contribution only for current view cell.
208        */
209        virtual float ComputeSampleContribution(VssRay &ray,
[1981]210                                                                                        const bool addContributions,
[1990]211                                                                                        ViewCell *currentViewCell,
212                                                                                        const bool useHitObject = false);
[452]213        /** Prints out statistics of the view cells.
214        */
[2176]215        virtual void PrintStatistics(std::ostream &s) const;
[440]216        /** Post processes view cells givemŽa number of rays.
217        */
[475]218        virtual int PostProcess(const ObjectContainer &objects,
219                                                        const VssRayContainer &rays) = 0;
[440]220        /** Show visualization of the view cells.
221        */
222        virtual void Visualize(const ObjectContainer &objects,
[466]223                                                   const VssRayContainer &sampleRays) = 0;
[1982]224        /** collect objects intersecting a given spatial box.
225        */
226        virtual void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects);
[440]227        /** type of the view cell container.
228        */
229        virtual int GetType() const = 0;
[463]230        /** Load the input viewcells. The input viewcells should be given as a collection
[1545]231                of meshes. Each mesh is assume to form a bounded polyhedron
232                defining the interior of the viewcell. The view cells manager
233                is responsible for building a hierarchy over these view cells.
[463]234               
235                @param filename file to load
236                @return true on success
[1982]237        */
238        virtual bool LoadViewCellsGeometry(const string filename, const bool extrudeBaseTriangle);
[440]239        /** Merges two view cells.
240                @note the piercing rays of the front and back will be ordered   
241                @returns new view cell based on the merging.
242        */
[582]243        ViewCellInterior *MergeViewCells(ViewCell *front, ViewCell *back) const;
244        /** Merges a container of view cells.
245                @returns new view cell based on the merging.
246        */
247        ViewCellInterior *MergeViewCells(ViewCellContainer &children) const;
[1545]248        /** Generates view cell of the type specified by this manager
[440]249        */
[580]250        virtual ViewCell *GenerateViewCell(Mesh *mesh = NULL) const = 0;
[1545]251        /** Constructs view cell from base triangle.
252                The view cell is extruded along the normal vector.
253                @param the base triangle
254                @param the height of the newly created view cell
[440]255        */
[1545]256        ViewCell *ExtrudeViewCell(const Triangle3 &baseTri, const float height) const;
[2539]257        /** Returns the intersectable that was hit by the ray.
258        */
[1982]259        virtual Intersectable *GetIntersectable(const VssRay &ray, const bool isTermination) const;
[440]260        /** Sets maximal number of samples used for the
261                construction of the view cells.
262        */
263        void SetVisualizationSamples(const int visSamples);
[574]264        /** Sets maximal number of samples used for the construction of the view cells.
[440]265        */
266        void SetConstructionSamples(const int constructionSamples);
[574]267        /** Sets maximal number of samples used for the visualization of the view cells.
268        */
269        void SetInitialSamples(const int initialSamples);
[440]270        /** Sets maximal number of samples used for the post processing of the view cells.
271        */
272        void SetPostProcessSamples(const int postProcessingSamples);
273        /** See set.
274        */
275        int GetVisualizationSamples() const;
276        /** See set.
277        */
278        int GetConstructionSamples() const;
279        /** See set.
280        */
281        int GetPostProcessSamples() const;
[1002]282        /** Returns true if view cells are already constructed.
[440]283        */
284        virtual bool ViewCellsConstructed() const = 0;
[477]285        /** cast line segment to get a list of unique viewcells which are intersected
286                by this line segment
287        */
[1977]288        virtual int CastLineSegment(const Vector3 &origin,
[2539]289                                                            const Vector3 &termination,
290                                                            ViewCellContainer &viewcells) = 0;
[1977]291        /** Tests if this line segment intersects a particular view cell.
292        */
293        virtual bool LineSegmentIntersects(const Vector3 &origin,
294                                                                           const Vector3 &termination,
295                                                                           ViewCell *viewCell) = 0;
[1294]296        /** Returns a stats about the global pvs.
297        */
[477]298        virtual void GetPvsStatistics(PvsStatistics &stat);
[2539]299        /** Returns the probably visible set of the view space filtered pvs.
300        */
[904]301        virtual void GetPrVS(const Vector3 &viewPoint, PrVs &prvs, const float filterWidth);
[2111]302        /** Get a viewcell containing the specified view point.
[879]303                @param active if the active or elementary view cell should be returned.
[697]304        */
[879]305        virtual ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const = 0;
[2539]306        /** Returns the view cell with the given index (different from the id).
307        */
[1982]308        ViewCell *GetViewCell(const int idx) const {return mViewCells[idx];}
[2539]309        /** Prints the statistics over the view cell pvss.
310        */
[2176]311        virtual void PrintPvsStatistics(std::ostream &s);
[719]312        /** Updates pvs of the view cell hierarchy if necessary.
313        */
314        void UpdatePvs();
[477]315        /** Returns probability that view point lies in one view cell.
316        */
317        virtual float GetProbability(ViewCell *viewCell) = 0;
318        /** Returns render cost of a single view cell given the render cost of an object.
319        */
[728]320        float GetRendercost(ViewCell *viewCell) const;
[720]321        /** Returns reference to container of loaded / generated view cells.
[477]322        */
323        ViewCellContainer &GetViewCells();
[485]324        /** Helper function used to split ray sets uniformly
325                into one that is currently used and the other that
326                is saved for later processing.
327                @param sourceRays the input ray set
328                @param maxSize the maximal number of rays that will be used
329                @param usedRays returns the used ray set
330                @param savedRays if not null, returns the saved ray set
[477]331        */
332        void GetRaySets(const VssRayContainer &sourceRays,
[485]333                                        const int maxSize,
334                                        VssRayContainer &usedRays,
335                                        VssRayContainer *savedRays = NULL) const;
[480]336        /** Returns accumulated area of all view cells.
337        */
338        float GetAccVcArea();
339        /** Returns area of one view cell.
340        */
341        virtual float GetArea(ViewCell *viewCell) const;
[551]342        /** Returns volume of view cell.
[480]343        */
344        virtual float GetVolume(ViewCell *viewCell) const;
345        /** Sets the current renderer mainly for view cells statistics.
346        */
347        void SetRenderer(Renderer *renderer);
[487]348        /** Computes a (random) view point in the valid view space.
349                @returns true if valid view point was found
350        */
351        virtual bool GetViewPoint(Vector3 &viewPoint) const;
[2539]352        /** Returns the current view point given a vector for activating the halton sequence.
353        */
[1982]354        virtual bool GetViewPoint(Vector3 &viewPoint, const Vector3 &params) const;
[490]355        /** Returns true if this view point is in the valid view space.
356        */
357        virtual bool ViewPointValid(const Vector3 &viewPoint) const;
[487]358        /** Sets a view space boundary.
359        */
360        void SetViewSpaceBox(const AxisAlignedBox3 &box);
[2539]361        /** Returns the boundaries of the view space.
362        */
[519]363        AxisAlignedBox3 GetViewSpaceBox() const;
[503]364        /** Creates mesh for this view cell.
365        */
[2575]366        virtual void CreateMesh(ViewCell *vc) = 0;
[508]367        /** Writes view cells to disc.
368        */
[1027]369        virtual bool ExportViewCells(const string filename,
[2575]370                                     const bool exportPvs,
371                                     const ObjectContainer &objects);
[532]372        /** Casts beam to collect view cells.
373        */
374        virtual int CastBeam(Beam &beam);
[547]375        /** Checks if view cell is considered as valid.
376        */
[561]377        virtual bool CheckValidity(ViewCell *vc,
[562]378                                                           int minPvsSize,
379                                                           int maxPvsSize) const;
[2539]380        /** Resort pvss after a pass of the algorithm.
381        */
[2117]382        void  SortViewCellPvs();
[2539]383        /** Map the ray intersection objects from triangles to high level objects.
384        */
[2117]385        void DeterminePvsObjects(VssRayContainer &rays,
386                                                         const bool useHitObjects = false);
[562]387        /** Sets validity of view cell
388        */
389        virtual void SetValidity(ViewCell *vc,
390                                                         int minPvsSize,
391                                                         int maxPvsSize) const;
[710]392        /** sets validy of all viewcells
393        */
[2539]394        virtual void SetValidity(int minPvsSize, int maxPvsSize) const;
[2117]395        /** Set valid viewcells in the range of pvs. sorts the viewcells
396                according to the pvs and then pickups those in the ranges
397        */
[710]398        void SetValidityPercentage(const float minValid, const float maxValid);
[1545]399        /** Returns number of valid view cells.
400        */
[609]401    int CountValidViewcells() const;
[547]402        /** Returns maximal allowed pvs size.
403        */
404        int GetMaxPvsSize() const;
[562]405        /** Returns maximal allowed pvs size.
406        */
407        int GetMinPvsSize() const;
[561]408        /** Returns maximal ratio. i.e., currentPVs / maxPvs,
409                where pvs is still considered valid.
410        */
411        float GetMaxPvsRatio() const;
[547]412        /** Exports view cell geometry.
413        */
[2117]414        virtual void ExportViewCellGeometry(Exporter *exporter,
415                                                                                ViewCell *vc,
416                                                                                const AxisAlignedBox3 *box,
417                                                                                const AxisAlignedPlane *clipPlane = NULL
418                                                                                ) const = 0;
[860]419        /** Brings the view cells into their final state, computes meshes and volume.
420        */
[551]421        virtual void FinalizeViewCells(const bool createMesh);
[579]422        /** Evaluates statistics values on view cells.
423        */
[580]424        void EvaluateRenderStatistics(float &totalRenderCost,
425                                                                  float &expectedRenderCost,
426                                                                  float &deviation,
427                                                                  float &variance,
[1709]428                                                                  float &totalPvs,
[580]429                                                                  float &avgRenderCost);
430        /** Returns hierarchy of the view cells.
431        */
432        ViewCellsTree *GetViewCellsTree();
[1545]433        /** Collect candidates for the view cell merge.
434        */
[581]435        virtual void CollectMergeCandidates(const VssRayContainer &rays,
[1022]436                                                                                vector<MergeCandidate> &candidates);
[1294]437        /** Collects n view cells and stores it as the active view cells.
438        */
[610]439        void CollectViewCells(const int n);
[1686]440        /** Sets current view cells set to active,
441                i.e., the sampling is done in this view cell set.
[660]442        */
443        void SetViewCellsActive();
[1145]444        /** Evaluates render cost statistics of current view cell hierarchy.
[660]445        */
[1178]446        virtual void EvalViewCellPartition();
[728]447        /** Sets maximal size of a view cell filter.
448        */
449        void SetMaxFilterSize(const int size);
[840]450        /** Returns maximal filter size.
451        */
452        int GetMaxFilterSize() const;
[1686]453        /** Deletes interior nodes from the tree which have negative
454                merge cost set (local merge).
[840]455        */ 
456        void DeleteLocalMergeTree(ViewCell *vc) const;
[728]457        /** Evaluautes histogram for a given number of view cells.
458        */
459        void EvalViewCellHistogram(const string filename, const int nViewCells);
[735]460        /** Evaluautes histogram for a given number of view cells.
461        */
[2117]462        void EvalViewCellHistogramForPvsSize(const string filename,
463                                                                                 const int nViewCells);
[2539]464        /** Evaluautes histogram for a given vector of view cells.
465        */
[1919]466        void EvalViewCellHistogramForPvsSize(const string filename,
467                                                                                 ViewCellContainer &viewCells);
[2332]468        float ComputeRenderCost(const int tri, const int obj); //const
[2569]469        /** Sets pvs size of a view cell as a scalar. Used when storing pvs only in the leaves
[1002]470                of the hierarchy.
471        */
[2117]472        void UpdateScalarPvsSize(ViewCell *vc,
473                                                         const float pvsCost,
474                                                         const int entriesInPvs) const;
[2569]475        /** Sets render cost of a view cell as a scalar.
476        */
477        void UpdateScalarPvsCost(ViewCell *vc, const float pvsCost) const;
478
[870]479        /** Returns bounding box of a view cell.
480        */
481        AxisAlignedBox3 GetViewCellBox(ViewCell *vc);
[840]482        /** Exports bounding boxes of objects to file.
483        */
[2117]484        bool ExportBoundingBoxes(const string filename,
485                                                         const ObjectContainer &objects) const;
[850]486        /** Load the bounding boxes into the container.
487        */
[2117]488        bool LoadBoundingBoxes(const string filename,
489                                                  IndexedBoundingBoxContainer &boxes) const;
[1002]490        /** Returns true if pvs should be exported together with the view cells.
491        */
492        bool GetExportPvs() const;
[1786]493        /** Efficiently merges the view cells in the container.
494        */
[1787]495        void MergeViewCellsRecursivly(ObjectPvs &pvs,
496                                                                  const ViewCellContainer &viewCells) const;
[2539]497        /** Compresses the view cells.
[2117]498        */
[1845]499        virtual void CompressViewCells();
[2539]500        /** Returns view cell with the given id.
501        */
[2017]502        ViewCell *GetViewCellById(const int id);
503        /** Returns number of view cells.
504        */
[1982]505        int GetNumViewCells() const;
506
[2017]507        bool GenerateRandomViewCells(ViewCellContainer &viewCells,
508                                                                 const int numViewCells);
509
510        bool GenerateRandomViewCells(vector<ViewCellPoints *> &viewCells,
511                                                                 const int nViewCells,
512                                                                 const int nViewPoints);
513
514
515        bool GenerateViewPoints(ViewCell *viewCell,
516                                                        const int numViewPoints,
517                                                        SimpleRayContainer &viewPoints);
518
519        bool ImportRandomViewCells(const string &filename,
520                                                           vector<ViewCellPoints *> &viewCells);
521
[2048]522        bool ImportRandomViewCells(const string &filename);
[2017]523
524        bool ExportRandomViewCells(const string &filename,
525                                                           const vector<ViewCellPoints *> &viewCells);
526
[2048]527        bool ExportRandomViewCells(const string &filename);
528
[2017]529        bool GenerateViewPoint(ViewCell *viewCell, SimpleRay &ray);
530
531        bool IsValidViewSpace(ViewCell *vc);
532
[2048]533
[2017]534        //////////////
[1582]535        // static members
536       
537        /** Loads view cells from file. The view cells manager is created with
538                respect to the loaded view cells.
[870]539
[1582]540                @param filename the filename of the view cells
541                @param objects the scene objects
[2115]542                @param finalizeViewCells if the view cells should be post processed, i.e.,
[2048]543                           a mesh is created representing the geometry
[1582]544                @param bconverter a conversion routine working with the similarities of bounding
[2048]545                           boxes: if there is a certain similarity of overlap between
546                           bounding boxes, two tested candidate objects are considered
547                           to be the same objects
[1582]548                @returns the view cells manager if loading was successful, false otherwise
549        */
550        static ViewCellsManager *LoadViewCells(const string &filename,
[2113]551                                                                                   ObjectContainer &pvsObjects,
552                                                                                   ObjectContainer &preprocessorObjects,
[1676]553                                                                                   bool finalizeViewCells = false,
[1582]554                                                                                   BoundingBoxConverter *bconverter = NULL);
[870]555
[2542]556        /** Convenience function assuming that there are no preprocessor objects.
557        */
[2115]558        static ViewCellsManager *LoadViewCells(const string &filename,
559                                                                                   ObjectContainer &pvsObjects,
560                                                                                   bool finalizeViewCells = false,
561                                                                                   BoundingBoxConverter *bconverter = NULL);
[904]562
[2542]563
[2113]564        ///////////////////////
[2542]565        //-- visiblity filter options
[1294]566
[931]567        // TODO: write own visibiltiy filter class
[2048]568        void ApplyFilter(KdTree *kdTree,
569                                         const float viewSpaceFilterSize,
570                                         const float spatialFilterSize);
[904]571
[2048]572        // new adaptive version of the filter
573        PvsFilterStatistics ApplyFilter2(ViewCell *viewCell,
574                                                                         const bool useViewSpaceFilter,
575                                                                         const float filterSize,
576                                                                         ObjectPvs &pvs,
[2574]577                                                                         vector<AxisAlignedBox3> *filteredBoxes = NULL,
578                                                                         const bool onlyNewObjects = false);
[1715]579
[931]580        void ApplySpatialFilter(KdTree *kdTree,
581                                                        const float spatialFilterSize,
582                                                        ObjectPvs &pvs);
[480]583
[931]584         void ApplyFilter(ViewCell *viewCell,
585                                          KdTree *kdTree,
586                                          const float viewSpaceFilterSize,
587                                          const float spatialFilterSize,
588                                          ObjectPvs &pvs);
589
590        float GetFilterWidth();
591
592        float GetAbsFilterWidth();
[697]593        /** Returns the bounding box of filter width.
594        */
[2117]595        AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint,
596                                                                  const float width) const;
[609]597
[2199]598
599
[1294]600        //////////////////////////////////////////////////////////////////
[979]601
[2048]602
[1155]603        /** If true, the kd nodes are stored instead of the object pvs.
604        */
605        void SetStoreKdPvs(const bool storeKdPvs);
606
607        /** Returns true if the kd nodes are stored instead of the object pvs.
608        **/
609        bool GetStoreKdPVs() const;
610
[1570]611        /** Exports single view cells for visualization.
612                @param objects the scene objects
613                @param limit the maximal number of output view cells
614                @param sortViewCells if the view cells should be sorted by pvs size
615                @param exportPvs if the pvs should also be exported
616                @param exportRays if sample rays should be exported as well
[1580]617                @param maxRays maximum number of rays to export
618                @param prefix the prefix for the output file
[1570]619                @param visRays additional rays
620        */
[1686]621        virtual void ExportSingleViewCells(const ObjectContainer &objects,
622                                                                           const int maxViewCells,
623                                                                           const bool sortViewCells,
624                                                                           const bool exportPvs,
625                                                                           const bool exportRays,
626                                                                           const int maxRays,
[2394]627                                                                           const string &prefix,
[2575]628                                                                           VssRayContainer *visRays = NULL) = 0;
[1570]629
[1932]630
[2048]631        void ResetPvs();
[1580]632
[2571]633        Preprocessor *GetPreprocessor() const
634        {
[1932]635                return mPreprocessor;
636        }
[1580]637
[2571]638        void SetPreprocessor(Preprocessor *p)
639        {
[1932]640                mPreprocessor = p;
641        }
[1608]642
[2048]643        vector<ViewCellPoints *> *GetViewCellPoints()
644        {
645                return &mViewCellPoints;
646        }
647
[1932]648        void UpdatePvsForEvaluation();
649
[2571]650
651        VizBuffer mVizBuffer;
652
653
[931]654protected:
[1145]655
[1932]656        void ComputeViewCellContribution(ViewCell *viewCell,
657                                                                         VssRay &ray,
658                                                                         Intersectable *obj,
659                                                                         const Vector3 &pt,
660                                                                         const bool addRays);
661
[1787]662        void MergeViewCellsRecursivly(ObjectPvs &pvs,
663                                                                  const ViewCellContainer &viewCells,
664                                                                  const int leftIdx,
665                                                                  const int rightIdx) const;
[697]666        /** Intersects box with the tree and returns the number of intersected boxes.
[2539]667                @returns number of view cells found
[697]668        */
[710]669        virtual int ComputeBoxIntersections(const AxisAlignedBox3 &box,
670                                                                                ViewCellContainer &viewCells) const;
[880]671        /** Tests the visibility filter functionality.
672        */
[697]673        virtual void TestFilter(const ObjectContainer &objects) {};
[931]674        /** If the view cells tree was already constructed or not.
[581]675        */
676        bool ViewCellsTreeConstructed() const;
[1294]677        /** Requests preprocessor to cast samplesPerPass samples of a specific type.
678        */
[574]679        int CastPassSamples(const int samplesPerPass,
[1768]680                                                const vector<int> &strategies,
[574]681                                                VssRayContainer &vssRays) const;
[2542]682        /** cast samples for the purpose of evaluating the view cells solution
683        */
[2199]684        int CastEvaluationSamples(const int samplesPerPass,
685                                                          VssRayContainer &passSamples);// const;
[931]686        /** Parse the options from the environment file.
687        */
[482]688        void ParseEnvironment();
[508]689        /** Creates unique view cell ids.
690        */
691        void CreateUniqueViewCellIds();
[551]692        /** Finalizes, i.e., creates mesh, volume, area etc. for the view cell.
693        */
694        virtual void Finalize(ViewCell *viewCell, const bool createMesh);
[480]695        /** Recollects view cells and resets statistics.
696        */
697        void ResetViewCells();
[1707]698        /** Sets this view cell to active.
699        */
700        void SetViewCellActive(ViewCell *vc) const;
[480]701        /** Collects the view cells in the view cell container.
702        */
703        virtual void CollectViewCells() = 0;
[2539]704        /** Evaluates view cells statistics and stores it in mViewCellsStatistics.
[479]705        */
706        void EvaluateViewCellsStats();
[2543]707       
[482]708
[2570]709        void UpdateStatsForViewCell(ViewCell *viewCell, Intersectable *obj);
710
711
[1416]712        ///////////////////////
[482]713        //-- helper functions for view cell visualization
714
715        /** Exports the view cell partition.
716        */
[1686]717        void ExportViewCellsForViz(Exporter *exporter,
718                                                           const AxisAlignedBox3 *box,
[1760]719                                                           const bool colorCode,
[1932]720                                                           const AxisAlignedPlane *clipPlane) const;
[482]721        /** Sets exporter color.
722        */
[1773]723        virtual void ExportColor(Exporter *exporter,
724                                                         ViewCell *vc,
[2394]725                                                         const int colorCode) const;
[1416]726        /** Creates meshes from the view cells.
727        */
728        void CreateViewCellMeshes();
[1932]729        /** Creates clip plane for visualization.
[1416]730        */
731        void CreateClipPlane();
[482]732
[1416]733        AxisAlignedPlane *GetClipPlane();
[1932]734
[1551]735        void ExportMergedViewCells(const ObjectContainer &objects);
736
[2048]737
[1416]738        ///////////////////////
739
[1002]740        /** Returns volume of the view space.
741        */
[557]742        virtual float GetViewSpaceVolume();
[1416]743        /** Prepares the view cells for sampling after loading them from disc.
[503]744        */
[577]745        virtual void PrepareLoadedViewCells() {};
[704]746        /** Constructs local view cell merge hierarchy.
747        */
748        ViewCell *ConstructLocalMergeTree(ViewCell *currentViewCell,
[2539]749                                          const ViewCellContainer &viewCells);
[713]750        /** Constructs local view cell merge hierarchy based solely on similarity with the
[2048]751                current viewcell
[713]752        */
753        ViewCell *ConstructLocalMergeTree2(ViewCell *currentViewCell,
754                                                                           const ViewCellContainer &viewCells);
[860]755        /** Updates pvs of all view cells for statistical evaluation after some more sampling
756        */
[1168]757        void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs);
[2543]758        /** Export statistics of the view cells tree.
759        */
[1679]760        virtual void ExportStats(const string &mergeStats);
[2547]761        /** Loads view cells in binary mode.
762        */
763        static ViewCellsManager *LoadViewCellsBinary(const string &filename,
[2539]764                                                                                                 ObjectContainer &pvsObjects,
765                                                                                                 bool finalizeViewCells,
766                                                 BoundingBoxConverter *bconverter);
[2543]767        /** This helper function loads the bounding boxes for a binary solution.
768        */
[2547]769        static void LoadIndexedBoundingBoxesBinary(IN_STREAM &stream,
770                                                       IndexedBoundingBoxContainer &iboxes);
[2048]771
[2539]772
[752]773
[2543]774        ///////////
775        //-- members
[2048]776
[2199]777        ofstream mStats;
[1145]778        Preprocessor *mPreprocessor;
779        /// if bounding boxes should be exported together with the view cells
[840]780        bool mExportBboxesForPvs;
[1416]781        /// the clip plane for visualization
782        AxisAlignedPlane mClipPlaneForViz;
783        /// if the visualization is using the clip plane
[660]784        bool mUseClipPlaneForViz;
[480]785        /// Renders the view cells.
786        Renderer *mRenderer;
[440]787        /// Loaded view cells
[469]788        ViewCellContainer mViewCells;
[1416]789        /// the view cell hierarchy (i.e., the logical description of view cells)
[580]790        ViewCellsTree *mViewCellsTree;
[1414]791       
[1773]792        std::vector<int> mStrategies;
793
[1416]794        /** if the values in the view cell leaves and the interiors are up to date
795                this is meant for lazy storing of the pvs, where only a scalar indicating
796                pvs size is stored in interiors and not the pvs itself.
797        */
[719]798        bool mViewCellPvsIsUpdated;
[1002]799
[1416]800        /// maximum number of samples for the view cell construction
[440]801        int mConstructionSamples;
[574]802        int mSamplesPerPass;
803        int mInitialSamples;
[440]804        int mPostProcessSamples;
805        int mVisualizationSamples;
[441]806
[2232]807        int mEvaluationSamples;
808
[470]809        float mTotalAreaValid;
810        float mTotalArea;
[475]811
[547]812        int mMaxPvsSize;
[562]813        int mMinPvsSize;
[547]814        float mMaxPvsRatio;
815
[660]816        int mSamplingType;
[722]817        int mEvaluationSamplingType;
[600]818        int mNumActiveViewCells;
[586]819        bool mCompressViewCells;
820
[2048]821        vector<ViewCellPoints *> mViewCellPoints;
822
[1002]823        /// holds the current view cell statistics
[660]824        ViewCellsStatistics mCurrentViewCellsStats;
[2048]825
[487]826        /// the scene bounding box
[542]827        AxisAlignedBox3 mViewSpaceBox;
[1001]828       
[508]829        /// if view cells should be exported
830        bool mExportViewCells;
[1002]831        // if only valid view cells should be considered for processing
[564]832        bool mOnlyValidViewCells;
[580]833        /// if rays should be used to collect merge candidates
834        bool mUseRaysForMerge;
[1002]835        /// if there should be an additional merge step after the subdivision
[592]836        bool mMergeViewCells;
[697]837        /// the width of the box filter
838        float mFilterWidth;
[1570]839        /// Maximal size of the filter in terms of contributing view cells
[697]840        int mMaxFilterSize;
[2538]841        /// only for debugging: stores some rays used during view cell construction
[1686]842        VssRayContainer storedRays;
[2538]843        /// if kd node based pvs is used for preprocessing
[1902]844        bool mUseKdPvs;
[2538]845        /// types of distributions used for sampling
[1903]846        MixtureDistribution *mMixtureDistribution;
847
[2048]848
[2571]849
[1545]850        //////////////////
[487]851        //-- visualization options
852       
[1002]853        /// color code for view cells visualization
[1570]854        bool mShowVisualization;
[487]855        int mColorCode;
856        bool mExportGeometry;
857        bool mExportRays;
[517]858        bool mViewCellsFinished;
[664]859        bool mEvaluateViewCells;
[844]860
861        /// if pvs should be exported with view cells
862        bool mExportPvs;
[1155]863
[1703]864        /// if view cells geometry should be used from other sources
[1545]865        bool mUsePredefinedViewCells;
[2538]866        /// the weight for one triangle in the heuristics
[2332]867        float mTriangleWeight;
[2538]868        /// the weight for one object (= one entity issued with one draw call) in the heuristics
[2332]869        float mObjectWeight;
870
871        vector<PerViewCellStat> mPerViewCellStat;
872        SamplesStatistics mSamplesStat;
[440]873};
874
[441]875
[1545]876/** Manages different higher order operations on the view cells.
[440]877*/
878class BspViewCellsManager: public ViewCellsManager
879{
880
881public:
[485]882        /** Constructor taking the bsp tree and the number of samples
883                used to construct the bsp tree.
884        */
[1264]885        BspViewCellsManager(ViewCellsTree *viewCellsTree, BspTree *tree);
[440]886
[477]887        ~BspViewCellsManager();
[1582]888
[574]889        int ConstructSubdivision(const ObjectContainer &objects,
[487]890                                  const VssRayContainer &rays);
[440]891
892        int PostProcess(const ObjectContainer &objects,
[466]893                                        const VssRayContainer &rays);
[440]894
895        void Visualize(const ObjectContainer &objects,
[466]896                                   const VssRayContainer &sampleRays);
[440]897
898        int GetType() const;
899       
900        ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
901
902        bool ViewCellsConstructed() const;
903
[475]904        //void PrintStatistics(ostream &s) const;
[452]905
[468]906        int CastLineSegment(const Vector3 &origin,
907                                                const Vector3 &termination,
908                                                ViewCellContainer &viewcells);
909       
[1294]910        /** Returns the probability that the view point lies
911                in this view cells.
912        */
[471]913        float GetProbability(ViewCell *viewCell);
[466]914
[1294]915        /** Get a viewcell containing the specified point.
[879]916        */
917        ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const;
[492]918
[1294]919        /** Creates mesh for this view cell.
920        */
[503]921        void CreateMesh(ViewCell *vc);
922
[1416]923        void ExportViewCellGeometry(Exporter *exporter,
924                                                                ViewCell *vc,
925                                                                const AxisAlignedBox3 *box,
926                                                                const AxisAlignedPlane *clipPlane = NULL
927                                                                ) const;
[580]928       
[587]929        void CollectMergeCandidates(const VssRayContainer &rays,
930                                                                vector<MergeCandidate> &candidates);
[547]931
[587]932        void Finalize(ViewCell *viewCell, const bool createMesh);
933
[1416]934        bool ExportViewCells(const string filename,
935                                                 const bool exportPvs,
936                                                 const ObjectContainer &objects);
[590]937
[752]938        /** Constructs merge hierarchy which corresponds to the spatial hierarchy.
939        */
[650]940        ViewCell *ConstructSpatialMergeTree(BspNode *root);
[610]941
[1686]942        void ExportSingleViewCells(const ObjectContainer &objects,
943                                                           const int maxViewCells,
944                                                           const bool sortViewCells,
945                                                           const bool exportPvs,
946                                                           const bool exportRays,
947                                                           const int maxRays,
[2394]948                                                           const string &prefix,
[1686]949                                                           VssRayContainer *visRays = NULL);
[1545]950
[1977]951        bool LineSegmentIntersects(const Vector3 &origin,
952                                                           const Vector3 &termination,
953                                                           ViewCell *viewCell);
954
[440]955protected:
956
[480]957        void CollectViewCells();
[547]958       
[440]959        /// the BSP tree.
960        BspTree *mBspTree;
[475]961        vector<BspRay *> mBspRays;
[440]962
963private:
964
[1545]965        /** Constructs a spatial merge tree only 2 levels deep.
966        */
967        ViewCell *ConstructDummyMergeTree(BspNode *root);
[440]968        /** Exports visualization of the BSP splits.
969        */
[477]970        void ExportSplits(const ObjectContainer &objects);
[1002]971        /** test if subdivision is valid in terms of volume / area.
972        */
[693]973        void TestSubdivision();
[440]974};
975
[1545]976
[440]977/**
978        Manages different higher order operations on the KD type view cells.
979*/
980class KdViewCellsManager: public ViewCellsManager
981{
982
983public:
984
[1264]985        KdViewCellsManager(ViewCellsTree *viewCellsTree, KdTree *tree);
[440]986
[574]987        int ConstructSubdivision(const ObjectContainer &objects,
[1686]988                                                         const VssRayContainer &rays);
[440]989
[478]990        int CastLineSegment(const Vector3 &origin,
991                                                const Vector3 &termination,
992                                                ViewCellContainer &viewcells);
[440]993
994        int PostProcess(const ObjectContainer &objects,
[466]995                                        const VssRayContainer &rays);
[440]996
997        void Visualize(const ObjectContainer &objects,
[466]998                                   const VssRayContainer &sampleRays);
[440]999
1000        int GetType() const;
1001
1002        bool ViewCellsConstructed() const;
1003
[580]1004        ViewCell *GenerateViewCell(Mesh *mesh) const;
[440]1005
[452]1006        /** Prints out statistics of this approach.
1007        */
[503]1008        //  virtual void PrintStatistics(ostream &s) const;
[1416]1009        ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const
1010        { return NULL; }
[452]1011
[503]1012        float GetProbability(ViewCell *viewCell);
[609]1013       
[503]1014        void CreateMesh(ViewCell *vc);
1015
[1686]1016        void ExportViewCellGeometry(Exporter *exporter,
1017                                                                ViewCell *vc,
1018                                                                const AxisAlignedBox3 *box,
1019                                                                const AxisAlignedPlane *clipPlane = NULL) const;
[547]1020
[1416]1021
[591]1022        void CollectMergeCandidates(const VssRayContainer &rays,
1023                                                                vector<MergeCandidate> &candidates);
[580]1024
[1686]1025        void ExportSingleViewCells(const ObjectContainer &objects,
1026                                                           const int maxViewCells,
1027                                                           const bool sortViewCells,
1028                                                           const bool exportPvs,
1029                                                           const bool exportRays,
1030                                                           const int maxRays,
[2394]1031                                                           const string &prefix,
[1686]1032                                                           VssRayContainer *visRays = NULL);
[752]1033
[1977]1034        bool LineSegmentIntersects(const Vector3 &origin,
1035                                                           const Vector3 &termination,
1036                                                           ViewCell *viewCell);
1037
[440]1038protected:
1039
[580]1040        /** Collects view cells from a hierarchy.
1041        */
[480]1042        void CollectViewCells();
[580]1043
[480]1044        KdNode *GetNodeForPvs(KdLeaf *leaf);
[440]1045
[1570]1046        ////////////////////////////////////////
[440]1047
[480]1048        /// the BSP tree.
1049        KdTree *mKdTree;
[440]1050
[480]1051        /// depth of the KD tree nodes with represent the view cells
1052        int mKdPvsDepth;
[938]1053
1054
[440]1055};
1056
[1570]1057
1058/** Manages different higher order operations on the view cells.
[442]1059*/
1060class VspBspViewCellsManager: public ViewCellsManager
1061{
1062
1063public:
1064
[1264]1065        VspBspViewCellsManager(ViewCellsTree *viewCellsTree, VspBspTree *tree);
[475]1066        ~VspBspViewCellsManager();
[442]1067
[574]1068        int ConstructSubdivision(const ObjectContainer &objects,
[1686]1069                                                         const VssRayContainer &rays);
[442]1070
1071        int PostProcess(const ObjectContainer &objects,
[466]1072                                        const VssRayContainer &rays);
[442]1073
1074        void Visualize(const ObjectContainer &objects,
[466]1075                                   const VssRayContainer &sampleRays);
[442]1076
1077        int GetType() const;
1078       
1079        ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
1080
1081        bool ViewCellsConstructed() const;
[468]1082       
1083        int CastLineSegment(const Vector3 &origin,
1084                                                const Vector3 &termination,
1085                                                ViewCellContainer &viewcells);
[452]1086
[471]1087        float GetProbability(ViewCell *viewCell);
[479]1088       
[879]1089        ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const;
[477]1090
[487]1091        bool GetViewPoint(Vector3 &viewPoint) const;
1092
[490]1093        bool ViewPointValid(const Vector3 &viewPoint) const;
[503]1094
1095        void CreateMesh(ViewCell *vc);
1096
[1686]1097        bool ExportViewCells(const string filename,
1098                                                 const bool exportPvs,
1099                                                 const ObjectContainer &objects);
[508]1100
[532]1101        int CastBeam(Beam &beam);
[1416]1102       
[1686]1103        void ExportViewCellGeometry(Exporter *exporter,
1104                                                                ViewCell *vc,
1105                                                                const AxisAlignedBox3 *box,
1106                                                                const AxisAlignedPlane *clipPlane = NULL) const;
[532]1107
[547]1108
[555]1109        void Finalize(ViewCell *viewCell, const bool createMesh);
[551]1110
[1686]1111        void CollectMergeCandidates(const VssRayContainer &rays,
1112                                                                vector<MergeCandidate> &candidates);
[580]1113
[1686]1114        void ExportSingleViewCells(const ObjectContainer &objects,
1115                                                           const int maxViewCells,
1116                                                           const bool sortViewCells,
1117                                                           const bool exportPvs,
1118                                                           const bool exportRays,               
1119                                                           const int maxRays,
[2394]1120                                                           const string &prefix,
[1686]1121                                                           VssRayContainer *visRays = NULL);
[1570]1122
[1920]1123       
[1977]1124        bool LineSegmentIntersects(const Vector3 &origin,
1125                                                           const Vector3 &termination,
1126                                                           ViewCell *viewCell);
1127
[442]1128protected:
[475]1129
[1686]1130        int ComputeBoxIntersections(const AxisAlignedBox3 &box,
1131                                                                ViewCellContainer &viewCells) const;
[651]1132       
[1021]1133        /** Merges view cells according to some criteria
[442]1134        */
[508]1135        void MergeViewCells(const VssRayContainer &rays,
1136                                                const ObjectContainer &objects);
[503]1137       
[564]1138        void RefineViewCells(const VssRayContainer &rays, const ObjectContainer &objects);
[442]1139
[480]1140        void CollectViewCells();
1141
[482]1142        /** Returns maximal depth difference of view cell
1143                leaves in tree.
1144        */
1145        int GetMaxTreeDiff(ViewCell *vc) const;
1146
[752]1147        /** Prepare view cells for use after loading them from disc.
1148        */
[577]1149        void PrepareLoadedViewCells();
1150
[752]1151        /** Constructs merge hierarchy which corresponds to the spatial hierarchy.
1152        */
[650]1153        ViewCell *ConstructSpatialMergeTree(BspNode *root);
[649]1154
[979]1155        /// HACK for testing visibility filter functionality
[697]1156        void TestFilter(const ObjectContainer &objects);
1157
[979]1158        /** Visualization of the pvs difference to exact visubility using
1159                from point queries.
1160        */
1161        void VisualizeWithFromPointQueries();
[697]1162
[991]1163        /** Evaluate from point queries for the current scene.
1164        */
1165        void EvalFromPointQueries();
[979]1166
[1021]1167        /** Exports visualization of the BSP splits.
1168        */
1169        void ExportSplits(const ObjectContainer &objects,
1170                                          const VssRayContainer &rays);
[991]1171
[1686]1172
1173        /////////////////////////
1174
[442]1175        /// the view space partition BSP tree.
1176        VspBspTree *mVspBspTree;
1177
[591]1178
[442]1179private:
1180
[1021]1181        /** test if subdivision is valid in terms of volume / area.
[442]1182        */
[1021]1183        void TestSubdivision();
1184};
[442]1185
[1021]1186
[2353]1187
1188/**     Manages different higher order operations on the view cells.
[1021]1189*/
1190class VspOspViewCellsManager: public ViewCellsManager
1191{
[1740]1192        friend class ViewCellsParseHandlers;
[2542]1193        friend class ViewCellsManager;
[1977]1194
[1021]1195public:
1196
[2542]1197        /** This version takes a view cells tree and a hierarchy
1198                as input.
1199        */
[2113]1200        VspOspViewCellsManager(ViewCellsTree *vcTree,
1201                                                   const string &hierarchyType);
[1278]1202       
[1021]1203        ~VspOspViewCellsManager();
1204
1205        int ConstructSubdivision(const ObjectContainer &objects,
1206                                                         const VssRayContainer &rays);
1207
1208        int PostProcess(const ObjectContainer &objects,
1209                                        const VssRayContainer &rays);
1210
[1686]1211        void Visualize(const ObjectContainer &objects,
[1021]1212                                   const VssRayContainer &sampleRays);
1213
1214        int GetType() const;
1215       
1216        ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
1217
[2539]1218        virtual Intersectable *GetIntersectable(const VssRay &ray,
1219                                                                                        const bool isTermination) const;
[1743]1220
[1021]1221        bool ViewCellsConstructed() const;
1222
1223        int CastLineSegment(const Vector3 &origin,
1224                                                const Vector3 &termination,
1225                                                ViewCellContainer &viewcells);
1226
[1977]1227        bool LineSegmentIntersects(const Vector3 &origin,
1228                                                           const Vector3 &termination,
1229                                                           ViewCell *viewCell);
1230
[1021]1231        float GetProbability(ViewCell *viewCell);
1232       
[2113]1233        ViewCell *GetViewCell(const Vector3 &point,
1234                                                  const bool active = false) const;
[1021]1235
1236        bool GetViewPoint(Vector3 &viewPoint) const;
1237
1238        bool ViewPointValid(const Vector3 &viewPoint) const;
1239
1240        void CreateMesh(ViewCell *vc);
1241
[1027]1242        bool ExportViewCells(const string filename,
1243                                                 const bool exportPvs,
1244                                                 const ObjectContainer &objects);
[1021]1245
1246        int CastBeam(Beam &beam);
1247
1248        void Finalize(ViewCell *viewCell, const bool createMesh);
1249
[1666]1250        void ExportSingleViewCells(const ObjectContainer &objects,
1251                                                           const int maxViewCells,
1252                                                           const bool sortViewCells,
1253                                                           const bool exportPvs,
1254                                                           const bool exportRays,
1255                                                           const int maxRays,
[2394]1256                                                           const string &prefix,
[1666]1257                                                           VssRayContainer *visRays = NULL);
[2539]1258        /** See parent class.
1259        */
[2124]1260        virtual void FinalizeViewCells(const bool createMesh);
1261
[2543]1262        bool ExportViewCellsBinary(const string filename,
[2539]1263                                                           const bool exportPvs,
1264                                                           const ObjectContainer &objects);
1265
[2332]1266#if TEST_PACKETS
1267
[2353]1268        float ComputeSampleContributions(const VssRayContainer &rays,
1269                                             const bool addContributions,
1270                                                                         const bool storeViewCells,
1271                                                                         const bool useHitObjects = false);
[2332]1272#endif
1273
[2539]1274
[1021]1275protected:
[1180]1276
[2539]1277        /** View cells manager taking a view cells tree and a hierarchy as input.
1278        */
[1740]1279        VspOspViewCellsManager(ViewCellsTree *vcTree, HierarchyManager *hm);
1280       
[1709]1281        virtual void EvalViewCellPartition();
[1027]1282        /** Exports view cell geometry.
1283        */
[1666]1284        void ExportViewCellGeometry(Exporter *exporter,
1285                                                                ViewCell *vc,
1286                                                                const AxisAlignedBox3 *box,
1287                                                                const AxisAlignedPlane *clipPlane = NULL) const;
[1027]1288
[1666]1289        int ComputeBoxIntersections(const AxisAlignedBox3 &box,
1290                                                                ViewCellContainer &viewCells) const;
[1021]1291       
1292        void CollectViewCells();
1293
[1845]1294        virtual void CompressViewCells();
[1021]1295        /** Prepare view cells for use after loading them from disc.
1296        */
1297        void PrepareLoadedViewCells();
1298        /** Constructs merge hierarchy which corresponds to the spatial hierarchy.
1299        */
1300        ViewCell *ConstructSpatialMergeTree(VspNode *root);
[1074]1301        /** Exports visualization of the PVS.
[442]1302        */
[1666]1303        void ExportPvs(const ObjectContainer &objects, const VssRayContainer &rays);
[1740]1304        /** Returns a hierarchy manager of the given name.
1305        */
1306        static HierarchyManager *CreateHierarchyManager(const string &name);
[1887]1307        /** collect objects intersecting a given spatial box
[1845]1308        */
1309        virtual void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects);
[2539]1310        /** Update the cost of pvss for hierarchy objects.
1311        */
1312        float UpdateObjectCosts();
[1737]1313
[2539]1314
1315        ////////////////
1316
1317        /** Fast view cell loader in binary mode.
1318        */
[2547]1319        friend ViewCellsManager *ViewCellsManager::
1320                LoadViewCellsBinary(const std::string &filename,
1321                                    ObjectContainer &pvsObjects,
1322                                                        bool finalizeViewCells,
1323                                                        BoundingBoxConverter *bconverter);
[2539]1324
[2547]1325
[2539]1326        /** Print statistics about the view cells compression.
1327        */
[2530]1328        static void PrintCompressionStats(HierarchyManager *hm, const int pvsEntries);
[1887]1329
1330
[2530]1331        ////////////////////
1332
[2547]1333        /// if we the objects are compressed after evaluation
1334        /// this makes only sense for testing purpose
[1887]1335        bool mCompressObjects;
[2547]1336        /// hierarchy manager managing view space / object subdivision.
[1027]1337        HierarchyManager *mHierarchyManager;
[442]1338};
1339
[575]1340
[860]1341}
1342
[440]1343#endif
Note: See TracBrowser for help on using the repository browser.