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 <memory>
15#include <unordered_map>
16#include <vector>
17
18namespace Mantid {
19
20namespace Kernel {
21class Quat;
22class V3D;
23} // namespace Kernel
24
25namespace Geometry {
26class IComponent;
27class IObject;
28} // namespace Geometry
29
30namespace Beamline {
31class ComponentInfo;
32}
33
34namespace Geometry {
35class Instrument;
36
40class MANTID_GEOMETRY_DLL ComponentInfo {
41private:
43 std::unique_ptr<Beamline::ComponentInfo> m_componentInfo;
45 std::shared_ptr<const std::vector<Geometry::IComponent *>> m_componentIds;
47 std::shared_ptr<const std::unordered_map<Geometry::IComponent *, size_t>> m_compIDToIndex;
48
50 std::shared_ptr<std::vector<std::shared_ptr<const Geometry::IObject>>> m_shapes;
51
52 BoundingBox componentBoundingBox(const size_t index, const BoundingBox *reference,
53 const bool excludeMonitors = false) const;
54
56 ComponentInfo(const ComponentInfo &other);
57 void growBoundingBoxAsRectuangularBank(size_t index, const Geometry::BoundingBox *reference,
58 Geometry::BoundingBox &mutableBB, const bool excludeMonitors = false) const;
59 void growBoundingBoxAsOutline(size_t index, const Geometry::BoundingBox *reference, Geometry::BoundingBox &mutableBB,
60 const bool excludeMonitors = false) const;
61
62public:
64 size_t topLeft;
65 size_t bottomLeft;
67 size_t topRight;
68 size_t nX;
69 size_t nY;
70 };
71
72 ComponentInfo(std::unique_ptr<Beamline::ComponentInfo> componentInfo,
73 std::shared_ptr<const std::vector<Mantid::Geometry::IComponent *>> componentIds,
74 std::shared_ptr<const std::unordered_map<Geometry::IComponent *, size_t>> componentIdToIndexMap,
75 std::shared_ptr<std::vector<std::shared_ptr<const Geometry::IObject>>> shapes);
79 std::unique_ptr<ComponentInfo> cloneWithoutDetectorInfo() const;
80 std::vector<size_t> detectorsInSubtree(size_t componentIndex) const;
81 std::vector<size_t> componentsInSubtree(size_t componentIndex) const;
82 const std::vector<size_t> &children(size_t componentIndex) const;
83 size_t size() const;
84 QuadrilateralComponent quadrilateralComponent(const size_t componentIndex) const;
85 size_t indexOf(Geometry::IComponent *id) const;
86 size_t indexOfAny(const std::string &name) const;
87 bool uniqueName(const std::string &name) const;
88 bool isDetector(const size_t componentIndex) const;
89 Kernel::V3D position(const size_t componentIndex) const;
90 Kernel::V3D position(const std::pair<size_t, size_t> &index) const;
91 Kernel::Quat rotation(const size_t componentIndex) const;
92 Kernel::Quat rotation(const std::pair<size_t, size_t> &index) const;
93 Kernel::V3D relativePosition(const size_t componentIndex) const;
94 Kernel::Quat relativeRotation(const size_t componentIndex) const;
95 void setPosition(size_t componentIndex, const Kernel::V3D &newPosition);
96 void setRotation(size_t componentIndex, const Kernel::Quat &newRotation);
97 void setPosition(const std::pair<size_t, size_t> &index, const Kernel::V3D &newPosition);
98 void setRotation(const std::pair<size_t, size_t> &index, const Kernel::Quat &newRotation);
99 size_t parent(const size_t componentIndex) const;
100 bool hasParent(const size_t componentIndex) const;
101 bool hasDetectorInfo() const;
102 Kernel::V3D sourcePosition() const;
103 Kernel::V3D samplePosition() const;
104 bool hasSource() const;
105 bool hasEquivalentSource(const ComponentInfo &other) const;
106 bool hasSample() const;
107 bool hasEquivalentSample(const ComponentInfo &other) const;
108 bool hasDetectors(const size_t componentIndex) const;
109 size_t source() const;
110 size_t sample() const;
111 double l1() const;
112 Kernel::V3D scaleFactor(const size_t componentIndex) const;
113 const std::string &name(const size_t componentIndex) const;
114 void setScaleFactor(const size_t componentIndex, const Kernel::V3D &scaleFactor);
115 size_t root() const;
116
117 const IComponent *componentID(const size_t componentIndex) const {
118 return m_componentIds->operator[](componentIndex);
119 }
120 bool hasValidShape(const size_t componentIndex) const;
121
122 const Geometry::IObject &shape(const size_t componentIndex) const;
123
124 double solidAngle(const size_t componentIndex, const Kernel::V3D &observer) const;
125 BoundingBox boundingBox(const size_t componentIndex, const BoundingBox *reference = nullptr,
126 const bool excludeMonitors = false) const;
127 Beamline::ComponentType componentType(const size_t componentIndex) const;
128 void setScanInterval(const std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime> &interval);
129 size_t scanCount() const;
130 void merge(const ComponentInfo &other);
131
136
137 friend class Instrument;
138};
139
142
143} // namespace Geometry
144} // namespace Mantid
double position
Definition: GetAllEi.cpp:154
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
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:34
ComponentInfoIterator for random access iteration over ComponentInfo.
ComponentInfo : Provides a component centric view on to the instrument.
Definition: ComponentInfo.h:40
ComponentInfo & operator=(const ComponentInfo &)=delete
Copy assignment is not possible for ComponentInfo.
std::shared_ptr< const std::unordered_map< Geometry::IComponent *, size_t > > m_compIDToIndex
Map of component ids to indexes.
Definition: ComponentInfo.h:47
std::shared_ptr< std::vector< std::shared_ptr< const Geometry::IObject > > > m_shapes
Shapes for each component.
Definition: ComponentInfo.h:50
const IComponent * componentID(const size_t componentIndex) const
std::unique_ptr< Beamline::ComponentInfo > m_componentInfo
Pointer to the actual ComponentInfo object (non-wrapping part).
Definition: ComponentInfo.h:43
std::shared_ptr< const std::vector< Geometry::IComponent * > > m_componentIds
Collection of component ids.
Definition: ComponentInfo.h:45
base class for Geometric IComponent
Definition: IComponent.h:51
IObject : Interface for geometry objects.
Definition: IObject.h:41
Base Instrument Class.
Definition: Instrument.h:47
Class for quaternions.
Definition: Quat.h:39
Class for 3D vectors.
Definition: V3D.h:34
Helper class which provides the Collimation Length for SANS instruments.