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

Revision 547, 2.5 KB checked in by mattausch, 19 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),
14mValid(true)
15{
16}
17
18ViewCell::ViewCell(Mesh *mesh):
19MeshInstance(mesh),
20mPiercingRays(0),
21mArea(0),
22mVolume(0),
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
87
88float ViewCell::GetArea() const
89{
90        return mArea;
91}
92
93
94void ViewCell::SetArea(float area)
95{
96        mArea = area;
97}
98
99
100void ViewCell::SetValid(const bool valid)
101{
102        mValid = true;
103}
104
105
106bool ViewCell::GetValid() const
107{
108        return mValid;
109}
110
111
112/************************************************************************/
113/*                class ViewCellsStatistics implementation              */
114/************************************************************************/
115
116void ViewCellsStatistics::Print(ostream &app) const
117{
118        app << "=========== View Cells Statistics ===============\n";
119
120        app << setprecision(4);
121
122        //app << "#N_CTIME  ( Construction time [s] )\n" << Time() << " \n";
123
124        app << "#N_OVERALLPVS ( objects in PVS )\n" << pvs << endl;
125
126        app << "#N_PMAXPVS ( largest PVS )\n" << maxPvs << endl;
127
128        app << "#N_PMINPVS ( smallest PVS )\n" << minPvs << endl;
129
130        app << "#N_PAVGPVS ( average PVS )\n" << AvgPvs() << endl;
131
132        app << "#N_PEMPTYPVS ( view cells with empty PVS )\n" << emptyPvs << endl;
133
134        app << "#N_VIEWCELLS ( number of view cells)\n" << viewCells << endl;
135
136        app << "#N_AVGLEAVES (average number of leaves per view cell )\n" << AvgLeaves() << endl;
137
138        app << "#N_MAXLEAVES ( maximal number of leaves per view cell )\n" << maxLeaves << endl;
139       
140        app << "========== End of View Cells Statistics ==========\n";
141}
Note: See TracBrowser for help on using the repository browser.