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

Frame members const; rm Frame::setScale

parent 26a5555b
No related branches found
No related tags found
1 merge request!2382cleanup in OwningVec, CloneableVec context; BeamScan now using OwningVec
Pipeline #130641 passed
......@@ -13,14 +13,26 @@
// ************************************************************************************************
#include "Base/Axis/Frame.h"
#include "Base/Axis/FrameUtil.h"
#include "Base/Axis/Scale.h"
#include "Base/Util/Assert.h"
#include "Base/Util/StringUtil.h"
namespace {
size_t product_size(const std::vector<const Scale*>& axes)
{
size_t result = 1;
for (const Scale* ax : axes)
result *= ax->size();
return result;
}
} // namespace
Frame::Frame(const std::vector<const Scale*>& axes)
: m_axes(axes)
, m_size(FrameUtil::product_size(m_axes.shared()))
, m_size(::product_size(axes))
{
}
......@@ -139,9 +151,3 @@ Frame* Frame::flat() const
outaxes.emplace_back(s->clone());
return new Frame(std::move(outaxes));
}
void Frame::setScale(size_t k_axis, Scale* scale)
{
m_axes.replace_at(k_axis, scale);
m_size = FrameUtil::product_size(m_axes.shared());
}
......@@ -76,12 +76,11 @@ public:
Frame* flat() const;
#ifndef SWIG
void setScale(size_t k_axis, Scale* scale);
std::vector<const Scale*> clonedAxes() const;
private:
CloneableVector<const Scale> m_axes;
size_t m_size; // cached product of axis sizes
const CloneableVector<const Scale> m_axes;
const size_t m_size; // cached product of axis sizes
#endif // SWIG
};
......
......@@ -16,16 +16,6 @@
#include "Base/Axis/Frame.h"
#include "Base/Axis/Scale.h"
size_t FrameUtil::product_size(const std::vector<const Scale*>& axes)
{
if (axes.empty())
return 1;
size_t result = 1;
for (const Scale* ax : axes)
result *= ax->size();
return result;
}
// For axis EquiDivision("axis", 8, -5.0, 3.0) the coordinate x=-4.5 (center of bin #0) will
// be converted into 0.5 (which is a bin center expressed in bin fraction coordinates).
// The coordinate -5.0 (outside of axis definition) will be converted to -0.5
......
......@@ -23,9 +23,6 @@ class Scale;
namespace FrameUtil {
//! Product of axis sizes.
size_t product_size(const std::vector<const Scale*>& axes);
//! Transforms coordinate on axis into the bin-fraction-coordinate.
double coordinateToBinf(double coordinate, const Scale& axis);
......
......@@ -310,8 +310,7 @@ Datafield* Datafield::crop(double xmin, double xmax) const
errout.push_back(m_err_sigmas[i]);
}
}
Frame* outframe = frame().clone();
outframe->setScale(0, xclipped);
Frame* outframe = new Frame(xclipped);
ASSERT(outframe->xAxis().size() == out.size());
return new Datafield(outframe, out, errout);
}
......
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