Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4427109
commit 2387ce5
Showing
4 changed files
with
377 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
Code/Mantid/Framework/DataObjects/inc/MantidDataObjects/PeakShapeEllipsoid.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#ifndef MANTID_DATAOBJECTS_PEAKSHAPEELLIPSOID_H_ | ||
#define MANTID_DATAOBJECTS_PEAKSHAPEELLIPSOID_H_ | ||
|
||
#include "MantidKernel/System.h" | ||
#include "MantidKernel/V3D.h" | ||
#include "MantidDataObjects/PeakShapeBase.h" | ||
|
||
|
||
namespace Mantid | ||
{ | ||
namespace DataObjects | ||
{ | ||
|
||
/** PeakShapeEllipsoid : PeakShape representing a 3D ellipsoid | ||
Copyright © 2015 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://github.com/mantidproject/mantid> | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
class DLLExport PeakShapeEllipsoid : public PeakShapeBase | ||
{ | ||
public: | ||
/// Constructor | ||
PeakShapeEllipsoid(std::vector<Mantid::Kernel::V3D> directions, std::vector<double> abcRadius, std::vector<double> abcBackgroundInnerRadius, std::vector<double> abcBackgroundOuterRadius, API::SpecialCoordinateSystem frame, | ||
std::string algorithmName = std::string(), | ||
int algorithmVersion = -1); | ||
/// Copy constructor | ||
PeakShapeEllipsoid(const PeakShapeEllipsoid& other); | ||
/// Assignment operator | ||
PeakShapeEllipsoid& operator=(const PeakShapeEllipsoid& other); | ||
/// Equals operator | ||
bool operator==(const PeakShapeEllipsoid& other) const; | ||
/// Destructor | ||
virtual ~PeakShapeEllipsoid(); | ||
/// Get radii | ||
std::vector<double> abcRadii() const; | ||
/// Get background inner radii | ||
std::vector<double> abcRadiiBackgroundInner() const; | ||
/// Get background outer radii | ||
std::vector<double> abcRadiiBackgroundOuter() const; | ||
/// Get ellipsoid directions | ||
std::vector<Mantid::Kernel::V3D> directions() const; | ||
|
||
/// PeakShape interface | ||
std::string toJSON() const; | ||
/// Clone ellipsoid | ||
PeakShape *clone() const; | ||
/// Get the peak shape | ||
std::string shapeName() const; | ||
|
||
private: | ||
/// principle axis | ||
std::vector<Mantid::Kernel::V3D> m_directions; | ||
/// radii | ||
std::vector<double> m_abc_radii; | ||
/// inner radii | ||
std::vector<double> m_abc_radiiBackgroundInner; | ||
/// outer radii | ||
std::vector<double> m_abc_radiiBackgroundOuter; | ||
|
||
|
||
}; | ||
|
||
|
||
} // namespace DataObjects | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_DATAOBJECTS_PEAKSHAPEELLIPSOID_H_ */ |
105 changes: 105 additions & 0 deletions
105
Code/Mantid/Framework/DataObjects/src/PeakShapeEllipsoid.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#include "MantidDataObjects/PeakShapeEllipsoid.h" | ||
#include "MantidKernel/cow_ptr.h" | ||
#include <jsoncpp/json/json.h> | ||
|
||
namespace Mantid { | ||
namespace DataObjects { | ||
|
||
PeakShapeEllipsoid::PeakShapeEllipsoid( | ||
std::vector<Kernel::V3D> directions, std::vector<double> abcRadii, | ||
std::vector<double> abcRadiiBackgroundInner, | ||
std::vector<double> abcRadiiBackgroundOuter, | ||
API::SpecialCoordinateSystem frame, std::string algorithmName, | ||
int algorithmVersion) | ||
: PeakShapeBase(frame, algorithmName, algorithmVersion), | ||
m_directions(directions), m_abc_radii(abcRadii), | ||
m_abc_radiiBackgroundInner(abcRadiiBackgroundInner), | ||
m_abc_radiiBackgroundOuter(abcRadiiBackgroundOuter) { | ||
|
||
if (directions.size() != 3) { | ||
throw std::invalid_argument("directions must be of size 3"); | ||
} | ||
if (abcRadii.size() != 3) { | ||
throw std::invalid_argument("radii must be of size 3"); | ||
} | ||
if (abcRadiiBackgroundInner.size() != 3) { | ||
throw std::invalid_argument("radii inner must be of size 3"); | ||
} | ||
if (abcRadiiBackgroundOuter.size() != 3) { | ||
throw std::invalid_argument("radii outer must be of size 3"); | ||
} | ||
} | ||
|
||
PeakShapeEllipsoid::PeakShapeEllipsoid(const PeakShapeEllipsoid &other) | ||
: PeakShapeBase(other), m_directions(other.directions()), | ||
m_abc_radii(other.abcRadii()), | ||
m_abc_radiiBackgroundInner(other.abcRadiiBackgroundInner()), | ||
m_abc_radiiBackgroundOuter(other.abcRadiiBackgroundOuter()) {} | ||
|
||
PeakShapeEllipsoid &PeakShapeEllipsoid:: | ||
operator=(const PeakShapeEllipsoid &other) { | ||
if (&other != this) { | ||
PeakShapeBase::operator=(other); | ||
m_directions = other.directions(); | ||
m_abc_radii = other.abcRadii(); | ||
m_abc_radiiBackgroundInner = other.abcRadiiBackgroundInner(); | ||
m_abc_radiiBackgroundOuter = other.abcRadiiBackgroundOuter(); | ||
} | ||
return *this; | ||
} | ||
|
||
bool PeakShapeEllipsoid::operator==(const PeakShapeEllipsoid &other) const { | ||
return PeakShapeBase::operator==(other) && | ||
other.directions() == this->directions() && | ||
other.abcRadii() == this->abcRadii() && | ||
other.abcRadiiBackgroundInner() == this->abcRadiiBackgroundInner() && | ||
other.abcRadiiBackgroundOuter() == this->abcRadiiBackgroundOuter(); | ||
} | ||
|
||
PeakShapeEllipsoid::~PeakShapeEllipsoid() {} | ||
|
||
std::vector<double> PeakShapeEllipsoid::abcRadii() const { return m_abc_radii; } | ||
|
||
std::vector<double> PeakShapeEllipsoid::abcRadiiBackgroundInner() const { | ||
return m_abc_radiiBackgroundInner; | ||
} | ||
|
||
std::vector<double> PeakShapeEllipsoid::abcRadiiBackgroundOuter() const { | ||
return m_abc_radiiBackgroundOuter; | ||
} | ||
|
||
std::vector<Kernel::V3D> PeakShapeEllipsoid::directions() const { | ||
return m_directions; | ||
} | ||
|
||
std::string PeakShapeEllipsoid::toJSON() const { | ||
Json::Value root; | ||
PeakShapeBase::buildCommon(root); | ||
root["radius0"] = Json::Value(m_abc_radii[0]); | ||
root["radius1"] = Json::Value(m_abc_radii[1]); | ||
root["radius2"] = Json::Value(m_abc_radii[2]); | ||
|
||
root["background_inner_radius0"] = Json::Value(m_abc_radiiBackgroundInner[0]); | ||
root["background_inner_radius1"] = Json::Value(m_abc_radiiBackgroundInner[1]); | ||
root["background_inner_radius2"] = Json::Value(m_abc_radiiBackgroundInner[2]); | ||
|
||
root["background_outer_radius0"] = Json::Value(m_abc_radiiBackgroundOuter[0]); | ||
root["background_outer_radius1"] = Json::Value(m_abc_radiiBackgroundOuter[1]); | ||
root["background_outer_radius2"] = Json::Value(m_abc_radiiBackgroundOuter[2]); | ||
|
||
root["direction0"] = m_directions[0].toString(); | ||
root["direction1"] = m_directions[1].toString(); | ||
root["direction2"] = m_directions[2].toString(); | ||
|
||
Json::StyledWriter writer; | ||
return writer.write(root); | ||
} | ||
|
||
PeakShape *PeakShapeEllipsoid::clone() const { | ||
return new PeakShapeEllipsoid(*this); | ||
} | ||
|
||
std::string PeakShapeEllipsoid::shapeName() const { return "ellipsoid"; } | ||
|
||
} // namespace DataObjects | ||
} // namespace Mantid |
Oops, something went wrong.