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

Revision 564, 2.7 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(-1),
13mVolume(-1),
14mValid(true)
15{
16}
17
18ViewCell::ViewCell(Mesh *mesh):
19MeshInstance(mesh),
20mPiercingRays(0),
21mArea(-1),
22mVolume(-1),
23mValid(true)
24{
25}
26
27
28const ObjectPvs &ViewCell::GetPvs() const
29{
30        return mPvs;
31}
32
33ObjectPvs &ViewCell::GetPvs()
34{
35        return mPvs;
36}
37
38
39int ViewCell::Type() const
40{
41        return VIEW_CELL;
42}
43
44
45void ViewCell::AddPassingRay(const Ray &ray, const int contributions)
46{
47        mPassingRays.AddRay(ray, contributions);
48}
49
50
51float ViewCell::GetVolume() const
52{
53        return mVolume;
54}
55
56
57void ViewCell::SetVolume(float volume)
58{
59        mVolume = volume;
60}
61
62
63void ViewCell::SetMesh(Mesh *mesh)
64{
65        mMesh = mesh;
66}
67
68
69void ViewCell::UpdateViewCellsStats(ViewCellsStatistics &vcStat)
70{
71        ++ vcStat.viewCells;
72               
73        const int pvsSize = mPvs.GetSize();
74
75        vcStat.pvs += pvsSize;
76
77        if (pvsSize == 0)
78                ++ vcStat.emptyPvs;
79
80        if (pvsSize > vcStat.maxPvs)
81                vcStat.maxPvs = pvsSize;
82
83        if (pvsSize < vcStat.minPvs)
84                vcStat.minPvs = pvsSize;
85
86        if (!mValid)
87                ++ vcStat.invalid;
88}
89
90
91float ViewCell::GetArea() const
92{
93        return mArea;
94}
95
96
97void ViewCell::SetArea(float area)
98{
99        mArea = area;
100}
101
102
103void ViewCell::SetValid(const bool valid)
104{
105        mValid = valid;
106}
107
108
109bool ViewCell::GetValid() const
110{
111        return mValid;
112}
113
114
115/************************************************************************/
116/*                class ViewCellsStatistics implementation              */
117/************************************************************************/
118
119void ViewCellsStatistics::Print(ostream &app) const
120{
121        app << "=========== View Cells Statistics ===============\n";
122
123        app << setprecision(4);
124
125        //app << "#N_CTIME  ( Construction time [s] )\n" << Time() << " \n";
126
127        app << "#N_OVERALLPVS ( objects in PVS )\n" << pvs << endl;
128
129        app << "#N_PMAXPVS ( largest PVS )\n" << maxPvs << endl;
130
131        app << "#N_PMINPVS ( smallest PVS )\n" << minPvs << endl;
132
133        app << "#N_PAVGPVS ( average PVS )\n" << AvgPvs() << endl;
134
135        app << "#N_PEMPTYPVS ( view cells with empty PVS )\n" << emptyPvs << endl;
136
137        app << "#N_VIEWCELLS ( number of view cells)\n" << viewCells << endl;
138
139        app << "#N_AVGLEAVES (average number of leaves per view cell )\n" << AvgLeaves() << endl;
140
141        app << "#N_MAXLEAVES ( maximal number of leaves per view cell )\n" << maxLeaves << endl;
142       
143        app << "#N_INVALID ( number of invalid view cells )\n" << invalid << endl;
144
145        app << "========== End of View Cells Statistics ==========\n";
146}
Note: See TracBrowser for help on using the repository browser.