34 "An input workspace from wich to copy sample information.");
36 "An output workspace to wich to copy sample information..");
38 "Copy the name of the sample");
40 "Copy the material of the sample");
42 "Copy the sample environment");
44 "Copy the sample shape");
46 "Copy the sample oriented lattice");
48 "Copy the U matrix only, if both origin and destination have "
51 std::make_unique<Kernel::EnabledWhenProperty>(
"CopyLattice",
IS_EQUAL_TO,
"1"));
53 "The number of the sample to be copied from, for an MD workspace "
56 "The number of the sample to be copied to for an MD "
57 "workspace (starting from 0). No number, or negative number, "
58 "means that it will copy to all samples");
62 std::map<std::string, std::string> result;
63 const bool copyLattice =
getProperty(
"CopyLattice");
64 const bool copyOrientationOnly =
getProperty(
"CopyOrientationOnly");
65 if (copyOrientationOnly && !copyLattice) {
66 result[
"CopyLattice"] =
"Need to check CopyLattice if CopyOrientationOnly is checked";
81 if (inMDWS !=
nullptr)
83 int inputSampleNumber =
getProperty(
"MDInputSampleNumber");
84 if (inputSampleNumber < 0) {
85 g_log.
warning() <<
"Number less then 0. Will use sample number 0 instead\n";
86 inputSampleNumber = 0;
88 if (
static_cast<uint16_t
>(inputSampleNumber) > (inMDWS->getNumExperimentInfo() - 1)) {
89 g_log.
warning() <<
"Number greater than the number of last sample in the workspace ("
90 << (inMDWS->getNumExperimentInfo() - 1) <<
"). Will use sample number 0 instead\n";
91 inputSampleNumber = 0;
93 sample = inMDWS->getExperimentInfo(
static_cast<uint16_t
>(inputSampleNumber))->sample();
98 throw std::invalid_argument(
"Wrong type of input workspace");
99 sample = ei->sample();
104 bool copyEnvironment =
getProperty(
"CopyEnvironment");
107 bool copyOrientation =
getProperty(
"CopyOrientationOnly");
111 if (outMDWS !=
nullptr) {
112 int outputSampleNumber =
getProperty(
"MDOutputSampleNumber");
113 if ((outputSampleNumber ==
EMPTY_INT()) || (outputSampleNumber < 0))
115 for (uint16_t i = 0; i < outMDWS->getNumExperimentInfo(); i++) {
116 auto ei = outMDWS->getExperimentInfo(i);
117 copyParameters(sample, ei->mutableSample(), copyName, copyMaterial, copyEnvironment, copyShape, copyLattice,
118 copyOrientation, ei->run().getGoniometer().getR());
122 if (
static_cast<uint16_t
>(outputSampleNumber) > (outMDWS->getNumExperimentInfo() - 1)) {
123 g_log.
warning() <<
"Number greater than the number of last sample in "
125 << (outMDWS->getNumExperimentInfo() - 1) <<
"). Will use sample number 0 instead\n";
126 outputSampleNumber = 0;
128 auto ei = outMDWS->getExperimentInfo(
static_cast<uint16_t
>(outputSampleNumber));
129 copyParameters(sample, ei->mutableSample(), copyName, copyMaterial, copyEnvironment, copyShape, copyLattice,
130 copyOrientation, ei->run().getGoniometer().getR());
136 throw std::invalid_argument(
"Wrong type of output workspace");
137 copyParameters(sample, ei->mutableSample(), copyName, copyMaterial, copyEnvironment, copyShape, copyLattice,
138 copyOrientation, ei->run().getGoniometer().getR());
144 bool shapeFlag,
bool latticeFlag,
bool orientationOnlyFlag,
148 if (environmentFlag) {
161 if (
auto csgObj = std::dynamic_pointer_cast<Geometry::CSGObject>(rhsObject)) {
163 std::string xml = csgObj->getShapeXML();
166 rhsObject->setMaterial(rhsMaterial);
168 if (
auto meshObj = std::dynamic_pointer_cast<Geometry::MeshObject>(rhsObject)) {
170 meshObj->rotate(rotationMatrix);
178 }
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.