Mantid
Loading...
Searching...
No Matches
PeakShapeSpherical.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 +
8#include "MantidJson/Json.h"
9#include <json/json.h>
10#include <stdexcept>
11#include <utility>
12
13namespace Mantid::DataObjects {
14
23 std::string algorithmName, int algorithmVersion)
24 : PeakShapeBase(frame, std::move(algorithmName), algorithmVersion), m_radius(peakRadius) {}
25
35PeakShapeSpherical::PeakShapeSpherical(const double &peakRadius, const double &peakInnerRadius,
36 const double &peakOuterRadius, Kernel::SpecialCoordinateSystem frame,
37 std::string algorithmName, int algorithmVersion)
38 : PeakShapeBase(frame, std::move(algorithmName), algorithmVersion), m_radius(peakRadius),
39 m_backgroundInnerRadius(peakInnerRadius), m_backgroundOuterRadius(peakOuterRadius) {
40 if (peakRadius == m_backgroundOuterRadius) {
42 }
43}
44
49std::string PeakShapeSpherical::toJSON() const {
50 Json::Value root;
52 root["radius"] = Json::Value(m_radius);
53
55 root["background_outer_radius"] = Json::Value(m_backgroundOuterRadius.get());
56 root["background_inner_radius"] = Json::Value(m_backgroundInnerRadius.get());
57 }
58
59 return Mantid::JsonHelpers::jsonToString(root);
60}
61
67
68std::string PeakShapeSpherical::shapeName() const { return sphereShapeName(); }
69
71 return PeakShapeBase::operator==(other) && other.radius() == this->radius() &&
74}
75
81boost::optional<double> PeakShapeSpherical::radius(RadiusType type) const {
82
83 boost::optional<double> value;
84 switch (type) {
85 case (RadiusType::Radius):
86 value = boost::optional<double>{m_radius};
87 break;
90 break;
93 break;
94 }
95 return value;
96}
97
104
111
116const std::string PeakShapeSpherical::sphereShapeName() { return "spherical"; }
117
118} // namespace Mantid::DataObjects
double value
The value of the point.
Definition: FitMW.cpp:51
double radius
Definition: Rasterize.cpp:31
PeakShapeBase : Base class for concrete PeakShapes containing common code.
Definition: PeakShapeBase.h:26
void buildCommon(Json::Value &root) const
Build common parts of outgoing JSON serialization.
bool operator==(const PeakShapeBase &other) const
Equals operator.
PeakShapeSpherical : PeakShape for a spherical peak.
PeakShapeSpherical(const double &peakRadius, Kernel::SpecialCoordinateSystem frame, std::string algorithmName=std::string(), int algorithmVersion=-1)
Constructor.
std::string shapeName() const override
Shape name.
boost::optional< double > radius(RadiusType type=RadiusType::Radius) const override
Peak radius.
boost::optional< double > backgroundInnerRadius() const
Peak inner background radius.
std::string toJSON() const override
Serialization method.
boost::optional< double > m_backgroundInnerRadius
Background inner radius;.
bool operator==(const PeakShapeSpherical &other) const
Equals operator.
static const std::string sphereShapeName()
Non-instance shape name.
boost::optional< double > backgroundOuterRadius() const
Peak outer background radius.
PeakShapeSpherical * clone() const override
Clone the peak shape.
boost::optional< double > m_backgroundOuterRadius
Background outer radius.
RadiusType
For selecting different radius types.
Definition: PeakShape.h:35
SpecialCoordinateSystem
Special coordinate systems for Q3D.
STL namespace.