Skip to content

Commit c4490d2

Browse files
Moved RotateSampleShape into MantidDataHandling
1 parent 0059417 commit c4490d2

File tree

7 files changed

+18
-45
lines changed

7 files changed

+18
-45
lines changed

Framework/Crystal/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ set(SRC_FILES
7272
src/SortPeaksWorkspace.cpp
7373
src/StatisticsOfPeaksWorkspace.cpp
7474
src/TransformHKL.cpp
75-
src/RotateSampleShape.cpp
7675
)
7776

7877
set(INC_FILES
@@ -152,7 +151,6 @@ set(INC_FILES
152151
inc/MantidCrystal/SortPeaksWorkspace.h
153152
inc/MantidCrystal/StatisticsOfPeaksWorkspace.h
154153
inc/MantidCrystal/TransformHKL.h
155-
inc/MantidCrystal/RotateSampleShape.h
156154
)
157155

158156
set(TEST_FILES
@@ -225,7 +223,6 @@ set(TEST_FILES
225223
SortPeaksWorkspaceTest.h
226224
StatisticsOfPeaksWorkspaceTest.h
227225
TransformHKLTest.h
228-
RotateSampleShapeTest.h
229226
)
230227

231228
if(COVERAGE)

Framework/DataHandling/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ set(SRC_FILES
218218
src/StartAndEndTimeFromNexusFileExtractor.cpp
219219
src/UpdateInstrumentFromFile.cpp
220220
src/XmlHandler.cpp
221+
src/RotateSampleShape.cpp
221222
)
222223

223224
set(INC_FILES
@@ -444,6 +445,7 @@ set(INC_FILES
444445
src/LoadRaw/isisraw2.h
445446
src/LoadRaw/item_struct.h
446447
src/LoadRaw/vms_convert.h
448+
inc/MantidDataHandling/RotateSampleShape.h
447449
)
448450

449451
set(TEST_FILES
@@ -642,6 +644,7 @@ set(TEST_FILES
642644
StartAndEndTimeFromNexusFileExtractorTest.h
643645
UpdateInstrumentFromFileTest.h
644646
XMLInstrumentParameterTest.h
647+
RotateSampleShapeTest.h
645648
)
646649

647650
if(COVERAGE)

Framework/DataHandling/inc/MantidDataHandling/CreateSampleShape.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace DataHandling {
2727
*/
2828
class MANTID_DATAHANDLING_DLL CreateSampleShape final : public API::Algorithm {
2929
public:
30-
static void setSampleShape(API::ExperimentInfo &expt, const std::string &shapeXML);
30+
static void setSampleShape(API::ExperimentInfo &expt, const std::string &shapeXML, bool addTypeTag = true);
3131

3232
public:
3333
const std::string name() const override { return "CreateSampleShape"; }

Framework/Crystal/inc/MantidCrystal/RotateSampleShape.h renamed to Framework/DataHandling/inc/MantidDataHandling/RotateSampleShape.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "MantidAPI/Algorithm.h"
1010
#include "MantidAPI/MultipleExperimentInfos.h"
11-
#include "MantidCrystal/DllConfig.h"
11+
#include "MantidDataHandling/DllConfig.h"
1212

1313
namespace Mantid {
1414
namespace Geometry {
@@ -17,14 +17,14 @@ class Goniometer;
1717
} // namespace Mantid
1818

1919
namespace Mantid {
20-
namespace Crystal {
20+
namespace DataHandling {
2121

2222
using Mantid::Geometry::Goniometer;
2323

2424
/** Define the initial orientation of the sample with respect to the beam and instrument by giving the axes and
2525
*directions of rotations.
2626
*/
27-
class MANTID_CRYSTAL_DLL RotateSampleShape final : public API::Algorithm {
27+
class MANTID_DATAHANDLING_DLL RotateSampleShape final : public API::Algorithm {
2828
public:
2929
/// Algorithm's name for identification
3030
const std::string name() const override { return "RotateSampleShape"; };
@@ -38,7 +38,7 @@ class MANTID_CRYSTAL_DLL RotateSampleShape final : public API::Algorithm {
3838
int version() const override { return 1; };
3939
const std::vector<std::string> seeAlso() const override { return {"SetGoniometer"}; }
4040
/// Algorithm's category for identification
41-
const std::string category() const override { return "Crystal\\Goniometer"; }
41+
const std::string category() const override { return "DataHandling\\Instrument"; }
4242

4343
private:
4444
/// Initialise the properties
@@ -47,8 +47,7 @@ class MANTID_CRYSTAL_DLL RotateSampleShape final : public API::Algorithm {
4747
void exec() override;
4848
void prepareGoniometerAxes(Goniometer &gon);
4949
bool checkIsValidShape(const API::ExperimentInfo_sptr &ei, std::string &shapeXML, bool &isMeshShape);
50-
void setSampleShape(API::ExperimentInfo &expt, const std::string &shapeXML, bool addTypeTag);
5150
};
5251

53-
} // namespace Crystal
52+
} // namespace DataHandling
5453
} // namespace Mantid

Framework/DataHandling/src/CreateSampleShape.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ using namespace Mantid::API;
2626
* @brief Set the shape via an XML string on the given experiment
2727
* @param expt A reference to the experiment holding the sample object
2828
* @param shapeXML XML defining the object's shape
29+
* @param addTypeTag true to wrap a \<type\> tag around the XML supplied(default)
2930
*/
30-
void CreateSampleShape::setSampleShape(API::ExperimentInfo &expt, const std::string &shapeXML) {
31+
void CreateSampleShape::setSampleShape(API::ExperimentInfo &expt, const std::string &shapeXML, bool addTypeTag) {
3132
Geometry::ShapeFactory sFactory;
3233
// Create the object
33-
auto shape = sFactory.createShape(shapeXML);
34+
auto shape = sFactory.createShape(shapeXML, addTypeTag);
3435
// Check it's valid and attach it to the workspace sample but preserve any
3536
// material
3637
if (shape->hasValidShape()) {

Framework/Crystal/src/RotateSampleShape.cpp renamed to Framework/DataHandling/src/RotateSampleShape.cpp

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
// NScD Oak Ridge National Laboratory, European Spallation Source,
55
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
66
// SPDX - License - Identifier: GPL - 3.0 +
7-
#include "MantidCrystal/RotateSampleShape.h"
7+
#include "MantidDataHandling/RotateSampleShape.h"
88
#include "MantidAPI/MatrixWorkspace.h"
99
#include "MantidAPI/Run.h"
1010
#include "MantidAPI/Sample.h"
11+
#include "MantidDataHandling/CreateSampleShape.h"
1112
#include "MantidGeometry/Instrument/Goniometer.h"
1213
#include "MantidGeometry/Objects/MeshObject.h"
1314
#include "MantidGeometry/Objects/ShapeFactory.h"
@@ -16,7 +17,7 @@
1617
#include <boost/algorithm/string/classification.hpp>
1718
#include <boost/algorithm/string/split.hpp>
1819

19-
namespace Mantid::Crystal {
20+
namespace Mantid::DataHandling {
2021

2122
// Register the algorithm into the AlgorithmFactory
2223
DECLARE_ALGORITHM(RotateSampleShape)
@@ -27,7 +28,6 @@ using namespace Mantid::API;
2728

2829
/// How many axes (max) to define
2930
const size_t NUM_AXES = 6;
30-
Mantid::Kernel::Logger g_log("RotateSampleShape");
3131

3232
/** Initialize the algorithm's properties.
3333
*/
@@ -90,34 +90,7 @@ void RotateSampleShape::exec() {
9090
meshShape->rotate(newSampleShapeRot);
9191
} else {
9292
shapeXML = Geometry::ShapeFactory().addGoniometerTag(newSampleShapeRot, shapeXML);
93-
setSampleShape(*ei, shapeXML, false);
94-
}
95-
}
96-
97-
/**
98-
* @brief Set the shape via an XML string on the given experiment
99-
* @param expt A reference to the experiment holding the sample object
100-
* @param shapeXML XML defining the object's shape
101-
* @param addTypeTag true to wrap a \<type\> tag around the XML supplied(default)
102-
*/
103-
void RotateSampleShape::setSampleShape(API::ExperimentInfo &expt, const std::string &shapeXML, bool addTypeTag) {
104-
Geometry::ShapeFactory sFactory;
105-
// Create the object
106-
auto shape = sFactory.createShape(shapeXML, addTypeTag);
107-
// Check it's valid and attach it to the workspace sample but preserve any
108-
// material
109-
if (shape->hasValidShape()) {
110-
const auto mat = expt.sample().getMaterial();
111-
shape->setMaterial(mat);
112-
expt.mutableSample().setShape(shape);
113-
} else {
114-
std::ostringstream msg;
115-
msg << "Object has invalid shape.";
116-
if (auto csgShape = dynamic_cast<Geometry::CSGObject *>(shape.get())) {
117-
msg << " TopRule = " << csgShape->topRule() << ", number of surfaces = " << csgShape->getSurfacePtr().size()
118-
<< "\n";
119-
}
120-
throw std::runtime_error(msg.str());
93+
Mantid::DataHandling::CreateSampleShape::setSampleShape(*ei, shapeXML, false);
12194
}
12295
}
12396

@@ -188,4 +161,4 @@ void RotateSampleShape::prepareGoniometerAxes(Goniometer &gon) {
188161
}
189162
}
190163

191-
} // namespace Mantid::Crystal
164+
} // namespace Mantid::DataHandling

Framework/Crystal/test/RotateSampleShapeTest.h renamed to Framework/DataHandling/test/RotateSampleShapeTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#pragma once
88

99
#include "MantidAPI/Sample.h"
10-
#include "MantidCrystal/RotateSampleShape.h"
10+
#include "MantidDataHandling/RotateSampleShape.h"
1111
#include "MantidFrameworkTestHelpers/ComponentCreationHelper.h"
1212
#include "MantidFrameworkTestHelpers/WorkspaceCreationHelper.h"
1313
#include "MantidGeometry/Instrument/Goniometer.h"

0 commit comments

Comments
 (0)