/*------------------------------------------------------------------------------ * Copyright (c) 2023 by Bai Bing (seread@163.com) * See COPYING file for copying and redistribution conditions. * * Alians IT Studio. *----------------------------------------------------------------------------*/ #include "Misc.h" namespace ais { std::vector generateAxisPoints(double start, double end, size_t pointCount) { std::vector points; double step = (end - start) / (pointCount - 1); for (size_t i = 0; i < pointCount; i++) { points.push_back(start + i * step); } return points; } AIS_EXPORT std::vector filter_points(const std::vector &areaPoints, const std::vector &samplePoints) { auto x = getAxisValues(areaPoints, Axis3DType::X); auto y = getAxisValues(areaPoints, Axis3DType::Y); auto [xMin, xMax] = getMinMax(x); auto [yMin, yMax] = getMinMax(y); std::vector filteredPoints; filteredPoints.reserve(samplePoints.size()); for (const auto &p : samplePoints) { if ((p.x >= xMin && p.x <= xMax) && (p.y >= yMin && p.y <= yMax)) { filteredPoints.push_back(p); } } return filteredPoints; } AIS_EXPORT void filter_copy_points(const std::pair &minPos, const std::pair &maxPos, const std::vector &samplePoints, std::vector &outputPoints) { auto [xMin, yMin] = minPos; auto [xMax, yMax] = maxPos; outputPoints.clear(); for (auto &p : samplePoints) { if (p.x >= xMin && p.x <= xMax && p.y >= yMin && p.y <= yMax) outputPoints.push_back(p); } return; } }