|
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 |
| 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. | |
| 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. | |
| 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. | |
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 50 of file InstrumentVisitor.h.
| Mantid::Geometry::InstrumentVisitor::InstrumentVisitor | ( | std::shared_ptr< const Instrument > | instrument | ) |
Constructor.
| instrument | : Instrument being visited |
Definition at line 90 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 147 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 382 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 396 of file InstrumentVisitor.cpp.
References m_componentIdToIndexMap.
Referenced by makeWrappers().
| std::unique_ptr< Beamline::ComponentInfo > Mantid::Geometry::InstrumentVisitor::componentInfo | ( | ) | const |
Definition at line 404 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, and m_sourceIndex.
Referenced by makeWrappers().
| std::shared_ptr< std::vector< detid_t > > Mantid::Geometry::InstrumentVisitor::detectorIds | ( | ) | const |
Definition at line 416 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 400 of file InstrumentVisitor.cpp.
References m_detectorIdToIndexMap.
Referenced by makeWrappers().
| std::unique_ptr< Beamline::DetectorInfo > Mantid::Geometry::InstrumentVisitor::detectorInfo | ( | ) | const |
Definition at line 411 of file InstrumentVisitor.cpp.
References m_detectorPositions, m_detectorRotations, and m_monitorIndices.
Referenced by makeWrappers().
| bool Mantid::Geometry::InstrumentVisitor::isEmpty | ( | ) | const |
Definition at line 393 of file InstrumentVisitor.cpp.
References size().
|
private |
Rekey the ParameterMap's parameters from legacy component pointers to component indices.
Definition at line 419 of file InstrumentVisitor.cpp.
References m_componentIdToIndexMap, m_pmap, and Mantid::Geometry::ParameterMap::rekey().
Referenced by makeWrappers().
|
private |
Definition at line 424 of file InstrumentVisitor.cpp.
References componentIds(), componentIdToIndexMap(), componentInfo(), detectorIds(), detectorIdToIndexMap(), detectorInfo(), m_instrument, m_shapes, and makeParameterInfo().
Referenced by Mantid::Geometry::InstrumentRayTracer::ensureOwnedInfoIsBuilt(), Mantid::Geometry::Instrument::makeBeamline(), Mantid::Geometry::Instrument::makeBeamlineNew(), makeWrappers(), and Mantid::Geometry::Instrument::parseTreeAndCacheBeamline().
|
static |
Definition at line 439 of file InstrumentVisitor.cpp.
References Mantid::Geometry::ParComponentFactory::createInstrument(), makeWrappers(), and walkInstrument().
|
private |
Definition at line 321 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 167 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 334 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 204 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 256 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 280 of file InstrumentVisitor.cpp.
References index, m_orderedDetectorIds, and registerComponentAssembly().
|
overridevirtual |
InstrumentVisitor::registerInfiniteComponent.
| component | : IComponent being visited |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 230 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 293 of file InstrumentVisitor.cpp.
References index, registerInfiniteComponent(), and Mantid::Geometry::IObjComponent::shape().
|
overridevirtual |
Implements Mantid::Geometry::ComponentVisitor.
Definition at line 311 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 267 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 304 of file InstrumentVisitor.cpp.
References index, m_orderedDetectorIds, and registerComponentAssembly().
| size_t Mantid::Geometry::InstrumentVisitor::size | ( | ) | const |
Definition at line 391 of file InstrumentVisitor.cpp.
References m_componentIds.
Referenced by isEmpty().
| void Mantid::Geometry::InstrumentVisitor::walkInstrument | ( | ) |
Definition at line 138 of file InstrumentVisitor.cpp.
References Mantid::Geometry::ParameterMap::empty(), m_instrument, m_pmap, and Mantid::Geometry::IComponent::registerContents().
Referenced by makeWrappers().
|
private |
Component indexes sorted by assembly.
Definition at line 62 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Detector indexes sorted by assembly.
Definition at line 59 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 68 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Detectors components always specified first.
Definition at line 56 of file InstrumentVisitor.h.
Referenced by commonRegistration(), componentIds(), and size().
|
private |
Component ID -> Component Index map.
Definition at line 77 of file InstrumentVisitor.h.
Referenced by componentIdToIndexMap(), InstrumentVisitor(), and makeParameterInfo().
|
private |
Component ranges.
Definition at line 74 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Structured bank flag.
Definition at line 125 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Detector ID -> index mappings.
Definition at line 80 of file InstrumentVisitor.h.
Referenced by detectorIdToIndexMap(), and registerDetector().
|
private |
Positions for detectors.
Definition at line 86 of file InstrumentVisitor.h.
Referenced by detectorInfo().
|
private |
Only Assemblies and other NON-detectors yield detector ranges.
Definition at line 71 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Rotations for detectors.
Definition at line 92 of file InstrumentVisitor.h.
Referenced by detectorInfo().
|
private |
Instrument to build around.
Definition at line 98 of file InstrumentVisitor.h.
Referenced by InstrumentVisitor(), makeWrappers(), registerDetector(), and walkInstrument().
|
private |
Monitor indexes for detectors.
Definition at line 95 of file InstrumentVisitor.h.
Referenced by detectorInfo(), and registerDetector().
|
private |
Component names.
Definition at line 128 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and componentInfo().
|
private |
Null shared (empty shape)
Definition at line 116 of file InstrumentVisitor.h.
Referenced by commonRegistration().
|
private |
Detector indices.
Definition at line 53 of file InstrumentVisitor.h.
Referenced by detectorIds(), InstrumentVisitor(), registerGridBank(), registerObjComponentAssembly(), registerRectangularBank(), and registerStructuredBank().
|
private |
Index of the parent component.
Definition at line 65 of file InstrumentVisitor.h.
Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().
|
private |
Rectangular/Grid bank pixel-grid metadata.
Definition at line 134 of file InstrumentVisitor.h.
Referenced by componentInfo().
|
private |
Parameter map to purge.
Definition at line 101 of file InstrumentVisitor.h.
Referenced by commonRegistration(), InstrumentVisitor(), makeParameterInfo(), registerDetector(), and walkInstrument().
|
private |
Positions for non-detectors.
Definition at line 83 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and componentInfo().
|
private |
Rotations for non-detectors.
Definition at line 89 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and componentInfo().
|
private |
Sample id to look for.
Definition at line 107 of file InstrumentVisitor.h.
Referenced by InstrumentVisitor(), and markAsSourceOrSample().
|
private |
Sample index to set.
Definition at line 113 of file InstrumentVisitor.h.
Referenced by componentInfo(), and markAsSourceOrSample().
|
private |
Scale factors.
Definition at line 122 of file InstrumentVisitor.h.
Referenced by commonRegistration(), and componentInfo().
|
private |
Shapes stored in fly-weight fashion.
Definition at line 119 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 131 of file InstrumentVisitor.h.
Referenced by componentInfo().
|
private |
Source id to look for.
Definition at line 104 of file InstrumentVisitor.h.
Referenced by InstrumentVisitor(), and markAsSourceOrSample().
|
private |
Source index to set.
Definition at line 110 of file InstrumentVisitor.h.
Referenced by componentInfo(), and markAsSourceOrSample().