Mantid
Loading...
Searching...
No Matches
ComponentInfo.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2017 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 "MantidBeamline/ComponentType.h"
10#include "MantidGeometry/DllConfig.h"
14#include "MantidTypes/Core/DateAndTime.h"
15#include <memory>
16#include <unordered_map>
17#include <vector>
18
19namespace Mantid {
20
21namespace Kernel {
22class Quat;
23class V3D;
24} // namespace Kernel
25
26namespace Geometry {
27class IComponent;
28class IObject;
29} // namespace Geometry
30
31namespace Beamline {
32class ComponentInfo;
33}
34
35namespace Geometry {
36class Instrument;
37
41class MANTID_GEOMETRY_DLL ComponentInfo {
42private:
44 std::unique_ptr<Beamline::ComponentInfo> m_componentInfo;
46 std::shared_ptr<const std::vector<Geometry::IComponent *>> m_componentIds;
48 std::shared_ptr<const std::unordered_map<Geometry::IComponent const *, size_t>> m_compIDToIndex;
49
51 std::shared_ptr<std::vector<std::shared_ptr<const Geometry::IObject>>> m_shapes;
52
53 BoundingBox componentBoundingBox(const size_t index, const BoundingBox *reference,
54 const bool excludeMonitors = false) const;
55
57 ComponentInfo(const ComponentInfo &other);
58 void growBoundingBoxAsRectuangularBank(size_t index, const Geometry::BoundingBox *reference,
59 Geometry::BoundingBox &mutableBB, const bool excludeMonitors = false) const;
60 void growBoundingBoxAsOutline(size_t index, const Geometry::BoundingBox *reference, Geometry::BoundingBox &mutableBB,
61 const bool excludeMonitors = false) const;
62
63public:
65 size_t topLeft;
66 size_t bottomLeft;
68 size_t topRight;
69 size_t nX;
70 size_t nY;
71 };
72
73 ComponentInfo(std::unique_ptr<Beamline::ComponentInfo> componentInfo,
74 std::shared_ptr<const std::vector<Mantid::Geometry::IComponent *>> componentIds,
75 std::shared_ptr<const std::unordered_map<Geometry::IComponent const *, size_t>> componentIdToIndexMap,
76 std::shared_ptr<std::vector<std::shared_ptr<const Geometry::IObject>>> shapes);
80 std::unique_ptr<ComponentInfo> cloneWithoutDetectorInfo() const;
81 std::vector<size_t> detectorsInSubtree(size_t componentIndex) const;
82 std::vector<size_t> componentsInSubtree(size_t componentIndex) const;
83 const std::vector<size_t> &children(size_t componentIndex) const;
84 size_t size() const;
85 QuadrilateralComponent quadrilateralComponent(const size_t componentIndex) const;
86 size_t indexOf(Geometry::IComponent const *id) const;
87 size_t indexOfAny(const std::string &name) const;
88 bool uniqueName(const std::string &name) const;
89 bool isDetector(const size_t componentIndex) const;
90 Kernel::V3D position(const size_t componentIndex) const;
91 Kernel::V3D position(const std::pair<size_t, size_t> &index) const;
92 Kernel::Quat rotation(const size_t componentIndex) const;
93 Kernel::Quat rotation(const std::pair<size_t, size_t> &index) const;
94 Kernel::V3D relativePosition(const size_t componentIndex) const;
95 Kernel::Quat relativeRotation(const size_t componentIndex) const;
96 void setPosition(size_t componentIndex, const Kernel::V3D &newPosition);
97 void setRotation(size_t componentIndex, const Kernel::Quat &newRotation);
98 void setPosition(const std::pair<size_t, size_t> &index, const Kernel::V3D &newPosition);
99 void setRotation(const std::pair<size_t, size_t> &index, const Kernel::Quat &newRotation);
100 void scaleComponent(const size_t componentIndex, const Kernel::V3D &newScaling);
101 void scaleComponent(const std::pair<size_t, size_t> &index, const Kernel::V3D &newScaling);
102 size_t parent(const size_t componentIndex) const;
103 bool hasParent(const size_t componentIndex) const;
104 bool hasDetectorInfo() const;
105 Kernel::V3D sourcePosition() const;
106 Kernel::V3D samplePosition() const;
107 bool hasSource() const;
108 bool hasEquivalentSource(const ComponentInfo &other) const;
109 bool hasSample() const;
110 bool hasEquivalentSample(const ComponentInfo &other) const;
111 bool hasDetectors(const size_t componentIndex) const;
112 size_t source() const;
113 size_t sample() const;
114 double l1() const;
115 Kernel::V3D scaleFactor(const size_t componentIndex) const;
116 const std::string &name(const size_t componentIndex) const;
117 void setScaleFactor(const size_t componentIndex, const Kernel::V3D &scaleFactor);
118 size_t root() const;
119
120 const IComponent *componentID(const size_t componentIndex) const {
121 return m_componentIds->operator[](componentIndex);
122 }
123 bool hasValidShape(const size_t componentIndex) const;
124
125 const Geometry::IObject &shape(const size_t componentIndex) const;
126
127 double solidAngle(const size_t componentIndex, const Geometry::SolidAngleParams &params) const;
128 BoundingBox boundingBox(const size_t componentIndex, const BoundingBox *reference = nullptr,
129 const bool excludeMonitors = false) const;
130 Beamline::ComponentType componentType(const size_t componentIndex) const;
131 void setScanInterval(const std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime> &interval);
132 size_t scanCount() const;
133 void merge(const ComponentInfo &other);
134
139
140 friend class Instrument;
141};
142
145
146} // namespace Geometry
147} // namespace Mantid
std::string name
Definition Run.cpp:60
double position
Definition GetAllEi.cpp:154
std::map< DeltaEMode::Type, std::string > index
Mantid::Kernel::Quat(ComponentInfo::* rotation)(const size_t) const
void(ComponentInfo::* setPosition)(const size_t, const Mantid::Kernel::V3D &)
void(ComponentInfo::* setRotation)(const size_t, const Mantid::Kernel::Quat &)
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
Definition BoundingBox.h:33
ComponentInfoIterator for random access iteration over ComponentInfo.
ComponentInfo : Provides a component centric view on to the instrument.
ComponentInfo & operator=(const ComponentInfo &)=delete
Copy assignment is not possible for ComponentInfo.
std::shared_ptr< std::vector< std::shared_ptr< const Geometry::IObject > > > m_shapes
Shapes for each component.
std::shared_ptr< const std::unordered_map< Geometry::IComponent const *, size_t > > m_compIDToIndex
Map of component ids to indexes.
const IComponent * componentID(const size_t componentIndex) const
std::unique_ptr< Beamline::ComponentInfo > m_componentInfo
Pointer to the actual ComponentInfo object (non-wrapping part).
std::shared_ptr< const std::vector< Geometry::IComponent * > > m_componentIds
Collection of component ids.
base class for Geometric IComponent
Definition IComponent.h:53
IObject : Interface for geometry objects.
Definition IObject.h:42
Base Instrument Class.
Definition Instrument.h:47
Class for quaternions.
Definition Quat.h:39
Class for 3D vectors.
Definition V3D.h:34
ComponentInfoIterator< const ComponentInfo > ComponentInfoConstIt
ComponentInfoIterator< ComponentInfo > ComponentInfoIt
Helper class which provides the Collimation Length for SANS instruments.