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

Revision 2571, 39.2 KB checked in by mattausch, 17 years ago (diff)
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        */
366        virtual void CreateMesh(ViewCell *vc) = NULL;
[508]367        /** Writes view cells to disc.
368        */
[1027]369        virtual bool ExportViewCells(const string filename,
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,
577                                                                         vector<AxisAlignedBox3> *filteredBoxes = NULL);
[1715]578
[931]579        void ApplySpatialFilter(KdTree *kdTree,
580                                                        const float spatialFilterSize,
581                                                        ObjectPvs &pvs);
[480]582
[931]583         void ApplyFilter(ViewCell *viewCell,
584                                          KdTree *kdTree,
585                                          const float viewSpaceFilterSize,
586                                          const float spatialFilterSize,
587                                          ObjectPvs &pvs);
588
589        float GetFilterWidth();
590
591        float GetAbsFilterWidth();
[697]592        /** Returns the bounding box of filter width.
593        */
[2117]594        AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint,
595                                                                  const float width) const;
[609]596
[2199]597
598
[1294]599        //////////////////////////////////////////////////////////////////
[979]600
[2048]601
[1155]602        /** If true, the kd nodes are stored instead of the object pvs.
603        */
604        void SetStoreKdPvs(const bool storeKdPvs);
605
606        /** Returns true if the kd nodes are stored instead of the object pvs.
607        **/
608        bool GetStoreKdPVs() const;
609
[1570]610        /** Exports single view cells for visualization.
611                @param objects the scene objects
612                @param limit the maximal number of output view cells
613                @param sortViewCells if the view cells should be sorted by pvs size
614                @param exportPvs if the pvs should also be exported
615                @param exportRays if sample rays should be exported as well
[1580]616                @param maxRays maximum number of rays to export
617                @param prefix the prefix for the output file
[1570]618                @param visRays additional rays
619        */
[1686]620        virtual void ExportSingleViewCells(const ObjectContainer &objects,
621                                                                           const int maxViewCells,
622                                                                           const bool sortViewCells,
623                                                                           const bool exportPvs,
624                                                                           const bool exportRays,
625                                                                           const int maxRays,
[2394]626                                                                           const string &prefix,
[1686]627                                                                           VssRayContainer *visRays = NULL) = NULL;
[1570]628
[1932]629
[2048]630        void ResetPvs();
[1580]631
[2571]632        Preprocessor *GetPreprocessor() const
633        {
[1932]634                return mPreprocessor;
635        }
[1580]636
[2571]637        void SetPreprocessor(Preprocessor *p)
638        {
[1932]639                mPreprocessor = p;
640        }
[1608]641
[2048]642        vector<ViewCellPoints *> *GetViewCellPoints()
643        {
644                return &mViewCellPoints;
645        }
646
[1932]647        void UpdatePvsForEvaluation();
648
[2571]649
650        VizBuffer mVizBuffer;
651
652
[931]653protected:
[1145]654
[1932]655        void ComputeViewCellContribution(ViewCell *viewCell,
656                                                                         VssRay &ray,
657                                                                         Intersectable *obj,
658                                                                         const Vector3 &pt,
659                                                                         const bool addRays);
660
[1787]661        void MergeViewCellsRecursivly(ObjectPvs &pvs,
662                                                                  const ViewCellContainer &viewCells,
663                                                                  const int leftIdx,
664                                                                  const int rightIdx) const;
[697]665        /** Intersects box with the tree and returns the number of intersected boxes.
[2539]666                @returns number of view cells found
[697]667        */
[710]668        virtual int ComputeBoxIntersections(const AxisAlignedBox3 &box,
669                                                                                ViewCellContainer &viewCells) const;
[880]670        /** Tests the visibility filter functionality.
671        */
[697]672        virtual void TestFilter(const ObjectContainer &objects) {};
[931]673        /** If the view cells tree was already constructed or not.
[581]674        */
675        bool ViewCellsTreeConstructed() const;
[1294]676        /** Requests preprocessor to cast samplesPerPass samples of a specific type.
677        */
[574]678        int CastPassSamples(const int samplesPerPass,
[1768]679                                                const vector<int> &strategies,
[574]680                                                VssRayContainer &vssRays) const;
[2542]681        /** cast samples for the purpose of evaluating the view cells solution
682        */
[2199]683        int CastEvaluationSamples(const int samplesPerPass,
684                                                          VssRayContainer &passSamples);// const;
[931]685        /** Parse the options from the environment file.
686        */
[482]687        void ParseEnvironment();
[508]688        /** Creates unique view cell ids.
689        */
690        void CreateUniqueViewCellIds();
[551]691        /** Finalizes, i.e., creates mesh, volume, area etc. for the view cell.
692        */
693        virtual void Finalize(ViewCell *viewCell, const bool createMesh);
[480]694        /** Recollects view cells and resets statistics.
695        */
696        void ResetViewCells();
[1707]697        /** Sets this view cell to active.
698        */
699        void SetViewCellActive(ViewCell *vc) const;
[480]700        /** Collects the view cells in the view cell container.
701        */
702        virtual void CollectViewCells() = 0;
[2539]703        /** Evaluates view cells statistics and stores it in mViewCellsStatistics.
[479]704        */
705        void EvaluateViewCellsStats();
[2543]706       
[482]707
[2570]708        void UpdateStatsForViewCell(ViewCell *viewCell, Intersectable *obj);
709
710
[1416]711        ///////////////////////
[482]712        //-- helper functions for view cell visualization
713
714        /** Exports the view cell partition.
715        */
[1686]716        void ExportViewCellsForViz(Exporter *exporter,
717                                                           const AxisAlignedBox3 *box,
[1760]718                                                           const bool colorCode,
[1932]719                                                           const AxisAlignedPlane *clipPlane) const;
[482]720        /** Sets exporter color.
721        */
[1773]722        virtual void ExportColor(Exporter *exporter,
723                                                         ViewCell *vc,
[2394]724                                                         const int colorCode) const;
[1416]725        /** Creates meshes from the view cells.
726        */
727        void CreateViewCellMeshes();
[1932]728        /** Creates clip plane for visualization.
[1416]729        */
730        void CreateClipPlane();
[482]731
[1416]732        AxisAlignedPlane *GetClipPlane();
[1932]733
[1551]734        void ExportMergedViewCells(const ObjectContainer &objects);
735
[2048]736
[1416]737        ///////////////////////
738
[1002]739        /** Returns volume of the view space.
740        */
[557]741        virtual float GetViewSpaceVolume();
[1416]742        /** Prepares the view cells for sampling after loading them from disc.
[503]743        */
[577]744        virtual void PrepareLoadedViewCells() {};
[704]745        /** Constructs local view cell merge hierarchy.
746        */
747        ViewCell *ConstructLocalMergeTree(ViewCell *currentViewCell,
[2539]748                                          const ViewCellContainer &viewCells);
[713]749        /** Constructs local view cell merge hierarchy based solely on similarity with the
[2048]750                current viewcell
[713]751        */
752        ViewCell *ConstructLocalMergeTree2(ViewCell *currentViewCell,
753                                                                           const ViewCellContainer &viewCells);
[860]754        /** Updates pvs of all view cells for statistical evaluation after some more sampling
755        */
[1168]756        void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs);
[2543]757        /** Export statistics of the view cells tree.
758        */
[1679]759        virtual void ExportStats(const string &mergeStats);
[2547]760        /** Loads view cells in binary mode.
761        */
762        static ViewCellsManager *LoadViewCellsBinary(const string &filename,
[2539]763                                                                                                 ObjectContainer &pvsObjects,
764                                                                                                 bool finalizeViewCells,
765                                                 BoundingBoxConverter *bconverter);
[2543]766        /** This helper function loads the bounding boxes for a binary solution.
767        */
[2547]768        static void LoadIndexedBoundingBoxesBinary(IN_STREAM &stream,
769                                                       IndexedBoundingBoxContainer &iboxes);
[2048]770
[2539]771
[752]772
[2543]773        ///////////
774        //-- members
[2048]775
[2199]776        ofstream mStats;
[1145]777        Preprocessor *mPreprocessor;
778        /// if bounding boxes should be exported together with the view cells
[840]779        bool mExportBboxesForPvs;
[1416]780        /// the clip plane for visualization
781        AxisAlignedPlane mClipPlaneForViz;
782        /// if the visualization is using the clip plane
[660]783        bool mUseClipPlaneForViz;
[480]784        /// Renders the view cells.
785        Renderer *mRenderer;
[440]786        /// Loaded view cells
[469]787        ViewCellContainer mViewCells;
[1416]788        /// the view cell hierarchy (i.e., the logical description of view cells)
[580]789        ViewCellsTree *mViewCellsTree;
[1414]790       
[1773]791        std::vector<int> mStrategies;
792
[1416]793        /** if the values in the view cell leaves and the interiors are up to date
794                this is meant for lazy storing of the pvs, where only a scalar indicating
795                pvs size is stored in interiors and not the pvs itself.
796        */
[719]797        bool mViewCellPvsIsUpdated;
[1002]798
[1416]799        /// maximum number of samples for the view cell construction
[440]800        int mConstructionSamples;
[574]801        int mSamplesPerPass;
802        int mInitialSamples;
[440]803        int mPostProcessSamples;
804        int mVisualizationSamples;
[441]805
[2232]806        int mEvaluationSamples;
807
[470]808        float mTotalAreaValid;
809        float mTotalArea;
[475]810
[547]811        int mMaxPvsSize;
[562]812        int mMinPvsSize;
[547]813        float mMaxPvsRatio;
814
[660]815        int mSamplingType;
[722]816        int mEvaluationSamplingType;
[600]817        int mNumActiveViewCells;
[586]818        bool mCompressViewCells;
819
[2048]820        vector<ViewCellPoints *> mViewCellPoints;
821
[1002]822        /// holds the current view cell statistics
[660]823        ViewCellsStatistics mCurrentViewCellsStats;
[2048]824
[487]825        /// the scene bounding box
[542]826        AxisAlignedBox3 mViewSpaceBox;
[1001]827       
[508]828        /// if view cells should be exported
829        bool mExportViewCells;
[1002]830        // if only valid view cells should be considered for processing
[564]831        bool mOnlyValidViewCells;
[580]832        /// if rays should be used to collect merge candidates
833        bool mUseRaysForMerge;
[1002]834        /// if there should be an additional merge step after the subdivision
[592]835        bool mMergeViewCells;
[697]836        /// the width of the box filter
837        float mFilterWidth;
[1570]838        /// Maximal size of the filter in terms of contributing view cells
[697]839        int mMaxFilterSize;
[2538]840        /// only for debugging: stores some rays used during view cell construction
[1686]841        VssRayContainer storedRays;
[2538]842        /// if kd node based pvs is used for preprocessing
[1902]843        bool mUseKdPvs;
[2538]844        /// types of distributions used for sampling
[1903]845        MixtureDistribution *mMixtureDistribution;
846
[2048]847
[2571]848
[1545]849        //////////////////
[487]850        //-- visualization options
851       
[1002]852        /// color code for view cells visualization
[1570]853        bool mShowVisualization;
[487]854        int mColorCode;
855        bool mExportGeometry;
856        bool mExportRays;
[517]857        bool mViewCellsFinished;
[664]858        bool mEvaluateViewCells;
[844]859
860        /// if pvs should be exported with view cells
861        bool mExportPvs;
[1155]862
[1703]863        /// if view cells geometry should be used from other sources
[1545]864        bool mUsePredefinedViewCells;
[2538]865        /// the weight for one triangle in the heuristics
[2332]866        float mTriangleWeight;
[2538]867        /// the weight for one object (= one entity issued with one draw call) in the heuristics
[2332]868        float mObjectWeight;
869
870        vector<PerViewCellStat> mPerViewCellStat;
871        SamplesStatistics mSamplesStat;
[440]872};
873
[441]874
[1545]875/** Manages different higher order operations on the view cells.
[440]876*/
877class BspViewCellsManager: public ViewCellsManager
878{
879
880public:
[485]881        /** Constructor taking the bsp tree and the number of samples
882                used to construct the bsp tree.
883        */
[1264]884        BspViewCellsManager(ViewCellsTree *viewCellsTree, BspTree *tree);
[440]885
[477]886        ~BspViewCellsManager();
[1582]887
[574]888        int ConstructSubdivision(const ObjectContainer &objects,
[487]889                                  const VssRayContainer &rays);
[440]890
891        int PostProcess(const ObjectContainer &objects,
[466]892                                        const VssRayContainer &rays);
[440]893
894        void Visualize(const ObjectContainer &objects,
[466]895                                   const VssRayContainer &sampleRays);
[440]896
897        int GetType() const;
898       
899        ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
900
901        bool ViewCellsConstructed() const;
902
[475]903        //void PrintStatistics(ostream &s) const;
[452]904
[468]905        int CastLineSegment(const Vector3 &origin,
906                                                const Vector3 &termination,
907                                                ViewCellContainer &viewcells);
908       
[1294]909        /** Returns the probability that the view point lies
910                in this view cells.
911        */
[471]912        float GetProbability(ViewCell *viewCell);
[466]913
[1294]914        /** Get a viewcell containing the specified point.
[879]915        */
916        ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const;
[492]917
[1294]918        /** Creates mesh for this view cell.
919        */
[503]920        void CreateMesh(ViewCell *vc);
921
[1416]922        void ExportViewCellGeometry(Exporter *exporter,
923                                                                ViewCell *vc,
924                                                                const AxisAlignedBox3 *box,
925                                                                const AxisAlignedPlane *clipPlane = NULL
926                                                                ) const;
[580]927       
[587]928        void CollectMergeCandidates(const VssRayContainer &rays,
929                                                                vector<MergeCandidate> &candidates);
[547]930
[587]931        void Finalize(ViewCell *viewCell, const bool createMesh);
932
[1416]933        bool ExportViewCells(const string filename,
934                                                 const bool exportPvs,
935                                                 const ObjectContainer &objects);
[590]936
[752]937        /** Constructs merge hierarchy which corresponds to the spatial hierarchy.
938        */
[650]939        ViewCell *ConstructSpatialMergeTree(BspNode *root);
[610]940
[1686]941        void ExportSingleViewCells(const ObjectContainer &objects,
942                                                           const int maxViewCells,
943                                                           const bool sortViewCells,
944                                                           const bool exportPvs,
945                                                           const bool exportRays,
946                                                           const int maxRays,
[2394]947                                                           const string &prefix,
[1686]948                                                           VssRayContainer *visRays = NULL);
[1545]949
[1977]950        bool LineSegmentIntersects(const Vector3 &origin,
951                                                           const Vector3 &termination,
952                                                           ViewCell *viewCell);
953
[440]954protected:
955
[480]956        void CollectViewCells();
[547]957       
[440]958        /// the BSP tree.
959        BspTree *mBspTree;
[475]960        vector<BspRay *> mBspRays;
[440]961
962private:
963
[1545]964        /** Constructs a spatial merge tree only 2 levels deep.
965        */
966        ViewCell *ConstructDummyMergeTree(BspNode *root);
[440]967        /** Exports visualization of the BSP splits.
968        */
[477]969        void ExportSplits(const ObjectContainer &objects);
[1002]970        /** test if subdivision is valid in terms of volume / area.
971        */
[693]972        void TestSubdivision();
[440]973};
974
[1545]975
[440]976/**
977        Manages different higher order operations on the KD type view cells.
978*/
979class KdViewCellsManager: public ViewCellsManager
980{
981
982public:
983
[1264]984        KdViewCellsManager(ViewCellsTree *viewCellsTree, KdTree *tree);
[440]985
[574]986        int ConstructSubdivision(const ObjectContainer &objects,
[1686]987                                                         const VssRayContainer &rays);
[440]988
[478]989        int CastLineSegment(const Vector3 &origin,
990                                                const Vector3 &termination,
991                                                ViewCellContainer &viewcells);
[440]992
993        int PostProcess(const ObjectContainer &objects,
[466]994                                        const VssRayContainer &rays);
[440]995
996        void Visualize(const ObjectContainer &objects,
[466]997                                   const VssRayContainer &sampleRays);
[440]998
999        int GetType() const;
1000
1001        bool ViewCellsConstructed() const;
1002
[580]1003        ViewCell *GenerateViewCell(Mesh *mesh) const;
[440]1004
[452]1005        /** Prints out statistics of this approach.
1006        */
[503]1007        //  virtual void PrintStatistics(ostream &s) const;
[1416]1008        ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const
1009        { return NULL; }
[452]1010
[503]1011        float GetProbability(ViewCell *viewCell);
[609]1012       
[503]1013        void CreateMesh(ViewCell *vc);
1014
[1686]1015        void ExportViewCellGeometry(Exporter *exporter,
1016                                                                ViewCell *vc,
1017                                                                const AxisAlignedBox3 *box,
1018                                                                const AxisAlignedPlane *clipPlane = NULL) const;
[547]1019
[1416]1020
[591]1021        void CollectMergeCandidates(const VssRayContainer &rays,
1022                                                                vector<MergeCandidate> &candidates);
[580]1023
[1686]1024        void ExportSingleViewCells(const ObjectContainer &objects,
1025                                                           const int maxViewCells,
1026                                                           const bool sortViewCells,
1027                                                           const bool exportPvs,
1028                                                           const bool exportRays,
1029                                                           const int maxRays,
[2394]1030                                                           const string &prefix,
[1686]1031                                                           VssRayContainer *visRays = NULL);
[752]1032
[1977]1033        bool LineSegmentIntersects(const Vector3 &origin,
1034                                                           const Vector3 &termination,
1035                                                           ViewCell *viewCell);
1036
[440]1037protected:
1038
[580]1039        /** Collects view cells from a hierarchy.
1040        */
[480]1041        void CollectViewCells();
[580]1042
[480]1043        KdNode *GetNodeForPvs(KdLeaf *leaf);
[440]1044
[1570]1045        ////////////////////////////////////////
[440]1046
[480]1047        /// the BSP tree.
1048        KdTree *mKdTree;
[440]1049
[480]1050        /// depth of the KD tree nodes with represent the view cells
1051        int mKdPvsDepth;
[938]1052
1053
[440]1054};
1055
[1570]1056
1057/** Manages different higher order operations on the view cells.
[442]1058*/
1059class VspBspViewCellsManager: public ViewCellsManager
1060{
1061
1062public:
1063
[1264]1064        VspBspViewCellsManager(ViewCellsTree *viewCellsTree, VspBspTree *tree);
[475]1065        ~VspBspViewCellsManager();
[442]1066
[574]1067        int ConstructSubdivision(const ObjectContainer &objects,
[1686]1068                                                         const VssRayContainer &rays);
[442]1069
1070        int PostProcess(const ObjectContainer &objects,
[466]1071                                        const VssRayContainer &rays);
[442]1072
1073        void Visualize(const ObjectContainer &objects,
[466]1074                                   const VssRayContainer &sampleRays);
[442]1075
1076        int GetType() const;
1077       
1078        ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
1079
1080        bool ViewCellsConstructed() const;
[468]1081       
1082        int CastLineSegment(const Vector3 &origin,
1083                                                const Vector3 &termination,
1084                                                ViewCellContainer &viewcells);
[452]1085
[471]1086        float GetProbability(ViewCell *viewCell);
[479]1087       
[879]1088        ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const;
[477]1089
[487]1090        bool GetViewPoint(Vector3 &viewPoint) const;
1091
[490]1092        bool ViewPointValid(const Vector3 &viewPoint) const;
[503]1093
1094        void CreateMesh(ViewCell *vc);
1095
[1686]1096        bool ExportViewCells(const string filename,
1097                                                 const bool exportPvs,
1098                                                 const ObjectContainer &objects);
[508]1099
[532]1100        int CastBeam(Beam &beam);
[1416]1101       
[1686]1102        void ExportViewCellGeometry(Exporter *exporter,
1103                                                                ViewCell *vc,
1104                                                                const AxisAlignedBox3 *box,
1105                                                                const AxisAlignedPlane *clipPlane = NULL) const;
[532]1106
[547]1107
[555]1108        void Finalize(ViewCell *viewCell, const bool createMesh);
[551]1109
[1686]1110        void CollectMergeCandidates(const VssRayContainer &rays,
1111                                                                vector<MergeCandidate> &candidates);
[580]1112
[1686]1113        void ExportSingleViewCells(const ObjectContainer &objects,
1114                                                           const int maxViewCells,
1115                                                           const bool sortViewCells,
1116                                                           const bool exportPvs,
1117                                                           const bool exportRays,               
1118                                                           const int maxRays,
[2394]1119                                                           const string &prefix,
[1686]1120                                                           VssRayContainer *visRays = NULL);
[1570]1121
[1920]1122       
[1977]1123        bool LineSegmentIntersects(const Vector3 &origin,
1124                                                           const Vector3 &termination,
1125                                                           ViewCell *viewCell);
1126
[442]1127protected:
[475]1128
[1686]1129        int ComputeBoxIntersections(const AxisAlignedBox3 &box,
1130                                                                ViewCellContainer &viewCells) const;
[651]1131       
[1021]1132        /** Merges view cells according to some criteria
[442]1133        */
[508]1134        void MergeViewCells(const VssRayContainer &rays,
1135                                                const ObjectContainer &objects);
[503]1136       
[564]1137        void RefineViewCells(const VssRayContainer &rays, const ObjectContainer &objects);
[442]1138
[480]1139        void CollectViewCells();
1140
[482]1141        /** Returns maximal depth difference of view cell
1142                leaves in tree.
1143        */
1144        int GetMaxTreeDiff(ViewCell *vc) const;
1145
[752]1146        /** Prepare view cells for use after loading them from disc.
1147        */
[577]1148        void PrepareLoadedViewCells();
1149
[752]1150        /** Constructs merge hierarchy which corresponds to the spatial hierarchy.
1151        */
[650]1152        ViewCell *ConstructSpatialMergeTree(BspNode *root);
[649]1153
[979]1154        /// HACK for testing visibility filter functionality
[697]1155        void TestFilter(const ObjectContainer &objects);
1156
[979]1157        /** Visualization of the pvs difference to exact visubility using
1158                from point queries.
1159        */
1160        void VisualizeWithFromPointQueries();
[697]1161
[991]1162        /** Evaluate from point queries for the current scene.
1163        */
1164        void EvalFromPointQueries();
[979]1165
[1021]1166        /** Exports visualization of the BSP splits.
1167        */
1168        void ExportSplits(const ObjectContainer &objects,
1169                                          const VssRayContainer &rays);
[991]1170
[1686]1171
1172        /////////////////////////
1173
[442]1174        /// the view space partition BSP tree.
1175        VspBspTree *mVspBspTree;
1176
[591]1177
[442]1178private:
1179
[1021]1180        /** test if subdivision is valid in terms of volume / area.
[442]1181        */
[1021]1182        void TestSubdivision();
1183};
[442]1184
[1021]1185
[2353]1186
1187/**     Manages different higher order operations on the view cells.
[1021]1188*/
1189class VspOspViewCellsManager: public ViewCellsManager
1190{
[1740]1191        friend class ViewCellsParseHandlers;
[2542]1192        friend class ViewCellsManager;
[1977]1193
[1021]1194public:
1195
[2542]1196        /** This version takes a view cells tree and a hierarchy
1197                as input.
1198        */
[2113]1199        VspOspViewCellsManager(ViewCellsTree *vcTree,
1200                                                   const string &hierarchyType);
[1278]1201       
[1021]1202        ~VspOspViewCellsManager();
1203
1204        int ConstructSubdivision(const ObjectContainer &objects,
1205                                                         const VssRayContainer &rays);
1206
1207        int PostProcess(const ObjectContainer &objects,
1208                                        const VssRayContainer &rays);
1209
[1686]1210        void Visualize(const ObjectContainer &objects,
[1021]1211                                   const VssRayContainer &sampleRays);
1212
1213        int GetType() const;
1214       
1215        ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
1216
[2539]1217        virtual Intersectable *GetIntersectable(const VssRay &ray,
1218                                                                                        const bool isTermination) const;
[1743]1219
[1021]1220        bool ViewCellsConstructed() const;
1221
1222        int CastLineSegment(const Vector3 &origin,
1223                                                const Vector3 &termination,
1224                                                ViewCellContainer &viewcells);
1225
[1977]1226        bool LineSegmentIntersects(const Vector3 &origin,
1227                                                           const Vector3 &termination,
1228                                                           ViewCell *viewCell);
1229
[1021]1230        float GetProbability(ViewCell *viewCell);
1231       
[2113]1232        ViewCell *GetViewCell(const Vector3 &point,
1233                                                  const bool active = false) const;
[1021]1234
1235        bool GetViewPoint(Vector3 &viewPoint) const;
1236
1237        bool ViewPointValid(const Vector3 &viewPoint) const;
1238
1239        void CreateMesh(ViewCell *vc);
1240
[1027]1241        bool ExportViewCells(const string filename,
1242                                                 const bool exportPvs,
1243                                                 const ObjectContainer &objects);
[1021]1244
1245        int CastBeam(Beam &beam);
1246
1247        void Finalize(ViewCell *viewCell, const bool createMesh);
1248
[1666]1249        void ExportSingleViewCells(const ObjectContainer &objects,
1250                                                           const int maxViewCells,
1251                                                           const bool sortViewCells,
1252                                                           const bool exportPvs,
1253                                                           const bool exportRays,
1254                                                           const int maxRays,
[2394]1255                                                           const string &prefix,
[1666]1256                                                           VssRayContainer *visRays = NULL);
[2539]1257        /** See parent class.
1258        */
[2124]1259        virtual void FinalizeViewCells(const bool createMesh);
1260
[2543]1261        bool ExportViewCellsBinary(const string filename,
[2539]1262                                                           const bool exportPvs,
1263                                                           const ObjectContainer &objects);
1264
[2332]1265#if TEST_PACKETS
1266
[2353]1267        float ComputeSampleContributions(const VssRayContainer &rays,
1268                                             const bool addContributions,
1269                                                                         const bool storeViewCells,
1270                                                                         const bool useHitObjects = false);
[2332]1271#endif
1272
[2539]1273
[1021]1274protected:
[1180]1275
[2539]1276        /** View cells manager taking a view cells tree and a hierarchy as input.
1277        */
[1740]1278        VspOspViewCellsManager(ViewCellsTree *vcTree, HierarchyManager *hm);
1279       
[1709]1280        virtual void EvalViewCellPartition();
[1027]1281        /** Exports view cell geometry.
1282        */
[1666]1283        void ExportViewCellGeometry(Exporter *exporter,
1284                                                                ViewCell *vc,
1285                                                                const AxisAlignedBox3 *box,
1286                                                                const AxisAlignedPlane *clipPlane = NULL) const;
[1027]1287
[1666]1288        int ComputeBoxIntersections(const AxisAlignedBox3 &box,
1289                                                                ViewCellContainer &viewCells) const;
[1021]1290       
1291        void CollectViewCells();
1292
[1845]1293        virtual void CompressViewCells();
[1021]1294        /** Prepare view cells for use after loading them from disc.
1295        */
1296        void PrepareLoadedViewCells();
1297        /** Constructs merge hierarchy which corresponds to the spatial hierarchy.
1298        */
1299        ViewCell *ConstructSpatialMergeTree(VspNode *root);
[1074]1300        /** Exports visualization of the PVS.
[442]1301        */
[1666]1302        void ExportPvs(const ObjectContainer &objects, const VssRayContainer &rays);
[1740]1303        /** Returns a hierarchy manager of the given name.
1304        */
1305        static HierarchyManager *CreateHierarchyManager(const string &name);
[1887]1306        /** collect objects intersecting a given spatial box
[1845]1307        */
1308        virtual void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects);
[2539]1309        /** Update the cost of pvss for hierarchy objects.
1310        */
1311        float UpdateObjectCosts();
[1737]1312
[2539]1313
1314        ////////////////
1315
1316        /** Fast view cell loader in binary mode.
1317        */
[2547]1318        friend ViewCellsManager *ViewCellsManager::
1319                LoadViewCellsBinary(const std::string &filename,
1320                                    ObjectContainer &pvsObjects,
1321                                                        bool finalizeViewCells,
1322                                                        BoundingBoxConverter *bconverter);
[2539]1323
[2547]1324
[2539]1325        /** Print statistics about the view cells compression.
1326        */
[2530]1327        static void PrintCompressionStats(HierarchyManager *hm, const int pvsEntries);
[1887]1328
1329
[2530]1330        ////////////////////
1331
[2547]1332        /// if we the objects are compressed after evaluation
1333        /// this makes only sense for testing purpose
[1887]1334        bool mCompressObjects;
[2547]1335        /// hierarchy manager managing view space / object subdivision.
[1027]1336        HierarchyManager *mHierarchyManager;
[442]1337};
1338
[575]1339
[860]1340}
1341
[440]1342#endif
Note: See TracBrowser for help on using the repository browser.