-
Notifications
You must be signed in to change notification settings - Fork 122
/
RectangularDetector.h
217 lines (170 loc) · 6.94 KB
/
RectangularDetector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#ifndef RECTANGULAR_DETECTOR_H
#define RECTANGULAR_DETECTOR_H
#include <string>
#include <vector>
#include "MantidGeometry/DllConfig.h"
#include "MantidGeometry/Instrument/Detector.h"
#include "MantidGeometry/Instrument/Component.h"
#include "MantidGeometry/Instrument/CompAssembly.h"
#include "MantidGeometry/Objects/Object.h"
#include "MantidGeometry/IObjComponent.h"
namespace Mantid {
namespace Geometry {
/**
* RectangularDetector is a type of CompAssembly, an assembly of components.
* It is designed to be an easy way to specify a rectangular (XY) array of
* Detector pixels.
*
* @class RectangularDetector
* @brief Assembly of Detector objects in a rectangular shape
* @author Janik Zikovsky, SNS
* @date 2010-Oct-06
Copyright © 2007-8 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>
*/
class MANTID_GEOMETRY_DLL RectangularDetector : public CompAssembly,
public IObjComponent {
friend class RectangularDetectorPixel;
public:
/// String description of the type of component
virtual std::string type() const { return "RectangularDetector"; }
//! Empty constructor
RectangularDetector();
//! Constructor with a name and parent reference
RectangularDetector(const std::string &, IComponent *reference = 0);
//! Parametrized constructor
RectangularDetector(const RectangularDetector *base, const ParameterMap *map);
/// Create all the detector pixels of this rectangular detector.
void initialize(boost::shared_ptr<Object> shape, int xpixels, double xstart,
double xstep, int ypixels, double ystart, double ystep,
int idstart, bool idfillbyfirst_y, int idstepbyrow,
int idstep = 1);
// //! Copy constructor
// RectangularDetector(const RectangularDetector&);
virtual ~RectangularDetector();
//! Make a clone of the present component
virtual IComponent *clone() const;
boost::shared_ptr<Detector> getAtXY(const int X, const int Y) const;
detid_t getDetectorIDAtXY(const int X, const int Y) const;
std::pair<int, int> getXYForDetectorID(const int detectorID) const;
int xpixels() const;
int ypixels() const;
double xstep() const;
double ystep() const;
double xstart() const;
double ystart() const;
/// Size in X of the detector
double xsize() const;
/// Size in Y of the detector
double ysize() const;
int idstart() const;
bool idfillbyfirst_y() const;
int idstepbyrow() const;
int idstep() const;
Kernel::V3D getRelativePosAtXY(int x, int y) const;
void getTextureSize(int &xsize, int &ysize) const;
unsigned int getTextureID() const;
void setTextureID(unsigned int textureID);
/// minimum detector id
int minDetectorID();
/// maximum detector id
int maxDetectorID();
virtual boost::shared_ptr<const IComponent>
getComponentByName(const std::string &cname, int nlevels = 0) const;
// This should inherit the getBoundingBox implementation from CompAssembly
// but
// the multiple inheritance seems to confuse it so we'll explicityly tell it
// that here
using CompAssembly::getBoundingBox;
virtual void testIntersectionWithChildren(
Track &testRay, std::deque<IComponent_const_sptr> &searchQueue) const;
// ------------ IObjComponent methods ----------------
/// Does the point given lie within this object component?
bool isValid(const Kernel::V3D &point) const;
/// Does the point given lie on the surface of this object component?
bool isOnSide(const Kernel::V3D &point) const;
/// Checks whether the track given will pass through this Component.
int interceptSurface(Track &track) const;
/// Finds the approximate solid angle covered by the component when viewed
/// from the point given
double solidAngle(const Kernel::V3D &observer) const;
/// Retrieve the cached bounding box
void getBoundingBox(BoundingBox &assemblyBox) const;
/// Try to find a point that lies within (or on) the object
int getPointInObject(Kernel::V3D &point) const;
// Rendering member functions
/// Draws the objcomponent.
void draw() const;
/// Draws the Object.
void drawObject() const;
/// Initializes the ObjComponent for rendering, this function should be called
/// before rendering.
void initDraw() const;
/// Returns the shape of the Object
const boost::shared_ptr<const Object> shape() const;
/// Returns the material of the detector
const boost::shared_ptr<const Kernel::Material> material() const {
return boost::shared_ptr<const Kernel::Material>();
}
// ------------ End of IObjComponent methods ----------------
private:
/// initialize members to bare defaults
void init();
/// Pointer to the base RectangularDetector, for parametrized instruments
const RectangularDetector *m_rectBase;
/// Private copy assignment operator
RectangularDetector &operator=(const ICompAssembly &);
/// The number of pixels in the X (horizontal) direction;
int m_xpixels;
/// The number of pixels in the Y (vertical) direction;
int m_ypixels;
/// Size in X of the detector
double m_xsize;
/// Size in Y of the detector
double m_ysize;
/// X position of the 0-th pixel
double m_xstart;
/// Y position of the 0-th pixel
double m_ystart;
/// Step size in the X direction of detector
double m_xstep;
/// Step size in the Y direction of detector
double m_ystep;
/// Texture ID to use in rendering
unsigned int m_textureID;
/// Pointer to the shape of the pixels in this detector array.
boost::shared_ptr<Object> mShape;
/// minimum detector id
int m_minDetId;
/// maximum detector id
int m_maxDetId;
/// IDs start here
int m_idstart;
/// IDs are filled in Y fastest
bool m_idfillbyfirst_y;
/// Step size in ID in each row
int m_idstepbyrow;
/// Step size in ID in each col
int m_idstep;
};
MANTID_GEOMETRY_DLL std::ostream &operator<<(std::ostream &,
const RectangularDetector &);
typedef boost::shared_ptr<RectangularDetector> RectangularDetector_sptr;
typedef boost::shared_ptr<const RectangularDetector>
RectangularDetector_const_sptr;
} // Namespace Geometry
} // Namespace Mantid
#endif