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

Revision 728, 23.0 KB checked in by mattausch, 19 years ago (diff)

added histogram (not tested)
last version before updating render cost evaluation

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