#include #include "vde/brep/assembly.h" #include "vde/brep/modeling.h" using namespace vde::brep; using namespace vde::core; TEST(AssemblyTest, CreateEmpty) { Assembly assy("test"); EXPECT_EQ(assy.name, "test"); EXPECT_EQ(assy.part_count(), 0u); } TEST(AssemblyTest, AddPart) { Assembly assy("test"); auto box = make_box(2, 2, 2); assy.root.add_part("box1", box); EXPECT_EQ(assy.part_count(), 1u); EXPECT_EQ(assy.node_count(), 2u); // root + box } TEST(AssemblyTest, NestedHierarchy) { Assembly assy("robot"); auto* base = assy.root.add_part("base", make_box(10, 5, 2)); auto* arm = assy.root.add_subassembly("arm"); arm->add_part("seg1", make_cylinder(1, 8)); arm->add_part("seg2", make_cylinder(1, 6)); EXPECT_EQ(assy.part_count(), 3u); EXPECT_EQ(assy.node_count(), 5u); // root + arm + seg1 + seg2 } TEST(AssemblyTest, VisitPartsWithTransform) { Assembly assy("test"); assy.root.add_part("p1", make_box(1, 1, 1)); size_t visited = 0; assy.visit_parts([&visited](const std::string& name, const BrepModel&, const Transform3D& xform) { EXPECT_EQ(name, "p1"); EXPECT_TRUE(xform.isApprox(Transform3D::Identity())); visited++; }); EXPECT_EQ(visited, 1u); }