Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::Geometry::InstrumentRayTracer Class Reference

This class is responsible for tracking rays and accumulating a list of objects that are intersected along the way. More...

#include <InstrumentRayTracer.h>

Public Member Functions

const ComponentInfo & componentInfo () const
 ComponentInfo/DetectorInfo for the traced instrument, against which the index returned by getDetectorResult is defined.
 
const DetectorInfo & detectorInfo () const
 
size_t getDetectorResult () const
 Get the index of the first non-monitor detector intersected since the previous call to trace, or ComponentInfo::invalidIndex if none.
 
Links getResults () const
 Get the results of the intersection tests that have been updated since the previous call to trace.
 
 InstrumentRayTracer (ComponentInfo const &componentInfo, DetectorInfo const &detectorInfo)
 Constructor taking the ComponentInfo/DetectorInfo of the instrument to trace, which must outlive this object.
 
void trace (const Kernel::V3D &dir) const
 Trace a given track from the instrument source in the given direction and compile a list of results that this track intersects.
 
void traceFromSample (const Kernel::V3D &dir) const
 Trace a given track from the sample position in the given direction.
 

Private Member Functions

void fireRay (Track &testRay) const
 Fire the given track at the instrument.
 
void testIntersectionWithGrid (size_t const index, Track &testRay) const
 Intersect the track with the first layer of a Rectangular or Grid bank.
 
void testIntersectionWithShape (size_t const index, Track &testRay) const
 Intersect the track with the shape of a leaf component.
 

Private Attributes

boost::unordered_map< size_t, BoundingBox > m_boxCache
 Map of component index -> bounding box.
 
ComponentInfo const & m_componentInfo
 ComponentInfo of the instrument being traced.
 
DetectorInfo const & m_detectorInfo
 DetectorInfo of the instrument being traced.
 
std::mutex m_mutex
 Mutex to lock box cache.
 
Track m_resultsTrack
 Accumulate results in this Track object, aids performance.
 

Detailed Description

This class is responsible for tracking rays and accumulating a list of objects that are intersected along the way.

Author
Martyn Gigg, Tessella plc
Date
22/10/2010

Definition at line 37 of file InstrumentRayTracer.h.

Constructor & Destructor Documentation

◆ InstrumentRayTracer()

Mantid::Geometry::InstrumentRayTracer::InstrumentRayTracer ( ComponentInfo const &  componentInfo,
DetectorInfo const &  detectorInfo 
)

Constructor taking the ComponentInfo/DetectorInfo of the instrument to trace, which must outlive this object.

Constructor specifying the instrument involved in the tracing, which must have a defined source.

Parameters
componentInfo:: The ComponentInfo of the instrument to perform the ray tracings on. It must outlive this object.
detectorInfo:: The DetectorInfo of the same instrument. It must outlive this object.

Definition at line 37 of file InstrumentRayTracer.cpp.

References Mantid::Geometry::ComponentInfo::hasSource(), and m_componentInfo.

Member Function Documentation

◆ componentInfo()

const ComponentInfo & Mantid::Geometry::InstrumentRayTracer::componentInfo ( ) const

ComponentInfo/DetectorInfo for the traced instrument, against which the index returned by getDetectorResult is defined.

Returns
the ComponentInfo for the traced instrument

Definition at line 106 of file InstrumentRayTracer.cpp.

References m_componentInfo.

◆ detectorInfo()

const DetectorInfo & Mantid::Geometry::InstrumentRayTracer::detectorInfo ( ) const
Returns
the DetectorInfo for the traced instrument

Definition at line 109 of file InstrumentRayTracer.cpp.

References m_detectorInfo.

Referenced by Mantid::DataObjects::Peak::findDetector().

◆ fireRay()

void Mantid::Geometry::InstrumentRayTracer::fireRay ( Track &  testRay) const
private

Fire the given track at the instrument.

Fire the test ray at the instrument and perform a breadth-first search of the ComponentInfo tree to find the components that were intersected.

Parameters
testRay:: An input/output parameter that defines the track and accumulates the intersection results

Definition at line 122 of file InstrumentRayTracer.cpp.

References Mantid::Geometry::BoundingBox::doesLineIntersect(), m_boxCache, m_componentInfo, m_mutex, testIntersectionWithGrid(), and testIntersectionWithShape().

Referenced by trace(), and traceFromSample().

◆ getDetectorResult()

size_t Mantid::Geometry::InstrumentRayTracer::getDetectorResult ( ) const

Get the index of the first non-monitor detector intersected since the previous call to trace, or ComponentInfo::invalidIndex if none.

Gets the results of the trace, then returns the index of the first detector (that is NOT a monitor) found in the results.

Returns
the index of the detector in detectorInfo(), or ComponentInfo::invalidIndex if not found

Definition at line 92 of file InstrumentRayTracer.cpp.

References getResults(), index, Mantid::Geometry::DetectorInfo::indexOf(), Mantid::Geometry::ComponentInfo::invalidIndex, m_componentInfo, and m_detectorInfo.

Referenced by Mantid::Algorithms::RayTracerTester::exec(), and Mantid::DataObjects::Peak::findDetector().

