g/sample/surface: add region sampling
This commit is contained in:
parent
f551e48ddb
commit
70c523d029
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "../../coord/fwd.hpp"
|
#include "../../coord/fwd.hpp"
|
||||||
#include "../../extent.hpp"
|
#include "../../extent.hpp"
|
||||||
|
#include "../../region.hpp"
|
||||||
#include "../../random.hpp"
|
#include "../../random.hpp"
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@ -102,4 +103,35 @@ namespace cruft::geom::sample {
|
|||||||
class surface<extent<2,T>> :
|
class surface<extent<2,T>> :
|
||||||
public volume<extent<2,T>>
|
public volume<extent<2,T>>
|
||||||
{ using volume<extent<2,T>>::volume; };
|
{ using volume<extent<2,T>>::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 <typename T>
|
||||||
|
class surface<region<2,T>> {
|
||||||
|
public:
|
||||||
|
using shape_type = region<2,T>;
|
||||||
|
|
||||||
|
surface (shape_type const &_shape)
|
||||||
|
: m_extent (_shape.e)
|
||||||
|
, m_offset (_shape.p.template as<vector> ())
|
||||||
|
{ ; }
|
||||||
|
|
||||||
|
|
||||||
|
template <typename GeneratorT>
|
||||||
|
decltype(auto)
|
||||||
|
eval (GeneratorT &&gen)
|
||||||
|
{
|
||||||
|
return m_extent.eval (
|
||||||
|
std::forward<GeneratorT> (gen)
|
||||||
|
) + m_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
surface<extent<2,T>> m_extent;
|
||||||
|
cruft::vector<2,T> m_offset;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user