Phase 1: Fix 6 stubs (ConstraintGraph ctor, G2/G3 continuity, surface_torsion, fill_n_sided, unfold_sheet_metal) Phase 2: New modules (as_array/from_array, closest_point BVH, tolerance_stackup WorstCase/RSS/MonteCarlo) Phase 3: Curve factories (arc_3point/rectangle/polygon/slot/ellipse/closed_from_points) + explode_to_brep Phase 4: Modeling wrappers (wrap/dome, boundary_surface_feature, create_fitting/auto_route_pipe) Phase 5: Fix pipe_surface guard, constraint_solver warnings, arc_3point angle frame; sync 6 docs to Fixed; 31 tests pass
84 lines
2.7 KiB
C++
84 lines
2.7 KiB
C++
#pragma once
|
||
#include "vde/foundation/math_types.h"
|
||
#include "vde/foundation/tolerance.h"
|
||
#include <array>
|
||
|
||
/**
|
||
* @defgroup core 核心几何模块
|
||
*
|
||
* 核心模块提供 VDE 引擎的几何操作 API:
|
||
* - 基础几何体(AABB、直线、射线、线段、平面、三角形、多边形)
|
||
* - 几何计算(距离、最近点、凸包、变换)
|
||
* - 点云配准(ICP)
|
||
* - Voronoi 图
|
||
*
|
||
* @{
|
||
*/
|
||
|
||
namespace vde::core {
|
||
|
||
/**
|
||
* @brief 通用 N 维点类型(重新导出,便于 core 模块使用)
|
||
*
|
||
* @tparam T 标量类型
|
||
* @tparam Dim 维度
|
||
*/
|
||
template <typename T, size_t Dim>
|
||
using Point = foundation::Point<T, Dim>;
|
||
|
||
/// 双精度二维点(重新导出)
|
||
using Point2D = foundation::Point2D;
|
||
/// 双精度三维点(重新导出)
|
||
using Point3D = foundation::Point3D;
|
||
/// 单精度二维点(重新导出)
|
||
using Point2f = foundation::Point2f;
|
||
/// 单精度三维点(重新导出)
|
||
using Point3f = foundation::Point3f;
|
||
|
||
/**
|
||
* @brief 通用 N 维向量类型(重新导出)
|
||
*
|
||
* @tparam T 标量类型
|
||
* @tparam Dim 维度
|
||
*/
|
||
template <typename T, size_t Dim>
|
||
using Vector = foundation::Vector<T, Dim>;
|
||
|
||
/// 双精度二维向量(重新导出)
|
||
using Vector2D = foundation::Vector2D;
|
||
/// 双精度三维向量(重新导出)
|
||
using Vector3D = foundation::Vector3D;
|
||
|
||
// ═══════════════════════════════════════════════
|
||
// VDE-491: as_array / from_array 自由函数
|
||
//
|
||
// Point3D / Vector3D 是 Eigen::Matrix<double, N, 1> 的别名,
|
||
// 不能添加成员函数。改用 inline 自由函数提供与 std::array
|
||
// 的互操作,便于序列化、C 接口绑定和跨语言互操作。
|
||
//
|
||
// 注意:Point2D 和 Vector2D 是同一类型(均 = Eigen::Matrix<double,2,1>),
|
||
// Point3D 和 Vector3D 同理。因此 as_array/from_array 对两者通用。
|
||
// ═══════════════════════════════════════════════
|
||
|
||
/// 将 Point2D/Vector2D 转换为 std::array<double, 2>
|
||
[[nodiscard]] inline std::array<double, 2> as_array(const Point2D& p) {
|
||
return {p.x(), p.y()};
|
||
}
|
||
/// 将 std::array<double, 2> 转换为 Point2D/Vector2D
|
||
[[nodiscard]] inline Point2D from_array(const std::array<double, 2>& a) {
|
||
return Point2D(a[0], a[1]);
|
||
}
|
||
|
||
/// 将 Point3D/Vector3D 转换为 std::array<double, 3>
|
||
[[nodiscard]] inline std::array<double, 3> as_array(const Point3D& p) {
|
||
return {p.x(), p.y(), p.z()};
|
||
}
|
||
/// 将 std::array<double, 3> 转换为 Point3D/Vector3D
|
||
[[nodiscard]] inline Point3D from_array(const std::array<double, 3>& a) {
|
||
return Point3D(a[0], a[1], a[2]);
|
||
}
|
||
|
||
} // namespace vde::core
|
||
|
||
/** @} */ // end of core group
|