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

Revision 479, 2.3 KB checked in by mattausch, 19 years ago (diff)
RevLine 
[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]9ViewCell::ViewCell():
10MeshInstance(NULL),
11mPiercingRays(0),
12mArea(0),
13mVolume(0)
[265]14{
15}
[235]16
[478]17ViewCell::ViewCell(Mesh *mesh):
18MeshInstance(mesh),
19mPiercingRays(0),
20mArea(0),
21mVolume(0)
[372]22{
23}
24
[469]25const ObjectPvs &ViewCell::GetPvs() const
[419]26{
27        return mPvs;
28}
29
[469]30ObjectPvs &ViewCell::GetPvs()
[372]31{
32        return mPvs;
33}
34
[235]35int ViewCell::Type() const
36{
[308]37        return VIEW_CELL;
[235]38}
39
[372]40void ViewCell::AddPassingRay(const Ray &ray, const int contributions)
41{
42        mPassingRays.AddRay(ray, contributions);
[462]43}
44
[478]45
[469]46float ViewCell::GetVolume() const
47{
48        return mVolume;
49}
50
[478]51
[469]52void ViewCell::SetVolume(float volume)
53{
54        mVolume = volume;
55}
56
[479]57void ViewCell::UpdateViewCellsStats(ViewCellsStatistics &vcStat)
58{
59        ++ vcStat.viewCells;
60               
61        const int pvsSize = mPvs.GetSize();
[478]62
[479]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
[478]75float ViewCell::GetArea() const
76{
77        return mArea;
78}
79
80
81void ViewCell::SetArea(float area)
82{
83        mArea = area;
84}
85
86
[462]87/************************************************************************/
88/*                class ViewCellsStatistics implementation              */
89/************************************************************************/
90
[463]91void 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 PVS smaller 2 )\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}
Note: See TracBrowser for help on using the repository browser.