19#include <boost/regex.hpp>
57 static const boost::regex exp(
"StructuredDetector|structuredDetector|"
58 "structureddetector|structured_detector");
60 return boost::regex_match(proposedMatch, exp);
95 throw std::runtime_error(
"StructuredDetector::getAtXY: X specified is out of range.");
97 throw std::runtime_error(
"StructuredDetector::getAtXY: Y specified is out of range.");
102 throw std::runtime_error(
"StructuredDetector::getAtXY: X specified is out of range.");
103 return std::dynamic_pointer_cast<Detector>(xCol->getChild(
static_cast<int>(
y)));
137 return std::pair<int, int>(-1, -1);
143 return std::pair<int, int>(row, col);
145 return std::pair<int, int>(col, row);
164 const std::vector<int> &b)
const {
279 bool isZBeam,
detid_t idStart,
bool idFillByFirstY,
int idStepByRow,
int idStep) {
281 throw std::runtime_error(
"StructuredDetector::initialize() called for a "
282 "parametrized StructuredDetector");
298 throw std::invalid_argument(
"StructuredDetector::initialize(): xPixels should be > 0");
300 throw std::invalid_argument(
"StructuredDetector::initialize(): yPixels should be > 0");
301 if (
x.size() !=
y.size())
302 throw std::invalid_argument(
"StructuredDetector::initialize(): x.size() should be = y.size()");
304 throw std::invalid_argument(
"StructuredDetector::initialize(): x.size() "
305 "should be = (xPixels+1)*(yPixels+1)");
307 throw std::invalid_argument(
"Expecting reference_frame to provide z as "
308 "beam axis. StructuredDetecor only allows "
309 "z-axis aligned beams.");
324 for (
size_t ix = 0; ix <
m_xPixels; ix++) {
326 std::ostringstream oss_col;
328 oss_col << this->
getName() <<
"(x=" << ix <<
")";
331 for (
size_t iy = 0; iy <
m_yPixels; iy++) {
332 std::ostringstream oss;
333 oss << this->
getName() <<
"(" << ix <<
"," << iy <<
")";
381 auto xpos = (xlb + xlf + xrf + xrb) / 4;
382 auto ypos = (ylb + ylf + yrf + yrb) / 4;
394 std::shared_ptr<Mantid::Geometry::IObject>
shape =
401 V3D pos(xpos, ypos, 0);
403 detector->translate(pos);
430 return std::shared_ptr<const IComponent>(
this);
435 const std::string MEMBER_NAME = this->
getName() +
"(";
439 if (cname.substr(0, MEMBER_NAME.length()) != MEMBER_NAME) {
440 return std::shared_ptr<const IComponent>();
494 std::shared_ptr<Detector> det =
getAtXY(0, 0);
495 det->getBoundingBox(compBox);
498 det->getBoundingBox(compBox);
501 det->getBoundingBox(compBox);
504 det->getBoundingBox(compBox);
551 std::ostringstream xmlShapeStream;
553 xmlShapeStream <<
"<hexahedron id=\"detector-shape\" >"
554 <<
"<left-back-bottom-point x=\"" << xlb <<
"\""
555 <<
" y=\"" << ylb <<
"\""
557 <<
"<left-front-bottom-point x=\"" << xlf <<
"\""
558 <<
" y=\"" << ylf <<
"\""
560 <<
"<right-front-bottom-point x=\"" << xrf <<
"\""
561 <<
" y=\"" << yrf <<
"\""
563 <<
"<right-back-bottom-point x=\"" << xrb <<
"\""
564 <<
" y=\"" << yrb <<
"\""
566 <<
"<left-back-top-point x=\"" << xlb <<
"\""
567 <<
" y=\"" << ylb <<
"\""
569 <<
"<left-front-top-point x=\"" << xlf <<
"\""
570 <<
" y=\"" << ylf <<
"\""
572 <<
"<right-front-top-point x=\"" << xrf <<
"\""
573 <<
" y=\"" << yrf <<
"\""
575 <<
"<right-back-top-point x=\"" << xrb <<
"\""
576 <<
" y=\"" << yrb <<
"\""
580 std::string xmlHexahedralShape(xmlShapeStream.str());
583 return shapeCreator.
createShape(xmlHexahedralShape);
606 os <<
"************************\n";
607 os <<
"Number of children :" << ass.
nelements() <<
'\n';
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
void grow(const BoundingBox &other)
Grow the bounding box so that it also encompasses the given box.
Class for Assembly of geometric components.
void printChildren(std::ostream &) const override
Print information about all children.
BoundingBox * m_cachedBoundingBox
A cached bounding box.
int add(IComponent *) override
Add a component to the assembly.
std::shared_ptr< const IComponent > getComponentByName(const std::string &cname, int nlevels=0) const override
Returns a pointer to the first component of assembly encountered with the given name.
std::shared_ptr< IComponent > getChild(const int i) const override
Get a pointer to the ith component within the assembly. Easier to use than.
CompAssembly()
Empty constructor.
int nelements() const override
Return the number of elements in the assembly.
BoundingBox boundingBox(const size_t componentIndex, const BoundingBox *reference=nullptr, const bool excludeMonitors=false) const
Compute the bounding box for the component with componentIndex taking into account all sub components...
ComponentVisitor : Visitor for IComponents.
virtual size_t registerStructuredBank(const ICompAssembly &bank)=0
const ParameterMap * m_map
A pointer to const ParameterMap containing the parameters.
size_t index() const
Helper for legacy access mode. Returns the index of the component.
bool hasComponentInfo() const
This class represents a detector - i.e.
void render() const
Render Object or ObjComponent.
void initialize() const
Prepare/Initialize Object/ObjComponent to be rendered.
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.
virtual std::string getName() const =0
Get the IComponent name.
Object Component class, this class brings together the physical attributes of the component to the po...
void setGeometryHandler(GeometryHandler *h)
Reset the current geometry handler.
GeometryHandler * Handle() const
Gets the GeometryHandler.
friend class GeometryHandler
const Geometry::ComponentInfo & componentInfo() const
Only for use by ExperimentInfo. Returns a reference to the ComponentInfo.
Class originally intended to be used with the DataHandling 'LoadInstrument' algorithm.
static std::shared_ptr< CSGObject > createHexahedralShape(double xlb, double xlf, double xrf, double xrb, double ylb, double ylf, double yrf, double yrb)
Create a hexahedral shape object.
std::shared_ptr< CSGObject > createShape(Poco::XML::Element *pElem)
Creates a geometric object from a DOM-element-node pointing to an element whose child nodes contain t...
StructuredDetector is a type of CompAssembly, an assembly of components.
void createDetectors()
Creates all detector pixels within the StructuredDetector.
std::vector< int > const & getB() const
Returns the blue color channel for detector colors.
Detector * addDetector(CompAssembly *parent, const std::string &name, size_t x, size_t y, detid_t id)
Creates new hexahedral detector pixel at row x column y using the detector vertex values.
void draw() const override
Draws the objcomponent.
std::vector< double > const & getXValues() const
int interceptSurface(Track &track) const override
Checks whether the track given will pass through this Component.
static bool compareName(const std::string &proposedMatch)
Matches name to Structured Detector.
size_t m_xPixels
The number of pixels in the X (horizontal) direction;.
detid_t maxDetectorID()
maximum detector id
int idStepByRow() const
Returns the idStepByRow.
virtual size_t registerContents(class ComponentVisitor &componentVisitor) const override
Register the structured detector for Instrument 2.0 usage.
detid_t m_maxDetId
maximum detector id
std::shared_ptr< Detector > getAtXY(const size_t x, const size_t y) const
Return a pointer to the component in the assembly at the (X,Y) pixel position.
std::vector< int > const & getG() const
Returns the green color channel for detector colors.
void drawObject() const override
Draws the Object.
int idStep() const
Returns the idStep.
detid_t getDetectorIDAtXY(const size_t X, const size_t Y) const
Return the detector ID corresponding to the component in the assembly at the (X,Y) pixel position.
size_t yPixels() const
Returns the number of pixels in the Y direction.
size_t m_yPixels
The number of pixels in the Y (vertical) direction;.
void initDraw() const override
Initializes the ObjComponent for rendering, this function should be called before rendering.
std::vector< int > const & getR() const
Returns the red color channel for detector colors.
const std::shared_ptr< const IObject > shape() const override
Returns the shape of the Object.
std::pair< size_t, size_t > getXYForDetectorID(const detid_t detectorID) const
Given a detector ID, return the X,Y coords into the structured detector.
bool idFillByFirstY() const
Returns the idFillByFirstY.
size_t xPixels() const
Returns the number of pixels in the X direction.
const StructuredDetector * m_base
Pointer to the base RectangularDetector, for parametrized instruments.
void initialize(size_t xPixels, size_t yPixels, std::vector< double > &&x, std::vector< double > &&y, bool isZBeam, detid_t idStart, bool idFillByFirstY, int idStepByRow, int idStep=1)
Create all the detector pixels of this rectangular detector.
int m_idStepByRow
Step size in ID in each row.
int getPointInObject(Kernel::V3D &point) const override
Try to find a point that lies within (or on) the object.
void getBoundingBox(BoundingBox &assemblyBox) const override
Retrieve the cached bounding box.
detid_t idStart() const
Returns the idStart.
bool isOnSide(const Kernel::V3D &point) const override
Does the point given lie on the surface of this object component?
int m_idStep
Step size in ID in each col.
std::vector< double > m_yvalues
detid_t m_minDetId
minimum detector id
std::shared_ptr< const IComponent > getComponentByName(const std::string &cname, int nlevels=0) const override
Returns a pointer to the first component of assembly encountered with the given name.
bool m_idFillByFirstY
IDs are filled in Y fastest.
bool isValid(const Kernel::V3D &point) const override
Does the point given lie within this object component?
double solidAngle(const Kernel::V3D &observer) const override
Finds the approximate solid angle covered by the component when viewed from the point given.
std::vector< double > const & getYValues() const
std::vector< double > m_xvalues
StructuredDetector()
Empty constructor.
const Kernel::Material material() const override
Returns the material of the detector.
detid_t minDetectorID()
minimum detector id
void setColors(const std::vector< int > &r, const std::vector< int > &g, const std::vector< int > &b) const
Sets the colours for detector IDs based on color maps created by instrument actor.
detid_t m_idStart
IDs start here.
void init()
initialize members to bare defaults
IComponent * clone() const override
Make a clone of the present component.
Defines a track as a start point and a direction.
Marks code as not implemented yet.
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
MANTID_GEOMETRY_DLL std::ostream & operator<<(std::ostream &stream, const PointGroup &self)
Returns a streamed representation of the PointGroup object.
std::shared_ptr< ICompAssembly > ICompAssembly_sptr
Shared pointer to a ICompAssembly.
int32_t detid_t
Typedef for a detector ID.