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(0),
|
---|
13 | mVolume(0)
|
---|
14 | {
|
---|
15 | }
|
---|
16 |
|
---|
17 | ViewCell::ViewCell(Mesh *mesh):
|
---|
18 | MeshInstance(mesh),
|
---|
19 | mPiercingRays(0),
|
---|
20 | mArea(0),
|
---|
21 | mVolume(0)
|
---|
22 | {
|
---|
23 | }
|
---|
24 |
|
---|
25 | const ObjectPvs &ViewCell::GetPvs() const
|
---|
26 | {
|
---|
27 | return mPvs;
|
---|
28 | }
|
---|
29 |
|
---|
30 | ObjectPvs &ViewCell::GetPvs()
|
---|
31 | {
|
---|
32 | return mPvs;
|
---|
33 | }
|
---|
34 |
|
---|
35 | int ViewCell::Type() const
|
---|
36 | {
|
---|
37 | return VIEW_CELL;
|
---|
38 | }
|
---|
39 |
|
---|
40 | void ViewCell::AddPassingRay(const Ray &ray, const int contributions)
|
---|
41 | {
|
---|
42 | mPassingRays.AddRay(ray, contributions);
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | float ViewCell::GetVolume() const
|
---|
47 | {
|
---|
48 | return mVolume;
|
---|
49 | }
|
---|
50 |
|
---|
51 |
|
---|
52 | void ViewCell::SetVolume(float volume)
|
---|
53 | {
|
---|
54 | mVolume = volume;
|
---|
55 | }
|
---|
56 |
|
---|
57 | void ViewCell::UpdateViewCellsStats(ViewCellsStatistics &vcStat)
|
---|
58 | {
|
---|
59 | ++ vcStat.viewCells;
|
---|
60 |
|
---|
61 | const int pvsSize = mPvs.GetSize();
|
---|
62 |
|
---|
63 | vcStat.pvs += pvsSize;
|
---|
64 |
|
---|
65 | if (pvsSize == 0)
|
---|
66 | ++ vcStat.emptyPvs;
|
---|
67 |
|
---|
68 | if (pvsSize > vcStat.maxPvs)
|
---|
69 | vcStat.maxPvs = pvsSize;
|
---|
70 |
|
---|
71 | if (pvsSize < vcStat.minPvs)
|
---|
72 | vcStat.minPvs = pvsSize;
|
---|
73 | }
|
---|
74 |
|
---|
75 | float ViewCell::GetArea() const
|
---|
76 | {
|
---|
77 | return mArea;
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 | void ViewCell::SetArea(float area)
|
---|
82 | {
|
---|
83 | mArea = area;
|
---|
84 | }
|
---|
85 |
|
---|
86 |
|
---|
87 | /************************************************************************/
|
---|
88 | /* class ViewCellsStatistics implementation */
|
---|
89 | /************************************************************************/
|
---|
90 |
|
---|
91 | void ViewCellsStatistics::Print(ostream &app) const
|
---|
92 | {
|
---|
93 | app << "=========== View Cells Statistics ===============\n";
|
---|
94 |
|
---|
95 | app << setprecision(4);
|
---|
96 |
|
---|
97 | //app << "#N_CTIME ( Construction time [s] )\n" << Time() << " \n";
|
---|
98 |
|
---|
99 | app << "#N_OVERALLPVS ( objects in PVS )\n" << pvs << endl;
|
---|
100 |
|
---|
101 | app << "#N_PMAXPVS ( largest PVS )\n" << maxPvs << endl;
|
---|
102 |
|
---|
103 | app << "#N_PMINPVS ( smallest PVS )\n" << minPvs << endl;
|
---|
104 |
|
---|
105 | app << "#N_PAVGPVS ( average PVS )\n" << AvgPvs() << endl;
|
---|
106 |
|
---|
107 | app << "#N_PEMPTYPVS ( view cells with empty PVS )\n" << emptyPvs << endl;
|
---|
108 |
|
---|
109 | app << "#N_VIEWCELLS ( number of view cells)\n" << viewCells << endl;
|
---|
110 |
|
---|
111 | app << "#N_AVGLEAVES (average number of leaves per view cell )\n" << AvgLeaves() << endl;
|
---|
112 |
|
---|
113 | app << "#N_MAXLEAVES ( maximal number of leaves per view cell )\n" << maxLeaves << endl;
|
---|
114 |
|
---|
115 | app << "========== End of View Cells Statistics ==========\n";
|
---|
116 | }
|
---|