[235] | 1 | #include "ViewCell.h"
|
---|
| 2 | #include "Mesh.h"
|
---|
[308] | 3 | #include "Intersectable.h"
|
---|
[235] | 4 | #include "MeshKdTree.h"
|
---|
| 5 | #include "Triangle3.h"
|
---|
[463] | 6 | #include <time.h>
|
---|
[462] | 7 | #include <iomanip>
|
---|
[235] | 8 |
|
---|
[478] | 9 | ViewCell::ViewCell():
|
---|
| 10 | MeshInstance(NULL),
|
---|
| 11 | mPiercingRays(0),
|
---|
| 12 | mArea(0),
|
---|
[547] | 13 | mVolume(0),
|
---|
| 14 | mValid(true)
|
---|
[265] | 15 | {
|
---|
| 16 | }
|
---|
[235] | 17 |
|
---|
[478] | 18 | ViewCell::ViewCell(Mesh *mesh):
|
---|
| 19 | MeshInstance(mesh),
|
---|
| 20 | mPiercingRays(0),
|
---|
| 21 | mArea(0),
|
---|
[547] | 22 | mVolume(0),
|
---|
| 23 | mValid(true)
|
---|
[372] | 24 | {
|
---|
| 25 | }
|
---|
| 26 |
|
---|
[503] | 27 |
|
---|
[469] | 28 | const ObjectPvs &ViewCell::GetPvs() const
|
---|
[419] | 29 | {
|
---|
| 30 | return mPvs;
|
---|
| 31 | }
|
---|
| 32 |
|
---|
[469] | 33 | ObjectPvs &ViewCell::GetPvs()
|
---|
[372] | 34 | {
|
---|
| 35 | return mPvs;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[503] | 38 |
|
---|
[235] | 39 | int ViewCell::Type() const
|
---|
| 40 | {
|
---|
[308] | 41 | return VIEW_CELL;
|
---|
[235] | 42 | }
|
---|
| 43 |
|
---|
[503] | 44 |
|
---|
[372] | 45 | void ViewCell::AddPassingRay(const Ray &ray, const int contributions)
|
---|
| 46 | {
|
---|
| 47 | mPassingRays.AddRay(ray, contributions);
|
---|
[462] | 48 | }
|
---|
| 49 |
|
---|
[478] | 50 |
|
---|
[469] | 51 | float ViewCell::GetVolume() const
|
---|
| 52 | {
|
---|
| 53 | return mVolume;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
[478] | 56 |
|
---|
[469] | 57 | void ViewCell::SetVolume(float volume)
|
---|
| 58 | {
|
---|
| 59 | mVolume = volume;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
[503] | 62 |
|
---|
| 63 | void ViewCell::SetMesh(Mesh *mesh)
|
---|
| 64 | {
|
---|
| 65 | mMesh = mesh;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 |
|
---|
[479] | 69 | void ViewCell::UpdateViewCellsStats(ViewCellsStatistics &vcStat)
|
---|
| 70 | {
|
---|
| 71 | ++ vcStat.viewCells;
|
---|
| 72 |
|
---|
| 73 | const int pvsSize = mPvs.GetSize();
|
---|
[478] | 74 |
|
---|
[479] | 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 |
|
---|
[520] | 87 |
|
---|
[478] | 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 |
|
---|
[547] | 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 |
|
---|
[462] | 112 | /************************************************************************/
|
---|
| 113 | /* class ViewCellsStatistics implementation */
|
---|
| 114 | /************************************************************************/
|
---|
| 115 |
|
---|
[463] | 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 |
|
---|
[485] | 132 | app << "#N_PEMPTYPVS ( view cells with empty PVS )\n" << emptyPvs << endl;
|
---|
[463] | 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";
|
---|
[547] | 141 | } |
---|