10#include <boost/lexical_cast.hpp>
30std::vector<std::string> createPBinStringVector(std::vector<Mantid::coord_t> minVector,
31 std::vector<Mantid::coord_t> maxVector,
33 size_t numDims = inputWs->getNumDims();
34 std::vector<std::string> pBinStrVector;
35 for (
size_t iter = 0; iter < numDims; iter++) {
38 boost::lexical_cast<std::string>(minVector[iter] - (inputWs->getDimension(iter)->getBinWidth() * 0.5)) +
",0," +
39 boost::lexical_cast<std::string>(maxVector[iter] + (inputWs->getDimension(iter)->getBinWidth() * 0.5));
40 pBinStrVector.emplace_back(pBinStr);
64 auto ws_iter = inputWs->createIterator();
66 if (ws_iter->getSignal() == 0) {
72 auto current_index = ws_iter->getLinearIndex();
73 auto current_center = inputWs->getCenter(current_index);
85 }
while (ws_iter->next());
94 if (minVec[
index] == inputWs->getDimension(
index)->getMaximum()) {
95 minVec[
index] = inputWs->getDimension(
index)->getMinimum();
97 if (maxVec[
index] == inputWs->getDimension(
index)->getMinimum()) {
98 maxVec[
index] = inputWs->getDimension(
index)->getMaximum();
109 "MDHistoWorkspace to compact");
112 "Output compacted workspace");
121 const size_t nDimensions = input_ws->getNumDims();
122 std::vector<Mantid::coord_t> minVector;
123 std::vector<Mantid::coord_t> maxVector;
127 minVector.emplace_back(input_ws->getDimension(
index)->getMaximum());
128 maxVector.emplace_back(input_ws->getDimension(
index)->getMinimum());
132 auto pBinStrings = createPBinStringVector(minVector, maxVector, input_ws);
135 cut_alg->setProperty(
"InputWorkspace", input_ws);
136 cut_alg->setProperty(
"OutputWorkspace",
"temp");
139 for (
size_t iter = 0; iter < input_ws->getNumDims(); iter++) {
140 std::string propertyString =
"P" +
std::to_string(iter + 1) +
"Bin";
141 cut_alg->setProperty(propertyString, pBinStrings[iter]);
#define DECLARE_ALGORITHM(classname)
std::map< DeltaEMode::Type, std::string > index
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
A property class for workspaces.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void init() override
Initiliase the algorithm's properties.
void findFirstNonZeroMinMaxExtents(const Mantid::API::IMDHistoWorkspace_sptr &inputWs, std::vector< Mantid::coord_t > &minVec, std::vector< Mantid::coord_t > &maxVec)
Finding the extents of the first non-zero signals.
void exec() override
Execute the algorithm.
std::shared_ptr< IMDHistoWorkspace > IMDHistoWorkspace_sptr
shared pointer to Mantid::API::IMDHistoWorkspace
std::shared_ptr< IMDWorkspace > IMDWorkspace_sptr
Shared pointer to the IMDWorkspace base class.
Helper class which provides the Collimation Length for SANS instruments.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Input
An input workspace.
@ Output
An output workspace.