◆ getResults()

Links Mantid::Geometry::InstrumentRayTracer::getResults ( ) const

Get the results of the intersection tests that have been updated since the previous call to trace.

Return the results of any trace() calls since the last call the getResults.

Returns
A collection of links defining intersection information

Definition at line 80 of file InstrumentRayTracer.cpp.

References Mantid::Geometry::Track::cbegin(), Mantid::Geometry::Track::cend(), Mantid::Geometry::Track::clearIntersectionResults(), and m_resultsTrack.

Referenced by getDetectorResult().

◆ testIntersectionWithGrid()

void Mantid::Geometry::InstrumentRayTracer::testIntersectionWithGrid ( size_t const  index,
Track &  testRay 
) const
private

Intersect the track with the first layer of a Rectangular or Grid bank.

Intersect the track with the first layer of a Rectangular or Grid bank by treating it as a plane, adding a link to the track for the pixel hit.

Parameters
index:: The component index of the bank
testRay:: The track to test, which accumulates the results

Base point (x,y,z) = position of pixel 0,0

Vertical (y-axis) basis vector of the detector

Horizontal (x-axis) basis vector of the detector

Definition at line 207 of file InstrumentRayTracer.cpp.

References Mantid::Geometry::Track::addLink(), Mantid::Geometry::Track::direction(), index, Mantid::Kernel::Matrix< T >::Invert(), m_componentInfo, Mantid::Geometry::ComponentInfo::pixelGridComponent(), Mantid::Kernel::Matrix< T >::setColumn(), and Mantid::Geometry::Track::startPoint().

Referenced by fireRay().

◆ testIntersectionWithShape()

void Mantid::Geometry::InstrumentRayTracer::testIntersectionWithShape ( size_t const  index,
Track &  testRay 
) const
private

Intersect the track with the shape of a leaf component.

Intersect the track with the shape of a leaf component, adding a link to the track for each intersection.

Parameters
index:: The component index of the leaf component
testRay:: The track to test, which accumulates the results

Definition at line 167 of file InstrumentRayTracer.cpp.

References Mantid::Geometry::Track::addLink(), Mantid::Geometry::Track::direction(), Mantid::Kernel::V3D::distance(), index, Mantid::Kernel::Quat::inverse(), m_componentInfo, Mantid::Kernel::Quat::rotate(), Mantid::Geometry::ComponentInfo::shape(), and Mantid::Geometry::Track::startPoint().

Referenced by fireRay().

◆ trace()

void Mantid::Geometry::InstrumentRayTracer::trace ( const Kernel::V3D &  dir) const

Trace a given track from the instrument source in the given direction and compile a list of results that this track intersects.

Trace a given track from the instrument source in the given direction.

For performance reasons the results are accumulated within the object and can be returned using getResults.

Parameters
dir:: A directional vector. The starting point is defined by the instrument source.

Definition at line 54 of file InstrumentRayTracer.cpp.

References fireRay(), m_componentInfo, m_resultsTrack, Mantid::Geometry::Track::reset(), and Mantid::Geometry::ComponentInfo::sourcePosition().

◆ traceFromSample()

void Mantid::Geometry::InstrumentRayTracer::traceFromSample ( const Kernel::V3D &  dir) const

Trace a given track from the sample position in the given direction.

For performance reasons the results are accumulated within the object and can be returned using getResults.

Parameters
dir:: A directional vector. The starting point is defined by the instrument source.

Definition at line 69 of file InstrumentRayTracer.cpp.

References fireRay(), m_componentInfo, m_resultsTrack, Mantid::Geometry::Track::reset(), and Mantid::Geometry::ComponentInfo::samplePosition().

Referenced by Mantid::Algorithms::RayTracerTester::exec(), and Mantid::DataObjects::Peak::findDetector().

Member Data Documentation

◆ m_boxCache

boost::unordered_map<size_t, BoundingBox> Mantid::Geometry::InstrumentRayTracer::m_boxCache
mutableprivate

Map of component index -> bounding box.

Definition at line 74 of file InstrumentRayTracer.h.

Referenced by fireRay().

◆ m_componentInfo

ComponentInfo const& Mantid::Geometry::InstrumentRayTracer::m_componentInfo
private

◆ m_detectorInfo

DetectorInfo const& Mantid::Geometry::InstrumentRayTracer::m_detectorInfo
private

DetectorInfo of the instrument being traced.

Definition at line 69 of file InstrumentRayTracer.h.

Referenced by detectorInfo(), and getDetectorResult().

◆ m_mutex

std::mutex Mantid::Geometry::InstrumentRayTracer::m_mutex
mutableprivate

Mutex to lock box cache.

Definition at line 76 of file InstrumentRayTracer.h.

Referenced by fireRay().

◆ m_resultsTrack

Track Mantid::Geometry::InstrumentRayTracer::m_resultsTrack
mutableprivate

Accumulate results in this Track object, aids performance.

This is cleared when getResults is called.

Definition at line 72 of file InstrumentRayTracer.h.

Referenced by getResults(), trace(), and traceFromSample().


The documentation for this class was generated from the following files: