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
49 lines
1.6 KiB
C++
49 lines
1.6 KiB
C++
#include <gtest/gtest.h>
|
|
#include "vde/core/point.h"
|
|
#include <array>
|
|
|
|
using namespace vde::core;
|
|
|
|
// ═══════════════════════════════════════════════════════════
|
|
// VDE-491: as_array / from_array 自由函数测试
|
|
// ═══════════════════════════════════════════════════════════
|
|
|
|
TEST(PointArrayTest, AsArray2D) {
|
|
Point2D p(1.5, 2.5);
|
|
auto a = as_array(p);
|
|
static_assert(std::is_same_v<decltype(a), std::array<double, 2>>);
|
|
EXPECT_DOUBLE_EQ(a[0], 1.5);
|
|
EXPECT_DOUBLE_EQ(a[1], 2.5);
|
|
}
|
|
|
|
TEST(PointArrayTest, AsArray3D) {
|
|
Point3D p(1.0, 2.0, 3.0);
|
|
auto a = as_array(p);
|
|
static_assert(std::is_same_v<decltype(a), std::array<double, 3>>);
|
|
EXPECT_DOUBLE_EQ(a[0], 1.0);
|
|
EXPECT_DOUBLE_EQ(a[1], 2.0);
|
|
EXPECT_DOUBLE_EQ(a[2], 3.0);
|
|
}
|
|
|
|
TEST(PointArrayTest, FromArrayRoundTrip) {
|
|
// 2D 往返
|
|
Point2D p2(3.14, 2.71);
|
|
Point2D r2 = from_array(as_array(p2));
|
|
EXPECT_DOUBLE_EQ(r2.x(), 3.14);
|
|
EXPECT_DOUBLE_EQ(r2.y(), 2.71);
|
|
|
|
// 3D 往返
|
|
Point3D p3(-1.0, 0.5, 4.2);
|
|
Point3D r3 = from_array(as_array(p3));
|
|
EXPECT_DOUBLE_EQ(r3.x(), -1.0);
|
|
EXPECT_DOUBLE_EQ(r3.y(), 0.5);
|
|
EXPECT_DOUBLE_EQ(r3.z(), 4.2);
|
|
|
|
// Vector3D 与 Point3D 同类型,as_array/from_array 通用
|
|
Vector3D v(7.0, 8.0, 9.0);
|
|
auto va = as_array(v);
|
|
EXPECT_DOUBLE_EQ(va[2], 9.0);
|
|
Vector3D rv = from_array(va);
|
|
EXPECT_DOUBLE_EQ(rv.z(), 9.0);
|
|
}
|