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

Revision 2562, 21.1 KB checked in by mattausch, 17 years ago (diff)

worked on visualization

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