Files
ViewDesignEngine/tests/core/test_point_array.cpp
T
hm a303114ef6 VDE-584~588: Feedback from ViewDesign Batch 254-258 panels
- VDE-584: Structural FEA mesh gen - Delaunay 3D tetrahedral meshing + quality optimization + CAE format export (Abaqus/Ansys/Nastran)

- VDE-585: FeatureWorks face extraction - mesh face clustering by normal direction, face type classification (planar/cylindrical/conical/toroidal)

- VDE-586: FeatureWorks measurement - mass properties (volume/centroid/inertia), surface area, bounding box from Shape geometry

- VDE-587: Python Shape module - pybind11 bindings for Shape creation, boolean ops, measurement, serialization to JSON

- VDE-588: PDM Shape validation - mesh validity check, watertightness, closed manifold detection, file stats from Shape
2026-08-07 15:39:39 +08:00

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);
}