Mantid
Loading...
Searching...
No Matches
SampleEnvironment.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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//------------------------------------------------------------------------------
10// Includes
11//------------------------------------------------------------------------------
12#include "MantidGeometry/DllConfig.h"
14
15namespace Mantid {
16namespace Kernel {
17class PseudoRandomNumberGenerator;
18}
19namespace Geometry {
20class Track;
21
26class MANTID_GEOMETRY_DLL SampleEnvironment {
27public:
28 SampleEnvironment(std::string name, const Container_const_sptr &getContainer);
29
31 inline const std::string name() const { return m_name; }
33 inline const std::string containerID() const { return getContainer().id(); }
35 inline const Container &getContainer() const {
36 if (m_components.empty())
37 throw std::runtime_error("Cannot get container from empty environment");
38 Container_const_sptr can = std::static_pointer_cast<const Container>(m_components.front());
39 return *can;
40 }
42 inline size_t nelements() const { return m_components.size(); }
43
49 const IObject &getComponent(const size_t index) const;
50 const IObject_const_sptr getComponentPtr(const size_t index) const;
51
52 Geometry::BoundingBox boundingBox() const;
53
54 bool isValid(const Kernel::V3D &point) const;
55 int interceptSurfaces(Track &track) const;
56
57 void add(const IObject_const_sptr &component);
58
59private:
60 std::string m_name;
61 // Element zero is always assumed to be the can
62 std::vector<IObject_const_sptr> m_components;
63};
64
65// Typedef a unique_ptr
66using SampleEnvironment_uptr = std::unique_ptr<SampleEnvironment>;
67// Typedef a unique_ptr to const
68using SampleEnvironment_const_uptr = std::unique_ptr<const SampleEnvironment>;
69} // namespace Geometry
70} // namespace Mantid
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
Definition: BoundingBox.h:34
Models a Container is used to hold a sample in the beam.
Definition: Container.h:24
IObject : Interface for geometry objects.
Definition: IObject.h:41
Defines a single instance of a SampleEnvironment.
std::vector< IObject_const_sptr > m_components
const Container & getContainer() const
const std::string name() const
const std::string containerID() const
Defines a track as a start point and a direction.
Definition: Track.h:165
Class for 3D vectors.
Definition: V3D.h:34
std::shared_ptr< const Container > Container_const_sptr
Typdef for a shared pointer to a const object.
Definition: Container.h:107
std::unique_ptr< const SampleEnvironment > SampleEnvironment_const_uptr
std::unique_ptr< SampleEnvironment > SampleEnvironment_uptr
std::shared_ptr< const IObject > IObject_const_sptr
Typdef for a shared pointer to a const object.
Definition: IObject.h:94
Helper class which provides the Collimation Length for SANS instruments.