diff --git a/geom/sample/surface.hpp b/geom/sample/surface.hpp index 3653ac0b..8ffc3927 100644 --- a/geom/sample/surface.hpp +++ b/geom/sample/surface.hpp @@ -14,6 +14,7 @@ #include "../../coord/fwd.hpp" #include "../../extent.hpp" +#include "../../region.hpp" #include "../../random.hpp" #include @@ -102,4 +103,35 @@ namespace cruft::geom::sample { class surface> : public volume> { using volume>::volume; }; + + + /// A surface sampler specialisation for 2d regions + /// + /// We encapsulate an extent sampler and an offset, then mainly pass off + /// the work to the extent sampler. + template + class surface> { + public: + using shape_type = region<2,T>; + + surface (shape_type const &_shape) + : m_extent (_shape.e) + , m_offset (_shape.p.template as ()) + { ; } + + + template + decltype(auto) + eval (GeneratorT &&gen) + { + return m_extent.eval ( + std::forward (gen) + ) + m_offset; + } + + + private: + surface> m_extent; + cruft::vector<2,T> m_offset; + }; }