#pragma once #include "ItemCurve.h" #include /** * 样条相关纯算法:简化曲线、最近点索引、插值。 * 无文档/视图依赖,可单独测试。 */ class SplineAlgorithm { public: /// 在曲线上找与给定点距离最近的点的索引;无点或曲线为空返回 -1 static int FindClosestPointIndex(const dfPoint& point, const CCurveEx* pCurve); /// 为每个给定点在曲线上找最近点索引,结果与 points 一一对应;无匹配时为 -1 static std::vector FindClosestPointIndices(const std::vector& points, const CCurveEx* pCurve); /// 按误差阈值简化曲线(去冗余),可限制相对原控制点数的增长 /// oldHandleCount 为 0 表示首次生成;否则若结果点数 > oldHandleCount * maxGrowthRatio 则放大误差重算 static void SimplifyCurve(CCurveEx& input, double errorThreshold, int oldHandleCount, CCurveEx& output); };