source: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h @ 2199

Revision 2199, 19.8 KB checked in by mattausch, 17 years ago (diff)

using mutationsamples for evaluation

RevLine 
[372]1#ifndef _ViewCell_H__
2#define _ViewCell_H__
3
4#include "Mesh.h"
5#include "Containers.h"
6#include "Ray.h"
[462]7#include "Statistics.h"
[608]8#include "Material.h"
[955]9#include "gzstream.h"
[2116]10#include "ObjectPvs.h"
[469]11
[860]12namespace GtpVisibilityPreprocessor {
13
[469]14struct Triangle3;
15
[372]16class BspInterior;
17class BspPvs;
18class BspLeaf;
[1008]19class VspLeaf;
[469]20class KdLeaf;
[580]21class ViewCellInterior;
22class MergeCandidate;
23class ViewCellsManager;
[881]24class ViewCellLeaf;
[372]25
[955]26
[2116]27//class ObjectPvs;
[1264]28
[2116]29
[479]30/** Statistics for a view cell partition.
31*/
32
33class ViewCellsStatistics: public StatisticsBase
34{
35public:
36
37        /// number of view cells
38        int viewCells;
[1709]39        /// cost of the PVS
40        float pvsCost;
[479]41        /// largest PVS of all view cells
[1709]42        float maxPvs;
[479]43        /// smallest PVS of all view cells
[1709]44        float minPvs;
[479]45        /// view cells with empty PVS
46        int emptyPvs;
47        /// number of leaves covering the view space
48        int leaves;
49        /// largest number of leaves covered by one view cell
50        int maxLeaves;
[1667]51        /// number of invalid view cells
[564]52        int invalid;
53
[479]54    // Constructor
55        ViewCellsStatistics()
56        {
57                Reset();
58        }
59
60        double AvgLeaves() const {return (double)leaves / (double)viewCells;};
[1709]61        double AvgPvs() const {return (double)pvsCost / (double)viewCells;};
[479]62
63        void Reset()
64        {
65                viewCells = 0;
[1709]66                pvsCost = 0;
[479]67                maxPvs = 0;
68
69                minPvs = 999999;
70                emptyPvs = 0;
71                leaves = 0;
72                maxLeaves = 0;
[564]73                invalid = 0;
[479]74        }
75
[2176]76        void Print(std::ostream &app) const;
[479]77
[2176]78        friend std::ostream &operator<<(std::ostream &s, const ViewCellsStatistics &stat)
[479]79        {
80                stat.Print(s);
81                return s;
82        }
83};
84
[580]85
[1709]86class ViewCellsTreeStats
87{
88public:
89        int mPass;
90   
91        int mNumViewCells;
92               
93        float mRenderCostDecrease;
94
95    float mTotalRenderCost;
96   
97        float mCurrentPvsCost;
98                                                       
99        float mExpectedCost;
100   
101        float mAvgRenderCost;
102       
103        float mDeviation;
104                       
105        float mTotalPvsCost;
106       
107        int mEntriesInPvs;
108   
109        float mMemoryCost;
110       
111        int mPvsSizeDecr;
[1771]112 
[1709]113        float mVolume;
114
115
116        void Reset()
117        {
118                mPass = 0;
119                mNumViewCells = 0;
120                mRenderCostDecrease = 0;
121                mTotalRenderCost = 0;
122                mCurrentPvsCost = 0;
123                mExpectedCost = 0;
124                mAvgRenderCost = 0;
125                mDeviation = 0;
126                mTotalPvsCost = 0;
127                mEntriesInPvs = 0;
128                mMemoryCost = 0;
129                mPvsSizeDecr = 0;
130                mVolume = 0;
131        }
132
133
[2176]134        void Print(std::ostream &app) const;
[1709]135
[2176]136        friend std::ostream &operator<<(std::ostream &s, const ViewCellsTreeStats &stat)
[1709]137        {
138                stat.Print(s);
139                return s;
140        }
141};
142
143
[372]144/**
[1667]145        A view cell. View cells are regions in space. The visibility informations,
146        i.e., the primitives seen by the view cell are stored in a PVs.
147        A view cell can be represented in many different ways, e.g.,
148        a mesh representation.
[372]149*/
150class ViewCell: public MeshInstance
151{
[752]152        friend class ViewCellsTree;
153        friend class ViewCellsManager;
154
[372]155public:
[1999]156
[372]157        ViewCell();
[471]158
[372]159        /** Constructor taking a mesh representing the shape of the viewcell.
160        */
161        ViewCell(Mesh *mesh);
[462]162
[469]163        /** Default destructor.
164        */
[1551]165        virtual ~ViewCell();
[471]166        /** Returns Pvs.
[372]167        */
[469]168        const ObjectPvs &GetPvs() const;
[1002]169        /** Returns pvs.
170        */
[469]171        ObjectPvs &GetPvs();
[1002]172        /** Completely substitutes the pvs.
173        */
[880]174        void SetPvs(const ObjectPvs &pvs);
[2199]175        /** Type of view cell.
[752]176        */
[372]177        int Type() const;
178        /** Adds a passing ray to the passing ray container.
179        */
[471]180        void AddPassingRay(const Ray &ray, const int contributions);
[469]181        /** Returns volume of the view cell.
182        */
[2199]183        inline float GetVolume() const
184        {
185                return mVolume;
186        }
187        /** Sets the volume of the view cell.
188        */
189        inline void SetVolume(float volume)
190        {
191                mVolume = volume;
192        }
[478]193        /** Returns area of the view cell.
[469]194        */
[2199]195        inline float GetArea() const
196        {
197                return mArea;
198        }
[478]199        /** Sets the area of the view cell.
200        */
[2199]201        void SetArea(float area)
202        {
203                mArea = area;
204        }
[580]205        /** if this view cell is the root of a view cell hierarchy
206        */
207        bool IsRoot() const;
208        /** Returns parent view cell.
209        */
210        ViewCellInterior *GetParent() const;
[1002]211        /** Sets parent of this view cell.
212        */
213        void SetParent(ViewCellInterior *parent);
[503]214        /** Sets the mesh for this view cell.
215        */
216        void SetMesh(Mesh *mesh);
[1002]217        /** Sets this view cell to be a valid view cell according to some criteria.
218        */
[547]219        void SetValid(const bool valid);
[1002]220        /** Returns true if this view cell is considered to be valid according to
221                some criteria.
222        */
[547]223        bool GetValid() const;
224
[728]225        /** Returns estimated render cost of this view cell.
226        */
227        float GetRenderCost() const;
[580]228
[752]229        /** set color for visiualizations.
230        */
231        void SetColor(const RgbColor &color);
[580]232
[752]233        /** get color for visualuzations.
234        */
235    RgbColor GetColor() const;
[580]236
[1002]237        /** Adds a sample to the pvs.
238                @param sample the sample to be added
239                @param pdf a continuos measure of visibility
240                @param contribution returns the contribution of this sample to the pvs
241        */
242        bool AddPvsSample(Intersectable *sample, const float pdf, float &contribution);
[580]243
244        /** if this is a view cell correspending to a leaf in a hierarchy.
245        */
246        virtual bool IsLeaf() const = 0;
247
[752]248        static bool SmallerPvs(const ViewCell *a, const ViewCell *b)
249        {
[997]250                // HACK: take scalar value because pvs may not have been stored properly
251#if 1
[1709]252                return a->mPvsCost < b->mPvsCost;
[997]253#else
[1707]254                return a->GetPvs().EvalPvsCost() < b->GetPvs().EvalPvsCost();
[997]255#endif
256        }
[569]257
[1999]258        static bool GreaterOrEqualPvs(const ViewCell *a, const ViewCell *b)
259        {
260                return !SmallerPvs(a, b);
261        }
[1761]262
[997]263        static bool SmallerRenderCost(const ViewCell *a, const ViewCell *b)
264        {
265                return a->GetRenderCost() < b->GetRenderCost();
266        }
[580]267
[997]268        static bool LargerRenderCost(const ViewCell *a, const ViewCell *b)
269        {
270                return a->GetRenderCost() > b->GetRenderCost();
271        }
[801]272
[1002]273        /** Sets merge cost used for merging this view cell from other cells.
274                @hack The function is available for leaves also to have a common interface,
275                but it should be less than zero for leaves.
[1999]276        */
[600]277        void SetMergeCost(const float mergeCost);
[997]278
[1002]279        /** Returns merge cost needed to merge this leaf from other cells.
280                @hack The function is available for leaves also to have a common interface,
281                but it should be less than zero for leaves.
282        */
[600]283        float GetMergeCost() const;
[997]284
[1999]285        void UpdatePvsCost() {
286                mPvsCost = GetPvs().EvalPvsCost();
287        }
[1002]288
[1999]289        void SetPvsCost(const float c) {
290                mPvsCost = c;
291        }
[1771]292
[1999]293        float GetPvsCost() const {
294                return mPvsCost;
295        }
[1761]296
[1999]297        int GetFilteredPvsSize() const
298        {
299                return mFilteredPvsSize;
300        }
301
302        void SetFilteredPvsSize(const int s) {
303                mFilteredPvsSize = s;
[2124]304        }
[1771]305
[2124]306        //virtual int ViewCellType;
307
[372]308protected:
309
[1002]310        /// parent view cell in the view cell hierarchy
311        ViewCellInterior *mParent;
[372]312        /// the potentially visible objects
[469]313        ObjectPvs mPvs;
[1160]314        /// the volume of this view cell
[469]315        float mVolume;
[1545]316        /// the area of this view cell
[478]317        float mArea;
[1160]318        /// the cost that were paid for merging this view cells from two others.
[600]319        float mMergeCost;
[1160]320        /// if the view cell is valid view space
[547]321        bool mValid;
[881]322        /// color used for consistent visualization
[660]323        RgbColor mColor;
[1002]324        /// store pvs size, used for evaluation purpose when pvss are stored only in the leaves
[1709]325        float mPvsCost;
[1161]326        /** stores number of entries in pvs
327            this variable has the same value as mPvsSize for object pvs,
328                but usually not for kd cell based pvs
329        */
[1160]330        int mEntriesInPvs;
[1297]331        /** if the pvs size scalar (+ entries into pvs)
332                is up to date and corresponding to the real pvs size
333        */
[752]334        bool mPvsSizeValid;
[1771]335
[1999]336        /// Filter cost of the pvs
337        int mFilteredPvsSize;
338
[372]339};
340
[580]341
342class ViewCellInterior: public ViewCell
343{
[752]344        friend class ViewCellsManager;
[1284]345
[580]346public:
347        ViewCellInterior();
348        ~ViewCellInterior();
349
350        ViewCellInterior(Mesh *mesh);
[1999]351
[580]352        /** Sets pointer from parent to child and vice versa.
353        */
354        void SetupChildLink(ViewCell *l);
[1286]355        void ReplaceChildLink(ViewCell *prev, ViewCell *cur);
356
[586]357        void RemoveChildLink(ViewCell *l);
[580]358        bool IsLeaf() const;
359
[1284]360        void SetCost(const float c) {
361                mCost = c;
362        }
[1999]363
[1284]364        float GetCost() const {
365                return mCost;
366        }
367
[1999]368        ViewCellContainer mChildren;
369
[608]370protected:
[1999]371
372        /// Pverall cost resulting from the merge.
373        float mCost;
[580]374};
375
[881]376
[469]377/**
[881]378        Leaf of the view cell.
[469]379*/
[580]380class ViewCellLeaf: public ViewCell
[366]381{
382public:
[881]383        ViewCellLeaf()  {  mActiveViewCell = this; }
384        ViewCellLeaf(Mesh *mesh):
385        ViewCell(mesh) { mActiveViewCell = this; }
[469]386
[881]387        bool IsLeaf() const
388        {
389                return true;
390        }
391
[1551]392        /** Returns active view cell, i.e. this view cell or
393                a parent view cell which is set as active view cell.
[881]394        */
395        ViewCell *GetActiveViewCell() const
396        { return mActiveViewCell; }
397
398        /** Sets this view cell to be an active view cell.
399        */
400        void SetActiveViewCell(ViewCell *vc)
401        { mActiveViewCell = vc;}
[605]402       
[997]403        /** points to the currently active view cell. This is the
404                view cell representing the current brach.
405        */
[881]406        ViewCell *mActiveViewCell;
407};
[479]408
[1732]409
[1121]410/** Leaf of the view cell hierarchy corresponding
411        to a leaf in a spatial hierarchy.
[881]412*/
413template<typename T>
414class HierarchyLeafViewCell: public ViewCellLeaf
415{
416public:
417
418        HierarchyLeafViewCell<T>(): ViewCellLeaf() {  }
419        HierarchyLeafViewCell<T>(Mesh *mesh):
420        ViewCellLeaf(mesh) {  }
421               
[580]422        bool IsLeaf() const
423        {
424                return true;
425        }
426
[1551]427        /// Leaves of some hierarchy which contains this view cell.
428        vector<T> mLeaves;
[469]429};
430
[479]431
[1010]432typedef HierarchyLeafViewCell<VspLeaf *> VspViewCell;
[881]433typedef HierarchyLeafViewCell<BspLeaf *> BspViewCell;
434typedef HierarchyLeafViewCell<KdLeaf *> KdViewCell;
[469]435
[366]436
[580]437
[1008]438
[580]439class ViewCellsTree
440{
[600]441        friend class ViewCellsManager;
[1263]442        friend class ViewCellsParseHandlers;
[752]443
[580]444public:
[1999]445
[1264]446        ViewCellsTree();
[1999]447
[1004]448        /** View cells tree constructor taking a view cell mnanager as parameter
[997]449        */
[1004]450        ViewCellsTree(ViewCellsManager *vcm);
[580]451        ~ViewCellsTree();
452
453        /** Returns number of leaves this view cell consists of.
454        */
[736]455        int GetNumInitialViewCells(ViewCell *vc) const;
[580]456
457        /** Collects leaves corresponding to a view cell.
458        */
459        void CollectLeaves(ViewCell *vc, ViewCellContainer &leaves) const;
460
461        /** Merges view cells according to some cost heuristics.
462        */
463        int ConstructMergeTree(const VssRayContainer &rays, const ObjectContainer &objects);
464       
465        /** Refines view cells using shuffling, i.e., border leaves
466                of two view cells are exchanged if the resulting view cells
467                are tested to be "better" than the old ones.
468                @returns number of refined view cells
469        */
470        int RefineViewCells(const VssRayContainer &rays, const ObjectContainer &objects);
[651]471       
472        /** Assign colors to the viewcells so that they can be renderered interactively without
[997]473            color flickering. 
474        */
[651]475        void AssignRandomColors();
[580]476
[997]477        /** Updates view cell stats for this particular view cell.
[605]478        */
479        void UpdateViewCellsStats(ViewCell *vc, ViewCellsStatistics &vcStat);
[580]480
[997]481        /** Get costs resulting from each merge step.
482        */
[651]483        void GetCostFunction(vector<float> &costFunction);
[1603]484       
485        /** Returns storage cost resulting from each merge step.
486        */
487        void GetStorageFunction(vector<int> &storageCost);
488
[580]489        /** Returns optimal set of view cells for a given number of view cells.
490        */
491        void CollectBestViewCellSet(ViewCellContainer &viewCells, const int numViewCells);
492
[581]493        /** Root of view cells tree.
494        */
[584]495        ViewCell *GetRoot() const;
[581]496
[584]497        /** Returns pvs of view cell.
498                @note pvs is returned per reference if tree is not compressed,
499                per copy else.
500        */
501        void GetPvs(ViewCell *vc, ObjectPvs &pvs) const;
502
[1709]503        /** Returns pvs size (i.e. the render cost of the stored objects)
[584]504        */
[1709]505        float GetPvsCost(ViewCell *vc) const;
[1761]506 
[1161]507        /** Returns number of entries associated with this view cell.
[1586]508
509                This returns the same value as the "GetPvsSize" function for object pvs
510                but most likely different values if we use object space grouping.
511                E.g., using bounding volumes.
[584]512        */
[1161]513        int GetPvsEntries(ViewCell *vc) const;
[584]514
[1586]515        /** Returns the number of physically stored entries in the view cells sub tree.
516                This can vary based on the current storage method
[1161]517        */
[1586]518        int CountStoredPvsEntries(ViewCell *root) const;
[1161]519
[584]520        /** Returns memory cost of this view cell.
521        */
522        float GetMemoryCost(ViewCell *vc) const;
523
[752]524        /** Sets method of storage for view cells.
[584]525        */
[752]526        void SetViewCellsStorage(int type);
[584]527
[837]528        /** pvs storage methods
529        */
[752]530        enum {PVS_IN_INTERIORS, COMPRESSED, PVS_IN_LEAVES};
531
[584]532        /** If view cells in this tree have compressed pvs.
533        */
[752]534        int ViewCellsStorage() const;
[584]535
[660]536        /** Returns active view cell that is in the path of this view cell.
537        */
[881]538        ViewCell *GetActiveViewCell(ViewCellLeaf *vc) const;
[590]539
[660]540        /** Sets the leaves to be the currently active view cells.
541        */
542    void SetActiveSetToLeaves();
543
[651]544        /** Propagates pvs up the tree to the root and downwards the tree.
[610]545        */
[651]546        void PropagatePvs(ViewCell *vc);
[610]547
[837]548        /** Exports view cells to file.
549        */
[1201]550        bool Export(OUT_STREAM &stream, const bool exportPvs = false);
[610]551
[649]552        /** Export statistics of this view cell tree.
553        */
[2176]554        void ExportStats(const std::string &mergeStats);
[610]555
[650]556        /** Sets root of hierarchy.
557        */
558        void SetRoot(ViewCell *root);
559
[651]560        /** Assignes unique ids to view cells.
561        */
562        void CreateUniqueViewCellsIds();
563
[660]564        /** Resets pvs of whole tree.
565        */
566        void ResetPvs();
[651]567
[1121]568        /** Counts pvs of the view cell taking the kd cells into account.
569        */
570        int CountKdPvs(const ViewCellLeaf *vc) const;
571
[1551]572        /** Sets pointer to view cells manager.
573        */
574        void SetViewCellsManager(ViewCellsManager *vcm);
[1264]575
[1603]576        void Update();
[1586]577
[580]578protected:
579
[1586]580        /** Reads the environment and sets member variables.
581        */
[1264]582        void ReadEnvironment();
[580]583
584
[1999]585        //////////////////////////////////////////////////////////////
586        //                    merge related stuff                   //
587        //////////////////////////////////////////////////////////////
588
589
[729]590        /** Computes render cost of the merged pvs.
591        */
592        float ComputeMergedPvsCost(const ObjectPvs &pvs1, const ObjectPvs &pvs2) const;
593
[580]594        /** Returns cost of this leaf according to current heuristics.
595        */
596        float GetCostHeuristics(ViewCell *vc) const;
597
598        /** Returns cost of leaf.
599        */
600        float GetRenderCost(ViewCell *vc) const;
601
602        /** Evaluates the merge cost of this merge candidate pair.
603        */
604        void EvalMergeCost(MergeCandidate &mc) const;
605
606        /** Variance of leaf.
607        */
608        float GetVariance(ViewCell *vc) const;
609
610        /** Standard deviation of leaf.
611        */
612        float GetDeviation(ViewCell *vc) const;
613
[582]614        /** Tries to set this merge candidate to valid.
615                @returns false if both view cells are the same
[580]616        */
[582]617        bool ValidateMergeCandidate(MergeCandidate &mc) const;
[580]618
619        /** Merge view cells of leaves l1 and l2.
620                @returns difference in pvs size
621        */
[1999]622        ViewCellInterior *MergeViewCells(ViewCell *l, ViewCell *r, float &pvsDiff);
[580]623
624        /** Shuffles, i.e. takes border leaf from view cell 1 and adds it
625                to view cell 2.
626        */
[586]627        void ShuffleLeaf(ViewCell *leaf, ViewCellInterior *vc1, ViewCellInterior *vc2) const;   
[580]628               
629        /** Shuffles the leaves, i.e., tests if exchanging
630                the leaves helps in improving the view cells.
631        */
[586]632        bool ShuffleLeaves(MergeCandidate &mc) const;
[580]633
634        /** Calculates cost for merge of view cell 1 and 2.
635        */
[586]636        float EvalShuffleCost(ViewCell *leaf,
637                                                  ViewCellInterior *vc1,
638                                                  ViewCellInterior *vc2) const;
[580]639
640        /** Exports a snapshot of the merged view cells to disc.
641        */
642        void ExportMergedViewCells(ViewCellContainer &viewCells,
643                                                           const ObjectContainer &objects,
644                                                           const int numNewViewCells);
645
[997]646        /** Merge queue must be reset after some time because expected value
[580]647                may not be valid.
648        */
649        void ResetMergeQueue();
650
[1551]651        /** Updates the current cut of view cells.
[582]652                @returns number of newly merged view cells
[580]653        */
[582]654        int UpdateActiveViewCells(ViewCellContainer &viewCells);
[580]655
[997]656        /** Helper function pullling pvs as high up in the tree as possible.
657        */
[610]658        void PullUpVisibility(ViewCellInterior *interior);
[580]659
[997]660        /** Compress pvs of view cell and children.
661        */
[584]662        void CompressViewCellsPvs(ViewCell *root);
[580]663
[582]664        /** Returns memory usage of view cells.
665        */
666        float GetMemUsage() const;
[837]667
668        /**     Exports single view cell.
[610]669                NOTE: should be in exporter!!
670        */
[1201]671        void ExportViewCell(ViewCell *viewCell, OUT_STREAM &stream, const bool exportPvs);     
[581]672
[837]673        /** Exports pvs of a view cell.
674        */
[1201]675        void ExportPvs(ViewCell *viewCell, OUT_STREAM &stream);
[582]676
[1586]677        /** Counts the logical number of entries in the pvs this view cell.
678                The pvs is assumed to be stored using lossless compression.
679        */
[1166]680        int GetEntriesInPvsForCompressedStorage(ViewCell *vc) const;
[1586]681
682        /** Computes pvs size of this view cell.
683                The pvs is assumed to be stored using lossless compression.
684        */
[1709]685        float GetPvsCostForCompressedStorage(ViewCell *vc) const;
[1586]686       
687        /** Computes pvs size of this view cell.
688                The pvs is assumed to be stored in the leaves.
689        */
[1709]690        float GetPvsCostForLeafStorage(ViewCell *vc) const;
[1586]691
692        /** Counts the logical number of entries in the pvs this view cell.
693                The pvs is assumed to be stored using the leaves.
694        */
[1166]695        int GetEntriesInPvsForLeafStorage(ViewCell *vc) const;
[610]696
[1586]697        /** Update stats for the log.
698        */
[2176]699        void UpdateStats(std::ofstream &stats,
[1709]700                                         const ViewCellsTreeStats &vcStats);
[1166]701
[1842]702       
[1586]703
704        //////////////////////////////////////
705
[584]706        /// if the view cell tree hold compressed pvs
[752]707        int mViewCellsStorage;
[1551]708        /// pointer to the view cells manager
[580]709        ViewCellsManager *mViewCellsManager;
[1551]710        /// the root of the view cells hierarchy
[580]711        ViewCell *mRoot;
712
713        /// if merge visualization should be shown
714        bool mExportMergedViewCells;
[837]715        /// intermediate container of merged view cells.
[582]716        ViewCellContainer mMergedViewCells;
[837]717        /// if merged view cells are refined.
[586]718        bool mRefineViewCells;
[1842]719        /// weights between variance and render cost increase in the range [0 .. 1].
[580]720        float mRenderCostWeight;
721
722        /// overall cost used to normalize cost ratio
723        float mOverallCost;
724        float mExpectedCost;
725    float mDeviation;
726        float mAvgRenderCost;
[1551]727       
[837]728        /// the area is used for pvs heuristics
[580]729        int mUseAreaForPvs;
[1551]730        /// number of currently active view cells (=current cut)
[582]731        int mNumActiveViewCells;
[580]732        /// minimal number of view cells
733        int mMergeMinViewCells;
734        /// maximal cost ratio for the merge
735        float mMergeMaxCostRatio;
736
[2176]737        typedef std::priority_queue<MergeCandidate> MergeQueue;
[580]738
739        MergeQueue mMergeQueue;
740
[582]741        float mMaxMemory;
[580]742
[938]743        int mMaxMergesPerPass;
744        float mAvgCostMaxDeviation;
[580]745};
746
747
748/**
749        Candidate for leaf merging based on priority.
750*/
751class MergeCandidate
752
753        friend class ViewCellsTree;
754
755public:
756
757        MergeCandidate(ViewCell *l, ViewCell *r);
758
759        /** If this merge pair is still valid.
760        */
761        bool IsValid() const;
762
763       
764        friend bool operator<(const MergeCandidate &leafa, const MergeCandidate &leafb)
765        {
766                return leafb.GetMergeCost() < leafa.GetMergeCost();
767        }
768
769        void SetLeftViewCell(ViewCell *l);
770        void SetRightViewCell(ViewCell *l);
771
772        ViewCell *GetLeftViewCell() const;
773        ViewCell *GetRightViewCell() const;
774
[703]775        /** Returns leaf view cell initially associated with this merge candidate.
776        */
[580]777        ViewCell *GetInitialLeftViewCell() const;
[1133]778        /** Returns leaf view cell initially associated with this merge candidate.
779        */
[580]780        ViewCell *GetInitialRightViewCell() const;
781
782        /** Returns the increase of the standard deviation of this merge candidate.
783        */
784        float GetDeviationIncr() const;
785
786        /** Merge cost of this candidate pair.
787        */
788        float GetMergeCost() const;
789
790        /** Render cost of this candidate.
791        */
792        float GetRenderCost() const;
793       
794        static float sRenderCostWeight;
795
796protected:
797
798        /// render cost increase by this merge
799        float mRenderCost;
800        /// increase / decrease of standard deviation
801        float mDeviationIncr;
802
803        ViewCell *mLeftViewCell;
804        ViewCell *mRightViewCell;
805
806        ViewCell *mInitialLeftViewCell;
807        ViewCell *mInitialRightViewCell;
808};
809
810
811class MergeStatistics: public StatisticsBase
812{
813public:
814       
815        int merged;
816        int siblings;
817        int candidates;
818        int nodes;
819
820        int accTreeDist;
821        int maxTreeDist;
822       
823        Real collectTime;
824        Real mergeTime;
825
826        Real overallCost;
827
828        Real expectedRenderCost;
829        Real deviation;
830        Real heuristics;
831
832        // Constructor
833        MergeStatistics()
834        {
835                Reset();
836        }
837       
838        double AvgTreeDist() const {return (double)accTreeDist / (double)merged;};
839
840        void Reset()
841        {
842                nodes = 0;
843                merged = 0;
844                siblings = 0;
845                candidates = 0;
846       
847                accTreeDist = 0;
848                maxTreeDist = 0;
849
850                collectTime = 0;
851                mergeTime = 0;
852                overallCost = 0;
853
854                expectedRenderCost = 0;
855                deviation = 0;
856                heuristics = 0;
857
858        }
859
[2176]860        void Print(std::ostream &app) const;
[580]861
[2176]862        friend std::ostream &operator<<(std::ostream &s, const MergeStatistics &stat)
[580]863        {
864                stat.Print(s);
865                return s;
866        }
867};
868
[860]869}
870
[372]871#endif
Note: See TracBrowser for help on using the repository browser.