27double DegreesToRadians(
double angle) {
return angle * M_PI / 180; }
33using namespace Kernel;
35using namespace Geometry;
38 auto wsValidator = std::make_shared<API::InstrumentValidator>();
43 "The name of the workspace containing the instrument to add the shape");
46 const std::vector<std::string> extensions{
".stl",
".off"};
48 "The path name of the file containing the shape");
54 declareProperty(
"XDegrees", 0.0,
"The degrees to rotate on the x axis by");
55 declareProperty(
"YDegrees", 0.0,
"The degrees to rotate on the y axis by");
56 declareProperty(
"ZDegrees", 0.0,
"The degrees to rotate on the z axis by");
60 "Vector by which to translate the loaded sample shape");
64 "The name of the workspace that will contain the loaded "
65 "shape of the sample");
73 if (inputWS != outputWS) {
74 outputWS = inputWS->clone();
77 auto ei = std::dynamic_pointer_cast<ExperimentInfo>(outputWS);
79 throw std::invalid_argument(
"Wrong type of input workspace");
81 const std::string filename =
getProperty(
"Filename");
83 const std::string filetype = filename.substr(filename.size() - 3);
85 std::shared_ptr<MeshObject> shape =
nullptr;
89 std::unique_ptr<LoadSingleMesh> reader =
nullptr;
90 if (filetype ==
"off") {
91 reader = std::make_unique<LoadOff>(filename, scaleType);
92 shape = reader->readShape();
95 shape = reader->readShape();
98 const double xRotation = DegreesToRadians(
getProperty(
"xDegrees"));
99 const double yRotation = DegreesToRadians(
getProperty(
"yDegrees"));
100 const double zRotation = DegreesToRadians(
getProperty(
"zDegrees"));
101 shape = reader->rotate(shape, xRotation, yRotation, zRotation);
103 const std::vector<double> translationVector =
getProperty(
"TranslationVector");
104 shape = reader->translate(shape, translationVector);
107 shape->rotate(ei->run().getGoniometer().getR());
110 Sample &sample = ei->mutableSample();
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
@ Load
allowed here which will be passed to the algorithm
This class stores information about the sample used in particular run.
void setShape(const Geometry::IObject_sptr &shape)
Update the shape of the object.
A property class for workspaces.
void exec() override
Virtual method - must be overridden by concrete algorithm.
void init() override
Virtual method - must be overridden by concrete algorithm.
static std::unique_ptr< LoadStl > createReader(const std::string &filename, ScaleUnits scaleType)
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.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< const Workspace > Workspace_const_sptr
shared pointer to Mantid::API::Workspace (const version)
ScaleUnits getScaleTypeFromStr(const std::string &scaleProperty)
@ Input
An input workspace.
@ Output
An output workspace.