Container.h 5.28 KB
Newer Older
Martyn Gigg's avatar
Martyn Gigg committed
1
2
#ifndef MANTID_GEOMETRY_CONTAINER_H_
#define MANTID_GEOMETRY_CONTAINER_H_
3
4

#include "MantidGeometry/DllConfig.h"
5
6
7
#include "MantidGeometry/Objects/IObject.h"
#include "MantidKernel/Material.h"
#include "MantidKernel/V3D.h"
8
#include <unordered_map>
9
10
11
12
13

namespace Mantid {
namespace Geometry {

/**
Martyn Gigg's avatar
Martyn Gigg committed
14
  Models a Container is used to hold a sample in the beam. It gets most
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  of its functionality from Geometry::Object but can also hold a
  definition of what the sample geometry itself would be. If the sample shape
  definition is set then we term this a constriained sample geometry.

  Copyright &copy; 2016 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
  National Laboratory & European Spallation Source

  This file is part of Mantid.

  Mantid is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 3 of the License, or
  (at your option) any later version.

  Mantid is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  File change history is stored at: <https://github.com/mantidproject/mantid>
  Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
40
class MANTID_GEOMETRY_DLL Container final : public IObject {
41
public:
42
43
  typedef std::unordered_map<std::string, double> ShapeArgs;

44
45
  Container();
  Container(IObject_sptr shape);
46
  Container(const Container &container);
Martyn Gigg's avatar
Martyn Gigg committed
47
  Container(std::string xml);
48
49

  bool hasSampleShape() const;
50
  IObject_sptr createSampleShape(const ShapeArgs &args) const;
51

52
  void setSampleShape(const std::string &sampleShapeXML);
53

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
  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);
  }
  int calcValidType(const Kernel::V3D &Pt,
                    const Kernel::V3D &uVec) const override {
    return m_shape->calcValidType(Pt, uVec);
  }
  bool hasValidShape() const override { return m_shape->hasValidShape(); }
  int setObject(const int ON, const std::string &Ln) override {
    return m_shape->setObject(ON, Ln);
  }
  int populate(const std::map<int, boost::shared_ptr<Surface>> &m) override {
    return m_shape->populate(m);
  }
  IObject *clone() const override { return new Container(*this); }

  int getName() const override { return m_shape->getName(); }
  void setName(const int nx) override { m_shape->setName(nx); }

  int interceptSurface(Geometry::Track &t) const override {
    return m_shape->interceptSurface(t);
  }
  double solidAngle(const Kernel::V3D &observer) const override {
    return m_shape->solidAngle(observer);
  }
82
  double solidAngle(const Kernel::V3D &observer,
83
84
85
86
87
88
89
90
91
92
93
                    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();
  }

  int getPointInObject(Kernel::V3D &point) const override {
    return m_shape->getPointInObject(point);
  }
94
  Kernel::V3D generatePointInObject(Kernel::PseudoRandomNumberGenerator &rng,
95
96
97
                                    const size_t i) const override {
    return m_shape->generatePointInObject(rng, i);
  }
98
  Kernel::V3D generatePointInObject(Kernel::PseudoRandomNumberGenerator &rng,
99
100
101
102
                                    const BoundingBox &activeRegion,
                                    const size_t i) const override {
    return m_shape->generatePointInObject(rng, activeRegion, i);
  }
103
104

  void GetObjectGeom(int &type, std::vector<Kernel::V3D> &vectors,
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
                     double &myradius, double &myheight) const override {
    m_shape->GetObjectGeom(type, vectors, myradius, myheight);
  }
  boost::shared_ptr<GeometryHandler> getGeometryHandler() override {
    return m_shape->getGeometryHandler();
  }

  std::string getShapeXML() const override { return m_shape->getShapeXML(); }

  void draw() const override { m_shape->draw(); }
  void initDraw() const override { m_shape->initDraw(); }
  void setVtkGeometryCacheReader(
      boost::shared_ptr<vtkGeometryCacheReader> reader) override {
    m_shape->setVtkGeometryCacheReader(reader);
  }
  void setVtkGeometryCacheWriter(
      boost::shared_ptr<vtkGeometryCacheWriter> writer) override {
    m_shape->setVtkGeometryCacheWriter(writer);
  }

  void setMaterial(const Kernel::Material &material) override {
    m_shape->setMaterial(material);
  }
  const Kernel::Material material() const override {
    return m_shape->material();
  }
  void setID(const std::string &id) override { m_shape->setID(id); }
  const std::string &id() const override { return m_shape->id(); }
133

134
private:
135
  IObject_sptr m_shape;
136
  std::string m_sampleShapeXML;
137
138
};

139
/// Typdef for a shared pointer
Martyn Gigg's avatar
Martyn Gigg committed
140
typedef boost::shared_ptr<Container> Container_sptr;
141
/// Typdef for a shared pointer to a const object
Martyn Gigg's avatar
Martyn Gigg committed
142
typedef boost::shared_ptr<const Container> Container_const_sptr;
143

144
145
146
} // namespace Geometry
} // namespace Mantid

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