Mantid
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::Geometry::InstrumentVisitor Class Reference

InstrumentVisitor : Visitor for components with access to Info wrapping features. More...

#include <InstrumentVisitor.h>

Inheritance diagram for Mantid::Geometry::InstrumentVisitor:
Mantid::Geometry::ComponentVisitor

Public Member Functions

std::shared_ptr< const std::vector< Mantid::Geometry::IComponent * > > componentIds () const
 InstrumentVisitor::componentIds. More...
 
std::shared_ptr< const std::unordered_map< Mantid::Geometry::IComponent *, 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. More...
 
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. More...
 
virtual size_t registerGenericComponent (const Mantid::Geometry::IComponent &component) override
 InstrumentVisitor::registerGenericComponent. More...
 
virtual size_t registerGenericObjComponent (const Mantid::Geometry::IObjComponent &objComponent) override
 InstrumentVisitor::registerGenericObjComponent. More...
 
virtual size_t registerGridBank (const Mantid::Geometry::ICompAssembly &bank) override
 Register a grid bank. More...
 
virtual size_t registerInfiniteComponent (const Mantid::Geometry::IComponent &component) override
 InstrumentVisitor::registerInfiniteComponent. More...
 
virtual size_t registerInfiniteObjComponent (const IObjComponent &objComponent) override
 InstrumentVisitor::registerInfiniteObjComponent. More...
 
virtual size_t registerObjComponentAssembly (const ObjCompAssembly &obj) override
 
virtual size_t registerRectangularBank (const Mantid::Geometry::ICompAssembly &bank) override
 Register a rectangular bank. More...
 
virtual size_t registerStructuredBank (const Mantid::Geometry::ICompAssembly &bank) override
 Register a structured bank. More...
 
size_t size () const
 InstrumentVisitor::size. More...
 
void walkInstrument ()
 
- Public Member Functions inherited from Mantid::Geometry::ComponentVisitor
virtual size_t registerComponentAssembly (const ICompAssembly &assembly)=0
 
virtual size_t registerDetector (const IDetector &detector)=0
 
virtual size_t registerGenericComponent (const IComponent &component)=0
 
virtual size_t registerGenericObjComponent (const IObjComponent &objComponent)=0
 
virtual size_t registerGridBank (const ICompAssembly &bank)=0
 
virtual size_t registerInfiniteComponent (const Mantid::Geometry::IComponent &component)=0
 
virtual size_t registerInfiniteObjComponent (const IObjComponent &component)=0
 
virtual size_t registerObjComponentAssembly (const ObjCompAssembly &obj)=0
 
virtual size_t registerRectangularBank (const ICompAssembly &bank)=0
 
virtual size_t registerStructuredBank (const ICompAssembly &bank)=0
 
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. 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::Instrumentm_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::IObjectm_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::ParameterMapm_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::IComponentm_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::IComponentm_sourceId
 Source id to look for. More...
 
int64_t m_sourceIndex = -1
 Source index to set. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ InstrumentVisitor()

Mantid::Geometry::InstrumentVisitor::InstrumentVisitor ( std::shared_ptr< const Instrument instrument)

Constructor.

Parameters
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.

Member Function Documentation

◆ commonRegistration()

size_t Mantid::Geometry::InstrumentVisitor::commonRegistration ( const Mantid::Geometry::IComponent component)
private

◆ componentIds()

std::shared_ptr< const std::vector< Mantid::Geometry::ComponentID > > Mantid::Geometry::InstrumentVisitor::componentIds ( ) const

InstrumentVisitor::componentIds.

Returns
component ids in the order in which they have been visited. Note that the number of component ids will be >= the number of detector indices since all detectors are components but not all components are detectors

Definition at line 347 of file InstrumentVisitor.cpp.

References m_componentIds.

Referenced by makeWrappers().

◆ componentIdToIndexMap()

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().

◆ componentInfo()

std::unique_ptr< Beamline::ComponentInfo > Mantid::Geometry::InstrumentVisitor::componentInfo ( ) const

◆ detectorIds()

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().

◆ detectorIdToIndexMap()

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().

◆ detectorInfo()

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().

◆ isEmpty()

