ShapeInfo.h 4.65 KB
Newer Older
1
2
3
4
5
6
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2017 ISIS Rutherford Appleton Laboratory UKRI,
//     NScD Oak Ridge National Laboratory, European Spallation Source
//     & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
7
8
9
10
#ifndef MANTID_GEOMETRY_SHAPEINFO_H_
#define MANTID_GEOMETRY_SHAPEINFO_H_

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

namespace Mantid {
namespace Geometry {
class RectangularDetector;
class StructuredDetector;
class IObjComponent;

Lamar Moore's avatar
Lamar Moore committed
20
21
22
23
/** ShapeInfo : Stores shape types and information relevant to drawing the
shape. For cylinders, spheres and cones, height and radius are stored. Points
are stored in the winding order shown in the IDF here
http://docs.mantidproject.org/nightly/concepts/HowToDefineGeometricShape.html.
24
25
26
27
28
29
*/
namespace detail {
class MANTID_GEOMETRY_DLL ShapeInfo {
public:
  enum class GeometryShape {
    NOSHAPE = 0,
30
31
32
33
34
35
    CUBOID,         ///< CUBOID
    HEXAHEDRON,     ///< HEXAHEDRON
    SPHERE,         ///< SPHERE
    CYLINDER,       ///< CYLINDER
    CONE,           ///< CONE
    HOLLOWCYLINDER, ///< HOLLOW CYLINDER
36
  };
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  struct CuboidGeometry {
    const Kernel::V3D &leftFrontBottom;
    const Kernel::V3D &leftFrontTop;
    const Kernel::V3D &leftBackBottom;
    const Kernel::V3D &rightFrontBottom;
  };
  struct HexahedronGeometry {
    const Kernel::V3D &leftBackBottom;
    const Kernel::V3D &leftFrontBottom;
    const Kernel::V3D &rightFrontBottom;
    const Kernel::V3D &rightBackBottom;
    const Kernel::V3D &leftBackTop;
    const Kernel::V3D &leftFrontTop;
    const Kernel::V3D &rightFrontTop;
    const Kernel::V3D &rightBackTop;
  };
  struct SphereGeometry {
    const Kernel::V3D &centre;
    double radius;
  };
  struct CylinderGeometry {
    const Kernel::V3D &centreOfBottomBase;
    const Kernel::V3D &axis;
    double radius;
    double height;
  };
  struct ConeGeometry {
    const Kernel::V3D &centre;
    const Kernel::V3D &axis;
    double radius;
    double height;
  };
69
  struct HollowCylinderGeometry {
70
71
72
    const Kernel::V3D &centreOfBottomBase;
    const Kernel::V3D &axis;
    double innerRadius;
73
    double radius;
74
75
    double height;
  };
76
77
78

private:
  std::vector<Kernel::V3D> m_points;
79
  double m_radius;      ///< Radius for the sphere, cone and cylinder;
Andre Bamidele's avatar
Andre Bamidele committed
80
                        ///< Also outer radius for hollow cylinder;
81
82
  double m_height;      ///< height for cone, cylinder and hollow cylinder;
  double m_innerRadius; ///< Inner radius for hollow cylinder
83
84
85
86
87
88
89
  GeometryShape m_shape;

public:
  ShapeInfo();
  ShapeInfo(const ShapeInfo &) = default;
  const std::vector<Kernel::V3D> &points() const;
  double radius() const;
90
  double innerRadius() const;
91
92
93
  double height() const;
  GeometryShape shape() const;

94
  void getObjectGeometry(GeometryShape &shape, std::vector<Kernel::V3D> &points,
95
96
                         double &innerRadius, double &outerRadius,
                         double &height) const;
mantid-builder's avatar
mantid-builder committed
97
98
  void getObjectGeometry(GeometryShape &shape, std::vector<Kernel::V3D> &points,
                         double &radius, double &height) const;
99

100
101
102
103
104
  CuboidGeometry cuboidGeometry() const;
  HexahedronGeometry hexahedronGeometry() const;
  SphereGeometry sphereGeometry() const;
  CylinderGeometry cylinderGeometry() const;
  ConeGeometry coneGeometry() const;
105
  HollowCylinderGeometry hollowCylinderGeometry() const;
106
107
108
109
110
111
112
113
  /// sets the geometry handler for a cuboid
  void setCuboid(const Kernel::V3D &, const Kernel::V3D &, const Kernel::V3D &,
                 const Kernel::V3D &);
  /// sets the geometry handler for a hexahedron
  void setHexahedron(const Kernel::V3D &, const Kernel::V3D &,
                     const Kernel::V3D &, const Kernel::V3D &,
                     const Kernel::V3D &, const Kernel::V3D &,
                     const Kernel::V3D &, const Kernel::V3D &);
114
115
  /// sets the geometry handler for a sphere
  void setSphere(const Kernel::V3D &center, double radius);
116
  /// sets the geometry handler for a cylinder
Peterson, Peter's avatar
Peterson, Peter committed
117
118
119
  void setCylinder(const Kernel::V3D &centerBottomBase,
                   const Kernel::V3D &symmetryAxis, double radius,
                   double height);
120
  /// sets the geometry handler for a cone
Peterson, Peter's avatar
Peterson, Peter committed
121
  void setCone(const Kernel::V3D &center, const Kernel::V3D &symmetryAxis,
122
               double radius, double height);
123
  /// sets the geometry handler for a hollow cylinder
124
125
126
  void setHollowCylinder(const Kernel::V3D &centreBottomBase,
                         const Kernel::V3D &symmetryAxis, double innerRadius,
                         double outerRadius, double height);
127
  bool operator==(const ShapeInfo &other);
128
129
130
131
132
};
} // namespace detail
} // namespace Geometry
} // namespace Mantid

133
#endif /* MANTID_GEOMETRY_SHAPEINFO_H_ */