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

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