6#include <Common/assertion.h>
7#include <Common/primitive_type.h>
32 template<std::
size_t N>
43 template<std::
size_t N>
44 std::array<real, N>
get(std::size_t index)
const;
53 std::size_t m_numDims;
54 std::size_t m_numSamples;
55 std::size_t m_readIndex;
56 std::vector<real> m_overreadBuffer;
62 const real*
const buffer,
63 const std::size_t numDims,
64 const std::size_t numSamples) :
68 m_numSamples (numSamples),
70 m_overreadBuffer(numDims)
79 PH_ASSERT_EQ(m_overreadBuffer.size(), m_numDims);
81 if(m_readIndex < m_numSamples)
83 return (*
this)[m_readIndex++];
87 for(
auto& element : m_overreadBuffer)
91 return m_overreadBuffer.data();
95template<std::
size_t N>
98 PH_ASSERT_EQ(N, m_numDims);
102 std::array<real, N> sample;
103 for(std::size_t di = 0; di < N; ++di)
105 sample[di] = samplePtr[di];
125template<std::
size_t N>
128 PH_ASSERT_EQ(N, m_numDims);
130 std::array<real, N> sample;
131 for(std::size_t di = 0; di < N; ++di)
133 sample[di] = (*this)[index][di];
142 return &(m_buffer[index * m_numDims]);
A sample with arbitrary dimensions with fine-grained sampling control.
Definition SampleFlow.h:19
Definition SamplesNDStream.h:17
const real * operator[](std::size_t index) const
Get the i-th N-dimensional sample.
Definition SamplesNDStream.h:138
std::size_t numSamples() const
Definition SamplesNDStream.h:120
const real * readSample()
Read the next N-dimensional sample.
Definition SamplesNDStream.h:77
std::array< real, N > get(std::size_t index) const
Definition SamplesNDStream.h:126
SampleFlow readSampleAsFlow()
Read the next N-dimensional sample as flow, which has more flexible controls for sampling.
Definition SamplesNDStream.h:110
std::size_t numDims() const
Definition SamplesNDStream.h:115
SamplesNDStream(const real *buffer, std::size_t numDims, std::size_t numSamples)
Definition SamplesNDStream.h:61
static real sample()
Get a uniform random value in [0, 1].
Definition Random.cpp:44
The root for all renderer implementations.
Definition EEngineProject.h:6