bool Mantid::Geometry::InstrumentVisitor::isEmpty ( ) const

Definition at line 358 of file InstrumentVisitor.cpp.

References size().

◆ makeWrappers() [1/2]

std::pair< std::unique_ptr< ComponentInfo >, std::unique_ptr< DetectorInfo > > Mantid::Geometry::InstrumentVisitor::makeWrappers ( ) const
private

◆ makeWrappers() [2/2]

std::pair< std::unique_ptr< ComponentInfo >, std::unique_ptr< DetectorInfo > > Mantid::Geometry::InstrumentVisitor::makeWrappers ( const Instrument instrument,
ParameterMap pmap = nullptr 
)
static

◆ markAsSourceOrSample()

void Mantid::Geometry::InstrumentVisitor::markAsSourceOrSample ( Mantid::Geometry::IComponent componentId,
const size_t  componentIndex 
)
private

Definition at line 289 of file InstrumentVisitor.cpp.

References m_sampleId, m_sampleIndex, m_sourceId, and m_sourceIndex.

Referenced by commonRegistration(), and registerDetector().

◆ registerComponentAssembly()

size_t Mantid::Geometry::InstrumentVisitor::registerComponentAssembly ( const Mantid::Geometry::ICompAssembly assembly)
overridevirtual

◆ registerDetector()

size_t Mantid::Geometry::InstrumentVisitor::registerDetector ( const Mantid::Geometry::IDetector detector)
overridevirtual

◆ registerGenericComponent()

size_t Mantid::Geometry::InstrumentVisitor::registerGenericComponent ( const Mantid::Geometry::IComponent component)
overridevirtual

◆ registerGenericObjComponent()

size_t Mantid::Geometry::InstrumentVisitor::registerGenericObjComponent ( const Mantid::Geometry::IObjComponent objComponent)
overridevirtual

InstrumentVisitor::registerGenericObjComponent.

Parameters
objComponent: IObjComponent being visited
Returns
Component index of this component

Implements Mantid::Geometry::ComponentVisitor.

Definition at line 226 of file InstrumentVisitor.cpp.

References index, registerGenericComponent(), and Mantid::Geometry::IObjComponent::shape().

◆ registerGridBank()

size_t Mantid::Geometry::InstrumentVisitor::registerGridBank ( const Mantid::Geometry::ICompAssembly bank)
overridevirtual

Register a grid bank.

Parameters
bank: Grid Detector
Returns
index assigned

Implements Mantid::Geometry::ComponentVisitor.

Definition at line 249 of file InstrumentVisitor.cpp.

References index, m_orderedDetectorIds, and registerComponentAssembly().

◆ registerInfiniteComponent()

size_t Mantid::Geometry::InstrumentVisitor::registerInfiniteComponent ( const Mantid::Geometry::IComponent component)
overridevirtual

◆ registerInfiniteObjComponent()

size_t Mantid::Geometry::InstrumentVisitor::registerInfiniteObjComponent ( const IObjComponent objComponent)
overridevirtual

InstrumentVisitor::registerInfiniteObjComponent.

Parameters
objComponent: IObjComponent being visited
Returns
Component index of this component

Implements Mantid::Geometry::ComponentVisitor.

Definition at line 261 of file InstrumentVisitor.cpp.

References index, registerInfiniteComponent(), and Mantid::Geometry::IObjComponent::shape().

◆ registerObjComponentAssembly()

size_t Mantid::Geometry::InstrumentVisitor::registerObjComponentAssembly ( const ObjCompAssembly obj)
overridevirtual

◆ registerRectangularBank()

size_t Mantid::Geometry::InstrumentVisitor::registerRectangularBank ( const Mantid::Geometry::ICompAssembly bank)
overridevirtual

Register a rectangular bank.

Parameters
bank: Rectangular Detector
Returns
index assigned

Implements Mantid::Geometry::ComponentVisitor.

Definition at line 237 of file InstrumentVisitor.cpp.

References index, m_orderedDetectorIds, and registerComponentAssembly().

◆ registerStructuredBank()

size_t Mantid::Geometry::InstrumentVisitor::registerStructuredBank ( const Mantid::Geometry::ICompAssembly bank)
overridevirtual

