Skip to content
Snippets Groups Projects
Commit afb39989 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

More accurate pixel construction. References in hash function.

parent 6afbe27b
No related branches found
No related tags found
No related merge requests found
......@@ -304,10 +304,11 @@ void RectangularDetector::initUandV(double alpha_i)
}
RectangularPixel::RectangularPixel(kvector_t corner_pos, kvector_t width, kvector_t height)
: m_corner_pos(corner_pos), m_width(width), m_height(height)
: m_corner_pos(std::move(corner_pos)), m_width(std::move(width)), m_height(std::move(height))
{
m_normal = m_width.cross(m_height);
m_solid_angle = calculateSolidAngle();
auto solid_angle_value = calculateSolidAngle();
m_solid_angle = solid_angle_value <= 0.0 ? 1.0 : solid_angle_value;
}
RectangularPixel* RectangularPixel::clone() const
......@@ -344,7 +345,6 @@ double RectangularPixel::getIntegrationFactor(double x, double y) const
double RectangularPixel::getSolidAngle() const
{
if (m_solid_angle<=0.0) return 1.0;
return m_solid_angle;
}
......
......@@ -111,7 +111,6 @@ class RectangularPixel : public IPixel
{
public:
RectangularPixel(kvector_t corner_pos, kvector_t width, kvector_t height);
virtual ~RectangularPixel() {}
RectangularPixel* clone() const override;
RectangularPixel* createZeroSizePixel(double x, double y) const override;
......
......@@ -86,18 +86,17 @@ size_t SphericalDetector::getIndexOfSpecular(const Beam& beam) const
return totalSize();
}
SphericalPixel::SphericalPixel(Bin1D alpha_bin, Bin1D phi_bin)
SphericalPixel::SphericalPixel(const Bin1D& alpha_bin, const Bin1D& phi_bin)
: m_alpha(alpha_bin.m_lower), m_phi(phi_bin.m_lower),
m_dalpha(alpha_bin.getBinSize()), m_dphi(phi_bin.getBinSize())
{
m_solid_angle = std::abs(m_dphi*(std::sin(m_alpha+m_dalpha) - std::sin(m_alpha)));
auto solid_angle_value = std::abs(m_dphi*(std::sin(m_alpha+m_dalpha) - std::sin(m_alpha)));
m_solid_angle = solid_angle_value <= 0.0 ? 1.0 : solid_angle_value;
}
SphericalPixel* SphericalPixel::clone() const
{
Bin1D alpha_bin(m_alpha, m_alpha+m_dalpha);
Bin1D phi_bin(m_phi, m_phi+m_dphi);
return new SphericalPixel(alpha_bin, phi_bin);
return new SphericalPixel(*this);
}
SphericalPixel* SphericalPixel::createZeroSizePixel(double x, double y) const
......@@ -125,6 +124,5 @@ double SphericalPixel::getIntegrationFactor(double /* x */, double y) const
double SphericalPixel::getSolidAngle() const
{
if (m_solid_angle<=0.0) return 1.0;
return m_solid_angle;
}
......@@ -64,8 +64,7 @@ protected:
class SphericalPixel : public IPixel
{
public:
SphericalPixel(Bin1D alpha_bin, Bin1D phi_bin);
virtual ~SphericalPixel() {}
SphericalPixel(const Bin1D& alpha_bin, const Bin1D& phi_bin);
SphericalPixel* clone() const override;
SphericalPixel* createZeroSizePixel(double x, double y) const override;
......
......@@ -27,7 +27,7 @@ ScalarFresnelMap::ScalarFresnelMap(std::unique_ptr<ISpecularStrategy> strategy)
ScalarFresnelMap::~ScalarFresnelMap() = default;
//! Returns hash value of a pair of doubles, computed by exclusive-or of the component hash values.
size_t ScalarFresnelMap::Hash2Doubles::operator()(std::pair<double, double> doubles) const noexcept
size_t ScalarFresnelMap::Hash2Doubles::operator()(const std::pair<double, double>& doubles) const noexcept
{
return std::hash<double>{}(doubles.first) ^ std::hash<double>{}(doubles.second);
}
......
......@@ -47,7 +47,7 @@ private:
class Hash2Doubles
{
public:
size_t operator()(std::pair<double, double> doubles) const noexcept;
size_t operator()(const std::pair<double, double>& doubles) const noexcept;
};
std::unique_ptr<const ILayerRTCoefficients> getCoefficients(const kvector_t& kvec,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment