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 |
|
---|
26 | const ObjectPvs &ViewCell::GetPvs() const
|
---|
27 | {
|
---|
28 | return mPvs;
|
---|
29 | }
|
---|
30 |
|
---|
31 | ObjectPvs &ViewCell::GetPvs()
|
---|
32 | {
|
---|
33 | return mPvs;
|
---|
34 | }
|
---|
35 |
|
---|
36 |
|
---|
37 | int ViewCell::Type() const
|
---|
38 | {
|
---|
39 | return VIEW_CELL;
|
---|
40 | }
|
---|
41 |
|
---|
42 |
|
---|
43 | void ViewCell::AddPassingRay(const Ray &ray, const int contributions)
|
---|
44 | {
|
---|
45 | mPassingRays.AddRay(ray, contributions);
|
---|
46 | }
|
---|
47 |
|
---|
48 |
|
---|
49 | float ViewCell::GetVolume() const
|
---|
50 | {
|
---|
51 | return mVolume;
|
---|
52 | }
|
---|
53 |
|
---|
54 |
|
---|
55 | void ViewCell::SetVolume(float volume)
|
---|
56 | {
|
---|
57 | mVolume = volume;
|
---|
58 | }
|
---|
59 |
|
---|
60 |
|
---|
61 | void ViewCell::SetMesh(Mesh *mesh)
|
---|
62 | {
|
---|
63 | mMesh = mesh;
|
---|
64 | }
|
---|
65 |
|
---|
66 |
|
---|
67 | void 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 | float ViewCell::GetArea() const
|
---|
86 | {
|
---|
87 | return mArea;
|
---|
88 | }
|
---|
89 |
|
---|
90 |
|
---|
91 | void ViewCell::SetArea(float area)
|
---|
92 | {
|
---|
93 | mArea = area;
|
---|
94 | }
|
---|
95 |
|
---|
96 |
|
---|
97 | /************************************************************************/
|
---|
98 | /* class ViewCellsStatistics implementation */
|
---|
99 | /************************************************************************/
|
---|
100 |
|
---|
101 | void ViewCellsStatistics::Print(ostream &app) const
|
---|
102 | {
|
---|
103 | app << "=========== View Cells Statistics ===============\n";
|
---|
104 |
|
---|
105 | app << setprecision(4);
|
---|
106 |
|
---|
107 | //app << "#N_CTIME ( Construction time [s] )\n" << Time() << " \n";
|
---|
108 |
|
---|
109 | app << "#N_OVERALLPVS ( objects in PVS )\n" << pvs << endl;
|
---|
110 |
|
---|
111 | app << "#N_PMAXPVS ( largest PVS )\n" << maxPvs << endl;
|
---|
112 |
|
---|
113 | app << "#N_PMINPVS ( smallest PVS )\n" << minPvs << endl;
|
---|
114 |
|
---|
115 | app << "#N_PAVGPVS ( average PVS )\n" << AvgPvs() << endl;
|
---|
116 |
|
---|
117 | app << "#N_PEMPTYPVS ( view cells with empty PVS )\n" << emptyPvs << endl;
|
---|
118 |
|
---|
119 | app << "#N_VIEWCELLS ( number of view cells)\n" << viewCells << endl;
|
---|
120 |
|
---|
121 | app << "#N_AVGLEAVES (average number of leaves per view cell )\n" << AvgLeaves() << endl;
|
---|
122 |
|
---|
123 | app << "#N_MAXLEAVES ( maximal number of leaves per view cell )\n" << maxLeaves << endl;
|
---|
124 |
|
---|
125 | app << "========== End of View Cells Statistics ==========\n";
|
---|
126 | }
|
---|