source: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp @ 520

Revision 520, 2.4 KB checked in by mattausch, 18 years ago (diff)
Line 
1#include "ViewCell.h"
2#include "Mesh.h"
3#include "Intersectable.h"
4#include "MeshKdTree.h"
5#include "Triangle3.h"
6#include <time.h>
7#include <iomanip>
8
9ViewCell::ViewCell():
10MeshInstance(NULL),
11mPiercingRays(0),
12mArea(0),
13mVolume(0)
14{
15}
16
17ViewCell::ViewCell(Mesh *mesh):
18MeshInstance(mesh),
19mPiercingRays(0),
20mArea(0),
21mVolume(0)
22{
23}
24
25
26const ObjectPvs &ViewCell::GetPvs() const
27{
28        return mPvs;
29}
30
31ObjectPvs &ViewCell::GetPvs()
32{
33        return mPvs;
34}
35
36
37int ViewCell::Type() const
38{
39        return VIEW_CELL;
40}
41
42
43void ViewCell::AddPassingRay(const Ray &ray, const int contributions)
44{
45        mPassingRays.AddRay(ray, contributions);
46}
47
48
49float ViewCell::GetVolume() const
50{
51        return mVolume;
52}
53
54
55void ViewCell::SetVolume(float volume)
56{
57        mVolume = volume;
58}
59
60
61void ViewCell::SetMesh(Mesh *mesh)
62{
63        mMesh = mesh;
64}
65
66
67void ViewCell::UpdateViewCellsStats(ViewCellsStatistics &vcStat)
68{
69        ++ vcStat.viewCells;
70               
71        const int pvsSize = mPvs.GetSize();
72
73        vcStat.pvs += pvsSize;
74
75        if (pvsSize == 0)
76                ++ vcStat.emptyPvs;
77
78        if (pvsSize > vcStat.maxPvs)
79                vcStat.maxPvs = pvsSize;
80
81        if (pvsSize < vcStat.minPvs)
82                vcStat.minPvs = pvsSize;
83}
84
85
86float ViewCell::GetArea() const
87{
88        return mArea;
89}
90
91
92void ViewCell::SetArea(float area)
93{
94        mArea = area;
95}
96
97
98/************************************************************************/
99/*                class ViewCellsStatistics implementation              */
100/************************************************************************/
101
102void ViewCellsStatistics::Print(ostream &app) const
103{
104        app << "=========== View Cells Statistics ===============\n";
105
106        app << setprecision(4);
107
108        //app << "#N_CTIME  ( Construction time [s] )\n" << Time() << " \n";
109
110        app << "#N_OVERALLPVS ( objects in PVS )\n" << pvs << endl;
111
112        app << "#N_PMAXPVS ( largest PVS )\n" << maxPvs << endl;
113
114        app << "#N_PMINPVS ( smallest PVS )\n" << minPvs << endl;
115
116        app << "#N_PAVGPVS ( average PVS )\n" << AvgPvs() << endl;
117
118        app << "#N_PEMPTYPVS ( view cells with empty PVS )\n" << emptyPvs << endl;
119
120        app << "#N_VIEWCELLS ( number of view cells)\n" << viewCells << endl;
121
122        app << "#N_AVGLEAVES (average number of leaves per view cell )\n" << AvgLeaves() << endl;
123
124        app << "#N_MAXLEAVES ( maximal number of leaves per view cell )\n" << maxLeaves << endl;
125       
126        app << "========== End of View Cells Statistics ==========\n";
127}
Note: See TracBrowser for help on using the repository browser.