13#include <boost/iterator/distance.hpp>
34 throw std::invalid_argument(
"Failed to construct track: direction is not a unit vector.");
47 throw std::invalid_argument(
"Failed to reset track: direction is not a unit vector.");
77 if ((ac->exitPoint).distance(bc->entryPoint) >
Tolerance) {
78 return (
static_cast<int>(boost::distance(
m_links.begin(), bc)) + 1);
95 auto prevNode =
m_links.begin();
96 auto nextNode =
m_links.begin();
98 while (nextNode !=
m_links.end()) {
99 if (prevNode->componentID == nextNode->componentID) {
100 prevNode->exitPoint = nextNode->exitPoint;
101 prevNode->distFromStart = prevNode->entryPoint.distance(prevNode->exitPoint);
102 prevNode->distInsideObject = nextNode->distInsideObject;
133 if (newPoint == *lowestPtr) {
155 Link newLink(firstPoint, secondPoint, distanceAlongTrack,
obj, compID);
166 if (newLink == *it) {
167 return static_cast<int>(std::distance(
m_links.begin(),
m_links.end()));
171 auto linkPtr = std::lower_bound(
m_links.begin(),
m_links.end(), newLink);
174 index =
static_cast<int>(std::distance(
m_links.begin(), linkPtr));
175 m_links.insert(linkPtr, newLink);
216 V3D workPt = ac->endPoint;
221 if (
fabs(ac->distFromStart - bc->distFromStart) >
Tolerance) {
223 addLink(ac->endPoint, bc->endPoint, bc->distFromStart, *ac->object, ac->componentID);
227 addLink(workPt, ac->endPoint, ac->distFromStart, *ac->object, ac->componentID);
229 workPt = bc->endPoint;
256 [](
double total,
const auto &link) { return total + link.distInsideObject; });
271 os.setstate(std::ios_base::failbit);
278 for (
const auto &segment :
m_links) {
279 const double length = segment.distInsideObject;
280 const auto &segObj = *(segment.object);
281 factor *= segObj.material().attenuation(length,
lambda);
const std::vector< double > * lambda
std::map< DeltaEMode::Type, std::string > index
double obj
the value of the quadratic function
base class for Geometric IComponent
IObject : Interface for geometry objects.
const Kernel::V3D & getOrigin() const
returns the origin
int setLine(const Kernel::V3D &, const Kernel::V3D &)
input Origin + direction
const Kernel::V3D & startPoint() const
Returns the starting point.
PType m_surfPoints
Intersection points.
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.
void clearIntersectionResults()
Clear the current set of intersection results.
void removeCojoins()
Remove touching Links that have identical components.
void addPoint(const TrackDirection direction, const Kernel::V3D &endPoint, const IObject &obj, const ComponentID compID=nullptr)
Adds a point of intersection to the track.
double totalDistInsideObject() const
Returns the sum of all the links distInsideObject in the track.
void buildLink()
Construct links between added points.
const Kernel::V3D & direction() const
Returns the direction as a unit vector.
int nonComplete() const
Is the link complete?
LType m_links
Track units.
virtual double calculateAttenuation(double lambda) const
Calculate attenuation across all links.
Track()
Default constructor.
void reset(const Kernel::V3D &startPoint, const Kernel::V3D &direction)
Set a starting point and direction.
Line m_line
Line object containing origin and direction.
double distance(const V3D &v) const noexcept
Calculates the distance between two vectors.
bool unitVector(const double tolerance=Kernel::Tolerance) const noexcept
MANTID_GEOMETRY_DLL std::ostream & operator<<(std::ostream &stream, const PointGroup &self)
Returns a streamed representation of the PointGroup object.
constexpr double Tolerance
Standard tolerance value.
Stores a point of intersection along a track.