19Kernel::Logger
g_log(
"ShapeRotation");
21const Kernel::Matrix<double> &identityMatrix() {
22 static const Kernel::Matrix<double> identity(3, 3,
true);
29 if (alreadyApplied == identityMatrix()) {
32 g_log.
information(
"The sample shape already carries a rotation, so only the remainder of the "
33 "goniometer rotation is applied");
36 return goniometerR * alreadyApplied.
Tprime();
41 if (outstanding == identityMatrix()) {
44 return std::shared_ptr<IObject>(shape.
clone());
47 if (
const auto *csgShape =
dynamic_cast<const CSGObject *
>(&shape)) {
54 if (csgShape->getShapeXML().empty()) {
55 throw std::invalid_argument(
"The sample shape ('" + shape.
id() +
56 "') carries no XML definition, so it cannot be rotated into the lab frame. It was "
57 "built directly from surfaces rather than parsed from a shape definition. Define "
58 "the sample with SetSample or CreateSampleShape to make it rotatable.");
66 labShape->setMaterial(shape.
material());
67 labShape->setID(shape.
id());
71 auto labShape = std::shared_ptr<IObject>(shape.
clone());
72 if (
auto *meshShape =
dynamic_cast<MeshObject *
>(labShape.get())) {
73 meshShape->bakeGoniometerRotation(outstanding);
78 g_log.
warning(
"The sample shape is of a type that cannot be rotated ('" + shape.
id() +
79 "'), so it is taken to be defined in the lab frame already and is used unchanged. "
80 "The goniometer rotation on the run has not been applied to it.");
Constructive Solid Geometry object.
IObject : Interface for geometry objects.
virtual const Kernel::Matrix< double > & getAppliedRotation() const
The goniometer rotation baked into this shape, i.e.
virtual const std::string & id() const =0
virtual const Kernel::Material & material() const =0
virtual IObject * clone() const =0
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 rebakeGoniometer(const Kernel::Matrix< double > &newBake, std::string xml, const Kernel::Matrix< double > ¤tBake)
Rebase the shape so the baked part becomes exactly newBake, preserving the definition-frame rotation.
void warning(const std::string &msg)
Logs at warning level.
void information(const std::string &msg)
Logs at information level.
Matrix< T > Tprime() const
Transpose the matrix.
Mantid::Kernel::Logger g_log("Goniometer")
MANTID_GEOMETRY_DLL std::shared_ptr< IObject > getLabFrameShape(const IObject &shape, const Kernel::Matrix< double > &goniometerR)
The shape as it sits in the lab frame: a clone rotated by whatever part of goniometerR it does not al...
MANTID_GEOMETRY_DLL Kernel::Matrix< double > outstandingGoniometerRotation(const IObject &shape, const Kernel::Matrix< double > &goniometerR)
The part of goniometerR that the shape does not already carry.