bb0029234f
M1 — Generative Surfaces: - sweep_surface: Explicit/Spine/TwoGuides modes - loft_surface: multi-section interpolation + guide + tangent constraints - net_surface: bidirectional curve grid → NURBS M3 — Curve Tools + Analysis: - curve_tools: project_curve, parallel_curve, connect_curve(G1-G3), helix, isoparametric - surface_analysis: inflection_lines, checker_mapping, surface_checker_report (A/B/C/D) - 14/14 tests passed Fixed: constraint_solver.h duplicate declaration, fea_mesh.h comment syntax Pending: M2 surface editing (retrying)
66 lines
2.4 KiB
C++
66 lines
2.4 KiB
C++
#pragma once
|
||
/**
|
||
* @file control_point_edit.h
|
||
* @brief 曲面编辑 — Control Point Edit(控制点编辑)
|
||
*
|
||
* 直接修改 NURBS 曲面的指定控制点位置,返回一个新的修改后曲面。
|
||
* 保持所有权重大于 0,自动处理退化曲面。
|
||
*
|
||
* 对标 CATIA / Rhino 的控制点编辑功能。
|
||
*
|
||
* @ingroup curves
|
||
*/
|
||
|
||
#include "vde/curves/nurbs_surface.h"
|
||
#include "vde/core/point.h"
|
||
#include <vector>
|
||
#include <utility>
|
||
|
||
namespace vde::curves {
|
||
|
||
using core::Point3D;
|
||
using core::Vector3D;
|
||
|
||
// ═══════════════════════════════════════════════════════════
|
||
// Control Point Edit — 控制点编辑
|
||
// ═══════════════════════════════════════════════════════════
|
||
|
||
/// 控制点编辑结果
|
||
struct ControlPointEditResult {
|
||
NurbsSurface modified_surface; ///< 修改后的曲面
|
||
std::vector<Point3D> displacements; ///< 各控制点的实际位移
|
||
double max_displacement = 0.0; ///< 最大控制点位移
|
||
int points_modified = 0; ///< 实际修改的控制点数
|
||
bool weights_preserved = true; ///< 是否所有权重保持 > 0
|
||
};
|
||
|
||
/**
|
||
* @brief 控制点编辑
|
||
*
|
||
* 修改 NURBS 曲面的指定控制点位置,保持所有权重大于 0,
|
||
* 返回一个新的修改后曲面。原始曲面保持不变。
|
||
*
|
||
* 算法:
|
||
* 1. 复制原始曲面的控制点网格和权重网格
|
||
* 2. 将指定索引的控制点移动到新位置
|
||
* 3. 确保所有权重 >= 1e-12(防止除零)
|
||
* 4. 保留原有的节点向量和阶次
|
||
* 5. 返回新的 NurbsSurface
|
||
*
|
||
* @param surface 输入 NURBS 曲面
|
||
* @param cp_indices 待修改控制点的 (i, j) 索引列表
|
||
* @param new_positions 新位置列表,与 cp_indices 一一对应
|
||
* @return 编辑结果
|
||
*
|
||
* @pre cp_indices 和 new_positions 大小一致
|
||
* @pre 所有索引在 [0, nu]×[0, nv] 范围内
|
||
* @note 所有权重保持 > 0,若输入权重 ≤ 0 则自动修正为 1e-12
|
||
* @ingroup curves
|
||
*/
|
||
[[nodiscard]] ControlPointEditResult control_point_edit(
|
||
const NurbsSurface& surface,
|
||
const std::vector<std::pair<int, int>>& cp_indices,
|
||
const std::vector<Point3D>& new_positions);
|
||
|
||
} // namespace vde::curves
|