30 int MaxRecursionDepth) {
31 auto mustBePositive = std::make_shared<BoundedValidator<int>>();
32 mustBePositive->setLower(0);
33 auto mustBeMoreThen1 = std::make_shared<BoundedValidator<int>>();
34 mustBeMoreThen1->setLower(1);
39 std::vector<int> valueVec;
40 valueVec.reserve(values.
count());
41 std::transform(values.
cbegin(), values.
cend(), std::back_inserter(valueVec), boost::lexical_cast<int, std::string>);
44 "A comma separated list of into how many sub-grid elements each "
45 "dimension should split; "
46 "or just one to split into the same number for all dimensions. Default " +
50 "How many events in a box before it should be split. Default " +
Strings::toString(SplitThreshold) +
54 "How many levels of box splitting recursion are allowed. "
55 "The smallest box will have each side length :math:`l = "
56 "(extents) / (SplitInto^{MaxRecursionDepth}).` "
75 const std::string splitThresholdName =
"SplitThreshold";
76 const std::string splitIntoName =
"SplitInto";
77 const std::string maxRecursionDepthName =
"MaxRecursionDepth";
80 std::vector<double> instrumentSplitThresholds = instrument->getNumberParameter(splitThresholdName,
true);
81 if (!instrumentSplitThresholds.empty()) {
82 setProperty(splitThresholdName,
static_cast<int>(instrumentSplitThresholds.front()));
87 std::vector<double> instrumentSplitInto = instrument->getNumberParameter(splitIntoName,
true);
88 if (!instrumentSplitInto.empty()) {
89 const auto splitInto =
static_cast<int>(instrumentSplitInto.front());
90 std::vector<int> newSplitInto(ndims, splitInto);
96 std::vector<double> instrumentMaxRecursionDepth = instrument->getNumberParameter(maxRecursionDepthName,
true);
97 if (!instrumentMaxRecursionDepth.empty()) {
98 setProperty(maxRecursionDepthName,
static_cast<int>(instrumentMaxRecursionDepth.front()));
112 size_t nd = bc->getNDims();
126 size_t nd = bc->getNDims();
130 bc->setSplitThreshold(val);
132 bc->setMaxDepth(val);
135 std::vector<int> splits =
getProperty(
"SplitInto");
136 if (splits.size() == 1) {
137 bc->setSplitInto(splits[0]);
138 }
else if (splits.size() == nd) {
139 for (
size_t d = 0;
d < nd; ++
d)
140 bc->setSplitInto(
d, splits[
d]);
142 throw std::invalid_argument(
"SplitInto parameter has " +
Strings::toString(splits.size()) +
143 " arguments. It should have either 1, or the "
144 "same as the number of dimensions.");
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.
void takeDefaultsFromInstrument(const Mantid::Geometry::Instrument_const_sptr &instrument, const size_t ndims)
Take the defaults for the box splitting from the instrument parameters.
void setBoxController(const Mantid::API::BoxController_sptr &bc, const Mantid::Geometry::Instrument_const_sptr &instrument)
Set the settings in the given box controller.
void initBoxControllerProps(const std::string &SplitInto="5", int SplitThreshold=1000, int MaxRecursionDepth=5)
Initialise the properties.
std::string getBoxSettingsGroupName()
Support for a property that holds an array of values.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void setPropertyGroup(const std::string &name, const std::string &group)
Set the group for a given property.
The concrete, templated class for properties.
Base class for properties.
virtual bool isDefault() const =0
Overriden function that returns if property has the same value that it was initialised with,...
@ TOK_IGNORE_EMPTY
ignore empty tokens
@ TOK_TRIM
remove leading and trailing whitespace from tokens
ConstIterator cend() const
Const iterator referring to the past-the-end element in the container.
ConstIterator cbegin() const
Const iterator referring to first element in the container.
std::size_t count() const
Get the total number of tokens.
std::shared_ptr< BoxController > BoxController_sptr
Shared ptr to BoxController.
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
std::string toString(const T &value)
Convert a number to a string.