Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacarniato committed Oct 10, 2023
1 parent b212b99 commit 3e058cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
19 changes: 11 additions & 8 deletions libs/MeshKernel/include/MeshKernel/Mesh2DIntersections.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
namespace meshkernel
{
/// An intersection with a mesh edge
struct EdgeMeshPolylineIntersection
struct EdgeMeshPolyLineIntersection
{
int polylineSegmentIndex{constants::missing::intValue}; ///< The intersected segment index (a polyline can formed by several segments)
double polylineDistance{constants::missing::doubleValue}; ///< The location of the intersection expressed as distance from the polyline start
Expand All @@ -48,7 +48,7 @@ namespace meshkernel
};

/// An intersection with a mesh face
struct FaceMeshPolylineIntersection
struct FaceMeshPolyLineIntersection
{
double polylineDistance{constants::missing::doubleValue}; ///< The location of the intersection expressed as an adimensional distance from the polyline start
UInt faceIndex{constants::missing::uintValue}; ///< The face index
Expand Down Expand Up @@ -81,6 +81,9 @@ namespace meshkernel
/// @returns The faces intersections
[[nodiscard]] const auto& FaceIntersections() const { return m_faceIntersections; }

/// @brief Sort intersections by polyline distance and erase entries with no intersections
/// @tparam T An intersection type, \ref EdgeMeshPolyLineIntersection or \ref FaceMeshPolyLineIntersection
/// @param intersections a vector containing the intersections
template <typename T>
static void sortAndEraseIntersections(std::vector<T>& intersections)
{
Expand Down Expand Up @@ -122,7 +125,7 @@ namespace meshkernel
const double crossProductValue,
const double adimensionalEdgeDistance,
const double adimensionalPolylineSegmentDistance,
std::vector<EdgeMeshPolylineIntersection>& intersections)
std::vector<EdgeMeshPolyLineIntersection>& intersections)
{
const auto [edgeFirstNode, edgeSecondNode] = edge;

Expand All @@ -139,17 +142,17 @@ namespace meshkernel
/// @brief Update face intersections
static void updateFaceIntersections(const UInt faceIndex,
const UInt edgeIndex,
std::vector<FaceMeshPolylineIntersection>& intersections)
std::vector<FaceMeshPolyLineIntersection>& intersections)
{
intersections[faceIndex].faceIndex = faceIndex;
intersections[faceIndex].edgeIndices.emplace_back(edgeIndex);
}

Mesh2D& m_mesh; ///< The mesh where the edges should be found
std::vector<EdgeMeshPolylineIntersection> m_edgesIntersectionsCache; ///< A cache for saving the edge intersections of one inner or outer
std::vector<FaceMeshPolylineIntersection> m_facesIntersectionsCache; ///< A cache for saving the local face intersections of one inner or outer
std::vector<EdgeMeshPolylineIntersection> m_edgesIntersections; ///< A vector collecting all edge intersection results
std::vector<FaceMeshPolylineIntersection> m_faceIntersections; ///< A vector collecting all face intersection results
std::vector<EdgeMeshPolyLineIntersection> m_edgesIntersectionsCache; ///< A cache for saving the edge intersections of one inner or outer
std::vector<FaceMeshPolyLineIntersection> m_facesIntersectionsCache; ///< A cache for saving the local face intersections of one inner or outer
std::vector<EdgeMeshPolyLineIntersection> m_edgesIntersections; ///< A vector collecting all edge intersection results
std::vector<FaceMeshPolyLineIntersection> m_faceIntersections; ///< A vector collecting all face intersection results
static constexpr UInt maxSearchSegments = 10; ///< mex number of steps in polyline intersection algorithm
};

Expand Down
4 changes: 2 additions & 2 deletions libs/MeshKernel/src/Mesh2DIntersections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ std::tuple<bool, UInt, UInt, double, double, double> Mesh2DIntersections::GetNex
void Mesh2DIntersections::Compute(const std::vector<Point>& polyLine)
{
// 1. Find the intersection of any segment of the polyline with the mesh return if nothing is found
std::ranges::fill(m_edgesIntersectionsCache, EdgeMeshPolylineIntersection());
std::ranges::fill(m_facesIntersectionsCache, FaceMeshPolylineIntersection());
std::ranges::fill(m_edgesIntersectionsCache, EdgeMeshPolyLineIntersection());
std::ranges::fill(m_facesIntersectionsCache, FaceMeshPolyLineIntersection());

const auto polyLineSize = static_cast<UInt>(polyLine.size());

Expand Down

0 comments on commit 3e058cc

Please sign in to comment.