Files
茂之钳 bb0029234f
CI / Build & Test (push) Failing after 31s
CI / Release Build (push) Failing after 38s
Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled
feat(v12): generative surfaces (Sweep/Loft/Net) + curve tools + surface analysis
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)
2026-07-27 09:08:01 +08:00

140 lines
5.6 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
/**
* @file curve_tools.h
* @brief 曲线工具集 — 投影、偏移、连接、螺旋线、等参线
*
* 提供 CAD 级曲线操作功能:
* - project_curve_on_surface: 空间曲线 → 参数空间 p-curve(采样→投影→拟合)
* - parallel_curve: 偏移曲线(等距线)
* - connect_curve: 连接曲线(G1/G2/G3 几何连续性)
* - helix_curve: 螺旋线
* - isoparametric_curves: u/v 等参线提取
*
* project_curve_on_surface 委托给 curve_surface_projection 模块。
*
* @ingroup curves
*/
#include "vde/curves/curve_surface_projection.h"
#include "vde/curves/nurbs_curve.h"
#include "vde/curves/nurbs_surface.h"
#include "vde/core/point.h"
#include <vector>
#include <utility>
namespace vde::curves {
using core::Point3D;
using core::Vector3D;
// project_curve_on_surface is imported from curve_surface_projection.h
// (included above). Users can call it directly:
// curve_tools.h → includes curve_surface_projection.h → project_curve_on_surface available
// ═══════════════════════════════════════════════════════════
// parallel_curve
// ═══════════════════════════════════════════════════════════
/**
* @brief 计算平面曲线的等距偏移(平行曲线)
*
* 将曲线投影到参考平面(默认 XY 平面),沿平面法线方向的曲线法向偏移
* 指定距离。采样原曲线 → 在局部法线方向偏移 → 拟合新 NURBS。
*
* @param curve 原 NURBS 曲线
* @param distance 偏移距离(正值沿法线正方向,负值反向)
* @param plane_normal 参考平面法线(默认 +Z,即曲线在 XY 平面内偏移)
* @param samples 采样点数(默认 100
* @return 偏移后的 NURBS 曲线
*/
[[nodiscard]] NurbsCurve parallel_curve(
const NurbsCurve& curve,
double distance,
const Vector3D& plane_normal = Vector3D(0, 0, 1),
int samples = 100);
// ═══════════════════════════════════════════════════════════
// connect_curve
// ═══════════════════════════════════════════════════════════
/// 几何连续性级别
enum class Continuity {
G1, ///< 切线连续(位置 + 切向匹配)
G2, ///< 曲率连续(位置 + 切向 + 曲率匹配)
G3 ///< 挠率连续(位置 + 切向 + 曲率 + 挠率匹配)
};
/**
* @brief 创建连接两曲线的过渡曲线
*
* 从 c1 的终点连接到 c2 的起点,根据连续性级别匹配端点条件。
* 使用 Bézier 过渡曲线(阶次根据连续性自动选择:G1→3次, G2→5次, G3→7次)。
*
* @param c1 首曲线
* @param c2 尾曲线
* @param continuity 连续性级别
* @param samples 拟合采样点数(默认 50)
* @return 连接过渡 NURBS 曲线
*/
[[nodiscard]] NurbsCurve connect_curve(
const NurbsCurve& c1,
const NurbsCurve& c2,
Continuity continuity,
int samples = 50);
// ═══════════════════════════════════════════════════════════
// helix_curve
// ═══════════════════════════════════════════════════════════
/**
* @brief 创建螺旋线
*
* 以 axis_origin 为起点沿 axis_dir 方向生成螺旋线。
* 参数方程(柱坐标):r = radius, θ = 2π·t·n, z = height·t
* 其中 n = height / pitch 为圈数。
* 采样后拟合为 NURBS。
*
* @param axis_origin 轴线起点
* @param axis_dir 轴线方向(自动归一化)
* @param radius 螺旋半径
* @param pitch 螺距(每圈上升高度),不能为 0
* @param height 总高度(从 axis_origin 沿 axis_dir),> 0
* @param samples 每圈采样点数(默认 50)
* @return 螺旋 NURBS 曲线
*/
[[nodiscard]] NurbsCurve helix_curve(
const Point3D& axis_origin,
const Vector3D& axis_dir,
double radius,
double pitch,
double height,
int samples = 50);
// ═══════════════════════════════════════════════════════════
// isoparametric_curves
// ═══════════════════════════════════════════════════════════
/// 等参线集合
struct IsoparametricCurves {
std::vector<NurbsCurve> u_curves; ///< u = const 等参线(每条对应一个 v 向变化)
std::vector<NurbsCurve> v_curves; ///< v = const 等参线(每条对应一个 u 向变化)
};
/**
* @brief 提取 NURBS 曲面的等参线
*
* 在曲面参数域中均匀分布 u_count 条 u 等参线和 v_count 条 v 等参线。
* 等参线仅为 NURBS 曲面的 1D 截面(一个参数固定、另一参数变化)。
*
* @param surface NURBS 曲面
* @param u_count u 等参线条数(≥ 1
* @param v_count v 等参线条数(≥ 1
* @return 等参线集合
*/
[[nodiscard]] IsoparametricCurves isoparametric_curves(
const NurbsSurface& surface,
int u_count,
int v_count);
} // namespace vde::curves