14#include <boost/function.hpp>
37 "An input peaks workspace.");
39 std::vector<std::string> propOptions;
43 propOptions.emplace_back(
hklFrame());
45 declareProperty(
"CoordinateFrame",
"DetectorSpace", std::make_shared<StringListValidator>(propOptions),
46 "What coordinate system to use for intersection criteria?\n"
47 " DetectorSpace: Real-space coordinates.\n"
48 " Q (lab frame): Wave-vector change of the lattice in the lab frame.\n"
49 " Q (sample frame): Momentum in the sample frame.\n"
52 declareProperty(
"PeakRadius", 0.0,
"Effective peak radius in CoordinateFrame");
55 "An output table workspace. Two columns. Peak index into "
56 "input workspace, and boolean, where true is for positive "
71 const std::string coordinateFrame = this->
getPropertyValue(
"CoordinateFrame");
76 boost::function<
V3D(
Peak *)> coordFrameFunc;
77 coordFrameFunc = &Peak::getHKL;
80 }
else if (coordinateFrame ==
qLabFrame()) {
89 const int nPeaks = ws->getNumberPeaks();
96 normals[i] = (face[1] - face[0]).cross_prod((face[2] - face[0]));
97 const auto norm = normals[i].norm();
100 const auto v = face[1] - face[0];
101 const auto r = std::hypot(v.X(), v.Y());
103 normals[i] =
V3D(1., 0., 0.);
105 const auto x = v.Y() / r;
106 const auto y = std::sqrt(1 -
x *
x);
107 normals[i] =
V3D(
x,
y, 0.);
115 std::make_shared<Mantid::DataObjects::TableWorkspace>(ws->rowCount());
116 outputWorkspace->addColumn(
"int",
"PeakIndex");
117 outputWorkspace->addColumn(
"bool",
"Intersecting");
118 outputWorkspace->addColumn(
"double",
"Distance");
120 size_t frequency = nPeaks;
121 if (frequency > 100) {
122 frequency = nPeaks / 100;
127 for (
int i = 0; i < nPeaks; ++i) {
129 Peak *peak =
dynamic_cast<Peak *
>(ws->getPeakPtr(i));
130 V3D peakCenter = coordFrameFunc(peak);
132 if (i % frequency == 0)
135 bool doesIntersect =
true;
139 doesIntersect =
false;
141 if (checkPeakExtents) {
144 distance = normals[j].scalar_prod(faces[j][0] - peakCenter);
150 const V3D touchPoint = (normals[j] * distance) + peakCenter;
157 doesIntersect =
true;
165 TableRow row = outputWorkspace->getRow(i);
166 row << i << doesIntersect << distance;
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PARALLEL_FOR_IF(condition)
Empty definitions - to enable set your complier to enable openMP.
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Helper class for reporting progress from algorithms.
TableRow represents a row in a TableWorkspace.
A property class for workspaces.
virtual VecVecV3D createFaces() const =0
Create all faces.
static std::string qSampleFrame()
void executePeaksIntersection(const bool checkPeakExtents=true)
Run the algorithm.
static std::string detectorSpaceFrame()
double getPeakRadius() const
Get the peak radius.
virtual bool pointOutsideAnyExtents(const Mantid::Kernel::V3D &testPoint) const =0
Check that a point is outside any of the extents.
static std::string hklFrame()
virtual bool pointInsideAllExtents(const Mantid::Kernel::V3D &testPoints, const Mantid::Kernel::V3D &peakCenter) const =0
Check that a point is inside ALL of the extents.
static std::string qLabFrame()
virtual int numberOfFaces() const =0
Number of surface faces that make up this object.
void initBaseProperties()
Initalize the common properties.
Structure describing a single-crystal peak.
Mantid::Kernel::V3D getDetectorPosition() const
Forwarding function.
Mantid::Kernel::V3D getQLabFrame() const override
Return the Q change (of the lattice, k_i - k_f) for this peak.
Mantid::Kernel::V3D getQSampleFrame() const override
Return the Q change (of the lattice, k_i - k_f) for this peak.
The class PeaksWorkspace stores information about a set of SCD peaks.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
std::vector< VecV3D > VecVecV3D
std::vector< Mantid::Kernel::V3D > VecV3D
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
std::enable_if< std::is_pointer< Arg >::value, bool >::type threadSafe(Arg workspace)
Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access.
@ Input
An input workspace.
@ Output
An output workspace.