#ifndef _SamplingStategy_H__ #define _SamplingStategy_H__ #include "Halton.h" namespace GtpVisibilityPreprocessor { class Preprocessor; struct SimpleRay; class SimpleRayContainer; /** This class generates a specific sampling strategy. */ class SamplingStrategy { public: /** Sample rays of particular type */ enum { OBJECT_BASED_DISTRIBUTION, DIRECTION_BASED_DISTRIBUTION, DIRECTION_BOX_BASED_DISTRIBUTION, SPATIAL_BOX_BASED_DISTRIBUTION, RSS_BASED_DISTRIBUTION, RSS_SILHOUETTE_BASED_DISTRIBUTION, VSS_BASED_DISTRIBUTION, OBJECT_DIRECTION_BASED_DISTRIBUTION, OBJECTS_INTERIOR_DISTRIBUTION, REVERSE_OBJECT_BASED_DISTRIBUTION, VIEWCELL_BORDER_BASED_DISTRIBUTION, VIEWSPACE_BORDER_BASED_DISTRIBUTION, REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION, GLOBAL_LINES_DISTRIBUTION }; /** Default constructor */ SamplingStrategy(const Preprocessor &preprocessor); virtual ~SamplingStrategy(); /** Each strategy has to implement this function. @returns true if generated valid sample. */ virtual int GenerateSamples(const int number, SimpleRayContainer &rays); private: virtual bool GenerateSample(SimpleRay &ray) = 0; public: /// variables usefull for mixed distribution sampling int mType; int mRays; float mContribution; float mTime; float mRatio; protected: const Preprocessor &mPreprocessor; }; class ObjectBasedDistribution: public SamplingStrategy { public: ObjectBasedDistribution(const Preprocessor &preprocessor): SamplingStrategy(preprocessor) { mType = OBJECT_BASED_DISTRIBUTION; } private: virtual bool GenerateSample(SimpleRay &ray); }; class ReverseObjectBasedDistribution: public SamplingStrategy { public: ReverseObjectBasedDistribution(const Preprocessor &preprocessor): SamplingStrategy(preprocessor) { mType = REVERSE_OBJECT_BASED_DISTRIBUTION; } private: virtual bool GenerateSample(SimpleRay &ray); }; class ObjectDirectionBasedDistribution: public SamplingStrategy { public: ObjectDirectionBasedDistribution(const Preprocessor &preprocessor): SamplingStrategy(preprocessor) { mType = OBJECT_DIRECTION_BASED_DISTRIBUTION; } private: virtual bool GenerateSample(SimpleRay &ray); }; class DirectionBasedDistribution: public SamplingStrategy { public: DirectionBasedDistribution(const Preprocessor &preprocessor): SamplingStrategy(preprocessor){ mType = DIRECTION_BASED_DISTRIBUTION; } private: virtual bool GenerateSample(SimpleRay &ray); }; class DirectionBoxBasedDistribution: public SamplingStrategy { public: DirectionBoxBasedDistribution(const Preprocessor &preprocessor): SamplingStrategy(preprocessor){ mType = DIRECTION_BOX_BASED_DISTRIBUTION; } private: virtual bool GenerateSample(SimpleRay &ray); }; class SpatialBoxBasedDistribution: public SamplingStrategy { public: Halton<6> halton; SpatialBoxBasedDistribution(const Preprocessor &preprocessor): SamplingStrategy(preprocessor){ mType = DIRECTION_BOX_BASED_DISTRIBUTION; } private: virtual bool GenerateSample(SimpleRay &ray); }; class ViewSpaceBorderBasedDistribution: public SamplingStrategy { public: ViewSpaceBorderBasedDistribution(const Preprocessor &preprocessor): SamplingStrategy(preprocessor){ mType = SPATIAL_BOX_BASED_DISTRIBUTION; } private: virtual bool GenerateSample(SimpleRay &ray); }; class ReverseViewSpaceBorderBasedDistribution: public SamplingStrategy { public: ReverseViewSpaceBorderBasedDistribution(const Preprocessor &preprocessor): SamplingStrategy(preprocessor){ mType = SPATIAL_BOX_BASED_DISTRIBUTION; } private: virtual bool GenerateSample(SimpleRay &ray); }; class RssBasedDistribution: public SamplingStrategy { public: RssBasedDistribution(const Preprocessor &preprocessor): SamplingStrategy(preprocessor){ mType = RSS_BASED_DISTRIBUTION; } virtual int GenerateSamples(const int number, SimpleRayContainer &ray) { // TBD!!! return 0; } private: virtual bool GenerateSample(SimpleRay &ray); }; class ViewCellBorderBasedDistribution: public SamplingStrategy { public: ViewCellBorderBasedDistribution(const Preprocessor &preprocessor): SamplingStrategy(preprocessor) {} virtual bool GenerateSample(SimpleRay &ray); }; class GlobalLinesDistribution: public SamplingStrategy { public: Halton<4> halton; //HaltonSequence mHalton; GlobalLinesDistribution(const Preprocessor &preprocessor): SamplingStrategy(preprocessor) { mType = GLOBAL_LINES_DISTRIBUTION; } virtual bool GenerateSample(SimpleRay &ray); }; /** This strategy generates samples inside of the objects, e.g., for sampling the inside of a colon. */ /*class ObjectsInteriorDistribution: public SamplingStrategy { public: ObjectsInteriorDistribution(const Preprocessor &preprocessor): SamplingStrategy(preprocessor) {} virtual bool GenerateSample(SimpleRay &ray); }; */ }; #endif