12#include <boost/algorithm/string.hpp>
13#include <boost/regex.hpp>
18#pragma warning(disable : 4005)
29using namespace Kernel;
54 "Position of the scatterer");
56 IValidator_sptr unitCellStringValidator = std::make_shared<UnitCellStringValidator>();
58 unitCellStringValidator),
71 for (
size_t i = 0; i < numberParts.size(); ++i) {
72 parser.SetExpr(numberParts[i]);
90 if (propertyName ==
"Position") {
94 }
else if (propertyName ==
"UnitCell") {
106 boost::regex unitCellRegex(
"((\\d+(\\.\\d+){0,1}\\s+){2}|(\\d+(\\.\\d+){0,1}"
107 "\\s+){5})(\\d+(\\.\\d+){0,1}\\s*)");
109 if (!boost::regex_match(unitCellString, unitCellRegex)) {
110 return "Unit cell string is invalid: " + unitCellString;
118 std::string positionStringClean =
position;
119 positionStringClean.erase(
120 std::remove_if(positionStringClean.begin(), positionStringClean.end(), boost::is_any_of(
"[]")),
121 positionStringClean.end());
123 std::vector<std::string> numberParts;
124 boost::split(numberParts, positionStringClean, boost::is_any_of(
","));
126 if (numberParts.size() != 3) {
127 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.
UnitCell getCell() const
Returns the cell which is currently set.
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.