Register a structured bank.

Parameters
bank: Structured Detector
Returns
index assigned

Implements Mantid::Geometry::ComponentVisitor.

Definition at line 272 of file InstrumentVisitor.cpp.

References index, m_orderedDetectorIds, and registerComponentAssembly().

◆ size()

size_t Mantid::Geometry::InstrumentVisitor::size ( ) const

InstrumentVisitor::size.

Returns
The total size of the components visited. This will be the same as the number of IDs.

Definition at line 356 of file InstrumentVisitor.cpp.

References m_componentIds.

Referenced by isEmpty().

◆ walkInstrument()

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().

Member Data Documentation

◆ m_assemblySortedComponentIndices

std::shared_ptr<std::vector<size_t> > Mantid::Geometry::InstrumentVisitor::m_assemblySortedComponentIndices
private

Component indexes sorted by assembly.

Definition at line 59 of file InstrumentVisitor.h.

Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().

◆ m_assemblySortedDetectorIndices

std::shared_ptr<std::vector<size_t> > Mantid::Geometry::InstrumentVisitor::m_assemblySortedDetectorIndices
private

Detector indexes sorted by assembly.

Definition at line 56 of file InstrumentVisitor.h.

Referenced by componentInfo(), InstrumentVisitor(), registerComponentAssembly(), and registerDetector().

◆ m_children

std::shared_ptr<std::vector<std::vector<size_t> > > Mantid::Geometry::InstrumentVisitor::m_children
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().

◆ m_componentIds

std::shared_ptr<std::vector<Mantid::Geometry::IComponent *> > Mantid::Geometry::InstrumentVisitor::m_componentIds
private

Detectors components always specified first.

Definition at line 53 of file InstrumentVisitor.h.

Referenced by commonRegistration(), componentIds(), and size().

◆ m_componentIdToIndexMap

std::shared_ptr<std::unordered_map<Mantid::Geometry::IComponent *, size_t> > Mantid::Geometry::InstrumentVisitor::m_componentIdToIndexMap
private

Component ID -> Component Index map.

Definition at line 74 of file InstrumentVisitor.h.

Referenced by componentIdToIndexMap(), and InstrumentVisitor().

◆ m_componentRanges

std::shared_ptr<std::vector<std::pair<size_t, size_t> > > Mantid::Geometry::InstrumentVisitor::m_componentRanges
private

◆ m_componentType

std::shared_ptr<std::vector<Beamline::ComponentType> > Mantid::Geometry::InstrumentVisitor::m_componentType
private

Structured bank flag.

Definition at line 122 of file InstrumentVisitor.h.

Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().

◆ m_detectorIdToIndexMap

std::shared_ptr<const std::unordered_map<detid_t, size_t> > Mantid::Geometry::InstrumentVisitor::m_detectorIdToIndexMap
private

Detector ID -> index mappings.

Definition at line 77 of file InstrumentVisitor.h.

Referenced by detectorIdToIndexMap(), and registerDetector().

◆ m_detectorPositions

std::shared_ptr<std::vector<Eigen::Vector3d> > Mantid::Geometry::InstrumentVisitor::m_detectorPositions
private

Positions for detectors.

Definition at line 83 of file InstrumentVisitor.h.

Referenced by detectorInfo().

◆ m_detectorRanges

std::shared_ptr<std::vector<std::pair<size_t, size_t> > > Mantid::Geometry::InstrumentVisitor::m_detectorRanges
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().

◆ m_detectorRotations

std::shared_ptr<std::vector<Eigen::Quaterniond, Eigen::aligned_allocator<Eigen::Quaterniond> > > Mantid::Geometry::InstrumentVisitor::m_detectorRotations
private

Rotations for detectors.

Definition at line 89 of file InstrumentVisitor.h.

Referenced by detectorInfo().

◆ m_instrument

std::shared_ptr<const Mantid::Geometry::Instrument> Mantid::Geometry::InstrumentVisitor::m_instrument
private

Instrument to build around.

Definition at line 95 of file InstrumentVisitor.h.

Referenced by InstrumentVisitor(), makeWrappers(), registerDetector(), and walkInstrument().

