35 "An input workspace from wich to copy sample information.");
37 "An output workspace to wich to copy sample information..");
39 "Copy the name of the sample");
41 "Copy the material of the sample");
43 "Copy the sample environment");
45 "Copy the sample shape");
47 "Copy the sample oriented lattice");
49 "Copy the U matrix only, if both origin and destination have "
52 std::make_unique<Kernel::EnabledWhenProperty>(
"CopyLattice",
IS_EQUAL_TO,
"1"));
54 "The number of the sample to be copied from, for an MD workspace "
57 "The number of the sample to be copied to for an MD "
58 "workspace (starting from 0). No number, or negative number, "
59 "means that it will copy to all samples");
63 std::map<std::string, std::string> result;
64 const bool copyLattice =
getProperty(
"CopyLattice");
65 const bool copyOrientationOnly =
getProperty(
"CopyOrientationOnly");
66 if (copyOrientationOnly && !copyLattice) {
67 result[
"CopyLattice"] =
"Need to check CopyLattice if CopyOrientationOnly is checked";
82 if (inMDWS !=
nullptr)
84 int inputSampleNumber =
getProperty(
"MDInputSampleNumber");
85 if (inputSampleNumber < 0) {
86 g_log.
warning() <<
"Number less then 0. Will use sample number 0 instead\n";
87 inputSampleNumber = 0;
89 if (
static_cast<uint16_t
>(inputSampleNumber) > (inMDWS->getNumExperimentInfo() - 1)) {
90 g_log.
warning() <<
"Number greater than the number of last sample in the workspace ("
91 << (inMDWS->getNumExperimentInfo() - 1) <<
"). Will use sample number 0 instead\n";
92 inputSampleNumber = 0;
94 sample = inMDWS->getExperimentInfo(
static_cast<uint16_t
>(inputSampleNumber))->sample();
99 throw std::invalid_argument(
"Wrong type of input workspace");
100 sample = ei->sample();
105 bool copyEnvironment =
getProperty(
"CopyEnvironment");
108 bool copyOrientation =
getProperty(
"CopyOrientationOnly");
112 if (outMDWS !=
nullptr) {
113 int outputSampleNumber =
getProperty(
"MDOutputSampleNumber");
114 if ((outputSampleNumber ==
EMPTY_INT()) || (outputSampleNumber < 0))
116 for (uint16_t i = 0; i < outMDWS->getNumExperimentInfo(); i++) {
117 auto ei = outMDWS->getExperimentInfo(i);
118 copyParameters(sample, ei->mutableSample(), copyName, copyMaterial, copyEnvironment, copyShape, copyLattice,
119 copyOrientation, ei->run().getGoniometer().getR());
123 if (
static_cast<uint16_t
>(outputSampleNumber) > (outMDWS->getNumExperimentInfo() - 1)) {
124 g_log.
warning() <<
"Number greater than the number of last sample in "
126 << (outMDWS->getNumExperimentInfo() - 1) <<
"). Will use sample number 0 instead\n";
127 outputSampleNumber = 0;
129 auto ei = outMDWS->getExperimentInfo(
static_cast<uint16_t
>(outputSampleNumber));
130 copyParameters(sample, ei->mutableSample(), copyName, copyMaterial, copyEnvironment, copyShape, copyLattice,
131 copyOrientation, ei->run().getGoniometer().getR());
137 throw std::invalid_argument(
"Wrong type of output workspace");
138 copyParameters(sample, ei->mutableSample(), copyName, copyMaterial, copyEnvironment, copyShape, copyLattice,
139 copyOrientation, ei->run().getGoniometer().getR());
145 bool shapeFlag,
bool latticeFlag,
bool orientationOnlyFlag,
149 if (environmentFlag) {
162 if (
auto csgObj = std::dynamic_pointer_cast<Geometry::CSGObject>(rhsObject)) {
164 std::string xml = csgObj->getShapeXML();
167 rhsObject->setMaterial(rhsMaterial);
169 if (
auto meshObj = std::dynamic_pointer_cast<Geometry::MeshObject>(rhsObject)) {
171 meshObj->rotate(rotationMatrix);
179 }
else if (materialFlag) {
#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.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
This class stores information about the sample used in particular run.
void setShape(const Geometry::IObject_sptr &shape)
Update the shape of the object.
const Kernel::Material & getMaterial() const
Return the material (convenience method)
const std::string & getName() const
Returns the name of the sample.
const Geometry::IObject & getShape() const
Return the sample shape.
void setEnvironment(std::shared_ptr< Geometry::SampleEnvironment > env)
Set the environment used to contain the sample.
int getGeometryFlag() const
Returns the geometry flag.
void setOrientedLattice(std::unique_ptr< Geometry::OrientedLattice > lattice)
Set the pointer to OrientedLattice defining the sample's lattice and orientation.
const Geometry::OrientedLattice & getOrientedLattice() const
Get a reference to the sample's OrientedLattice.
bool hasOrientedLattice() const
void setGeometryFlag(int geom_id)
Sets the geometry flag.
void setName(const std::string &name)
Set the name of the sample.
void setWidth(double width)
Sets the width.
double getWidth() const
Returns the width.
void setHeight(double height)
Sets the height.
double getHeight() const
Returns the height.
const Geometry::SampleEnvironment & getEnvironment() const
Get a reference to the sample's environment.
void setThickness(double thick)
Sets the thickness.
double getThickness() const
Returns the thickness.
A property class for workspaces.
void init() override
Initialise the properties.
std::map< std::string, std::string > validateInputs() override
Method checking errors on ALL the inputs, before execution.
void copyParameters(API::Sample &from, API::Sample &to, bool nameFlag, bool materialFlag, bool environmentFlag, bool shapeFlag, bool latticeFlag, bool orientationOnlyFlag, const Kernel::Matrix< double > &rotationMatrix)
Function to copy information from one sample to another.
void exec() override
Run the algorithm.
IObject : Interface for geometry objects.
virtual IObject * cloneWithMaterial(const Kernel::Material &material) const =0
Class to implement UB matrix.
void setU(const Kernel::DblMatrix &newU, const bool force=true)
Sets the U matrix.
const Kernel::DblMatrix & getU() const
Get the U matrix.
Defines a single instance of a SampleEnvironment.
Class originally intended to be used with the DataHandling 'LoadInstrument' algorithm.
std::shared_ptr< CSGObject > createShape(Poco::XML::Element *pElem)
Creates a geometric object from a DOM-element-node pointing to an element whose child nodes contain t...
std::string addGoniometerTag(const Kernel::Matrix< double > &rotateMatrix, std::string xml)
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void setPropertySettings(const std::string &name, std::unique_ptr< IPropertySettings > settings)
void warning(const std::string &msg)
Logs at warning level.
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
The concrete, templated class for properties.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< ExperimentInfo > ExperimentInfo_sptr
Shared pointer to ExperimentInfo.
std::shared_ptr< MultipleExperimentInfos > MultipleExperimentInfos_sptr
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
@ InOut
Both an input & output workspace.
@ Input
An input workspace.