diff --git a/Device/Data/Datafield.cpp b/Device/Data/Datafield.cpp index e629fa32a6337ed732272c17bc385dc118d83d04..2231ba80e57cd720f89121007d07a4f24537bbc6 100644 --- a/Device/Data/Datafield.cpp +++ b/Device/Data/Datafield.cpp @@ -274,9 +274,6 @@ Datafield* Datafield::crop(double xmin, double ymin, double xmax, double ymax) c { ASSERT(rank() == 2); - const Scale* xclipped = xAxis().clipped(xmin, xmax).clone(); - const Scale* yclipped = yAxis().clipped(ymin, ymax).clone(); - const size_t N = size(); std::vector<double> out; for (size_t i = 0; i < N; ++i) { @@ -285,7 +282,11 @@ Datafield* Datafield::crop(double xmin, double ymin, double xmax, double ymax) c if (xmin <= x && x <= xmax && ymin <= y && y <= ymax) out.push_back(m_values[i]); } + + const Scale* xclipped = xAxis().clipped(xmin, xmax).clone(); + const Scale* yclipped = yAxis().clipped(ymin, ymax).clone(); Frame* outframe = new Frame(xclipped, yclipped); + ASSERT(outframe->size() == out.size()); return new Datafield(outframe, out); } @@ -294,8 +295,6 @@ Datafield* Datafield::crop(double xmin, double xmax) const { ASSERT(rank() == 1); - const Scale* xclipped = xAxis().clipped(xmin, xmax).clone(); - const size_t N = size(); std::vector<double> out; std::vector<double> errout; @@ -307,7 +306,9 @@ Datafield* Datafield::crop(double xmin, double xmax) const errout.push_back(m_err_sigmas[i]); } } + const Scale* xclipped = xAxis().clipped(xmin, xmax).clone(); Frame* outframe = new Frame(xclipped); + ASSERT(outframe->xAxis().size() == out.size()); return new Datafield(outframe, out, errout); }