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

Revision 703, 22.7 KB checked in by mattausch, 18 years ago (diff)

started implementation of visibility filter

Line 
1#ifndef _ViewCellsManager_H__
2#define _ViewCellsManager_H__
3
4#include "Ray.h"
5#include "VssRay.h"
6#include "Containers.h"
7#include "ViewCell.h"
8#include "ViewCellBsp.h"
9
10class ViewCell;
11class Intersectable;
12class RenderSimulator;
13class Renderer;
14class Mesh;
15struct Triangle3;
16class SimulationStatistics;
17class BspTree;
18class KdTree;
19class VspKdTree;
20class VspBspTree;
21class KdNode;
22class KdLeaf;
23class VspKdTree;
24class AxisAlignedBox3;
25class BspLeaf;
26class ViewCellsStatistics;
27class Exporter;
28class Beam;
29class Preprocessor;
30class ViewCellsTree;
31class MergeCandidate;
32
33struct BspRay;
34
35
36/** Probably Visible Set */
37class PrVs
38{
39public:
40  /// viewcells
41  ViewCellContainer mViewCells;
42  /// aggregated pvs
43  ObjectPvs mPvs;
44
45  // input parameter is the render budget for the PrVS
46  float mRenderBudget;
47
48  /// some characteristic values could be here
49 
50};
51
52/**
53        Manages different higher order operations on the view cells.
54*/
55class ViewCellsManager
56{
57
58public:
59  struct PvsStatistics {
60        int minPvs;
61        int maxPvs;
62        float avgPvs;
63        int viewcells;
64  };
65 
66  /**
67        Candidate for leaf merging based on priority.
68        */
69        class LocalMergeCandidate
70        { 
71        public:
72                LocalMergeCandidate(ViewCell *l, ViewCell *r);
73
74                /** If this merge pair is still valid.
75                */
76                //bool IsValid() const;
77       
78                friend bool operator<(const LocalMergeCandidate &leafa, const LocalMergeCandidate &leafb)
79                {
80                        return leafb.GetMergeCost() < leafa.GetMergeCost();
81                }
82
83                void SetLeftViewCell(ViewCell *l) {mLeftViewCell = l;}
84                void SetRightViewCell(ViewCell *l) {mRightViewCell = l;}
85
86                ViewCell *GetLeftViewCell() const {return mLeftViewCell;}
87                ViewCell *GetRightViewCell() const { return mRightViewCell;}
88
89                float GetMergeCost() const {return mMergeCost;}
90                void SetMergeCost(const float cost) {mMergeCost = cost;}
91
92        protected:
93
94                /// render cost increase by this merge
95                float mMergeCost;
96       
97                ViewCell *mLeftViewCell;
98                ViewCell *mRightViewCell;
99        };
100
101
102
103  /// view cell container types
104  enum {BSP, KD, VSP_KD, VSP_BSP};
105 
106        /** Constructor taking the initial and construction samples.
107                @param initialSamples the maximal number of samples used for creating the hierarchy
108                of view cells
109                @param constructionSamples the maximal number of samples used for construction
110        */
111        ViewCellsManager(const int initialSamples, const int constructionSamples);
112
113        ViewCellsManager();
114
115        virtual ~ViewCellsManager();
116
117        /** Constructs view cells container taking a preprocessor
118                @returns the output rays (if not null)
119        */
120        int Construct(Preprocessor *preprocessor, VssRayContainer *outRays = NULL);
121
122        /** Constructs view cell container with a given number of samples.
123        */
124        virtual int ConstructSubdivision(const ObjectContainer &objects,
125                                                  const VssRayContainer &rays) = 0;
126
127        /** Computes sample contributions of the rays to the view cells PVS.
128       
129                @param rays bundle of rays used to find intersections with view cells and
130                adding the contribution
131                @param addRays true if rays should be added to the PVSs of the viewcells they
132                intersect
133                @param storeViewCells true if view cells should be stored in the ray
134        */
135        float ComputeSampleContributions(const VssRayContainer &rays,
136                                                                   const bool addContributions,
137                                                                   const bool storeViewCells);
138
139        /** Add sample contributions to the viewcells they intersect */
140        void AddSampleContributions(const VssRayContainer &rays);
141 
142
143        /** Computes sample contribution of a simgle ray to the view cells PVS.
144                @param ray finds intersections with view cells and holds the contribution
145                @param castRay true if ray should be cast to gain the information, false if ray
146                is already holding the information and need not be recast.
147         
148                @returns number of sample contributions
149        */
150        virtual float ComputeSampleContributions(VssRay &ray,
151                                                                                         const bool addRays,
152                                                                                         const bool storeViewCells);
153
154        virtual void AddSampleContributions(VssRay &ray);
155
156        /** Prints out statistics of the view cells.
157        */
158        virtual void PrintStatistics(ostream &s) const;
159
160        /** Post processes view cells givemŽa number of rays.
161        */
162        virtual int PostProcess(const ObjectContainer &objects,
163                                                        const VssRayContainer &rays) = 0;
164
165        /** Show visualization of the view cells.
166        */
167        virtual void Visualize(const ObjectContainer &objects,
168                                                   const VssRayContainer &sampleRays) = 0;
169
170        /** type of the view cell container.
171        */
172        virtual int GetType() const = 0;
173
174        /** Load the input viewcells. The input viewcells should be given as a collection
175                of meshes. Each mesh is assume to form a bounded polyhedron defining the interior of
176                the viewcell. The method then builds a BSP tree of these view cells.
177               
178                @param filename file to load
179                @return true on success
180    */
181    virtual bool LoadViewCellsGeometry(const string filename);
182
183       
184        /** Constructs view cell from base triangle. The ViewCell is extruded along the normal vector.
185                @param the base triangle
186                @param the height of the newly created view cell
187        */
188        ViewCell *ExtrudeViewCell(const Triangle3 &baseTri, const float height) const;
189
190        /** Merges two view cells.
191                @note the piercing rays of the front and back will be ordered   
192                @returns new view cell based on the merging.
193        */
194        ViewCellInterior *MergeViewCells(ViewCell *front, ViewCell *back) const;
195
196        /** Merges a container of view cells.
197                @returns new view cell based on the merging.
198        */
199        ViewCellInterior *MergeViewCells(ViewCellContainer &children) const;
200       
201        /** Generates view cell of type specified by this manager
202        */
203        virtual ViewCell *GenerateViewCell(Mesh *mesh = NULL) const = 0;
204
205        /** Adds a new view cell to the list of predefined view cells.
206        */
207        void AddViewCell(ViewCell *viewCell);
208
209        /** Derive view cells from objects.
210        */
211        void DeriveViewCells(const ObjectContainer &objects,
212                                                 ViewCellContainer &viewCells,
213                                                 const int maxViewCells) const;
214
215        /** Sets maximal number of samples used for the
216                construction of the view cells.
217        */
218        void SetVisualizationSamples(const int visSamples);
219
220        /** Sets maximal number of samples used for the construction of the view cells.
221        */
222        void SetConstructionSamples(const int constructionSamples);
223
224        /** Sets maximal number of samples used for the visualization of the view cells.
225        */
226        void SetInitialSamples(const int initialSamples);
227
228        /** Sets maximal number of samples used for the post processing of the view cells.
229        */
230        void SetPostProcessSamples(const int postProcessingSamples);
231
232        /** See set.
233        */
234        int GetVisualizationSamples() const;
235
236        /** See set.
237        */
238        int GetConstructionSamples() const;
239
240        /** See set.
241        */
242        int GetPostProcessSamples() const;
243
244        /** Returns true if view cells wer already constructed.
245        */
246        virtual bool ViewCellsConstructed() const = 0;
247
248        /** cast line segment to get a list of unique viewcells which are intersected
249                by this line segment
250        */
251 
252        virtual int CastLineSegment(const Vector3 &origin,
253                                                          const Vector3 &termination,
254                                                          ViewCellContainer &viewcells
255                                                          ) = 0;
256
257        virtual void GetPvsStatistics(PvsStatistics &stat);
258
259        virtual void GetPrVS(const Vector3 &viewPoint, PrVs &prvs);
260 
261        /** Get a viewcell containing the specified point
262        */
263        virtual ViewCell *GetViewCell(const Vector3 &point) const = 0;
264 
265        virtual void PrintPvsStatistics(ostream &s);
266
267        /** Returns probability that view point lies in one view cell.
268        */
269        virtual float GetProbability(ViewCell *viewCell) = 0;
270
271        /** Returns render cost of a single view cell given the render cost of an object.
272        */
273        float GetRendercost(ViewCell *viewCell, float objRendercost) const;
274
275        /** Returns container of loaded / generated view cells.
276        */
277        ViewCellContainer &GetViewCells();
278
279        /** Helper function used to split ray sets uniformly
280                into one that is currently used and the other that
281                is saved for later processing.
282                @param sourceRays the input ray set
283                @param maxSize the maximal number of rays that will be used
284                @param usedRays returns the used ray set
285                @param savedRays if not null, returns the saved ray set
286        */
287        void GetRaySets(const VssRayContainer &sourceRays,
288                                        const int maxSize,
289                                        VssRayContainer &usedRays,
290                                        VssRayContainer *savedRays = NULL) const;
291       
292        /** Returns accumulated area of all view cells.
293        */
294        float GetAccVcArea();
295
296        /** Returns area of one view cell.
297        */
298        virtual float GetArea(ViewCell *viewCell) const;
299
300        /** Returns volume of view cell.
301        */
302        virtual float GetVolume(ViewCell *viewCell) const;
303
304        /** Sets the current renderer mainly for view cells statistics.
305        */
306        void SetRenderer(Renderer *renderer);
307
308        /** Computes a (random) view point in the valid view space.
309                @returns true if valid view point was found
310        */
311        virtual bool GetViewPoint(Vector3 &viewPoint) const;
312
313        /** Returns true if this view point is in the valid view space.
314        */
315        virtual bool ViewPointValid(const Vector3 &viewPoint) const;
316
317        /** Sets a view space boundary.
318        */
319        void SetViewSpaceBox(const AxisAlignedBox3 &box);
320
321        AxisAlignedBox3 GetViewSpaceBox() const;
322
323        /** Creates mesh for this view cell.
324        */
325        virtual void CreateMesh(ViewCell *vc) = NULL;
326
327        /** Writes view cells to disc.
328        */
329        virtual bool ExportViewCells(const string filename);
330
331        /** Casts beam to collect view cells.
332        */
333        virtual int CastBeam(Beam &beam);
334
335        /** Checks if view cell is considered as valid.
336        */
337        virtual bool CheckValidity(ViewCell *vc,
338                                                           int minPvsSize,
339                                                           int maxPvsSize) const;
340
341       
342        /** Sets validity of view cell
343        */
344        virtual void SetValidity(ViewCell *vc,
345                                                         int minPvsSize,
346                                                         int maxPvsSize) const;
347
348  /** sets validy of all viewcells */
349        virtual void SetValidity(
350                                                         int minPvsSize,
351                                                         int maxPvsSize) const;
352
353
354        /** set valid viewcells in the range of pvs. sorts the viewcells
355          according to the pvs and then pickups those in the ranges */
356
357   
358        void SetValidityPercentage(const float minValid,        const float maxValid);
359
360    int CountValidViewcells() const;
361
362        /** Returns maximal allowed pvs size.
363        */
364        int GetMaxPvsSize() const;
365
366        /** Returns maximal allowed pvs size.
367        */
368        int GetMinPvsSize() const;
369
370        /** Returns maximal ratio. i.e., currentPVs / maxPvs,
371                where pvs is still considered valid.
372        */
373        float GetMaxPvsRatio() const;
374
375        /** Exports view cell geometry.
376        */
377        virtual void ExportViewCellGeometry(Exporter *exporter,
378                                                                                ViewCell *vc,
379                                                                                const Plane3 *clipPlane = NULL) const = 0;
380
381        virtual void FinalizeViewCells(const bool createMesh);
382
383
384        /** Loads view cells from file. The view cells manager is created with
385                respect to the loaded view cells.
386
387                @returns the view cells manager if loading was successful, false otherwise
388        */
389        static ViewCellsManager *LoadViewCells(const string filename,
390                                                                                   ObjectContainer *objects);
391
392        /** Evaluates statistics values on view cells.
393        */
394        void EvaluateRenderStatistics(float &totalRenderCost,
395                                                                  float &expectedRenderCost,
396                                                                  float &deviation,
397                                                                  float &variance,
398                                                                  int &totalPvs,
399                                                                  float &avgRenderCost);
400
401
402        /** Returns hierarchy of the view cells.
403        */
404        ViewCellsTree *GetViewCellsTree();
405
406        virtual void CollectMergeCandidates(const VssRayContainer &rays,
407                                                                                vector<MergeCandidate> &candidates) = 0;
408
409        void CollectViewCells(const int n);
410
411        /** Returns true if this (logical) view cell is equal to a spatial node.
412        */
413        virtual bool EqualToSpatialNode(ViewCell *viewCell) const { return false;}
414
415        /** Sets current view cells set to active, i.e., the sampling is done in this view cell set.
416        */
417        void SetViewCellsActive();
418
419        /** Evaluates worth of current view cell hierarchy.
420        */
421        void EvalViewCellPartition(Preprocessor *preprocessor);
422
423
424protected:
425
426        /** Returns the bounding box of filter width.
427        */
428        AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint, const float width) const;
429
430        /** Intersects box with the tree and returns the number of intersected boxes.
431                @returns number of view cells found
432        */
433        virtual int ComputeBoxIntersections(const AxisAlignedBox3 &box, ViewCellContainer &viewCells) const {return 0;};
434
435        virtual void TestFilter(const ObjectContainer &objects) {};
436
437        /**
438                if the view cells tree was already constructed or not.
439        */
440        bool ViewCellsTreeConstructed() const;
441
442        int CastPassSamples(const int samplesPerPass,
443                                                const int sampleType,
444                                                VssRayContainer &vssRays) const;
445
446        void ParseEnvironment();
447
448        /** Creates unique view cell ids.
449        */
450        void CreateUniqueViewCellIds();
451
452        /** Finalizes, i.e., creates mesh, volume, area etc. for the view cell.
453        */
454        virtual void Finalize(ViewCell *viewCell, const bool createMesh);
455
456        /** Recollects view cells and resets statistics.
457        */
458        void ResetViewCells();
459       
460        /** Collects the view cells in the view cell container.
461        */
462        virtual void CollectViewCells() = 0;
463       
464        /** Evaluates view cells statistics and stores it in
465                mViewCellsStatistics.
466        */
467        void EvaluateViewCellsStats();
468
469        //-- helper functions for view cell visualization
470
471        /** Exports the view cell partition.
472        */
473        void ExportViewCellsForViz(Exporter *exporter) const;
474
475        /** Sets exporter color.
476        */
477        virtual void ExportColor(Exporter *exporter, ViewCell *vc) const = 0;
478
479
480        virtual float GetViewSpaceVolume();
481       
482        /** Creates meshes from the view cells.
483        */
484        void CreateViewCellMeshes();
485
486        /** Takes different measures to prepares the view cells after loading them from disc.
487        */
488        virtual void PrepareLoadedViewCells() {};
489
490        /** Creates clip plane for visualization.
491        */
492        void CreateClipPlane();
493
494        Plane3 mClipPlane;
495        bool mUseClipPlaneForViz;
496
497
498        /// Renders the view cells.
499        Renderer *mRenderer;
500
501        /// Loaded view cells
502        ViewCellContainer mViewCells;
503
504        ViewCellsTree *mViewCellsTree;
505
506        /// maximum number of samples taken for construction of the view cells
507        int mConstructionSamples;
508        int mSamplesPerPass;
509        int mInitialSamples;
510        int mPostProcessSamples;
511        int mVisualizationSamples;
512
513        float mTotalAreaValid;
514        float mTotalArea;
515
516        int mMaxPvsSize;
517        int mMinPvsSize;
518        float mMaxPvsRatio;
519
520        int mSamplingType;
521        int mNumActiveViewCells;
522        bool mCompressViewCells;
523
524        ViewCellsStatistics mCurrentViewCellsStats;
525        /// the scene bounding box
526        AxisAlignedBox3 mViewSpaceBox;
527        /// holds the view cell meshes
528        MeshContainer mMeshContainer;
529        /// if view cells should be exported
530        bool mExportViewCells;
531
532        //bool mMarchTree);
533        bool mOnlyValidViewCells;
534
535        /// if rays should be used to collect merge candidates
536        bool mUseRaysForMerge;
537        /// merge the view cells?
538        bool mMergeViewCells;
539
540        /// the width of the box filter
541        float mFilterWidth;
542        int mMaxFilterSize;
543
544        //-- visualization options
545       
546        /// color code for view cells
547        int mColorCode;
548        bool mExportGeometry;
549        bool mExportRays;
550
551        bool mViewCellsFinished;
552
553        bool mEvaluateViewCells;
554
555        bool mShowVisualization;
556
557        // HACK in order to detect empty view cells
558        void CollectEmptyViewCells();
559        void TestEmptyViewCells(const ObjectContainer &obj);
560
561        ViewCellContainer mEmptyViewCells;
562};
563
564
565
566/**
567        Manages different higher order operations on the view cells.
568*/
569class BspViewCellsManager: public ViewCellsManager
570{
571
572public:
573        /** Constructor taking the bsp tree and the number of samples
574                used to construct the bsp tree.
575        */
576        BspViewCellsManager(BspTree *tree);
577
578        ~BspViewCellsManager();
579
580        int ConstructSubdivision(const ObjectContainer &objects,
581                                  const VssRayContainer &rays);
582
583        int PostProcess(const ObjectContainer &objects,
584                                        const VssRayContainer &rays);
585
586        void Visualize(const ObjectContainer &objects,
587                                   const VssRayContainer &sampleRays);
588
589        int GetType() const;
590       
591        ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
592
593        bool ViewCellsConstructed() const;
594
595        //void PrintStatistics(ostream &s) const;
596
597        int CastLineSegment(const Vector3 &origin,
598                                                const Vector3 &termination,
599                                                ViewCellContainer &viewcells);
600       
601        float GetProbability(ViewCell *viewCell);
602       
603
604        /** Get a viewcell containing the specified point */
605        ViewCell *GetViewCell(const Vector3 &point) const;
606
607        void CreateMesh(ViewCell *vc);
608
609        void ExportViewCellGeometry(Exporter *exporter,
610                                                                ViewCell *vc,
611                                                                const Plane3 *clipPlane = NULL) const;
612       
613        void CollectMergeCandidates(const VssRayContainer &rays,
614                                                                vector<MergeCandidate> &candidates);
615
616        void Finalize(ViewCell *viewCell, const bool createMesh);
617
618        bool ExportViewCells(const string filename);
619
620        ViewCell *ConstructSpatialMergeTree(BspNode *root);
621
622
623protected:
624
625
626        /** HACK
627        */
628        void AddCurrentViewCellsToHierarchy();
629
630        void CollectViewCells();
631
632        void ExportColor(Exporter *exporter, ViewCell *vc) const;
633       
634
635
636        /// the BSP tree.
637        BspTree *mBspTree;
638       
639        vector<BspRay *> mBspRays;
640
641private:
642
643        /** Exports visualization of the BSP splits.
644        */
645        void ExportSplits(const ObjectContainer &objects);
646
647        /** Exports visualization of the BSP PVS.
648        */
649        void ExportBspPvs(const ObjectContainer &objects);
650
651        void TestSubdivision();
652};
653
654/**
655        Manages different higher order operations on the KD type view cells.
656*/
657class KdViewCellsManager: public ViewCellsManager
658{
659
660public:
661
662        KdViewCellsManager(KdTree *tree);
663
664        int ConstructSubdivision(const ObjectContainer &objects,
665                                  const VssRayContainer &rays);
666
667        int CastLineSegment(const Vector3 &origin,
668                                                const Vector3 &termination,
669                                                ViewCellContainer &viewcells);
670
671        int PostProcess(const ObjectContainer &objects,
672                                        const VssRayContainer &rays);
673
674        void Visualize(const ObjectContainer &objects,
675                                   const VssRayContainer &sampleRays);
676
677        int GetType() const;
678
679        bool ViewCellsConstructed() const;
680
681        ViewCell *GenerateViewCell(Mesh *mesh) const;
682
683        /** Prints out statistics of this approach.
684        */
685        //  virtual void PrintStatistics(ostream &s) const;
686        ViewCell *GetViewCell(const Vector3 &point) const { return NULL; }
687
688        float GetProbability(ViewCell *viewCell);
689       
690
691        void CreateMesh(ViewCell *vc);
692
693        void ExportViewCellGeometry(Exporter *exporter,
694                                                                ViewCell *vc,
695                                                                const Plane3 *clipPlane = NULL) const;
696
697        void CollectMergeCandidates(const VssRayContainer &rays,
698                                                                vector<MergeCandidate> &candidates);
699
700protected:
701
702        /** Collects view cells from a hierarchy.
703        */
704        void CollectViewCells();
705
706        KdNode *GetNodeForPvs(KdLeaf *leaf);
707
708        void ExportColor(Exporter *exporter, ViewCell *vc) const;
709
710
711        /// the BSP tree.
712        KdTree *mKdTree;
713
714        /// depth of the KD tree nodes with represent the view cells
715        int mKdPvsDepth;
716};
717
718/**
719        Manages different higher order operations on the view cells
720        for vsp kd tree view cells.
721*/
722class VspKdViewCellsManager: public ViewCellsManager
723{
724
725public:
726
727        VspKdViewCellsManager(VspKdTree *vspKdTree);
728
729        int ConstructSubdivision(const ObjectContainer &objects,
730                                  const VssRayContainer &rays);
731
732
733        int PostProcess(const ObjectContainer &objects,
734                                        const VssRayContainer &rays);
735
736        void Visualize(const ObjectContainer &objects,
737                                   const VssRayContainer &sampleRays);
738
739        int GetType() const;
740       
741        bool ViewCellsConstructed() const;
742
743        //virtual void PrintStatistics(ostream &s) const;
744
745        ViewCell *GenerateViewCell(Mesh *mesh) const;
746
747
748    int CastLineSegment(const Vector3 &origin,
749                                                const Vector3 &termination,
750                                                ViewCellContainer &viewcells);
751
752        ViewCell *GetViewCell(const Vector3 &point) const { return NULL; }
753
754        float GetProbability(ViewCell *viewCell);
755
756
757        void CreateMesh(ViewCell *vc);
758
759        void ExportViewCellGeometry(Exporter *exporter,
760                                                                ViewCell *vc,
761                                                                const Plane3 *clipPlane = NULL) const;
762
763        void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates);
764
765protected:
766
767        void ExportLeaves(const ObjectContainer &objects,
768                                          const VssRayContainer &sampleRays);
769
770        void CollectViewCells();
771
772        void ExportColor(Exporter *exporter, ViewCell *vc) const;
773
774
775
776        /// the BSP tree.
777        VspKdTree *mVspKdTree;
778};
779
780
781
782/**
783        Manages different higher order operations on the view cells.
784*/
785class VspBspViewCellsManager: public ViewCellsManager
786{
787
788public:
789
790        VspBspViewCellsManager(VspBspTree *tree);
791        ~VspBspViewCellsManager();
792
793        int ConstructSubdivision(const ObjectContainer &objects,
794                                  const VssRayContainer &rays);
795
796        int PostProcess(const ObjectContainer &objects,
797                                        const VssRayContainer &rays);
798
799        void Visualize(const ObjectContainer &objects,
800                                   const VssRayContainer &sampleRays);
801
802        int GetType() const;
803       
804        ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
805
806        bool ViewCellsConstructed() const;
807
808       
809        int CastLineSegment(const Vector3 &origin,
810                                                const Vector3 &termination,
811                                                ViewCellContainer &viewcells);
812
813        float GetProbability(ViewCell *viewCell);
814       
815        ViewCell *GetViewCell(const Vector3 &point) const;
816
817        bool GetViewPoint(Vector3 &viewPoint) const;
818
819        bool ViewPointValid(const Vector3 &viewPoint) const;
820
821        void CreateMesh(ViewCell *vc);
822
823        //bool LoadViewCellsGeometry(const string filename, ObjectContainer *objects);
824        bool ExportViewCells(const string filename);
825
826        int CastBeam(Beam &beam);
827
828        void ExportViewCellGeometry(Exporter *exporter,
829                                                                ViewCell *vc,
830                                                                const Plane3 *clipPlane = NULL) const;
831
832        //float GetVolume(ViewCell *viewCell) const;
833
834        void Finalize(ViewCell *viewCell, const bool createMesh);
835
836        void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates);
837
838        /** Returns true if this view cell is equivavalent to a spatial node.
839        */
840        bool EqualToSpatialNode(ViewCell *viewCell) const;
841
842
843protected:
844
845        int ComputeBoxIntersections(const AxisAlignedBox3 &box, ViewCellContainer &viewCells) const;
846       
847        /** Returns node of the spatial hierarchy corresponding to the view cell
848                if such a node exists.
849        */
850        BspNode *GetSpatialNode(ViewCell *viewCell) const;
851
852        /** HACK
853        */
854        void AddCurrentViewCellsToHierarchy();
855
856        /** Merges the view cells.
857        */
858        void MergeViewCells(const VssRayContainer &rays,
859                                                const ObjectContainer &objects);
860       
861        void RefineViewCells(const VssRayContainer &rays, const ObjectContainer &objects);
862
863        void CollectViewCells();
864
865        /** Returns maximal depth difference of view cell
866                leaves in tree.
867        */
868        int GetMaxTreeDiff(ViewCell *vc) const;
869       
870
871        void ExportColor(Exporter *exporter, ViewCell *vc) const;
872
873        void PrepareLoadedViewCells();
874
875        ViewCell *ConstructSpatialMergeTree(BspNode *root);
876
877        void TestFilter(const ObjectContainer &objects);
878
879
880
881        /// the view space partition BSP tree.
882        VspBspTree *mVspBspTree;
883
884
885private:
886
887        /** Exports visualization of the BSP splits.
888        */
889        void ExportSplits(const ObjectContainer &objects,
890                                          const VssRayContainer &rays);
891
892        /** Exports visualization of the BSP PVS.
893        */
894        void ExportBspPvs(const ObjectContainer &objects,
895                                          const VssRayContainer &rays);
896
897        void TestSubdivision();
898};
899
900
901class ViewCellsManagerFactory
902{
903
904public:
905
906        ViewCellsManager *Create(const string mName);
907
908};
909
910#endif
Note: See TracBrowser for help on using the repository browser.