Skip to content
Snippets Groups Projects
Commit a332bede authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

ZLimits inherits from Span

parent 3f221c11
No related branches found
No related tags found
1 merge request!1174IFormFactor and children: replace BottomZ, TopZ by spanZ
......@@ -17,21 +17,9 @@
#include <algorithm>
#include <cmath>
ZLimits::ZLimits(double _min, double _max)
: m_zmin(_min)
, m_zmax(_max)
{
ASSERT(_min < _max);
}
ZLimits::ZLimits()
: ZLimits(-inf, inf)
{
}
bool ZLimits::isFinite() const
{
return !std::isinf(m_zmin) && !std::isinf(m_zmax);
return !std::isinf(zBottom()) && !std::isinf(zTop());
}
// TODO sep22: rm all the following if they remain UNUSED
......
......@@ -20,6 +20,7 @@
#ifndef BORNAGAIN_RESAMPLE_SLICE_ZLIMITS_H
#define BORNAGAIN_RESAMPLE_SLICE_ZLIMITS_H
#include "Base/Types/Span.h"
#include <cmath>
#include <iostream>
#include <limits>
......@@ -29,31 +30,26 @@
//!
//! @ingroup intern
class ZLimits {
class ZLimits : public Span {
public:
ZLimits();
ZLimits(double _min, double _max);
bool isFinite() const;
double zBottom() const { return m_zmin; }
double zTop() const { return m_zmax; }
double zTopOr0() const { return std::isfinite(m_zmax) ? m_zmax : 0; }
double thicknessOr0() const { return isFinite() ? m_zmax - m_zmin : 0; }
static constexpr double inf = std::numeric_limits<double>::infinity();
bool contains(double z) const { return m_zmin <= z && z <= m_zmax; }
ZLimits()
: Span(-inf, inf)
{
}
ZLimits(double _min, double _max)
: Span(_min, _max)
{
}
std::pair<double, double> pair() const { return {m_zmin, m_zmax}; }
bool isFinite() const;
static constexpr double inf = std::numeric_limits<double>::infinity();
double zTopOr0() const { return std::isfinite(zTop()) ? zTop() : 0; }
double thicknessOr0() const { return isFinite() ? zTop() - zBottom() : 0; }
//! Returns the union of two ZLimits (the minimal interval that contains both input intervals).
static ZLimits unite(const ZLimits& left, const ZLimits& right);
private:
// members are not const because we need the implicit copy assignement operator
double m_zmin;
double m_zmax;
};
bool operator==(const ZLimits& left, const ZLimits& right);
......
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