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 |
|
---|
9 | ViewCell::ViewCell():
|
---|
10 | MeshInstance(NULL),
|
---|
11 | mPiercingRays(0),
|
---|
12 | mArea(-1),
|
---|
13 | mVolume(-1),
|
---|
14 | mValid(true)
|
---|
15 | {
|
---|
16 | }
|
---|
17 |
|
---|
18 | ViewCell::ViewCell(Mesh *mesh):
|
---|
19 | MeshInstance(mesh),
|
---|
20 | mPiercingRays(0),
|
---|
21 | mArea(-1),
|
---|
22 | mVolume(-1),
|
---|
23 | mValid(true)
|
---|
24 | {
|
---|
25 | }
|
---|
26 |
|
---|
27 |
|
---|
28 | const ObjectPvs &ViewCell::GetPvs() const
|
---|
29 | {
|
---|
30 | return mPvs;
|
---|
31 | }
|
---|
32 |
|
---|
33 | ObjectPvs &ViewCell::GetPvs()
|
---|
34 | {
|
---|
35 | return mPvs;
|
---|
36 | }
|
---|
37 |
|
---|
38 |
|
---|
39 | int ViewCell::Type() const
|
---|
40 | {
|
---|
41 | return VIEW_CELL;
|
---|
42 | }
|
---|
43 |
|
---|
44 |
|
---|
45 | void ViewCell::AddPassingRay(const Ray &ray, const int contributions)
|
---|
46 | {
|
---|
47 | mPassingRays.AddRay(ray, contributions);
|
---|
48 | }
|
---|
49 |
|
---|
50 |
|
---|
51 | float ViewCell::GetVolume() const
|
---|
52 | {
|
---|
53 | return mVolume;
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | void ViewCell::SetVolume(float volume)
|
---|
58 | {
|
---|
59 | mVolume = volume;
|
---|
60 | }
|
---|
61 |
|
---|
62 |
|
---|
63 | void ViewCell::SetMesh(Mesh *mesh)
|
---|
64 | {
|
---|
65 | mMesh = mesh;
|
---|
66 | }
|
---|
67 |
|
---|
68 |
|
---|
69 | void 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 |
|
---|
88 | float ViewCell::GetArea() const
|
---|
89 | {
|
---|
90 | return mArea;
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | void ViewCell::SetArea(float area)
|
---|
95 | {
|
---|
96 | mArea = area;
|
---|
97 | }
|
---|
98 |
|
---|
99 |
|
---|
100 | void ViewCell::SetValid(const bool valid)
|
---|
101 | {
|
---|
102 | mValid = true;
|
---|
103 | }
|
---|
104 |
|
---|
105 |
|
---|
106 | bool ViewCell::GetValid() const
|
---|
107 | {
|
---|
108 | return mValid;
|
---|
109 | }
|
---|
110 |
|
---|
111 |
|
---|
112 | /************************************************************************/
|
---|
113 | /* class ViewCellsStatistics implementation */
|
---|
114 | /************************************************************************/
|
---|
115 |
|
---|
116 | void 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 | } |
---|