◆ m_monitorIndices

std::shared_ptr<std::vector<size_t> > Mantid::Geometry::InstrumentVisitor::m_monitorIndices
private

Monitor indexes for detectors.

Definition at line 92 of file InstrumentVisitor.h.

Referenced by detectorInfo(), and registerDetector().

◆ m_names

std::shared_ptr<std::vector<std::string> > Mantid::Geometry::InstrumentVisitor::m_names
private

Component names.

Definition at line 125 of file InstrumentVisitor.h.

Referenced by commonRegistration(), and componentInfo().

◆ m_nullShape

std::shared_ptr<const Mantid::Geometry::IObject> Mantid::Geometry::InstrumentVisitor::m_nullShape
private

Null shared (empty shape)

Definition at line 113 of file InstrumentVisitor.h.

Referenced by commonRegistration().

◆ m_orderedDetectorIds

std::shared_ptr<std::vector<detid_t> > Mantid::Geometry::InstrumentVisitor::m_orderedDetectorIds
private

◆ m_parentComponentIndices

std::shared_ptr<std::vector<size_t> > Mantid::Geometry::InstrumentVisitor::m_parentComponentIndices
private

Index of the parent component.

Definition at line 62 of file InstrumentVisitor.h.

Referenced by componentInfo(), registerComponentAssembly(), registerGenericComponent(), and registerInfiniteComponent().

◆ m_pmap

Mantid::Geometry::ParameterMap* Mantid::Geometry::InstrumentVisitor::m_pmap
private

Parameter map to purge.

Definition at line 98 of file InstrumentVisitor.h.

Referenced by commonRegistration(), InstrumentVisitor(), registerDetector(), and walkInstrument().

◆ m_positions

std::shared_ptr<std::vector<Eigen::Vector3d> > Mantid::Geometry::InstrumentVisitor::m_positions
private

Positions for non-detectors.

Definition at line 80 of file InstrumentVisitor.h.

Referenced by commonRegistration(), and componentInfo().

◆ m_rotations

std::shared_ptr<std::vector<Eigen::Quaterniond, Eigen::aligned_allocator<Eigen::Quaterniond> > > Mantid::Geometry::InstrumentVisitor::m_rotations
private

Rotations for non-detectors.

Definition at line 86 of file InstrumentVisitor.h.

Referenced by commonRegistration(), and componentInfo().

◆ m_sampleId

Mantid::Geometry::IComponent* Mantid::Geometry::InstrumentVisitor::m_sampleId
private

Sample id to look for.

Definition at line 104 of file InstrumentVisitor.h.

Referenced by InstrumentVisitor(), and markAsSourceOrSample().

◆ m_sampleIndex

int64_t Mantid::Geometry::InstrumentVisitor::m_sampleIndex = -1
private

Sample index to set.

Definition at line 110 of file InstrumentVisitor.h.

Referenced by componentInfo(), and markAsSourceOrSample().

◆ m_scaleFactors

std::shared_ptr<std::vector<Eigen::Vector3d> > Mantid::Geometry::InstrumentVisitor::m_scaleFactors
private

Scale factors.

Definition at line 119 of file InstrumentVisitor.h.

Referenced by commonRegistration(), and componentInfo().

◆ m_shapes

std::shared_ptr<std::vector<std::shared_ptr<const Mantid::Geometry::IObject> > > Mantid::Geometry::InstrumentVisitor::m_shapes
private

Shapes stored in fly-weight fashion.

Definition at line 116 of file InstrumentVisitor.h.

Referenced by commonRegistration(), and makeWrappers().

◆ m_sourceId

Mantid::Geometry::IComponent* Mantid::Geometry::InstrumentVisitor::m_sourceId
private

Source id to look for.

Definition at line 101 of file InstrumentVisitor.h.

Referenced by InstrumentVisitor(), and markAsSourceOrSample().

◆ m_sourceIndex

int64_t Mantid::Geometry::InstrumentVisitor::m_sourceIndex = -1
private

Source index to set.

Definition at line 107 of file InstrumentVisitor.h.

Referenced by componentInfo(), and markAsSourceOrSample().


The documentation for this class was generated from the following files: