Mantid
|
InstrumentVisitor : Visitor for components with access to Info wrapping features. More...
#include <InstrumentVisitor.h>
Static Public Member Functions | |
static std::pair< std::unique_ptr< ComponentInfo >, std::unique_ptr< DetectorInfo > > | makeWrappers (const Instrument &instrument, ParameterMap *pmap=nullptr) |
Private Member Functions | |
size_t | commonRegistration (const Mantid::Geometry::IComponent &component) |
Extract the common aspects relevant to all component types. More... | |
std::pair< std::unique_ptr< ComponentInfo >, std::unique_ptr< DetectorInfo > > | makeWrappers () const |
void | markAsSourceOrSample (Mantid::Geometry::IComponent *componentId, const size_t componentIndex) |
Private Attributes | |
std::shared_ptr< std::vector< size_t > > | m_assemblySortedComponentIndices |
Component indexes sorted by assembly. More... | |
std::shared_ptr< std::vector< size_t > > | m_assemblySortedDetectorIndices |
Detector indexes sorted by assembly. More... | |
std::shared_ptr< std::vector< std::vector< size_t > > > | m_children |
Stores instrument tree structure by storing children of all Components. More... | |
std::shared_ptr< std::vector< Mantid::Geometry::IComponent * > > | m_componentIds |
Detectors components always specified first. More... | |
std::shared_ptr< std::unordered_map< Mantid::Geometry::IComponent *, size_t > > | m_componentIdToIndexMap |
Component ID -> Component Index map. More... | |
std::shared_ptr< std::vector< std::pair< size_t, size_t > > > | m_componentRanges |
Component ranges. More... | |
std::shared_ptr< std::vector< Beamline::ComponentType > > | m_componentType |
Structured bank flag. More... | |
std::shared_ptr< const std::unordered_map< detid_t, size_t > > | m_detectorIdToIndexMap |
Detector ID -> index mappings. More... | |
std::shared_ptr< std::vector< Eigen::Vector3d > > | m_detectorPositions |
Positions for detectors. More... | |
std::shared_ptr< std::vector< std::pair< size_t, size_t > > > | m_detectorRanges |
Only Assemblies and other NON-detectors yield detector ranges. More... | |
std::shared_ptr< std::vector< Eigen::Quaterniond, Eigen::aligned_allocator< Eigen::Quaterniond > > > | m_detectorRotations |
Rotations for detectors. More... | |
std::shared_ptr< const Mantid::Geometry::Instrument > | m_instrument |
Instrument to build around. More... | |
std::shared_ptr< std::vector< size_t > > | m_monitorIndices |
Monitor indexes for detectors. More... | |
std::shared_ptr< std::vector< std::string > > | m_names |
Component names. More... | |
std::shared_ptr< const Mantid::Geometry::IObject > | m_nullShape |
Null shared (empty shape) More... | |
std::shared_ptr< std::vector< detid_t > > | m_orderedDetectorIds |
Detector indices. More... | |
std::shared_ptr< std::vector< size_t > > | m_parentComponentIndices |
Index of the parent component. More... | |
Mantid::Geometry::ParameterMap * | m_pmap |
Parameter map to purge. More... | |
std::shared_ptr< std::vector< Eigen::Vector3d > > | m_positions |
Positions for non-detectors. More... | |
std::shared_ptr< std::vector< Eigen::Quaterniond, Eigen::aligned_allocator< Eigen::Quaterniond > > > | m_rotations |
Rotations for non-detectors. More... | |
Mantid::Geometry::IComponent * | m_sampleId |
Sample id to look for. More... | |
int64_t | m_sampleIndex = -1 |
Sample index to set. More... | |
std::shared_ptr< std::vector< Eigen::Vector3d > > | m_scaleFactors |
Scale factors. More... | |
std::shared_ptr< std::vector< std::shared_ptr< const Mantid::Geometry::IObject > > > | m_shapes |
Shapes stored in fly-weight fashion. More... | |
Mantid::Geometry::IComponent * | m_sourceId |
Source id to look for. More... | |
int64_t | m_sourceIndex = -1 |
Source index to set. More... | |
InstrumentVisitor : Visitor for components with access to Info wrapping features.
This visitor ensures only minimal changes are required to any of the IComponent/Instrument1.0 hierachy in order to fully process it. It also eliminates the need for any dynamic casting. Note that InstrumentVisitor provides accessors for the client to extract visited information such as ComponentIDs.
Definition at line 47 of file InstrumentVisitor.h.
Mantid::Geometry::InstrumentVisitor::InstrumentVisitor | ( | std::shared_ptr< const Instrument > | instrument | ) |
Constructor.
instrument | : Instrument being visited |
Definition at line 65 of file InstrumentVisitor.cpp.
References m_assemblySortedDetectorIndices, m_componentIdToIndexMap, m_instrument, m_orderedDetectorIds, m_pmap, m_sampleId, and m_sourceId.
|
private |
Extract the common aspects relevant to all component types.
Definition at line 119 of file InstrumentVisitor.cpp.
References Mantid::Geometry::IComponent::getComponentID(), Mantid::Geometry::IComponent::getName(), Mantid::Geometry::IComponent::getPos(), Mantid::Geometry::IComponent::getRotation(), Mantid::Geometry::IComponent::getScaleFactor(), m_componentIds, m_names, m_nullShape, m_pmap, m_positions, m_rotations, m_scaleFactors, m_shapes, markAsSourceOrSample(), Mantid::Kernel::toQuaterniond(), and Mantid::Kernel::toVector3d().
Referenced by registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
std::shared_ptr< const std::vector< Mantid::Geometry::ComponentID > > Mantid::Geometry::InstrumentVisitor::componentIds | ( | ) | const |
InstrumentVisitor::componentIds.
Definition at line 347 of file InstrumentVisitor.cpp.
References m_componentIds.
Referenced by makeWrappers().
std::shared_ptr< const std::unordered_map< Mantid::Geometry::IComponent *, size_t > > Mantid::Geometry::InstrumentVisitor::componentIdToIndexMap | ( | ) | const |
Definition at line 361 of file InstrumentVisitor.cpp.
References m_componentIdToIndexMap.
Referenced by makeWrappers().
std::unique_ptr< Beamline::ComponentInfo > Mantid::Geometry::InstrumentVisitor::componentInfo | ( | ) | const |
Definition at line 369 of file InstrumentVisitor.cpp.
References m_assemblySortedComponentIndices, m_assemblySortedDetectorIndices, m_children, m_componentRanges, m_componentType, m_detectorRanges, m_names, m_parentComponentIndices, m_positions, m_rotations, m_sampleIndex, m_scaleFactors, and m_sourceIndex.
Referenced by makeWrappers().
std::shared_ptr< std::vector< detid_t > > Mantid::Geometry::InstrumentVisitor::detectorIds | ( | ) | const |
Definition at line 381 of file InstrumentVisitor.cpp.
References m_orderedDetectorIds.
Referenced by makeWrappers().
std::shared_ptr< const std::unordered_map< detid_t, size_t > > Mantid::Geometry::InstrumentVisitor::detectorIdToIndexMap | ( | ) | const |
Definition at line 365 of file InstrumentVisitor.cpp.
References m_detectorIdToIndexMap.
Referenced by makeWrappers().
std::unique_ptr< Beamline::DetectorInfo > Mantid::Geometry::InstrumentVisitor::detectorInfo | ( | ) | const |
Definition at line 376 of file InstrumentVisitor.cpp.
References m_detectorPositions, m_detectorRotations, and m_monitorIndices.
Referenced by makeWrappers().
bool Mantid::Geometry::InstrumentVisitor::isEmpty | ( | ) | const |
Definition at line 358 of file InstrumentVisitor.cpp.
References size().
|
private |
Definition at line 383 of file InstrumentVisitor.cpp.
References componentIds(), componentIdToIndexMap(), componentInfo(), detectorIds(), detectorIdToIndexMap(), detectorInfo(), m_instrument, and m_shapes.
Referenced by Mantid::Geometry::Instrument::makeBeamline(), makeWrappers(), and Mantid::Geometry::Instrument::parseTreeAndCacheBeamline().
|
static |
Definition at line 398 of file InstrumentVisitor.cpp.
References Mantid::Geometry::ParComponentFactory::createInstrument(), makeWrappers(), and walkInstrument().
|
private |
Definition at line 289 of file InstrumentVisitor.cpp.
References m_sampleId, m_sampleIndex, m_sourceId, and m_sourceIndex.
Referenced by commonRegistration(), and registerDetector().
|
overridevirtual |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 136 of file InstrumentVisitor.cpp.
References commonRegistration(), Mantid::Geometry::ICompAssembly::getChildren(), m_assemblySortedComponentIndices, m_assemblySortedDetectorIndices, m_children, m_componentRanges, m_componentType, m_detectorRanges, and m_parentComponentIndices.
Referenced by registerGridBank(), registerObjComponentAssembly(), registerRectangularBank(), and registerStructuredBank().
|
overridevirtual |
InstrumentVisitor::registerDetector.
detector | : IDetector being visited |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 302 of file InstrumentVisitor.cpp.
References detectorIndex, Mantid::Geometry::IComponent::getComponentID(), Mantid::Geometry::IDetector::getID(), Mantid::Geometry::IComponent::getName(), Mantid::Geometry::IComponent::getPos(), Mantid::Geometry::IComponent::getRotation(), Mantid::Geometry::IComponent::getScaleFactor(), m_assemblySortedDetectorIndices, m_detectorIdToIndexMap, m_instrument, m_monitorIndices, m_pmap, markAsSourceOrSample(), Mantid::Geometry::IObjComponent::shape(), Mantid::Kernel::toQuaterniond(), and Mantid::Kernel::toVector3d().
|
overridevirtual |
InstrumentVisitor::registerGenericComponent.
component | : IComponent being visited |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 174 of file InstrumentVisitor.cpp.
References commonRegistration(), m_assemblySortedComponentIndices, m_children, m_componentRanges, m_componentType, m_detectorRanges, and m_parentComponentIndices.
Referenced by registerGenericObjComponent().
|
overridevirtual |
InstrumentVisitor::registerGenericObjComponent.
objComponent | : IObjComponent being visited |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 226 of file InstrumentVisitor.cpp.
References index, registerGenericComponent(), and Mantid::Geometry::IObjComponent::shape().
|
overridevirtual |
Register a grid bank.
bank | : Grid Detector |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 249 of file InstrumentVisitor.cpp.
References index, m_orderedDetectorIds, and registerComponentAssembly().
|
overridevirtual |
InstrumentVisitor::registerInfiniteComponent.
component | : IComponent being visited |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 200 of file InstrumentVisitor.cpp.
References commonRegistration(), m_assemblySortedComponentIndices, m_children, m_componentRanges, m_componentType, m_detectorRanges, and m_parentComponentIndices.
Referenced by registerInfiniteObjComponent().
|
overridevirtual |
InstrumentVisitor::registerInfiniteObjComponent.
objComponent | : IObjComponent being visited |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 261 of file InstrumentVisitor.cpp.
References index, registerInfiniteComponent(), and Mantid::Geometry::IObjComponent::shape().
|
overridevirtual |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 279 of file InstrumentVisitor.cpp.
References index, m_orderedDetectorIds, obj, and registerComponentAssembly().
|
overridevirtual |
Register a rectangular bank.
bank | : Rectangular Detector |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 237 of file InstrumentVisitor.cpp.
References index, m_orderedDetectorIds, and registerComponentAssembly().
|
overridevirtual |
Register a structured bank.
bank | : Structured Detector |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 272 of file InstrumentVisitor.cpp.
References index, m_orderedDetectorIds, and registerComponentAssembly().
size_t Mantid::Geometry::InstrumentVisitor::size | ( | ) | const |
Definition at line 356 of file InstrumentVisitor.cpp.
References m_componentIds.
Referenced by isEmpty().
void Mantid::Geometry::InstrumentVisitor::walkInstrument | ( | ) |
Definition at line 111 of file InstrumentVisitor.cpp.
References Mantid::Geometry::ParameterMap::empty(), m_instrument, and m_pmap.
Referenced by makeWrappers().
|
private |
Component indexes sorted by assembly.
Definition at line 59 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Detector indexes sorted by assembly.
Definition at line 56 of file InstrumentVisitor.h.
Referenced by componentInfo(), InstrumentVisitor(), registerComponentAssembly(), and registerDetector().
|
private |
Stores instrument tree structure by storing children of all Components.
Definition at line 65 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Detectors components always specified first.
Definition at line 53 of file InstrumentVisitor.h.
Referenced by commonRegistration(), componentIds(), and size().
|
private |
Component ID -> Component Index map.
Definition at line 74 of file InstrumentVisitor.h.
Referenced by componentIdToIndexMap(), and InstrumentVisitor().
|
private |
Component ranges.
Definition at line 71 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Structured bank flag.
Definition at line 122 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Detector ID -> index mappings.
Definition at line 77 of file InstrumentVisitor.h.
Referenced by detectorIdToIndexMap(), and registerDetector().
|
private |
Positions for detectors.
Definition at line 83 of file InstrumentVisitor.h.
Referenced by detectorInfo().
|
private |
Only Assemblies and other NON-detectors yield detector ranges.
Definition at line 68 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Rotations for detectors.
Definition at line 89 of file InstrumentVisitor.h.
Referenced by detectorInfo().
|
private |
Instrument to build around.
Definition at line 95 of file InstrumentVisitor.h.
Referenced by InstrumentVisitor(), makeWrappers(), registerDetector(), and walkInstrument().
|
private |
Monitor indexes for detectors.
Definition at line 92 of file InstrumentVisitor.h.
Referenced by detectorInfo(), and registerDetector().
|
private |
Component names.
Definition at line 125 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and componentInfo().
|
private |
Null shared (empty shape)
Definition at line 113 of file InstrumentVisitor.h.
Referenced by commonRegistration().
|
private |
Detector indices.
Definition at line 50 of file InstrumentVisitor.h.
Referenced by detectorIds(), InstrumentVisitor(), registerGridBank(), registerObjComponentAssembly(), registerRectangularBank(), and registerStructuredBank().
|
private |
Index of the parent component.
Definition at line 62 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Parameter map to purge.
Definition at line 98 of file InstrumentVisitor.h.
Referenced by commonRegistration(), InstrumentVisitor(), registerDetector(), and walkInstrument().
|
private |
Positions for non-detectors.
Definition at line 80 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and componentInfo().
|
private |
Rotations for non-detectors.
Definition at line 86 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and componentInfo().
|
private |
Sample id to look for.
Definition at line 104 of file InstrumentVisitor.h.
Referenced by InstrumentVisitor(), and markAsSourceOrSample().
|
private |
Sample index to set.
Definition at line 110 of file InstrumentVisitor.h.
Referenced by componentInfo(), and markAsSourceOrSample().
|
private |
Scale factors.
Definition at line 119 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and componentInfo().
|
private |
Shapes stored in fly-weight fashion.
Definition at line 116 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and makeWrappers().
|
private |
Source id to look for.
Definition at line 101 of file InstrumentVisitor.h.
Referenced by InstrumentVisitor(), and markAsSourceOrSample().
|
private |
Source index to set.
Definition at line 107 of file InstrumentVisitor.h.
Referenced by componentInfo(), and markAsSourceOrSample().