Implemented: VDE-234: unfold_flat_pattern (sheet metal) VDE-236: push_face/pull_edge/move_face_vector/rotate_face (direct modeling) VDE-242: three_plus_two_toolpath (CAM 3+2-axis) Closed (Out of Scope): 32 CAE/CFD/rendering/PLM issues Fixed (already exists): 5 kinematics/LOD/reverse_engineering/PMI
86 lines
2.7 KiB
C++
86 lines
2.7 KiB
C++
#include <gtest/gtest.h>
|
|
#include "vde/core/cam_5axis.h"
|
|
#include "vde/core/cam_toolpath.h"
|
|
#include "vde/core/cam_strategies.h"
|
|
#include "vde/brep/brep.h"
|
|
#include "vde/brep/modeling.h"
|
|
#include <cmath>
|
|
|
|
using namespace vde::core;
|
|
using namespace vde::brep;
|
|
using namespace vde::curves;
|
|
|
|
// ===========================================================================
|
|
// 辅助函数
|
|
// ===========================================================================
|
|
|
|
/// 创建测试用 B-Rep 方体
|
|
static BrepModel make_test_box() {
|
|
return make_box(50, 50, 30);
|
|
}
|
|
|
|
// ===========================================================================
|
|
// VDE-242: three_plus_two_toolpath 测试 (4项)
|
|
// ===========================================================================
|
|
|
|
TEST(Cam3Plus2Test, ThreePlusTwoToolpath_ProducesOutput) {
|
|
auto box = make_test_box();
|
|
Tool tool;
|
|
tool.diameter = 10.0;
|
|
ThreePlusTwoParams params;
|
|
params.tilt_angle = 15.0;
|
|
params.step_down = 5.0;
|
|
params.step_over = 6.0;
|
|
|
|
auto tp = three_plus_two_toolpath(box, tool, params);
|
|
EXPECT_FALSE(tp.segments.empty());
|
|
EXPECT_GT(tp.segments.size(), static_cast<size_t>(0));
|
|
EXPECT_EQ(tp.name, "3+2-Axis Milling");
|
|
}
|
|
|
|
TEST(Cam3Plus2Test, ThreePlusTwoToolpath_HasCorrectDefaults) {
|
|
auto box = make_test_box();
|
|
Tool tool;
|
|
tool.diameter = 10.0;
|
|
ThreePlusTwoParams params;
|
|
|
|
auto tp = three_plus_two_toolpath(box, tool, params);
|
|
EXPECT_FALSE(tp.segments.empty());
|
|
EXPECT_DOUBLE_EQ(tp.safe_z, params.safe_z);
|
|
EXPECT_DOUBLE_EQ(tp.cut_z, params.cut_z);
|
|
EXPECT_DOUBLE_EQ(tp.step_down, params.step_down);
|
|
}
|
|
|
|
TEST(Cam3Plus2Test, ThreePlusTwoToolpath_ZeroStepDownSafe) {
|
|
auto box = make_test_box();
|
|
Tool tool;
|
|
ThreePlusTwoParams params;
|
|
params.step_down = 0.0;
|
|
params.step_over = 10.0;
|
|
|
|
auto tp = three_plus_two_toolpath(box, tool, params);
|
|
// 即使 step_down=0,也应产生至少一个段
|
|
EXPECT_FALSE(tp.segments.empty());
|
|
}
|
|
|
|
TEST(Cam3Plus2Test, ThreePlusTwoToolpath_ContainsRapidAndLinear) {
|
|
auto box = make_test_box();
|
|
Tool tool;
|
|
tool.diameter = 10.0;
|
|
ThreePlusTwoParams params;
|
|
params.step_down = 20.0;
|
|
params.step_over = 30.0;
|
|
|
|
auto tp = three_plus_two_toolpath(box, tool, params);
|
|
EXPECT_FALSE(tp.segments.empty());
|
|
|
|
bool has_rapid = false;
|
|
bool has_linear = false;
|
|
for (const auto& seg : tp.segments) {
|
|
if (seg.type == PathSegmentType::Rapid) has_rapid = true;
|
|
if (seg.type == PathSegmentType::Linear) has_linear = true;
|
|
}
|
|
EXPECT_TRUE(has_rapid) << "Toolpath should contain rapid moves";
|
|
EXPECT_TRUE(has_linear) << "Toolpath should contain linear cut moves";
|
|
}
|