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

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