Mantid
Loading...
Searching...
No Matches
Sample.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#include "MantidAPI/Sample.h"
8
15
16#include <boost/python/class.hpp>
17#include <boost/python/copy_const_reference.hpp>
18#include <boost/python/register_ptr_to_python.hpp>
19
24using Mantid::Kernel::Material; // NOLINT
25using namespace boost::python;
26using namespace Mantid::Geometry;
27
31
32bool equals_wrapper(const Sample &self, const Sample &other) { return self == other; }
33
35 register_ptr_to_python<Sample *>();
36 register_ptr_to_python<std::shared_ptr<Sample>>();
37
38 class_<Sample, boost::noncopyable>("Sample")
39 .def("getName", &Sample::getName, return_value_policy<copy_const_reference>(), arg("self"),
40 "Returns the string name of the sample")
41 .def("getOrientedLattice", (const OrientedLattice &(Sample::*)() const) & Sample::getOrientedLattice, arg("self"),
42 return_value_policy<reference_existing_object>(), "Get the oriented lattice for this sample")
43 .def("hasOrientedLattice", &Sample::hasOrientedLattice, arg("self"),
44 "Returns True if this sample has an oriented lattice, false "
45 "otherwise")
46 .def("clearOrientedLattice", &Sample::clearOrientedLattice, arg("self"),
47 "Clears any attached lattice information")
48 .def("getCrystalStructure", &Sample::getCrystalStructure, arg("self"),
49 return_value_policy<reference_existing_object>(), "Get the crystal structure for this sample")
50 .def("hasCrystalStructure", &Sample::hasCrystalStructure, arg("self"),
51 "Returns True if this sample has a crystal structure, false "
52 "otherwise")
53 .def("setCrystalStructure", &Sample::setCrystalStructure, (arg("self"), arg("newCrystalStructure")),
54 "Assign a crystal structure object to the sample.")
55 .def("clearCrystalStructure", &Sample::clearCrystalStructure, arg("self"),
56 "Removes the internally stored crystal structure.")
57 .def("size", &Sample::size, arg("self"), "Return the number of samples contained within this sample")
58 // Required for ISIS SANS reduction until the full sample geometry is
59 // defined on loading
60 .def("getGeometryFlag", &Sample::getGeometryFlag, arg("self"), "Return the geometry flag.")
61 .def("getThickness", &Sample::getThickness, arg("self"), "Return the thickness in mm")
62 .def("getHeight", &Sample::getHeight, arg("self"), "Return the height in mm")
63 .def("getWidth", &Sample::getWidth, arg("self"), "Return the width in mm")
64 .def("getMaterial", &Sample::getMaterial, arg("self"), "The material the sample is composed of",
65 return_internal_reference<>())
66 .def("setGeometryFlag", &Sample::setGeometryFlag, (arg("self"), arg("geom_id")), "Set the geometry flag.")
67 .def("setThickness", &Sample::setThickness, (arg("self"), arg("thick")), "Set the thickness in mm.")
68 .def("setHeight", &Sample::setHeight, (arg("self"), arg("height")), "Set the height in mm.")
69 .def("setWidth", &Sample::setWidth, (arg("self"), arg("width")), "Set the width in mm.")
70 .def("getShape", &Sample::getShapePtr, return_value_policy<return_by_value>(), "Returns the shape of the Sample")
71 .def("setShape", &Sample::setShape, (arg("self"), arg("shape")), "Set shape of Sample object.")
72 .def("hasEnvironment", &Sample::hasEnvironment, arg("self"),
73 "Returns True if the sample has an environment defined")
74 .def("hasShape", &Sample::hasShape, arg("self"), "Returns True if the sample has a shape defined")
75 .def("getEnvironment", &Sample::getEnvironment, return_value_policy<reference_existing_object>(), arg("self"),
76 "Returns the sample environment")
77 .def("setEnvironment", &Sample::setEnvironment, (arg("self"), arg("env")), "Set the sample environment")
78 // -------------------------Operators
79 // -------------------------------------
80 .def("__len__", &Sample::size, arg("self"), "Gets the number of samples in this collection")
81 .def("__getitem__", &Sample::operator[], (arg("self"), arg("index")), return_internal_reference<>())
82 .def("__copy__", &Mantid::PythonInterface::generic__copy__<Sample>)
83 .def("__deepcopy__", &Mantid::PythonInterface::generic__deepcopy__<Sample>)
84 .def("__eq__", &equals_wrapper, (arg("self"), arg("other")));
85}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition GetPointer.h:17
bool equals_wrapper(const Sample &self, const Sample &other)
Definition Sample.cpp:32
void export_Sample()
Definition Sample.cpp:34
This class stores information about the sample used in particular run.
Definition Sample.h:33
void setShape(const Geometry::IObject_sptr &shape)
Update the shape of the object.
Definition Sample.cpp:115
void clearOrientedLattice()
Delete the oriented lattice.
Definition Sample.cpp:407
const Kernel::Material & getMaterial() const
Return the material (convenience method)
Definition Sample.cpp:126
bool hasEnvironment() const
Definition Sample.cpp:128
const std::string & getName() const
Returns the name of the sample.
Definition Sample.cpp:85
void setEnvironment(std::shared_ptr< Geometry::SampleEnvironment > env)
Set the environment used to contain the sample.
Definition Sample.cpp:147
int getGeometryFlag() const
Returns the geometry flag.
Definition Sample.cpp:215
const Geometry::OrientedLattice & getOrientedLattice() const
Get a reference to the sample's OrientedLattice.
Definition Sample.cpp:153
void setCrystalStructure(const Geometry::CrystalStructure &newCrystalStructure)
Resets the internal pointer to the new CrystalStructure (it's copied).
Definition Sample.cpp:189
bool hasOrientedLattice() const
Definition Sample.cpp:178
void setGeometryFlag(int geom_id)
Sets the geometry flag.
Definition Sample.cpp:208
std::size_t size() const
the number of samples
Definition Sample.cpp:272
void setWidth(double width)
Sets the width.
Definition Sample.cpp:245
double getWidth() const
Returns the width.
Definition Sample.cpp:251
bool hasCrystalStructure() const
Returns true if the sample actually holds a CrystalStructure.
Definition Sample.cpp:194
void setHeight(double height)
Sets the height.
Definition Sample.cpp:233
double getHeight() const
Returns the height.
Definition Sample.cpp:239
void clearCrystalStructure()
Destroys the internally stored CrystalStructure-object.
Definition Sample.cpp:201
const Geometry::SampleEnvironment & getEnvironment() const
Get a reference to the sample's environment.
Definition Sample.cpp:135
void setThickness(double thick)
Sets the thickness.
Definition Sample.cpp:221
const Geometry::CrystalStructure & getCrystalStructure() const
Definition Sample.cpp:180
double getThickness() const
Returns the thickness.
Definition Sample.cpp:227
const Geometry::IObject_sptr getShapePtr() const
Return a pointer to the sample shape.
Definition Sample.cpp:109
bool hasShape() const
Check if sample has a valid shape.
Definition Sample.cpp:93
IObject : Interface for geometry objects.
Definition IObject.h:42
Class to implement UB matrix.
Defines a single instance of a SampleEnvironment.
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
Definition Material.h:50