32 #include "MeshKernel/Definitions.hpp"
33 #include "MeshKernel/Mesh2D.hpp"
34 #include "MeshKernel/Polygons.hpp"
76 void Compute(
const std::vector<Point>& polyLine);
92 std::ranges::sort(intersections,
93 [](
const T& first,
const T& second)
94 {
return first.polylineDistance < second.polylineDistance; });
96 std::erase_if(intersections, [](
const T& v)
97 {
return v.polylineDistance < 0; });
110 std::tuple<UInt, UInt> GetIntersectionSeed(
const Mesh2D& mesh,
111 const std::vector<Point>& polyLine,
112 const std::vector<BoundingBox>& polyLineBoundingBoxes,
113 const std::vector<bool>& vistedEdges)
const;
117 std::tuple<bool, UInt, UInt, double, double, double> GetNextEdgeIntersection(
const std::vector<Point>& polyLine,
118 const std::vector<BoundingBox>& polyLineBoundingBoxes,
122 Direction direction)
const;
126 void IntersectFaceEdges(
const std::vector<Point>& polyLine,
127 const std::vector<BoundingBox>& polyLineBoundingBoxes,
128 const std::vector<double>& cumulativeLength,
129 UInt currentCrossingEdge,
130 UInt currentFaceIndex,
132 std::vector<bool>& vistedEdges,
133 std::vector<bool>& vistedFace,
134 std::queue<std::array<UInt, 2>>& crossingEdges);
137 static void updateEdgeIntersections(
const UInt segmentIndex,
138 const UInt edgeIndex,
140 const std::vector<double>& cumulativeLength,
141 const double crossProductValue,
142 const double adimensionalEdgeDistance,
143 const double adimensionalPolylineSegmentDistance,
144 std::vector<EdgeMeshPolyLineIntersection>& intersections)
146 const auto [edgeFirstNode, edgeSecondNode] = edge;
148 intersections[edgeIndex].polylineSegmentIndex =
static_cast<int>(segmentIndex);
149 intersections[edgeIndex].polylineDistance = cumulativeLength[segmentIndex] +
150 adimensionalPolylineSegmentDistance * (cumulativeLength[segmentIndex + 1] - cumulativeLength[segmentIndex]);
151 intersections[edgeIndex].adimensionalPolylineSegmentDistance = adimensionalPolylineSegmentDistance;
152 intersections[edgeIndex].edgeFirstNode = crossProductValue < 0 ? edgeSecondNode : edgeFirstNode;
153 intersections[edgeIndex].edgeSecondNode = crossProductValue < 0 ? edgeFirstNode : edgeSecondNode;
154 intersections[edgeIndex].edgeDistance = adimensionalEdgeDistance;
155 intersections[edgeIndex].edgeIndex = edgeIndex;
159 static void updateFaceIntersections(
const UInt faceIndex,
160 const UInt edgeIndex,
161 std::vector<FaceMeshPolyLineIntersection>& intersections)
163 intersections[faceIndex].faceIndex = faceIndex;
164 intersections[faceIndex].edgeIndices.emplace_back(edgeIndex);
168 std::vector<EdgeMeshPolyLineIntersection> m_edgesIntersectionsCache;
169 std::vector<FaceMeshPolyLineIntersection> m_facesIntersectionsCache;
170 std::vector<EdgeMeshPolyLineIntersection> m_edgesIntersections;
171 std::vector<FaceMeshPolyLineIntersection> m_faceIntersections;
172 BoundingBox m_meshBoundingBox;
173 std::vector<BoundingBox> m_meshEdgesBoundingBoxes;
174 static constexpr
UInt maxSearchSegments = 1000;