fix: shell vertex ID→map lookup, fix SEGFAULT
CI / Build & Test (push) Failing after 11s
CI / Release Build (push) Failing after 31s

This commit is contained in:
茂之钳
2026-07-24 10:11:59 +00:00
parent 080776930f
commit bfe2ecbe95
6 changed files with 808 additions and 5 deletions
+87
View File
@@ -0,0 +1,87 @@
#pragma once
#include "vde/curves/nurbs_surface.h"
#include "vde/curves/nurbs_curve.h"
#include "vde/core/point.h"
#include <vector>
namespace vde::curves {
using core::Point3D;
using core::Vector3D;
/// Offset a NURBS surface by a constant distance along its normal.
/// Computes the normal at each control point's Greville abscissa and
/// offsets the control point along that normal (Piegl & Tiller approximation).
/// @param surf Input NURBS surface
/// @param distance Offset distance (positive = outward along normal)
/// @return Offset NURBS surface (approximation)
[[nodiscard]] NurbsSurface offset_surface(const NurbsSurface& surf, double distance);
/// Trim a NURBS surface to a parameter sub-domain via reparameterization.
/// Maps the old domain [u_min,u_max]×[v_min,v_max] to [0,1]×[0,1] by
/// shifting and scaling knot vectors. Control points and weights are unchanged;
/// the surface geometry is preserved, only the parameter range changes.
/// @param surf Input surface
/// @param u_min, u_max Trimmed u range (must be within original domain)
/// @param v_min, v_max Trimmed v range (must be within original domain)
/// @return Trimmed NURBS surface
[[nodiscard]] NurbsSurface trim_surface(const NurbsSurface& surf,
double u_min, double u_max,
double v_min, double v_max);
/// Blend between two surfaces along their boundary edges.
/// Extracts boundary curves, offsets them inward by blend_radius along
/// the surface normal, and creates a ruled (lofted) surface between them.
/// @param surf_a First surface
/// @param surf_b Second surface
/// @param edge_a Edge of surf_a to blend from (0=umin, 1=umax, 2=vmin, 3=vmax)
/// @param edge_b Edge of surf_b to blend to (0=umin, 1=umax, 2=vmin, 3=vmax)
/// @param blend_radius Radius of the blend transition
/// @return Blend surface (ruled surface between offset boundary curves)
[[nodiscard]] NurbsSurface blend_surfaces(const NurbsSurface& surf_a,
const NurbsSurface& surf_b,
int edge_a, int edge_b,
double blend_radius);
/// Create a ruled surface between two NURBS curves.
/// The surface is linear (degree=1) in the ruling direction and inherits
/// the curve degree in the longitudinal direction.
/// @param curve_a First curve (v=0 edge of ruled surface)
/// @param curve_b Second curve (v=1 edge of ruled surface)
/// @return Ruled NURBS surface
[[nodiscard]] NurbsSurface ruled_surface(const NurbsCurve& curve_a,
const NurbsCurve& curve_b);
/// Create a Coons patch from four boundary curves.
/// Bilinear interpolation: S(u,v) = (1-u)*C_v0(v) + u*C_v1(v)
/// + (1-v)*C_u0(u) + v*C_u1(u)
/// - corner correction terms.
/// All four curves should have compatible degree and knot structure.
/// @param curve_u0 Boundary at v=0 (runs along u)
/// @param curve_u1 Boundary at v=1 (runs along u)
/// @param curve_v0 Boundary at u=0 (runs along v)
/// @param curve_v1 Boundary at u=1 (runs along v)
/// @return Coons patch NURBS surface
[[nodiscard]] NurbsSurface coons_patch(const NurbsCurve& curve_u0,
const NurbsCurve& curve_u1,
const NurbsCurve& curve_v0,
const NurbsCurve& curve_v1);
/// Extrude a NURBS curve along a direction vector.
/// Creates a degree(d)×1 NURBS surface where d is the curve degree.
/// First row of control points = curve CPs, last row = offset CPs.
/// @param curve Profile curve
/// @param direction Extrusion direction (will be normalized internally)
/// @param length Extrusion length
/// @return Extruded NURBS surface
[[nodiscard]] NurbsSurface extrude_curve(const NurbsCurve& curve,
const Vector3D& direction,
double length);
/// Extract a boundary isoparametric curve from a NURBS surface.
/// @param surf Input surface
/// @param edge Which boundary: 0=umin, 1=umax, 2=vmin, 3=vmax
/// @return NURBS curve along the specified boundary
[[nodiscard]] NurbsCurve extract_boundary_curve(const NurbsSurface& surf, int edge);
} // namespace vde::curves