Mantid
Loading...
Searching...
No Matches
LineIntersectVisit.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
17#include <algorithm>
18
19namespace Mantid::Geometry {
20
22 : m_line(point, unitVector)
26{
27 m_intersectionPointsOut.reserve(2);
28 m_distancesOut.reserve(2);
29}
30
36{
37 (void)Surf; // Avoid compiler warning
38 throw std::runtime_error("LineIntersectVisit::Accept Surface");
39}
40
46{
48}
49
55{
57}
58
64{
66}
67
73{
75}
76
82{
84}
85
91{
93}
94
100 const auto &u_vec = m_line.getDirect();
101 const auto &origin = m_line.getOrigin();
102 if (m_intersectionPointsOut.size() > 1) {
103 // sort the points by its distance to the track origin
104 std::sort(
106 [&u_vec](const Kernel::V3D &Pt_a, const Kernel::V3D &Pt_b) { return u_vec.scalar_prod(Pt_a - Pt_b) < 0; });
107 // remove consecutive duplicated points
108 const auto last = std::unique(m_intersectionPointsOut.begin(), m_intersectionPointsOut.end(),
109 [](const Kernel::V3D &Pt_a, const Kernel::V3D &Pt_b) { return Pt_a == Pt_b; });
110 // erase the tail
111 if (last != m_intersectionPointsOut.cend())
113 }
114
115 // update the distance list
116 const auto origin_scaler = u_vec.scalar_prod(origin);
117 m_distancesOut.clear();
119 std::transform(m_intersectionPointsOut.begin(), m_intersectionPointsOut.end(), m_distancesOut.begin(),
120 [&u_vec, &origin_scaler](const Kernel::V3D &Pt) { return u_vec.scalar_prod(Pt) - origin_scaler; });
121}
122
123} // namespace Mantid::Geometry
Holds a cone in vector form.
Definition: Cone.h:29
Holds a cylinder as a vector form.
Definition: Cylinder.h:32
Holds a general quadratic surface.
Definition: General.h:28
DistancesType m_distancesOut
The distance.
Line::PType m_intersectionPointsOut
The intersection point.
void Accept(const Surface &) override
Process an intersect track.
LineIntersectVisit(const Kernel::V3D &, const Kernel::V3D &)
Constructor.
void sortAndRemoveDuplicates()
Prune out duplicated points and sort by distance to starting point.
const Kernel::V3D & getOrigin() const
returns the origin
Definition: Line.h:52
const Kernel::V3D & getDirect() const
returns the direction
Definition: Line.h:53
int intersect(PType &, const Quadratic &) const
For the line that intersects the surfaces add the point(s) to the VecOut, return number of points add...
Definition: Line.cpp:152
Holds a simple Plane.
Definition: Plane.h:35
Holds a basic quadratic surface.
Definition: Quadratic.h:29
Holds a Sphere as vector form.
Definition: Sphere.h:29
Holds a basic quadratic surface.
Definition: Surface.h:33
Class for 3D vectors.
Definition: V3D.h:34