#ifndef _ViewCell_H__ #define _ViewCell_H__ #include "Mesh.h" #include "Containers.h" #include "Ray.h" #include "Statistics.h" //namespace GtpVisibilityPreprocessor { struct Triangle3; class BspInterior; class BspPvs; class BspLeaf; class VspKdTree; class VspKdLeaf; class KdLeaf; /** View cell with an optional mesh representation */ class ViewCell: public MeshInstance { public: ViewCell(); /** Constructor taking a mesh representing the shape of the viewcell. */ ViewCell(Mesh *mesh); /** Default destructor. */ virtual ~ViewCell() {} /** Returns Pvs. */ const ObjectPvs &GetPvs() const; ObjectPvs &GetPvs(); int Type() const; /** Adds a passing ray to the passing ray container. */ void AddPassingRay(const Ray &ray, const int contributions); /** Returns volume of the view cell. */ virtual float GetVolume() const; /** Sets volume of the view cell. */ void SetVolume(float size); /// Ray set description of the rays passing through this node. PassingRaySet mPassingRays; /// Rays piercing this view cell. RayContainer mPiercingRays; protected: /// the potentially visible objects ObjectPvs mPvs; float mVolume; }; /** View cell belonging to a hierarchy. */ template class HierarchyViewCell: public ViewCell { public: HierarchyViewCell(): mLeaves(0) {} HierarchyViewCell(Mesh *mesh): ViewCell(mesh), mLeaves(0) {} /// Leaves of the hierarchy which are part of this view cell. std::vector mLeaves; }; typedef HierarchyViewCell BspViewCell; typedef HierarchyViewCell KdViewCell; typedef HierarchyViewCell VspKdViewCell; /** Statistics for a view cell partition. */ class ViewCellsStatistics: public StatisticsBase { public: /// number of view cells int viewCells; /// size of the PVS int pvs; /// largest PVS of all view cells int maxPvs; /// smallest PVS of all view cells int minPvs; /// view cells with empty PVS int emptyPvs; /// number of leaves covering the view space int leaves; /// largest number of leaves covered by one view cell int maxLeaves; // Constructor ViewCellsStatistics() { Reset(); } double AvgLeaves() const {return (double)leaves / (double)viewCells;}; double AvgPvs() const {return (double)pvs / (double)viewCells;}; void Reset() { viewCells = 0; pvs = 0; maxPvs = 0; minPvs = 999999; emptyPvs = 0; leaves = 0; maxLeaves = 0; } void Print(ostream &app) const; friend ostream &operator<<(ostream &s, const ViewCellsStatistics &stat) { stat.Print(s); return s; } }; #endif