BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
IOUtils.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Support/IO/IOUtils.cpp
6 //! @brief Implements DatafieldUtils namespace
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #include "GUI/Support/IO/IOUtils.h"
16 #include "Base/Axis/IAxis.h"
17 #include "Base/Util/Assert.h"
18 #include "Device/Data/Datafield.h"
19 
20 // TODO: just clones the input, can probably be eliminated
21 
22 std::unique_ptr<Datafield> GUI::Util::IO::binifyAxes(const Datafield& data)
23 {
24  std::vector<IAxis*> axes;
25  for (size_t i = 0; i < data.rank(); ++i)
26  axes.emplace_back(data.axis(i).clone());
27 
28  auto result = std::make_unique<Datafield>(axes);
29 
30  result->setVector(data.flatVector());
31 
32  return result;
33 }
Defines namespace GUI::Util::IO.
std::unique_ptr< Datafield > binifyAxes(const Datafield &data)
Creates Datafield with bin-valued axes.
Definition: IOUtils.cpp:22