Mantid
Loading...
Searching...
No Matches
WorkspaceNearestNeighbours.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 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 +
7#pragma once
8
9#include "MantidAPI/DllConfig.h"
11#include "MantidKernel/V3D.h"
12#include <memory>
13// Boost graphing
14#ifndef Q_MOC_RUN
15#define BOOST_ALLOW_DEPRECATED_HEADERS
16#include <boost/graph/adjacency_list.hpp>
17#undef BOOST_ALLOW_DEPRECATED_HEADERS
18#include <unordered_map>
19#endif
20
21namespace Mantid {
22namespace Geometry {
23class Instrument;
24class IDetector;
25} // namespace Geometry
26namespace API {
27class SpectrumInfo;
50class MANTID_API_DLL WorkspaceNearestNeighbours {
51public:
52 WorkspaceNearestNeighbours(int nNeighbours, const SpectrumInfo &spectrumInfo, std::vector<specnum_t> spectrumNumbers,
53 bool ignoreMaskedDetectors = false);
54
55 // Neighbouring spectra by radius
56 std::map<specnum_t, Mantid::Kernel::V3D> neighboursInRadius(specnum_t spectrum, double radius = 0.0) const;
57
58 // Neighbouring spectra by
59 std::map<specnum_t, Mantid::Kernel::V3D> neighbours(specnum_t spectrum) const;
60
61protected:
62 std::vector<size_t> getSpectraDetectors();
63
64private:
68 const std::vector<specnum_t> m_spectrumNumbers;
69
71 using Graph =
72 boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, boost::property<boost::vertex_name_t, int64_t>,
73 boost::property<boost::edge_name_t, Mantid::Kernel::V3D>>;
75 using Vertex = boost::graph_traits<Graph>::vertex_descriptor;
77 using MapIV = std::unordered_map<specnum_t, Vertex>;
78
81 void build(const int noNeighbours);
84 std::map<specnum_t, Mantid::Kernel::V3D> defaultNeighbours(const specnum_t spectrum) const;
88 double m_cutoff;
94 boost::property_map<Graph, boost::vertex_name_t>::type m_vertexID;
96 boost::property_map<Graph, boost::edge_name_t>::type m_edgeLength;
100 mutable double m_radius;
103};
104
105} // namespace API
106} // namespace Mantid
double radius
Definition: Rasterize.cpp:31
API::SpectrumInfo is an intermediate step towards a SpectrumInfo that is part of Instrument-2....
Definition: SpectrumInfo.h:53
This class is not intended for direct use.
bool m_bIgnoreMaskedDetectors
Flag indicating that masked detectors should be ignored.
boost::property_map< Graph, boost::edge_name_t >::type m_edgeLength
property map holding the edge's related Distance value.
int m_noNeighbours
The current number of nearest neighbours.
double m_cutoff
The largest value of the distance to a nearest neighbour.
boost::property_map< Graph, boost::vertex_name_t >::type m_vertexID
property map holding the node's related DetectorID's
boost::graph_traits< Graph >::vertex_descriptor Vertex
Vertex descriptor object for Graph.
double m_radius
Cached radius value. used to avoid uncessary recalculations.
std::unordered_map< specnum_t, Vertex > MapIV
map object of int to Graph Vertex descriptor
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, boost::property< boost::vertex_name_t, int64_t >, boost::property< boost::edge_name_t, Mantid::Kernel::V3D > > Graph
typedef for Graph object used to hold the calculated information
MapIV m_specToVertex
map between the DetectorID and the Graph node descriptor
const SpectrumInfo & m_spectrumInfo
A reference to the SpectrumInfo.
const std::vector< specnum_t > m_spectrumNumbers
Vector of spectrum numbers.
Class for 3D vectors.
Definition: V3D.h:34
Helper class which provides the Collimation Length for SANS instruments.
int32_t specnum_t
Typedef for a spectrum Number.
Definition: IDTypes.h:16