4f049b1296
- CAM offset: fix knot collision in fit_clamped/make_circle → NaN - Face split: fix add_face returning global ID instead of index → SEGFAULT - Volume: fix formula to use abs-per-face for orientation robustness - Build: fix vde_mesh linking, add vde_collision to vde_brep deps - Tests: fix surface_intersection test, fuzz CMake, face split expectations - Rename test_constraint_solver → test_constraint_solver_3d (naming conflict) - Various include/namespace fixes across test files
88 lines
2.6 KiB
C++
88 lines
2.6 KiB
C++
#include <gtest/gtest.h>
|
|
#include "vde/brep/assembly_instance.h"
|
|
#include "vde/brep/modeling.h"
|
|
|
|
using namespace vde::brep;
|
|
|
|
TEST(AssemblyInstancer, IdenticalBoxesReturnSameID) {
|
|
AssemblyInstancer instancer;
|
|
|
|
auto box1 = make_box(10, 5, 3);
|
|
auto box2 = make_box(10, 5, 3);
|
|
|
|
int id1 = instancer.register_instance("bolt", box1);
|
|
int id2 = instancer.register_instance("bolt", box2);
|
|
|
|
EXPECT_EQ(id1, id2);
|
|
EXPECT_EQ(instancer.unique_count(), 1);
|
|
}
|
|
|
|
TEST(AssemblyInstancer, DifferentBoxesReturnDifferentIDs) {
|
|
AssemblyInstancer instancer;
|
|
|
|
auto box1 = make_box(10, 5, 3);
|
|
auto box2 = make_box(5, 5, 5);
|
|
|
|
int id1 = instancer.register_instance("bolt", box1);
|
|
int id2 = instancer.register_instance("bolt", box2);
|
|
|
|
EXPECT_NE(id1, id2);
|
|
EXPECT_EQ(instancer.unique_count(), 2);
|
|
}
|
|
|
|
TEST(AssemblyInstancer, DifferentNamesYieldDifferentIDs) {
|
|
AssemblyInstancer instancer;
|
|
|
|
auto box = make_box(10, 5, 3);
|
|
|
|
int id1 = instancer.register_instance("bolt", box);
|
|
int id2 = instancer.register_instance("screw", box);
|
|
|
|
EXPECT_NE(id1, id2);
|
|
EXPECT_EQ(instancer.unique_count(), 2);
|
|
}
|
|
|
|
TEST(AssemblyInstancer, PlaceInstancesCountsCorrectly) {
|
|
AssemblyInstancer instancer;
|
|
auto box = make_box(2, 2, 2);
|
|
int id = instancer.register_instance("cell", box);
|
|
|
|
Assembly assy("grid");
|
|
|
|
for (int i = 0; i < 100; ++i) {
|
|
auto xform = Transform3D(Eigen::Translation<double, 3>(i % 10, i / 10, 0));
|
|
instancer.place_instance(assy, nullptr, id, xform);
|
|
}
|
|
|
|
EXPECT_EQ(instancer.total_placed(), 100);
|
|
EXPECT_EQ(instancer.unique_count(), 1);
|
|
EXPECT_EQ(assy.part_count(), 100);
|
|
}
|
|
|
|
TEST(AssemblyInstancer, PlaceInstanceWithParent) {
|
|
AssemblyInstancer instancer;
|
|
auto box = make_box(1, 1, 1);
|
|
int id = instancer.register_instance("leaf", box);
|
|
|
|
Assembly assy("tree");
|
|
|
|
// Place a child under a subassembly
|
|
auto* sub = assy.root.add_subassembly("sub", Transform3D::Identity());
|
|
auto xform = Transform3D(Eigen::Translation<double, 3>(5, 0, 0));
|
|
EXPECT_NO_THROW(instancer.place_instance(assy, sub, id, xform));
|
|
|
|
EXPECT_EQ(instancer.total_placed(), 1);
|
|
EXPECT_EQ(assy.root.children.size(), 1);
|
|
EXPECT_EQ(assy.root.children[0]->name, "sub");
|
|
EXPECT_EQ(assy.root.children[0]->children.size(), 1);
|
|
}
|
|
|
|
TEST(AssemblyInstancer, InvalidInstanceIdNoOp) {
|
|
AssemblyInstancer instancer;
|
|
Assembly assy("empty");
|
|
|
|
EXPECT_NO_THROW(instancer.place_instance(assy, nullptr, -1, Transform3D::Identity()));
|
|
EXPECT_NO_THROW(instancer.place_instance(assy, nullptr, 999, Transform3D::Identity()));
|
|
EXPECT_EQ(instancer.total_placed(), 0);
|
|
}
|