12#include <boost/algorithm/string.hpp>
13#include <boost/regex.hpp>
18#pragma warning(disable : 4005)
29using namespace Kernel;
51 "Position of the scatterer");
53 IValidator_sptr unitCellStringValidator = std::make_shared<UnitCellStringValidator>();
55 unitCellStringValidator),
68 for (
size_t i = 0; i < numberParts.size(); ++i) {
69 parser.SetExpr(numberParts[i]);
87 if (propertyName ==
"Position") {
91 }
else if (propertyName ==
"UnitCell") {
103 boost::regex unitCellRegex(
"((\\d+(\\.\\d+){0,1}\\s+){2}|(\\d+(\\.\\d+){0,1}"
104 "\\s+){5})(\\d+(\\.\\d+){0,1}\\s*)");
106 if (!boost::regex_match(unitCellString, unitCellRegex)) {
107 return "Unit cell string is invalid: " + unitCellString;
115 std::string positionStringClean =
position;
116 positionStringClean.erase(
117 std::remove_if(positionStringClean.begin(), positionStringClean.end(), boost::is_any_of(
"[]")),
118 positionStringClean.end());
120 std::vector<std::string> numberParts;
121 boost::split(numberParts, positionStringClean, boost::is_any_of(
","));
123 if (numberParts.size() != 3) {
124 throw std::invalid_argument(
"Cannot parse '" +
position +
"' as a position.");
void(ComponentInfo::* setPosition)(const size_t, const Mantid::Kernel::V3D &)
void afterPropertySet(const std::string &propertyName) override
Additional property processing.
virtual void setCell(const UnitCell &cell)
Assigns a unit cell, which may be required for certain calculations.
void declareProperties() override
Declares basic properties, should not be overridden by subclasses, use declareScattererProperties ins...
Kernel::V3D getPositionFromString(const std::string &positionString) const
virtual void declareScattererProperties()
This method should be implemented by subclasses for declaring additional properties.
virtual void afterScattererPropertySet(const std::string &)
This method should be re-implemented by subclasses for additional parameter processing.
BraggScattererInCrystalStructure()
Default constructor.
Kernel::V3D getPosition() const
Returns the position of the scatterer.
virtual void setPosition(const Kernel::V3D &position)
Sets the position of the scatterer to the supplied coordinates - vector is wrapped to [0,...
BraggScatterer is a general interface for representing scatterers in the unit cell of a periodic stru...
void exposePropertyToComposite(const std::string &propertyName)
Exposes the property with the supplied name to BraggScattererComposite.
std::string checkValidity(const std::string &unitCellString) const override
Check if the string is valid input for Geometry::strToUnitCell.
Kernel::IValidator_sptr clone() const override
Return a clone of the validator.
Class to implement unit cell of crystals.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void declareProperty(std::unique_ptr< Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
The concrete, templated class for properties.
MANTID_GEOMETRY_DLL UnitCell strToUnitCell(const std::string &unitCellString)
MANTID_GEOMETRY_DLL std::vector< std::string > getTokenizedPositionString(const std::string &position)
Returns components of comma-separated position string, cleaned from [ and ].
MANTID_GEOMETRY_DLL V3R getWrappedVector(const V3R &vector)
Wraps a V3R to the interval (0, 1].
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.