Mantid
Loading...
Searching...
No Matches
Container.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2016 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 "MantidGeometry/DllConfig.h"
12#include "MantidKernel/V3D.h"
13#include <unordered_map>
14
15namespace Mantid {
16namespace Geometry {
17
24class MANTID_GEOMETRY_DLL Container final : public IObject {
25public:
26 using ShapeArgs = std::unordered_map<std::string, double>;
27
28 Container();
30 Container(const Container &container);
31 Container &operator=(const Container &container);
32 Container(const std::string &xml);
33
34 bool hasCustomizableSampleShape() const;
35 bool hasFixedSampleShape() const;
36 IObject_sptr createSampleShape(const ShapeArgs &args) const;
37 IObject_sptr getSampleShape() const;
38
39 void setSampleShape(const std::string &sampleShapeXML);
40 void setSampleShape(IObject_sptr sampleShape) { m_sampleShape = std::move(sampleShape); };
41
42 const IObject &getShape() const { return *m_shape; }
43 const IObject_sptr getShapePtr() const { return m_shape; }
44
45 bool isValid(const Kernel::V3D &p) const override { return m_shape->isValid(p); }
46 bool isOnSide(const Kernel::V3D &p) const override { return m_shape->isOnSide(p); }
47 bool hasValidShape() const override { return m_shape->hasValidShape(); }
48
49 IObject *clone() const override { return new Container(*this); }
50
51 IObject *cloneWithMaterial(const Kernel::Material &material) const override {
52 return m_shape->cloneWithMaterial(material);
53 }
54
55 int getName() const override { return m_shape->getName(); }
56
57 int interceptSurface(Geometry::Track &t) const override { return m_shape->interceptSurface(t); }
58 double distance(const Geometry::Track &t) const override { return m_shape->distance(t); }
59 double solidAngle(const Kernel::V3D &observer) const override { return m_shape->solidAngle(observer); }
60 double solidAngle(const Kernel::V3D &observer, const Kernel::V3D &scaleFactor) const override {
61 return m_shape->solidAngle(observer, scaleFactor);
62 }
63 double volume() const override { return m_shape->volume(); }
64 const BoundingBox &getBoundingBox() const override { return m_shape->getBoundingBox(); }
65 void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin,
66 double &zmin) const override {
67 m_shape->getBoundingBox(xmax, ymax, zmax, xmin, ymin, zmin);
68 }
69
70 int getPointInObject(Kernel::V3D &point) const override { return m_shape->getPointInObject(point); }
72 const size_t i) const override {
73 return m_shape->generatePointInObject(rng, i);
74 }
76 const BoundingBox &activeRegion, const size_t i) const override {
77 return m_shape->generatePointInObject(rng, activeRegion, i);
78 }
79
80 detail::ShapeInfo::GeometryShape shape() const override { return m_shape->shape(); }
81
82 const detail::ShapeInfo &shapeInfo() const override { return m_shape->shapeInfo(); }
83
84 void GetObjectGeom(detail::ShapeInfo::GeometryShape &type, std::vector<Kernel::V3D> &vectors, double &innerRadius,
85 double &radius, double &height) const override {
86 m_shape->GetObjectGeom(type, vectors, innerRadius, radius, height);
87 }
88 std::shared_ptr<GeometryHandler> getGeometryHandler() const override { return m_shape->getGeometryHandler(); }
89
90 void draw() const override { m_shape->draw(); }
91 void initDraw() const override { m_shape->initDraw(); }
92
93 const Kernel::Material &material() const override { return m_shape->material(); }
94 virtual void setMaterial(const Kernel::Material &material) override { m_shape->setMaterial(material); };
95 void setID(const std::string &id) override;
96 const std::string &id() const override { return m_shape->id(); }
97
98private:
100 std::string m_sampleShapeXML;
101 IObject_sptr m_sampleShape = nullptr;
102};
103
105using Container_sptr = std::shared_ptr<Container>;
107using Container_const_sptr = std::shared_ptr<const Container>;
108
109} // namespace Geometry
110} // namespace Mantid
double height
Definition: GetAllEi.cpp:155
double radius
Definition: Rasterize.cpp:31
double innerRadius
Definition: Rasterize.cpp:39
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
double distance(const Geometry::Track &t) const override
Definition: Container.h:58
void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) const override
Calculate (or return cached value of) Axis Aligned Bounding box (DEPRECATED)
Definition: Container.h:65
int getPointInObject(Kernel::V3D &point) const override
Definition: Container.h:70
const IObject_sptr getShapePtr() const
Definition: Container.h:43
const Kernel::Material & material() const override
Definition: Container.h:93
std::shared_ptr< GeometryHandler > getGeometryHandler() const override
Definition: Container.h:88
int interceptSurface(Geometry::Track &t) const override
Definition: Container.h:57
boost::optional< Kernel::V3D > generatePointInObject(Kernel::PseudoRandomNumberGenerator &rng, const BoundingBox &activeRegion, const size_t i) const override
Definition: Container.h:75
std::unordered_map< std::string, double > ShapeArgs
Definition: Container.h:26
double solidAngle(const Kernel::V3D &observer, const Kernel::V3D &scaleFactor) const override
Definition: Container.h:60
void setSampleShape(IObject_sptr sampleShape)
Definition: Container.h:40
IObject * clone() const override
Definition: Container.h:49
virtual void setMaterial(const Kernel::Material &material) override
Definition: Container.h:94
double solidAngle(const Kernel::V3D &observer) const override
Definition: Container.h:59
const BoundingBox & getBoundingBox() const override
Return cached value of axis-aligned bounding box.
Definition: Container.h:64
const std::string & id() const override
Definition: Container.h:96
std::string m_sampleShapeXML
Definition: Container.h:100
bool hasValidShape() const override
Definition: Container.h:47
IObject * cloneWithMaterial(const Kernel::Material &material) const override
Definition: Container.h:51
void initDraw() const override
Definition: Container.h:91
boost::optional< Kernel::V3D > generatePointInObject(Kernel::PseudoRandomNumberGenerator &rng, const size_t i) const override
Definition: Container.h:71
bool isOnSide(const Kernel::V3D &p) const override
Definition: Container.h:46
bool isValid(const Kernel::V3D &p) const override
Definition: Container.h:45
detail::ShapeInfo::GeometryShape shape() const override
Definition: Container.h:80
const IObject & getShape() const
Definition: Container.h:42
double volume() const override
Definition: Container.h:63
void GetObjectGeom(detail::ShapeInfo::GeometryShape &type, std::vector< Kernel::V3D > &vectors, double &innerRadius, double &radius, double &height) const override
Definition: Container.h:84
const detail::ShapeInfo & shapeInfo() const override
Definition: Container.h:82
void draw() const override
Definition: Container.h:90
int getName() const override
Definition: Container.h:55
IObject : Interface for geometry objects.
Definition: IObject.h:41
virtual IObject * cloneWithMaterial(const Kernel::Material &material) const =0
Defines a track as a start point and a direction.
Definition: Track.h:165
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
Definition: Material.h:50
Defines a 1D pseudo-random number generator, i.e.
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::shared_ptr< Container > Container_sptr
Typdef for a shared pointer.
Definition: Container.h:105
std::shared_ptr< IObject > IObject_sptr
Typdef for a shared pointer.
Definition: IObject.h:92
Helper class which provides the Collimation Length for SANS instruments.