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

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
[478]85float ViewCell::GetArea() const
86{
87        return mArea;
88}
89
90
91void ViewCell::SetArea(float area)
92{
93        mArea = area;
94}
95
96
[462]97/************************************************************************/
98/*                class ViewCellsStatistics implementation              */
99/************************************************************************/
100
[463]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
[485]117        app << "#N_PEMPTYPVS ( view cells with empty PVS )\n" << emptyPvs << endl;
[463]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.