#include "ViewCell.h" #include "Mesh.h" #include "Intersectable.h" #include "MeshKdTree.h" #include "Triangle3.h" #include #include ViewCell::ViewCell(): MeshInstance(NULL), mPiercingRays(0), mArea(0), mVolume(0) { } ViewCell::ViewCell(Mesh *mesh): MeshInstance(mesh), mPiercingRays(0), mArea(0), mVolume(0) { } const ObjectPvs &ViewCell::GetPvs() const { return mPvs; } ObjectPvs &ViewCell::GetPvs() { return mPvs; } int ViewCell::Type() const { return VIEW_CELL; } void ViewCell::AddPassingRay(const Ray &ray, const int contributions) { mPassingRays.AddRay(ray, contributions); } float ViewCell::GetVolume() const { return mVolume; } void ViewCell::SetVolume(float volume) { mVolume = volume; } void ViewCell::SetMesh(Mesh *mesh) { mMesh = mesh; } void ViewCell::UpdateViewCellsStats(ViewCellsStatistics &vcStat) { ++ vcStat.viewCells; const int pvsSize = mPvs.GetSize(); vcStat.pvs += pvsSize; if (pvsSize == 0) ++ vcStat.emptyPvs; if (pvsSize > vcStat.maxPvs) vcStat.maxPvs = pvsSize; if (pvsSize < vcStat.minPvs) vcStat.minPvs = pvsSize; } float ViewCell::GetArea() const { return mArea; } void ViewCell::SetArea(float area) { mArea = area; } /************************************************************************/ /* class ViewCellsStatistics implementation */ /************************************************************************/ void ViewCellsStatistics::Print(ostream &app) const { app << "=========== View Cells Statistics ===============\n"; app << setprecision(4); //app << "#N_CTIME ( Construction time [s] )\n" << Time() << " \n"; app << "#N_OVERALLPVS ( objects in PVS )\n" << pvs << endl; app << "#N_PMAXPVS ( largest PVS )\n" << maxPvs << endl; app << "#N_PMINPVS ( smallest PVS )\n" << minPvs << endl; app << "#N_PAVGPVS ( average PVS )\n" << AvgPvs() << endl; app << "#N_PEMPTYPVS ( view cells with empty PVS )\n" << emptyPvs << endl; app << "#N_VIEWCELLS ( number of view cells)\n" << viewCells << endl; app << "#N_AVGLEAVES (average number of leaves per view cell )\n" << AvgLeaves() << endl; app << "#N_MAXLEAVES ( maximal number of leaves per view cell )\n" << maxLeaves << endl; app << "========== End of View Cells Statistics ==========\n"; }