feat(v3.9): parallel OpenMP boolean + assembly instancing + update notifier
This commit is contained in:
@@ -13,3 +13,4 @@ add_vde_test(test_assembly_constraints)
|
||||
add_vde_test(test_trimmed_surface)
|
||||
add_vde_test(test_brep_heal)
|
||||
add_vde_test(test_brep_drawing)
|
||||
add_vde_test(test_assembly_instance)
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
#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::Translation(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::Translation(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);
|
||||
}
|
||||
Reference in New Issue
Block a user