diff --git a/Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp b/Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp index e644f6846fa2..c13756de0f9c 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp @@ -32,6 +32,7 @@ #include "MantidKernel/MultiThreaded.h" #include "MantidDataObjects/PeakNoShapeFactory.h" #include "MantidDataObjects/PeakShapeSphericalFactory.h" +#include "MantidDataObjects/PeakShapeEllipsoidFactory.h" #include "MantidDataObjects/PeakShape.h" namespace Mantid { @@ -1122,26 +1123,30 @@ API::Workspace_sptr LoadNexusProcessed::loadPeaksEntry(NXEntry &entry) { // Read shape information using namespace Mantid::DataObjects; - PeakShapeFactory_sptr peakFactory = boost::make_shared(); - peakFactory->setSuccessor(boost::make_shared()); + PeakShapeFactory_sptr peakFactoryEllipsoid = boost::make_shared(); + PeakShapeFactory_sptr peakFactorySphere = boost::make_shared(); + PeakShapeFactory_sptr peakFactoryNone = boost::make_shared(); + + peakFactoryEllipsoid->setSuccessor(peakFactorySphere); + peakFactorySphere->setSuccessor(peakFactoryNone); NXInfo info = nx_tw.getDataSetInfo(str.c_str()); NXChar data = nx_tw.openNXChar(str.c_str()); const int maxShapeJSONLength = info.dims[1]; data.load(); - for (int r = 0; r < numberPeaks; r++) { + for (int i = 0; i < numberPeaks; ++i) { // iR = peak row number - auto startPoint = data() + (maxShapeJSONLength * r); + auto startPoint = data() + (maxShapeJSONLength * i); std::string shapeJSON(startPoint, startPoint + maxShapeJSONLength); boost::trim_right(shapeJSON); // Make the shape - PeakShape* peakShape = peakFactory->create(shapeJSON); + PeakShape* peakShape = peakFactoryEllipsoid->create(shapeJSON); // Set the shape - peakWS->getPeak(r).setPeakShape(peakShape); + peakWS->getPeak(i).setPeakShape(peakShape); } } diff --git a/Code/Mantid/Framework/DataObjects/inc/MantidDataObjects/PeakShapeSpherical.h b/Code/Mantid/Framework/DataObjects/inc/MantidDataObjects/PeakShapeSpherical.h index 18e63d3c3ade..3311ea1c8185 100644 --- a/Code/Mantid/Framework/DataObjects/inc/MantidDataObjects/PeakShapeSpherical.h +++ b/Code/Mantid/Framework/DataObjects/inc/MantidDataObjects/PeakShapeSpherical.h @@ -65,6 +65,8 @@ class DLLExport PeakShapeSpherical : public PeakShapeBase { boost::optional backgroundOuterRadius() const; /// Peak inner background radius boost::optional backgroundInnerRadius() const; + /// Non-instance shape name + static const std::string sphereShapeName(); private: /// Peak radius diff --git a/Code/Mantid/Framework/DataObjects/src/PeakShapeSpherical.cpp b/Code/Mantid/Framework/DataObjects/src/PeakShapeSpherical.cpp index 2680933a1d61..80f964054163 100644 --- a/Code/Mantid/Framework/DataObjects/src/PeakShapeSpherical.cpp +++ b/Code/Mantid/Framework/DataObjects/src/PeakShapeSpherical.cpp @@ -106,7 +106,7 @@ PeakShapeSpherical *PeakShapeSpherical::clone() const { return new PeakShapeSpherical(*this); } -std::string PeakShapeSpherical::shapeName() const { return "spherical"; } +std::string PeakShapeSpherical::shapeName() const { return sphereShapeName() ; } bool PeakShapeSpherical::operator==(const PeakShapeSpherical &other) const { return PeakShapeBase::operator==(other) && other.radius() == this->radius() && @@ -135,7 +135,16 @@ boost::optional PeakShapeSpherical::backgroundOuterRadius() const { * @return boost optional inner radius. */ boost::optional PeakShapeSpherical::backgroundInnerRadius() const { - return m_backgroundInnerRadius; + return m_backgroundInnerRadius; +} + +/** + * @brief PeakShapeSpherical::sphereShapeName + * @return Spherical shape name for this type. + */ +const std::string PeakShapeSpherical::sphereShapeName() +{ + return "spherical"; } } // namespace DataObjects diff --git a/Code/Mantid/Framework/DataObjects/src/PeakShapeSphericalFactory.cpp b/Code/Mantid/Framework/DataObjects/src/PeakShapeSphericalFactory.cpp index afb0f706e2bc..e541ad8001a6 100644 --- a/Code/Mantid/Framework/DataObjects/src/PeakShapeSphericalFactory.cpp +++ b/Code/Mantid/Framework/DataObjects/src/PeakShapeSphericalFactory.cpp @@ -30,7 +30,7 @@ PeakShape *PeakShapeSphericalFactory::create(const std::string &source) const { PeakShape *product = NULL; if (reader.parse(source, root)) { const std::string shape = root["shape"].asString(); - if (shape == "spherical") { + if (shape == PeakShapeSpherical::sphereShapeName()) { const std::string algorithmName(root["algorithm_name"].asString()); const int algorithmVersion(root["algorithm_version"].asInt());