Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TReceiverMeasurementEstimator.ipp
Go to the documentation of this file.
1#pragma once
2
4#include "Math/TVector2.h"
5#include "Core/Ray.h"
7
8namespace ph
9{
10
11template<typename SamplingFilmType, typename EstimationType>
14 const std::size_t numFilms,
15 const std::size_t numEstimations,
16 Integrand integrand,
17 SampleFilter filter) :
18
19 m_filter (std::move(filter)),
20 m_estimations (numEstimations),
21 m_filmActualResFPx(0),
22 m_films (numFilms),
23 m_estimators (),
24 m_integrand (std::move(integrand)),
25 m_estimationToFilm()
26{
27 for(SamplingFilmType& film : m_films)
28 {
29 film = SamplingFilmType(
30 0,
31 0,
32 {{0, 0}, {0, 0}},
33 m_filter);
34 }
35}
36
37template<typename SamplingFilmType, typename EstimationType>
40 m_filter (std::move(other.m_filter)),
41 m_estimations (std::move(other.m_estimations)),
42 m_filmActualResFPx(std::move(other.m_filmActualResFPx)),
43 m_films (std::move(other.m_films)),
44 m_estimators (std::move(other.m_estimators)),
45 m_integrand (std::move(other.m_integrand)),
46 m_estimationToFilm(std::move(other.m_estimationToFilm))
47{}
48
49template<typename SamplingFilmType, typename EstimationType>
52 const math::Vector2D& rasterCoord,
53 const Ray& sensedRay,
54 const math::Spectrum& quantityWeight,
55 SampleFlow& sampleFlow)
56 -> void
57{
58 for(const auto* estimator : m_estimators)
59 {
60 estimator->estimate(sensedRay, m_integrand, sampleFlow, m_estimations);
61 }
62
63 for(const auto& estimationToFilm : m_estimationToFilm)
64 {
65 const std::size_t estimationIndex = estimationToFilm.first;
66 const std::size_t filmIndex = estimationToFilm.second;
67
68 m_films[filmIndex].addSample(rasterCoord.x(), rasterCoord.y(), m_estimations[estimationIndex] * quantityWeight);
69 }
70}
71
72template<typename SamplingFilmType, typename EstimationType>
74addEstimator(const Estimator* const estimator)
75 -> void
76{
77 PH_ASSERT(estimator);
78
79 m_estimators.push_back(estimator);
80}
81
82template<typename SamplingFilmType, typename EstimationType>
85 const std::size_t filmIndex,
86 const std::size_t estimationIndex)
87 -> void
88{
89 PH_ASSERT_LT(filmIndex, m_films.size());
90 PH_ASSERT_LT(estimationIndex, m_estimations.numEstimations());
91
92 m_estimationToFilm.push_back({estimationIndex, filmIndex});
93}
94
95template<typename SamplingFilmType, typename EstimationType>
98 -> void
99{
100 for(std::size_t i = 0; i < m_films.size(); ++i)
101 {
102 clearFilm(i);
103 }
104}
105
106template<typename SamplingFilmType, typename EstimationType>
108clearFilm(const std::size_t index)
109 -> void
110{
111 PH_ASSERT_LT(index, m_films.size());
112
113 m_films[index].clear();
114}
115
116template<typename SamplingFilmType, typename EstimationType>
118mergeFilmTo(const std::size_t fromIndex, SamplingFilmType& toFilm)
119 -> void
120{
121 PH_ASSERT_LT(fromIndex, m_films.size());
122
123 toFilm.mergeWith(m_films[fromIndex]);
124}
125
126template<typename SamplingFilmType, typename EstimationType>
129 const math::TVector2<int64>& actualResPx,
130 const math::TAABB2D<int64>& effectiveWindowPx,
131 const bool useSoftEdge)
132 -> void
133{
134 m_filmActualResFPx = math::Vector2D(actualResPx);
135
136 for(SamplingFilmType& film : m_films)
137 {
138 film.setActualResPx(actualResPx);
139 film.setEffectiveWindowPx(effectiveWindowPx);
140 film.setSoftEdge(useSoftEdge);
141 }
142}
143
144template<typename SamplingFilmType, typename EstimationType>
146numEstimations() const
147 -> std::size_t
148{
149 return m_estimations.numEstimations();
150}
151
152template<typename SamplingFilmType, typename EstimationType>
155 -> math::TAABB2D<int64>
156{
157 PH_ASSERT(!m_films.empty());
158
159 return m_films.front().getEffectiveWindowPx();
160}
161
162template<typename SamplingFilmType, typename EstimationType>
164getFilmDimensions() const
166{
167 PH_ASSERT(!m_films.empty());
168
169 return m_films.front().getDimensions();
170}
171
172template<typename SamplingFilmType, typename EstimationType>
174isSoftEdgedFilm() const
175 -> bool
176{
177 PH_ASSERT(!m_films.empty());
178
179 return m_films.front().isSoftEdged();
180}
181
182template<typename SamplingFilmType, typename EstimationType>
186{
187 IReceivedRayProcessor::operator = (std::move(other));
188
189 m_filter = std::move(other.m_filter);
190 m_estimations = std::move(other.m_estimations);
191 m_filmActualResFPx = std::move(other.m_filmActualResFPx);
192 m_films = std::move(other.m_films);
193 m_estimators = std::move(other.m_estimators);
194 m_integrand = std::move(other.m_integrand);
195 m_estimationToFilm = std::move(other.m_estimationToFilm);
196
197 return *this;
198}
199
200}// end namespace ph
Definition Integrand.h:12
Represents a ray in space.
Definition Ray.h:21
An image reconstruction kernel.
Definition SampleFilter.h:17
A sample with arbitrary dimensions with fine-grained sampling control.
Definition SampleFlow.h:19
Definition TIRayEstimator.h:17
Definition TReceiverMeasurementEstimator.h:23
bool isSoftEdgedFilm() const
Definition TReceiverMeasurementEstimator.ipp:174
std::vector< SamplingFilmType > m_films
Definition TReceiverMeasurementEstimator.h:66
void process(const math::Vector2D &rasterCoord, const Ray &sensedRay, const math::Spectrum &quantityWeight, SampleFlow &sampleFlow) override
Definition TReceiverMeasurementEstimator.ipp:51
void clearFilm(std::size_t index)
Definition TReceiverMeasurementEstimator.ipp:108
void addEstimator(const Estimator *estimator)
Definition TReceiverMeasurementEstimator.ipp:74
TReceiverMeasurementEstimator & operator=(TReceiverMeasurementEstimator &&other)
Definition TReceiverMeasurementEstimator.ipp:184
void setFilmDimensions(const math::TVector2< int64 > &actualResPx, const math::TAABB2D< int64 > &effectiveWindowPx, bool useSoftEdge=true)
Definition TReceiverMeasurementEstimator.ipp:128
void addFilmEstimation(std::size_t filmIndex, std::size_t estimationIndex)
Definition TReceiverMeasurementEstimator.ipp:84
SamplingFilmDimensions getFilmDimensions() const
Definition TReceiverMeasurementEstimator.ipp:164
void clearFilms()
Definition TReceiverMeasurementEstimator.ipp:97
SampleFilter m_filter
Definition TReceiverMeasurementEstimator.h:63
math::TAABB2D< int64 > getFilmEffectiveWindowPx() const
Definition TReceiverMeasurementEstimator.ipp:154
std::size_t numEstimations() const
Definition TReceiverMeasurementEstimator.ipp:146
void mergeFilmTo(std::size_t fromIndex, SamplingFilmType &toFilm)
Definition TReceiverMeasurementEstimator.ipp:118
A 2-D Axis-Aligned Bounding Box (AABB).
Definition TAABB2D.h:26
Definition TTristimulusSpectrum.h:11
TVector2< float64 > Vector2D
Definition math_fwd.h:47
The root for all renderer implementations.
Definition EEngineProject.h:6
Definition TAABB2D.h:96
Definition SamplingFilmDimensions.h:12