diff --git a/libs/MeshKernel/include/MeshKernel/MeshTriangulation.hpp b/libs/MeshKernel/include/MeshKernel/MeshTriangulation.hpp index a808f7e1e..8fb36d4e2 100644 --- a/libs/MeshKernel/include/MeshKernel/MeshTriangulation.hpp +++ b/libs/MeshKernel/include/MeshKernel/MeshTriangulation.hpp @@ -48,6 +48,8 @@ namespace meshkernel class BoundedArray { public: + BoundedArray() : m_size(0) {} + UInt size() const { return m_size; @@ -55,6 +57,12 @@ namespace meshkernel void push_back(const UInt index) { + if (m_size == Dimension - 1) + { + throw ConstraintError("array already at size limit: {}", Dimension); + } + + // m_indices.push_back(index); m_indices[m_size] = index; ++m_size; } @@ -71,6 +79,16 @@ namespace meshkernel // begin and end (probably const only needed) for stl algos + // auto begin() const + // { + // return m_indices.begin(); + // } + + // auto end() const + // { + // return m_indices.begin() + m_size; + // } + std::array::const_iterator begin() const { return m_indices.begin(); @@ -87,6 +105,7 @@ namespace meshkernel } private: + // std::vector m_indices; std::array m_indices; UInt m_size = 0; }; @@ -154,12 +173,13 @@ namespace meshkernel void Compute(const std::span& xNodes, const std::span& yNodes); - std::vector m_nodes; ///< x-node values - std::vector m_faceNodes; ///< Face nodes flat array passed to the triangulation library - std::vector m_edgeNodes; ///< Edge nodes flat array passed to the triangulation library - std::vector m_faceEdges; ///< Face edges flat array passed to the triangulation library - std::vector> m_edgesFaces; ///< edge-face connectivity, generated from triangulation data - std::vector> m_nodesEdges; ///< node-edge connectivity, generated from triangulation data + std::vector m_nodes; ///< x-node values + std::vector m_faceNodes; ///< Face nodes flat array passed to the triangulation library + std::vector m_edgeNodes; ///< Edge nodes flat array passed to the triangulation library + std::vector m_faceEdges; ///< Face edges flat array passed to the triangulation library + std::vector> m_edgesFaces; ///< edge-face connectivity, generated from triangulation data + std::vector> m_nodesEdges; ///< node-edge connectivity, generated from triangulation data + // std::vector> m_nodesEdges; ///< node-edge connectivity, generated from triangulation data std::vector m_elementCentres; ///< Array of the centres of the elements diff --git a/libs/MeshKernel/include/MeshKernel/SampleInterpolator.hpp b/libs/MeshKernel/include/MeshKernel/SampleInterpolator.hpp index feaf46857..933edeaae 100644 --- a/libs/MeshKernel/include/MeshKernel/SampleInterpolator.hpp +++ b/libs/MeshKernel/include/MeshKernel/SampleInterpolator.hpp @@ -197,7 +197,11 @@ namespace meshkernel m_interpolationParameters(interpolationParameters), m_strategy(averaging::AveragingStrategyFactory::GetAveragingStrategy(interpolationParameters.m_method, interpolationParameters.m_minimumNumberOfSamples, - projection)) {} + projection)), + m_nodeRTree(RTreeFactory::Create(projection)) + { + m_nodeRTree->BuildTree(m_samplePoints); + } /// @brief Constructor. /// @@ -211,7 +215,11 @@ namespace meshkernel m_interpolationParameters(interpolationParameters), m_strategy(averaging::AveragingStrategyFactory::GetAveragingStrategy(interpolationParameters.m_method, interpolationParameters.m_minimumNumberOfSamples, - projection)) {} + projection)), + m_nodeRTree(RTreeFactory::Create(projection)) + { + m_nodeRTree->BuildTree(m_samplePoints); + } /// @brief Get the number of nodes of size of the sample data. UInt Size() const override; @@ -277,7 +285,6 @@ namespace meshkernel const Projection projection, std::vector& sampleCache) const; - std::vector m_samplePoints; // SHould use the m_projection from the mesh in the interpolate function or @@ -293,7 +300,6 @@ namespace meshkernel ///< RTree of mesh nodes std::unique_ptr m_nodeRTree; - }; } // namespace meshkernel diff --git a/libs/MeshKernel/src/CasulliRefinement.cpp b/libs/MeshKernel/src/CasulliRefinement.cpp index e82cc4cb7..a48b68386 100644 --- a/libs/MeshKernel/src/CasulliRefinement.cpp +++ b/libs/MeshKernel/src/CasulliRefinement.cpp @@ -802,6 +802,13 @@ void meshkernel::CasulliRefinement::ComputeNewNodes(Mesh2D& mesh, std::vector& newNodes) { + + if (newNodeId == constants::missing::uintValue) + { + // TODO is this ok to do? + return; + } + UInt edgeId1 = edge1Index; UInt edgeId2 = edge2Index; diff --git a/libs/MeshKernel/src/Mesh2D.cpp b/libs/MeshKernel/src/Mesh2D.cpp index 58fe67267..20524fa8b 100644 --- a/libs/MeshKernel/src/Mesh2D.cpp +++ b/libs/MeshKernel/src/Mesh2D.cpp @@ -1505,9 +1505,15 @@ void Mesh2D::MakeDualFace(UInt node, double enlargementFactor, std::vector elementsChecked; + BoundedArray<4 * MaximumNumberOfEdgesPerNode> elementsChecked; elementsChecked.push_back(faceId); for (UInt i = 0; i < edgeIds.size(); ++i) @@ -269,6 +269,7 @@ meshkernel::UInt meshkernel::MeshTriangulation::FindNearestFace(const Point& pnt } } } + std::cout << "elementsChecked.size " << elementsChecked.size() << std::endl; } } diff --git a/libs/MeshKernel/src/SampleInterpolator.cpp b/libs/MeshKernel/src/SampleInterpolator.cpp index 8001911b5..e8dfdc164 100644 --- a/libs/MeshKernel/src/SampleInterpolator.cpp +++ b/libs/MeshKernel/src/SampleInterpolator.cpp @@ -177,7 +177,6 @@ double meshkernel::SampleAveragingInterpolator::GetSearchRadiusSquared(const std for (const auto& value : searchPolygon) { auto const squaredDistance = ComputeSquaredDistance(interpolationPoint, value, projection); - std::cout << "search radius: " << value.x << ", " << value.y << " " << squaredDistance << std::endl; result = std::max(result, squaredDistance); } diff --git a/libs/MeshKernel/tests/src/MeshRefinementTests.cpp b/libs/MeshKernel/tests/src/MeshRefinementTests.cpp index c7aaf54f0..38e618be6 100644 --- a/libs/MeshKernel/tests/src/MeshRefinementTests.cpp +++ b/libs/MeshKernel/tests/src/MeshRefinementTests.cpp @@ -2907,7 +2907,7 @@ TEST(MeshRefinement, CasulliRefinementBasedOnDepthReal) mk::Print(mesh.Nodes(), mesh.Edges()); - // std::cout << "min max x " << minX << " " << maxX << std::endl; - // std::cout << "min max y " << minY << " " << maxY << std::endl; - // std::cout << "min max d " << minD << " " << maxD << std::endl; + std::cout << "min max x " << minX << " " << maxX << std::endl; + std::cout << "min max y " << minY << " " << maxY << std::endl; + std::cout << "min max d " << minD << " " << maxD << std::endl; }