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
23using Mantid::Kernel::Material; // NOLINT
24using namespace boost::python;
25
29
31 register_ptr_to_python<Sample *>();
32 register_ptr_to_python<std::shared_ptr<Sample>>();
33
34 class_<Sample, boost::noncopyable>("Sample")
35 .def("getName", &Sample::getName, return_value_policy<copy_const_reference>(), arg("self"),
36 "Returns the string name of the sample")
37 .def("getOrientedLattice", (const OrientedLattice &(Sample::*)() const) & Sample::getOrientedLattice, arg("self"),
38 return_value_policy<reference_existing_object>(), "Get the oriented lattice for this sample")
39 .def("hasOrientedLattice", &Sample::hasOrientedLattice, arg("self"),
40 "Returns True if this sample has an oriented lattice, false "
41 "otherwise")
42 .def("clearOrientedLattice", &Sample::clearOrientedLattice, arg("self"),
43 "Clears any attached lattice information")
44 .def("getCrystalStructure", &Sample::getCrystalStructure, arg("self"),
45 return_value_policy<reference_existing_object>(), "Get the crystal structure for this sample")
46 .def("hasCrystalStructure", &Sample::hasCrystalStructure, arg("self"),
47 "Returns True if this sample has a crystal structure, false "
48 "otherwise")
49 .def("setCrystalStructure", &Sample::setCrystalStructure, (arg("self"), arg("newCrystalStructure")),
50 "Assign a crystal structure object to the sample.")
51 .def("clearCrystalStructure", &Sample::clearCrystalStructure, arg("self"),
52 "Removes the internally stored crystal structure.")
53 .def("size", &Sample::size, arg("self"), "Return the number of samples contained within this sample")
54 // Required for ISIS SANS reduction until the full sample geometry is
55 // defined on loading
56 .def("getGeometryFlag", &Sample::getGeometryFlag, arg("self"), "Return the geometry flag.")
57 .def("getThickness", &Sample::getThickness, arg("self"), "Return the thickness in mm")
58 .def("getHeight", &Sample::getHeight, arg("self"), "Return the height in mm")
59 .def("getWidth", &Sample::getWidth, arg("self"), "Return the width in mm")
60 .def("getMaterial", &Sample::getMaterial, arg("self"), "The material the sample is composed of",
61 return_value_policy<reference_existing_object>())
62 .def("setGeometryFlag", &Sample::setGeometryFlag, (arg("self"), arg("geom_id")), "Set the geometry flag.")
63 .def("setThickness", &Sample::setThickness, (arg("self"), arg("thick")), "Set the thickness in mm.")
64 .def("setHeight", &Sample::setHeight, (arg("self"), arg("height")), "Set the height in mm.")
65 .def("setWidth", &Sample::setWidth, (arg("self"), arg("width")), "Set the width in mm.")
66 .def("getShape", &Sample::getShape, arg("self"), "Returns a shape of a Sample object.",
67 return_value_policy<reference_existing_object>())
68 .def("setShape", &Sample::setShape, arg("self"), "Set shape of Sample object.")
69 .def("hasEnvironment", &Sample::hasEnvironment, arg("self"),
70 "Returns True if the sample has an environment defined")
71 .def("hasShape", &Sample::hasShape, arg("self"), "Returns True if the sample has a shape defined")
72 .def("getEnvironment", &Sample::getEnvironment, return_value_policy<reference_existing_object>(), arg("self"),
73 "Returns the sample environment")
74 .def("setEnvironment", &Sample::setEnvironment, (arg("self"), arg("env")), "Set the sample environment")
75 // -------------------------Operators
76 // -------------------------------------
77 .def("__len__", &Sample::size, arg("self"), "Gets the number of samples in this collection")
78 .def("__getitem__", &Sample::operator[], (arg("self"), arg("index")), return_internal_reference<>())
79 .def("__copy__", &Mantid::PythonInterface::generic__copy__<Sample>)
80 .def("__deepcopy__", &Mantid::PythonInterface::generic__deepcopy__<Sample>)
81 .def("__eq__", &Sample::operator==, (arg("self"), arg("other")));
82}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition: GetPointer.h:17
void export_Sample()
Definition: Sample.cpp:30
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:116
void clearOrientedLattice()
Delete the oriented lattice.
Definition: Sample.cpp:408
const Kernel::Material & getMaterial() const
Return the material (convenience method)
Definition: Sample.cpp:127
bool hasEnvironment() const
Definition: Sample.cpp:129
const std::string & getName() const
Returns the name of the sample.
Definition: Sample.cpp:86
const Geometry::IObject & getShape() const
Return the sample shape.
Definition: Sample.cpp:102
void setEnvironment(std::shared_ptr< Geometry::SampleEnvironment > env)
Set the environment used to contain the sample.
Definition: Sample.cpp:148
int getGeometryFlag() const
Returns the geometry flag.
Definition: Sample.cpp:216
const Geometry::OrientedLattice & getOrientedLattice() const
Get a reference to the sample's OrientedLattice.
Definition: Sample.cpp:154
void setCrystalStructure(const Geometry::CrystalStructure &newCrystalStructure)
Resets the internal pointer to the new CrystalStructure (it's copied).
Definition: Sample.cpp:190
bool hasOrientedLattice() const
Definition: Sample.cpp:179
void setGeometryFlag(int geom_id)
Sets the geometry flag.
Definition: Sample.cpp:209
std::size_t size() const
the number of samples
Definition: Sample.cpp:273
void setWidth(double width)
Sets the width.
Definition: Sample.cpp:246
double getWidth() const
Returns the width.
Definition: Sample.cpp:252
bool hasCrystalStructure() const
Returns true if the sample actually holds a CrystalStructure.
Definition: Sample.cpp:195
void setHeight(double height)
Sets the height.
Definition: Sample.cpp:234
double getHeight() const
Returns the height.
Definition: Sample.cpp:240
void clearCrystalStructure()
Destroys the internally stored CrystalStructure-object.
Definition: Sample.cpp:202
const Geometry::SampleEnvironment & getEnvironment() const
Get a reference to the sample's environment.
Definition: Sample.cpp:136
void setThickness(double thick)
Sets the thickness.
Definition: Sample.cpp:222
const Geometry::CrystalStructure & getCrystalStructure() const
Definition: Sample.cpp:181
double getThickness() const
Returns the thickness.
Definition: Sample.cpp:228
bool hasShape() const
Check if sample has a valid shape.
Definition: Sample.cpp:94
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