Files
ViewDesignEngine/include/vde/core/cam_optimization.h
T
茂之钳 2ecad1543f
CI / Build & Test (push) Failing after 1m31s
CI / Release Build (push) Failing after 31s
Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled
feat(v8): ultimate performance + CAM full optimization + visualization/IGA/quality
v8.1 — 极致性能 (SIMD + LockFree + Transaction + NUMA):
- simd_vector.h: Vec4d/Vec4f SSE/AVX/NEON auto-detect, batch AABB, SoA transpose
- concurrent_data: LockFreeQueue (MPMC CAS), LockFreeStack (Treiber), ConcurrentHashMap (64-segment sharded)
- transaction: Command pattern, UndoManager (infinite undo/redo), crash-recovery journal
- performance_tuning: NUMA-aware, cache_line aligned, prefetch, hot/cold separation
- 20 tests (concurrent + transaction), ~2600 lines

v8.2 — CAM 全面优化 + 装配模式:
- cam_optimization: chip_thinning, HSM, constant_engagement, trochoidal_turn_milling
- tool_life_management, probing_cycle, thread_milling
- cam_advanced enhanced: Mazak/Okuma/Haas/DMG post-processors (8 total)
- assembly_patterns: Circular/Rectangular/Mirror/PatternDriven/fill arrays
- assembly_feature enhanced: assembly-level PMI propagation, batch interference check
- 28 tests, compiled 0 errors (~2800 lines)

v8.3 — 可视化+压缩+IGA+质量闭环:
- visualization_quality: ambient_occlusion, edge_highlighting, wireframe, normals
- topology_compression: Brep compression, Edgebreaker, vertex quantization
- iga_prep: knot_insertion, degree_elevation, Bezier extraction for IGA analysis
- quality_feedback: design_rule_check, manufacturability, cost_estimation, quality_score (0-100)
- 28 tests, ~2349 lines

27 files, ~7750 lines, 76 tests
2026-07-26 23:13:22 +08:00

