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

Revision 485, 2.3 KB checked in by mattausch, 19 years ago (diff)

changed castlinesegment of vspbpstree
changed rayinfo ray classification for bsp tree
implemented shuffling

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
25const ObjectPvs &ViewCell::GetPvs() const
26{
27        return mPvs;
28}
29
30ObjectPvs &ViewCell::GetPvs()
31{
32        return mPvs;
33}
34
35int ViewCell::Type() const
36{
37        return VIEW_CELL;
38}
39
40void ViewCell::AddPassingRay(const Ray &ray, const int contributions)
41{
42        mPassingRays.AddRay(ray, contributions);
43}
44
45
46float ViewCell::GetVolume() const
47{
48        return mVolume;
49}
50
51
52void ViewCell::SetVolume(float volume)
53{
54        mVolume = volume;
55}
56
57void ViewCell::UpdateViewCellsStats(ViewCellsStatistics &vcStat)
58{
59        ++ vcStat.viewCells;
60               
61        const int pvsSize = mPvs.GetSize();
62
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
75float ViewCell::GetArea() const
76{
77        return mArea;
78}
79
80
81void ViewCell::SetArea(float area)
82{
83        mArea = area;
84}
85
86
87/************************************************************************/
88/*                class ViewCellsStatistics implementation              */
89/************************************************************************/
90
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 empty PVS )\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.