Container.h 4.47 KB
Newer Older
1
2
3
4
5
6
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2016 ISIS Rutherford Appleton Laboratory UKRI,
//     NScD Oak Ridge National Laboratory, European Spallation Source
//     & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
Martyn Gigg's avatar
Martyn Gigg committed
7
8
#ifndef MANTID_GEOMETRY_CONTAINER_H_
#define MANTID_GEOMETRY_CONTAINER_H_
9
10

#include "MantidGeometry/DllConfig.h"
11
12
13
#include "MantidGeometry/Objects/IObject.h"
#include "MantidKernel/Material.h"
#include "MantidKernel/V3D.h"
14
#include <unordered_map>
15
16
17
18
19

namespace Mantid {
namespace Geometry {

/**
Martyn Gigg's avatar
Martyn Gigg committed
20
  Models a Container is used to hold a sample in the beam. It gets most
21
  of its functionality from wrapped Geometry::IObject but can also hold a
22
  definition of what the sample geometry itself would be. If the sample shape
23
  definition is set then we term this a constrained sample geometry.
24
*/
25
class MANTID_GEOMETRY_DLL Container final : public IObject {
26
public:
27
  using ShapeArgs = std::unordered_map<std::string, double>;
28

29
30
  Container();
  Container(IObject_sptr shape);
31
  Container(const Container &container);
Martyn Gigg's avatar
Martyn Gigg committed
32
  Container(std::string xml);
33
34

  bool hasSampleShape() const;
35
  IObject_sptr createSampleShape(const ShapeArgs &args) const;
36

37
  void setSampleShape(const std::string &sampleShapeXML);
38

39
  const IObject &getShape() const { return *m_shape; }
40

41
42
43
44
45
46
47
  bool isValid(const Kernel::V3D &p) const override {
    return m_shape->isValid(p);
  }
  bool isOnSide(const Kernel::V3D &p) const override {
    return m_shape->isOnSide(p);
  }
  bool hasValidShape() const override { return m_shape->hasValidShape(); }
48

49
50
  IObject *clone() const override { return new Container(*this); }

Karl Palmen's avatar
Karl Palmen committed
51
52
53
54
  IObject *cloneWithMaterial(const Kernel::Material &material) const override {
    return m_shape->cloneWithMaterial(material);
  }

55
56
57
58
59
  int getName() const override { return m_shape->getName(); }

  int interceptSurface(Geometry::Track &t) const override {
    return m_shape->interceptSurface(t);
  }
Martyn Gigg's avatar
Martyn Gigg committed
60
61
62
  double distance(const Geometry::Track &t) const override {
    return m_shape->distance(t);
  }
63
64
65
  double solidAngle(const Kernel::V3D &observer) const override {
    return m_shape->solidAngle(observer);
  }
66
  double solidAngle(const Kernel::V3D &observer,
67
68
69
70
71
72
73
                    const Kernel::V3D &scaleFactor) const override {
    return m_shape->solidAngle(observer, scaleFactor);
  }
  double volume() const override { return m_shape->volume(); }
  const BoundingBox &getBoundingBox() const override {
    return m_shape->getBoundingBox();
  }
74
75
76
77
  void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin,
                      double &ymin, double &zmin) const override {
    m_shape->getBoundingBox(xmax, ymax, zmax, xmin, ymin, zmin);
  }
78
79
80
81

  int getPointInObject(Kernel::V3D &point) const override {
    return m_shape->getPointInObject(point);
  }
Danny Hindson's avatar
Danny Hindson committed
82
83
84
85
  boost::optional<Kernel::V3D>
  generatePointInObject(Kernel::PseudoRandomNumberGenerator &rng,
                        const size_t i) const override {
    return m_shape->generatePointInObject(rng, i);
86
  }
Danny Hindson's avatar
Danny Hindson committed
87
88
89
90
91
  boost::optional<Kernel::V3D>
  generatePointInObject(Kernel::PseudoRandomNumberGenerator &rng,
                        const BoundingBox &activeRegion,
                        const size_t i) const override {
    return m_shape->generatePointInObject(rng, activeRegion, i);
92
  }
93

94
95
96
97
  detail::ShapeInfo::GeometryShape shape() const override {
    return m_shape->shape();
  }

98
99
100
101
  const detail::ShapeInfo &shapeInfo() const override {
    return m_shape->shapeInfo();
  }

Lamar Moore's avatar
Lamar Moore committed
102
  void GetObjectGeom(detail::ShapeInfo::GeometryShape &type,
103
104
105
                     std::vector<Kernel::V3D> &vectors, double &innerRadius,
                     double &radius, double &height) const override {
    m_shape->GetObjectGeom(type, vectors, innerRadius, radius, height);
106
  }
107
  boost::shared_ptr<GeometryHandler> getGeometryHandler() const override {
108
109
110
111
112
113
    return m_shape->getGeometryHandler();
  }

  void draw() const override { m_shape->draw(); }
  void initDraw() const override { m_shape->initDraw(); }

114
  const Kernel::Material &material() const override {
115
116
    return m_shape->material();
  }
117
  void setID(const std::string &id);
118
  const std::string &id() const override { return m_shape->id(); }
119

120
private:
121
  IObject_sptr m_shape;
122
  std::string m_sampleShapeXML;
123
124
};

125
/// Typdef for a shared pointer
126
using Container_sptr = boost::shared_ptr<Container>;
127
/// Typdef for a shared pointer to a const object
128
using Container_const_sptr = boost::shared_ptr<const Container>;
129

130
131
132
} // namespace Geometry
} // namespace Mantid

Martyn Gigg's avatar
Martyn Gigg committed
133
#endif /* MANTID_GEOMETRY_CONTAINER_H_ */