21#include <boost/regex.hpp>
34int getOneTextureSize(
int desired) {
36 while (desired > size) {
74 static const boost::regex exp(
"RectangularDetector|rectangularDetector|"
75 "rectangulardetector|rectangular_detector");
77 return boost::regex_match(proposedMatch, exp);
123 return std::pair<int, int>(std::get<0>(xyz), std::get<1>(xyz));
176 int ypixels,
double ystart,
double ystep,
int idstart,
bool idfillbyfirst_y,
177 int idstepbyrow,
int idstep) {
179 GridDetector::initialize(std::move(
shape),
xpixels,
xstart,
xstep,
ypixels,
ystart,
ystep, 0, 0, 0,
idstart,
194 std::deque<IComponent_const_sptr> & )
const {
228 double u = (double(
xpixels() - 1) * tuv[1] + 0.5);
229 double v = (double(
ypixels() - 1) * tuv[2] + 0.5);
234 auto xIndex = int(u);
235 auto yIndex = int(v);
248 auto comp =
getAtXY(xIndex, yIndex);
249 testRay.
addLink(intersec, intersec, 0.0, *(comp->shape()), comp->getComponentID());
260 ysize = getOneTextureSize(this->
ypixels());
294 os <<
"************************\n";
295 os <<
"Number of children :" << ass.
nelements() <<
'\n';
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
void printChildren(std::ostream &) const override
Print information about all children.
int nelements() const override
Return the number of elements in the assembly.
ComponentVisitor : Visitor for IComponents.
virtual size_t registerRectangularBank(const ICompAssembly &bank)=0
Handles rendering of all object Geometry.
GridDetector is a type of CompAssembly, an assembly of components.
double ystart() const
Returns the start position in the Y direction.
std::tuple< int, int, int > getXYZForDetectorID(const detid_t detectorID) const
Given a detector ID, return the X,Y,Z coords into the grid detector.
const std::shared_ptr< const IObject > shape() const override
Returns the shape of the Object.
std::shared_ptr< Detector > getAtXYZ(const int x, const int y, const int z) const
Return a pointer to the component in the assembly at the (X,Y) pixel position.
int const & ypixels() const
Returns the number of pixels in the Y direction.
Kernel::V3D getPosAtXYZ(int const x, int const y, int const z) const
Returns the position of the center of the pixel at x,y, relative to the center of the GridDetector,...
double xsize() const
Size in X of the detector.
void initialize(std::shared_ptr< IObject > shape, int xpixels, double xstart, double xstep, int ypixels, double ystart, double ystep, int zpixels, double zstart, double zstep, int idstart, const std::string &idFillOrder, int idstepbyrow, int idstep=1)
Create all the detector pixels of this grid detector.
bool const & idfillbyfirst_y() const
returns if IDs are filled along y direction first
double ystep() const
Returns the step size in the Y direction.
double xstep() const
Returns the step size in the X direction.
void init()
initialize members to bare defaults
int const & xpixels() const
Returns the number of pixels in the X direction.
int const & idstepbyrow() const
Returns the idstepbyrow.
double xstart() const
Returns the start position in the X direction.
detid_t getDetectorIDAtXYZ(const int x, const int y, const int z) const
Return the detector ID corresponding to the component in the assembly at the (X,Y) pixel position.
int const & idstart() const
Returns the idstart.
void getBoundingBoxAtXYZ(int const x, int const y, int const z, BoundingBox &box) const
bool inBoundsXYZ(const int x, const int y, const int z) const
int const & idstep() const
Returns the idstep.
Kernel::V3D getRelativePosAtXYZ(int const x, int const y, int const z) const
Returns the position of the center of the pixel at x,y, relative to the center of the GridDetector,...
base class for Geometric IComponent
virtual void printSelf(std::ostream &) const =0
Prints a text representation of itself.
virtual void setName(const std::string &)=0
Set the IComponent name.
void setGeometryHandler(GeometryHandler *h)
Reset the current geometry handler.
RectangularDetector is a type of CompAssembly, an assembly of components.
void setTextureID(unsigned int textureID)
Set the texture ID to use when rendering the RectangularDetector.
bool inBoundsXY(int x, int y) const
const Kernel::Material material() const override
Returns the material of the detector.
unsigned int getTextureID() const
Return the texture ID to be used in plotting .
void getTextureSize(int &xsize, int &ysize) const
Return the number of pixels to make a texture in, given the desired pixel size.
RectangularDetector()
Empty constructor.
RectangularDetector * clone() const override
Make a clone of the present component.
Kernel::V3D getPosAtXY(const int x, const int y) const
void getBoundingBoxAtXY(const int x, const int y, BoundingBox &box) const
std::pair< int, int > getXYForDetectorID(const int detectorID) const
Given a detector ID, return the X,Y coords into the rectangular detector.
unsigned int m_textureID
Texture ID to use in rendering.
detid_t getDetectorIDAtXY(const int X, const int Y) const
Return the detector ID corresponding to the component in the assembly at the (X,Y) pixel position.
std::shared_ptr< Detector > getAtXY(const int X, const int Y) const
Return a pointer to the component in the assembly at the (X,Y) pixel position.
Kernel::V3D getRelativePosAtXY(int x, int y) const
Returns the position of the center of the pixel at x,y, relative to the center of the RectangularDete...
void initialize(std::shared_ptr< IObject > shape, int xpixels, double xstart, double xstep, int ypixels, double ystart, double ystep, int idstart, bool idfillbyfirst_y, int idstepbyrow, int idstep=1)
Create all the detector pixels of this rectangular detector.
static bool compareName(const std::string &proposedMatch)
Matches name to Structured Detector.
virtual size_t registerContents(class ComponentVisitor &componentVisitor) const override
void testIntersectionWithChildren(Track &testRay, std::deque< IComponent_const_sptr > &searchQueue) const override
Test the intersection of the ray with the children of the component assembly, for InstrumentRayTracer...
Defines a track as a start point and a direction.
const Kernel::V3D & startPoint() const
Returns the starting point.
int addLink(const Kernel::V3D &firstPoint, const Kernel::V3D &secondPoint, const double distanceAlongTrack, const IObject &obj, const ComponentID compID=nullptr)
Adds a link to the track.
const Kernel::V3D & direction() const
Returns the direction as a unit vector.
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
T Invert()
LU inversion routine.
void setColumn(const size_t nCol, const std::vector< T > &newCol)
MANTID_GEOMETRY_DLL std::ostream & operator<<(std::ostream &stream, const PointGroup &self)
Returns a streamed representation of the PointGroup object.
int32_t detid_t
Typedef for a detector ID.