From 3f5e1f2aaa280d69feb6dd042d5168649376974f Mon Sep 17 00:00:00 2001 From: Fabian Reister <fabian.reister@kit.edu> Date: Tue, 24 May 2022 09:25:34 +0200 Subject: [PATCH] fix: usage of cumulativeAreas --- VirtualRobot/Visualization/TriMeshUtils.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/VirtualRobot/Visualization/TriMeshUtils.cpp b/VirtualRobot/Visualization/TriMeshUtils.cpp index 77b5d986d..8226594f5 100644 --- a/VirtualRobot/Visualization/TriMeshUtils.cpp +++ b/VirtualRobot/Visualization/TriMeshUtils.cpp @@ -24,6 +24,7 @@ #include "TriMeshUtils.h" #include "../VirtualRobotException.h" #include <Eigen/Geometry> +#include <cstddef> #include <numeric> namespace VirtualRobot { @@ -167,8 +168,9 @@ Eigen::Vector3f TriMeshUtils::sampleSurfacePoint(const std::vector<float>& cumul } float r = static_cast<float>(uniformDeviate(rand()) * totalArea); - std::vector<float>::iterator low = std::lower_bound(cumulativeAreas->begin(), cumulativeAreas->end(), r); - auto f = tri.faces[low - cumulativeAreas->begin()]; + const auto low = std::lower_bound(cumulativeAreas.begin(), cumulativeAreas.end(), r); + // const std::size_t idx = std::distance(cumulativeAreas.begin(), low); + auto f = tri.faces[low - cumulativeAreas.begin()]; float r1 = static_cast<float>(uniformDeviate(rand())); float r2 = static_cast<float>(uniformDeviate(rand())); -- GitLab