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

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