198 lines
8.5 KiB
C++
Raw 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 cam_optimization.h
* @brief CAM 综合优化 — 切屑减薄、车铣复合摆线、HSM高速加工、恒接触角铣削、刀具寿命管理
*
* cam_advanced.h 提供高级加工策略,本模块在其之上提供面向效率与刀具保护的优化:
* - chip_thinning_optimization — 切屑减薄优化,调整进给以维持恒定切屑厚度
* - trochoidal_turn_milling — 车铣复合摆线加工
* - high_speed_machining — HSM 高速加工策略(浅层大切宽)
* - constant_engagement_milling — 恒接触角铣削,保持刀具啮合角恒定
* - tool_life_management — 刀具寿命管理,基于磨损模型预测剩余寿命
*
* @ingroup core
*/
#include "vde/core/point.h"
#include "vde/core/aabb.h"
#include "vde/core/cam_toolpath.h"
#include "vde/core/cam_strategies.h"
#include "vde/core/cam_advanced.h"
#include "vde/mesh/halfedge_mesh.h"
#include <vector>
#include <string>
#include <utility>
#include <chrono>
namespace vde::brep {
class BrepModel;
} // namespace vde::brep
namespace vde::core {
using core::Point3D;
using core::Vector3D;
using core::AABB3D;
// ═══════════════════════════════════════════════════════════════════════════
// 优化参数类型
// ═══════════════════════════════════════════════════════════════════════════
/// 高速加工 (HSM) 参数
struct HSMParams {
double step_down = 0.5; ///< 每层切深 (mm) — HSM 通常浅层
double step_over = 4.0; ///< 横向步距 (mm) — HSM 大切宽
double feed_rate = 2000.0; ///< 进给速度 (mm/min)
double spindle_rpm = 15000.0; ///< 主轴转速 (rpm)
double safe_z = 15.0; ///< 安全高度 (mm)
double stock_to_leave = 0.3; ///< 留量 (mm)
double corner_radius = 2.0; ///< 拐角过渡半径 (mm)
bool trochoidal_corners = true; ///< 拐角处是否使用摆线过渡
};
/// 恒接触角铣削参数
struct ConstantEngagementParams {
double target_engagement = 45.0; ///< 目标啮合角 (度)
double step_down = 0.8; ///< 每层切深 (mm)
double feed_rate = 600.0; ///< 进给速度 (mm/min)
double safe_z = 15.0; ///< 安全高度 (mm)
double min_step_over = 0.3; ///< 最小横向步距 (mm)
double max_step_over = 4.0; ///< 最大横向步距 (mm)
double engagement_tolerance = 5.0; ///< 啮合角容差 (度)
};
/// 刀具寿命管理参数
struct ToolLifeParams {
double max_cutting_time_min = 60.0; ///< 最大切削时间 (分钟)
double max_cutting_length_m = 500.0; ///< 最大切削距离 (米)
double wear_coefficient = 1.0e-6; ///< 磨损系数 (mm³/N·m)
double critical_flank_wear = 0.3; ///< 临界后刀面磨损 (mm)
double spindle_speed_factor = 1.2; ///< 主轴转速修正系数
bool enable_adaptive_feed = true; ///< 是否启用自适应进给降级
};
/// 刀具寿命预估结果
struct ToolLifeResult {
double estimated_life_min = 0.0; ///< 预估剩余寿命 (分钟)
double accumulated_wear_mm = 0.0; ///< 累计磨损量 (mm)
double material_removed_mm3 = 0.0; ///< 已切除材料体积 (mm³)
double current_flank_wear = 0.0; ///< 当前后刀面磨损 (mm)
bool needs_replacement = false;///< 是否需要更换刀具
double recommended_feed_scale = 1.0; ///< 推荐的进给缩放系数
std::string warning_message; ///< 警告消息
};
/// 车铣复合摆线参数
struct TurnMillParams {
double stock_diameter = 0.0; ///< 毛坯直径 (mm)0 表示从模型推测
double step_down = 1.0; ///< 每层切深 (mm)
double trochoid_radius = 2.5; ///< 摆线圈半径 (mm)
double step_forward = 1.0; ///< 每圈前进量 (mm)
double feed_rate = 500.0; ///< 进给速度 (mm/min)
double spindle_rpm = 8000.0; ///< 铣主轴转速 (rpm)
double turning_rpm = 500.0; ///< 车主轴转速 (rpm)
double safe_z = 20.0; ///< 安全高度 (mm)
bool sync_axes = true; ///< C/Y 轴同步
};
// ═══════════════════════════════════════════════════════════════════════════
// CAM 优化函数
// ═══════════════════════════════════════════════════════════════════════════
/// 切屑减薄优化 (Chip Thinning Optimization)
///
/// 当径向切削深度小于刀具半径时,实际切屑厚度小于设定的每齿进给量。
/// 此函数调整进给率以补偿切屑减薄效应,维持恒定的实际切屑厚度,
/// 避免切削过薄导致刀具摩擦而非切削。
///
/// 公式: f_adj = f_nominal × (D / (2 × √(ae×(Dae)))) 当 ae < D/2
///
/// @param toolpath 原始刀路(进给率为名义值)
/// @param tool 使用的刀具
/// @return 进给补偿后的刀路
///
/// @ingroup core
[[nodiscard]] Toolpath chip_thinning_optimization(
const Toolpath& toolpath,
const Tool& tool);
/// 车铣复合摆线加工 (Trochoidal Turn-Milling)
///
/// 在车铣复合机床上使用铣刀对旋转工件进行摆线切削。
/// 工件旋转(C 轴)提供车削运动,铣刀沿径向和轴向做摆线切入。
/// 适用于轴类零件的深槽、偏心特征等。
///
/// 策略:
/// 1. 工件以 turning_rpm 旋转
/// 2. 铣刀沿径向做摆线切入(trochoid_radius / step_forward
/// 3. 轴向分层推进(step_down
///
/// @param body B-Rep 实体模型
/// @param tool 铣刀参数
/// @param params 车铣复合参数
/// @return 车铣复合刀路
///
/// @ingroup core
[[nodiscard]] Toolpath trochoidal_turn_milling(
const brep::BrepModel& body,
const Tool& tool,
const TurnMillParams& params = TurnMillParams{});
/// 高速加工 (High-Speed Machining)
///
/// 采用浅层大切宽策略,配合拐角摆线过渡以维持恒定切削负载。
/// 不同于传统粗加工的重切削,HSM 利用高主轴转速和快速进给,
/// 以"高速轻切"的方式实现更高的材料去除率。
///
/// 特点:
/// - 浅切深 (step_down ~0.5mm),大切宽 (step_over ~4mm)
/// - 拐角自动摆线过渡,避免负载突变
/// - 更高进给率 (通常 >2000 mm/min)
/// - 平滑的刀路轨迹减少加减速
///
/// @param toolpath 原始刀路(作基础路径参考)
/// @param params HSM 参数
/// @return 优化后的高速刀路
///
/// @ingroup core
[[nodiscard]] Toolpath high_speed_machining(
const Toolpath& toolpath,
const HSMParams& params);
/// 恒接触角铣削 (Constant Engagement Milling)
///
/// 在加工过程中动态调整横向步距,使刀具与材料的啮合角始终保持恒定。
/// 恒定啮合角 = 恒定切削力 = 刀具负载稳定 → 延长刀具寿命、提高表面质量。
///
/// 在进入角落或狭窄区域时减小步距,在开放区域时增大步距。
///
/// @param body B-Rep 实体模型
/// @param tool 使用的刀具
/// @param params 恒接触角参数
/// @return 恒接触角刀路
///
/// @ingroup core
[[nodiscard]] Toolpath constant_engagement_milling(
const brep::BrepModel& body,
const Tool& tool,
const ConstantEngagementParams& params = ConstantEngagementParams{});
/// 刀具寿命管理 (Tool Life Management)
///
/// 基于 Taylor 刀具寿命公式和累积磨损模型,预测刀具的剩余寿命,
/// 并在需要时建议降低进给率以延长刀具寿命至完成当前任务。
///
/// Taylor 公式: Vc × T^n = C Vc = 切削速度,T = 刀具寿命,n, C 为材料常数)
///
/// @param tool 当前刀具
/// @param material 工件材料属性
/// @param params 刀具寿命管理参数
/// @return 刀具寿命预估结果(包含磨损量和建议进给修正)
///
/// @ingroup core
[[nodiscard]] ToolLifeResult tool_life_management(
const Tool& tool,
const Material& material,
const ToolLifeParams& params = ToolLifeParams{});
} // namespace vde::core