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

Revision 713, 23.4 KB checked in by bittner, 19 years ago (diff)

visibility filter used in glrenderer

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