You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.9 KiB
C++
60 lines
1.9 KiB
C++
/*------------------------------------------------------------------------------
|
|
* 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<double> generateAxisPoints(double start, double end, size_t pointCount)
|
|
{
|
|
std::vector<double> 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<ais::PointXYZ> filter_points(const std::vector<ais::Point> &areaPoints, const std::vector<ais::PointXYZ> &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<ais::PointXYZ> 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<double, double> &minPos, const std::pair<double, double> &maxPos,
|
|
const std::vector<ais::PointXYZ> &samplePoints, std::vector<ais::PointXYZ> &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;
|
|
}
|
|
} |