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

Revision 503, 2.4 KB checked in by mattausch, 19 years ago (diff)

added mesh creation function

Line 
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
9ViewCell::ViewCell():
10MeshInstance(NULL),
11mPiercingRays(0),
12mArea(0),
13mVolume(0)
14{
15}
16
17ViewCell::ViewCell(Mesh *mesh):
18MeshInstance(mesh),
19mPiercingRays(0),
20mArea(0),
21mVolume(0)
22{
23}
24
25
26const ObjectPvs &ViewCell::GetPvs() const
27{
28        return mPvs;
29}
30
31ObjectPvs &ViewCell::GetPvs()
32{
33        return mPvs;
34}
35
36
37int ViewCell::Type() const
38{
39        return VIEW_CELL;
40}
41
42
43void ViewCell::AddPassingRay(const Ray &ray, const int contributions)
44{
45        mPassingRays.AddRay(ray, contributions);
46}
47
48
49float ViewCell::GetVolume() const
50{
51        return mVolume;
52}
53
54
55void ViewCell::SetVolume(float volume)
56{
57        mVolume = volume;
58}
59
60
61void ViewCell::SetMesh(Mesh *mesh)
62{
63        mMesh = mesh;
64}
65
66
67void 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
85float ViewCell::GetArea() const
86{
87        return mArea;
88}
89
90
91void ViewCell::SetArea(float area)
92{
93        mArea = area;
94}
95
96
97/************************************************************************/
98/*                class ViewCellsStatistics implementation              */
99/************************************************************************/
100
101void 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}
Note: See TracBrowser for help on using the repository browser.