|
Mantid
|
InstrumentVisitor : Visitor for components with access to Info wrapping features. More...
#include <InstrumentVisitor.h>
Public Member Functions | |
| std::shared_ptr< const std::vector< Mantid::Geometry::IComponent * > > | componentIds () const |
| InstrumentVisitor::componentIds. | |
| std::shared_ptr< const std::unordered_map< Mantid::Geometry::IComponent const *, size_t > > | componentIdToIndexMap () const |
| std::unique_ptr< Beamline::ComponentInfo > | componentInfo () const |
| std::shared_ptr< std::vector< detid_t > > | detectorIds () const |
| std::shared_ptr< const std::unordered_map< detid_t, size_t > > | detectorIdToIndexMap () const |
| std::unique_ptr< Beamline::DetectorInfo > | detectorInfo () const |
| InstrumentVisitor (std::shared_ptr< const Instrument > instrument) | |
| Constructor. | |
| bool | isEmpty () const |
| std::pair< std::unique_ptr< ComponentInfo >, std::unique_ptr< DetectorInfo > > | makeWrappers () const |
| Make the wrappers from the data collected by walkInstrument(), which must be called first. | |
| virtual size_t | registerComponentAssembly (const Mantid::Geometry::ICompAssembly &assembly) override |
| virtual size_t | registerDetector (const Mantid::Geometry::IDetector &detector) override |
| InstrumentVisitor::registerDetector. | |
| virtual size_t | registerGenericComponent (const Mantid::Geometry::IComponent &component) override |
| InstrumentVisitor::registerGenericComponent. | |
| virtual size_t | registerGenericObjComponent (const Mantid::Geometry::IObjComponent &objComponent) override |
| InstrumentVisitor::registerGenericObjComponent. | |
| virtual size_t | registerGridBank (const Mantid::Geometry::ICompAssembly &bank) override |
| Register a grid bank. | |
| virtual size_t | registerInfiniteComponent (const Mantid::Geometry::IComponent &component) override |
| InstrumentVisitor::registerInfiniteComponent. | |
| virtual size_t | registerInfiniteObjComponent (const IObjComponent &objComponent) override |
| InstrumentVisitor::registerInfiniteObjComponent. | |
| virtual size_t | registerObjComponentAssembly (const ObjCompAssembly &obj) override |
| virtual size_t | registerRectangularBank (const Mantid::Geometry::ICompAssembly &bank) override |
| Register a rectangular bank. | |
| virtual size_t | registerStructuredBank (const Mantid::Geometry::ICompAssembly &bank) override |
| Register a structured bank. | |
| size_t | size () const |
| InstrumentVisitor::size. | |
| void | walkInstrument () |
Public Member Functions inherited from Mantid::Geometry::ComponentVisitor | |
| virtual | ~ComponentVisitor ()=default |
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. | |
| std::shared_ptr< ParameterInfo > | makeParameterInfo () const |
| Rekey the ParameterMap's parameters from legacy component pointers to component indices. | |
| 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. | |
| std::shared_ptr< std::vector< size_t > > | m_assemblySortedDetectorIndices |
| Detector indexes sorted by assembly. | |
| std::shared_ptr< std::vector< std::vector< size_t > > > | m_children |
| Stores instrument tree structure by storing children of all Components. | |
| std::shared_ptr< std::vector< Mantid::Geometry::IComponent * > > | m_componentIds |
| Detectors components always specified first. | |
| std::shared_ptr< std::unordered_map< Mantid::Geometry::IComponent const *, size_t > > | m_componentIdToIndexMap |
| Component ID -> Component Index map. | |
| std::shared_ptr< std::vector< std::pair< size_t, size_t > > > | m_componentRanges |
| Component ranges. | |
| std::shared_ptr< std::vector< Beamline::ComponentType > > | m_componentType |
| Structured bank flag. | |
| std::shared_ptr< const std::unordered_map< detid_t, size_t > > | m_detectorIdToIndexMap |
| Detector ID -> index mappings. | |
| std::shared_ptr< std::vector< Eigen::Vector3d > > | m_detectorPositions |
| Positions for detectors. | |
| std::shared_ptr< std::vector< std::pair< size_t, size_t > > > | m_detectorRanges |
| Only Assemblies and other NON-detectors yield detector ranges. | |
| std::shared_ptr< std::vector< Eigen::Quaterniond, Eigen::aligned_allocator< Eigen::Quaterniond > > > | m_detectorRotations |
| Rotations for detectors. | |
| std::shared_ptr< const Mantid::Geometry::Instrument > | m_instrument |
| Instrument to build around. | |
| std::shared_ptr< std::vector< size_t > > | m_monitorIndices |
| Monitor indexes for detectors. | |
| std::shared_ptr< std::vector< std::string > > | m_names |
| Component names. | |
| std::shared_ptr< const Mantid::Geometry::IObject > | m_nullShape |
| Null shared (empty shape) | |
| std::shared_ptr< std::vector< detid_t > > | m_orderedDetectorIds |
| Detector indices. | |
| std::shared_ptr< std::vector< size_t > > | m_parentComponentIndices |
| Index of the parent component. | |
| std::shared_ptr< std::map< size_t, Beamline::PixelGridComponent > > | m_pixelGridComponents |
| Rectangular/Grid bank pixel-grid metadata. | |
| Mantid::Geometry::ParameterMap * | m_pmap |
| Parameter map to purge. | |
| std::shared_ptr< std::vector< Eigen::Vector3d > > | m_positions |
| Positions for non-detectors. | |
| std::shared_ptr< std::vector< Eigen::Quaterniond, Eigen::aligned_allocator< Eigen::Quaterniond > > > | m_rotations |
| Rotations for non-detectors. | |
| Mantid::Geometry::IComponent * | m_sampleId |
| Sample id to look for. | |
| int64_t | m_sampleIndex = -1 |
| Sample index to set. | |
| std::shared_ptr< std::vector< Eigen::Vector3d > > | m_scaleFactors |
| Scale factors. | |
| std::shared_ptr< std::vector< std::shared_ptr< const Mantid::Geometry::IObject > > > | m_shapes |
| Shapes stored in fly-weight fashion. | |
| std::shared_ptr< std::map< size_t, Eigen::Vector2d > > | m_sideBySideViewPositions |
| Side-by-side (unwrapped) instrument-view positions when declared in the IDF. | |
| Mantid::Geometry::IComponent * | m_sourceId |
| Source id to look for. | |
| int64_t | m_sourceIndex = -1 |
| Source index to set. | |
| std::shared_ptr< std::map< size_t, Beamline::StructuredGridComponent > > | m_structuredGridComponents |
| Pixel counts, ID numbering and pixel vertices of Structured banks, keyed by component index. | |
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 51 of file InstrumentVisitor.h.
| Mantid::Geometry::InstrumentVisitor::InstrumentVisitor | ( | std::shared_ptr< const Instrument > | instrument | ) |
Constructor.
| instrument | : Instrument being visited |
Definition at line 106 of file InstrumentVisitor.cpp.
References Mantid::Geometry::ParameterMap::get(), Mantid::Geometry::IComponent::getComponentID(), 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 164 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(), Mantid::Geometry::IComponent::getSideBySideViewPos(), m_componentIds, m_names, m_nullShape, m_pmap, m_positions, m_rotations, m_scaleFactors, m_shapes, markAsSourceOrSample(), Mantid::Kernel::toQuaterniond(), Mantid::Kernel::toVector2d(), 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 400 of file InstrumentVisitor.cpp.
References m_componentIds.
Referenced by makeWrappers().
| std::shared_ptr< const std::unordered_map< Mantid::Geometry::IComponent const *, size_t > > Mantid::Geometry::InstrumentVisitor::componentIdToIndexMap | ( | ) | const |
Definition at line 414 of file InstrumentVisitor.cpp.
References m_componentIdToIndexMap.
Referenced by makeWrappers().
| std::unique_ptr< Beamline::ComponentInfo > Mantid::Geometry::InstrumentVisitor::componentInfo | ( | ) | const |
Definition at line 422 of file InstrumentVisitor.cpp.
References m_assemblySortedComponentIndices, m_assemblySortedDetectorIndices, m_children, m_componentRanges, m_componentType, m_detectorRanges, m_names, m_parentComponentIndices, m_pixelGridComponents, m_positions, m_rotations, m_sampleIndex, m_scaleFactors, m_sideBySideViewPositions, m_sourceIndex, and m_structuredGridComponents.
Referenced by makeWrappers().
| std::shared_ptr< std::vector< detid_t > > Mantid::Geometry::InstrumentVisitor::detectorIds | ( | ) | const |
Definition at line 434 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 418 of file InstrumentVisitor.cpp.
References m_detectorIdToIndexMap.
Referenced by makeWrappers().
| std::unique_ptr< Beamline::DetectorInfo > Mantid::Geometry::InstrumentVisitor::detectorInfo | ( | ) | const |
Definition at line 429 of file InstrumentVisitor.cpp.
References m_detectorPositions, m_detectorRotations, and m_monitorIndices.
Referenced by makeWrappers().
| bool Mantid::Geometry::InstrumentVisitor::isEmpty | ( | ) | const |
Definition at line 411 of file InstrumentVisitor.cpp.
References size().
|
private |
Rekey the ParameterMap's parameters from legacy component pointers to component indices.
Definition at line 437 of file InstrumentVisitor.cpp.
References m_componentIds, m_componentIdToIndexMap, m_pmap, and Mantid::Geometry::ParameterMap::rekey().
Referenced by makeWrappers().
| std::pair< std::unique_ptr< ComponentInfo >, std::unique_ptr< DetectorInfo > > Mantid::Geometry::InstrumentVisitor::makeWrappers | ( | ) | const |
Make the wrappers from the data collected by walkInstrument(), which must be called first.
The DetectorInfo shares ownership of the visited instrument.
Definition at line 442 of file InstrumentVisitor.cpp.
References componentIds(), componentIdToIndexMap(), componentInfo(), detectorIds(), detectorIdToIndexMap(), detectorInfo(), m_instrument, m_shapes, and makeParameterInfo().
Referenced by Mantid::API::ExperimentInfo::baseComponentInfo(), Mantid::Geometry::ParameterMap::buildInstrumentMetadata(), Mantid::Geometry::Instrument::makeBeamline(), Mantid::Geometry::Instrument::makeBeamlineNew(), makeWrappers(), and Mantid::Geometry::Instrument::parseTreeAndCacheBeamline().
|
static |
Definition at line 460 of file InstrumentVisitor.cpp.
References Mantid::Geometry::Instrument::baseInstrument(), Mantid::Geometry::ParComponentFactory::createInstrument(), Mantid::Geometry::Instrument::getParameterMap(), Mantid::Geometry::Component::isParametrized(), makeWrappers(), and walkInstrument().
|
private |
Definition at line 339 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 184 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 352 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(), Mantid::Geometry::IComponent::getSideBySideViewPos(), m_assemblySortedDetectorIndices, m_detectorIdToIndexMap, m_instrument, m_monitorIndices, m_pmap, markAsSourceOrSample(), Mantid::Geometry::IObjComponent::shape(), Mantid::Kernel::toQuaterniond(), Mantid::Kernel::toVector2d(), and Mantid::Kernel::toVector3d().
|
overridevirtual |
InstrumentVisitor::registerGenericComponent.
| component | : IComponent being visited |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 221 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 273 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 297 of file InstrumentVisitor.cpp.
References index, m_orderedDetectorIds, and registerComponentAssembly().
|
overridevirtual |
InstrumentVisitor::registerInfiniteComponent.
| component | : IComponent being visited |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 247 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 310 of file InstrumentVisitor.cpp.
References index, registerInfiniteComponent(), and Mantid::Geometry::IObjComponent::shape().
|
overridevirtual |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 329 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 284 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 321 of file InstrumentVisitor.cpp.
References index, m_orderedDetectorIds, and registerComponentAssembly().
| size_t Mantid::Geometry::InstrumentVisitor::size | ( | ) | const |
Definition at line 409 of file InstrumentVisitor.cpp.
References m_componentIds.
Referenced by isEmpty().
| void Mantid::Geometry::InstrumentVisitor::walkInstrument | ( | ) |
Definition at line 155 of file InstrumentVisitor.cpp.
References Mantid::Geometry::ParameterMap::empty(), m_instrument, m_pmap, and Mantid::Geometry::IComponent::registerContents().
Referenced by Mantid::Geometry::ParameterMap::buildInstrumentMetadata(), and makeWrappers().
|
private |
Component indexes sorted by assembly.
Definition at line 63 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Detector indexes sorted by assembly.
Definition at line 60 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 69 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Detectors components always specified first.
Definition at line 57 of file InstrumentVisitor.h.
Referenced by commonRegistration(), componentIds(), makeParameterInfo(), and size().
|
private |
Component ID -> Component Index map.
Definition at line 78 of file InstrumentVisitor.h.
Referenced by componentIdToIndexMap(), InstrumentVisitor(), and makeParameterInfo().
|
private |
Component ranges.
Definition at line 75 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Structured bank flag.
Definition at line 126 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Detector ID -> index mappings.
Definition at line 81 of file InstrumentVisitor.h.
Referenced by detectorIdToIndexMap(), and registerDetector().
|
private |
Positions for detectors.
Definition at line 87 of file InstrumentVisitor.h.
Referenced by detectorInfo().
|
private |
Only Assemblies and other NON-detectors yield detector ranges.
Definition at line 72 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Rotations for detectors.
Definition at line 93 of file InstrumentVisitor.h.
Referenced by detectorInfo().
|
private |
Instrument to build around.
Definition at line 99 of file InstrumentVisitor.h.
Referenced by InstrumentVisitor(), makeWrappers(), registerDetector(), and walkInstrument().
|
private |
Monitor indexes for detectors.
Definition at line 96 of file InstrumentVisitor.h.
Referenced by detectorInfo(), and registerDetector().
|
private |
Component names.
Definition at line 129 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and componentInfo().
|
private |
Null shared (empty shape)
Definition at line 117 of file InstrumentVisitor.h.
Referenced by commonRegistration().
|
private |
Detector indices.
Definition at line 54 of file InstrumentVisitor.h.
Referenced by detectorIds(), InstrumentVisitor(), registerGridBank(), registerObjComponentAssembly(), registerRectangularBank(), and registerStructuredBank().
|
private |
Index of the parent component.
Definition at line 66 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Rectangular/Grid bank pixel-grid metadata.
Definition at line 135 of file InstrumentVisitor.h.
Referenced by componentInfo().
|
private |
Parameter map to purge.
Definition at line 102 of file InstrumentVisitor.h.
Referenced by commonRegistration(), InstrumentVisitor(), makeParameterInfo(), registerDetector(), and walkInstrument().
|
private |
Positions for non-detectors.
Definition at line 84 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and componentInfo().
|
private |
Rotations for non-detectors.
Definition at line 90 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and componentInfo().
|
private |
Sample id to look for.
Definition at line 108 of file InstrumentVisitor.h.
Referenced by InstrumentVisitor(), and markAsSourceOrSample().
|
private |
Sample index to set.
Definition at line 114 of file InstrumentVisitor.h.
Referenced by componentInfo(), and markAsSourceOrSample().
|
private |
Scale factors.
Definition at line 123 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and componentInfo().
|
private |
Shapes stored in fly-weight fashion.
Definition at line 120 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and makeWrappers().
|
private |
Side-by-side (unwrapped) instrument-view positions when declared in the IDF.
Definition at line 132 of file InstrumentVisitor.h.
Referenced by componentInfo().
|
private |
Source id to look for.
Definition at line 105 of file InstrumentVisitor.h.
Referenced by InstrumentVisitor(), and markAsSourceOrSample().
|
private |
Source index to set.
Definition at line 111 of file InstrumentVisitor.h.
Referenced by componentInfo(), and markAsSourceOrSample().
|
private |
Pixel counts, ID numbering and pixel vertices of Structured banks, keyed by component index.
Definition at line 138 of file InstrumentVisitor.h.
Referenced by componentInfo().