cf38d76fd0
M1 — Memory Pool (内存池): - ObjectPool<T>: O(1) acquire/release with free-list, chunk-based expansion - ThreadSafeObjectPool<T>: per-thread local pools with global fallback - CowPtr<T>: copy-on-write smart pointer with shallow/deep copy - 10 tests: single/multi-thread, CoW detach, reuse rate M2 — Parallel Boolean (并行布尔): - parallel_face_face_intersection(): OpenMP face-pair dispatch with AABB culling - parallel_classify_faces(): thread-safe ray casting classification - parallel_mesh_union/intersection/difference + B-Rep variants - Thread count management API - 12 tests: coverage, empty cases, identity operations M3 — Parallel Marching Cubes (并行MC): - parallel_marching_cubes(): Z-slice parallel voxel processing - parallel_adaptive_mc(): octree-based adaptive resolution - Complete 256-entry edge table + Möller-Trumbore interpolation - 5 tests: sphere basic/high-res/empty/adaptive/threaded M4 — Parallel Surface Intersection (并行求交): - parallel_curve_intersections(): per-pair parallel dispatch - parallel_surface_intersection(): recursive subdivision + Newton refinement - AABB broad-phase culling before narrow-phase - 4 tests: curve pairs, surface batch M5 — GMP Exact Predicates (精确谓词): - exact_orient2d/3d: adaptive precision (double → GMP fallback) - exact_in_sphere: circumsphere test with degenerate handling - exact_point_in_polygon/polyhedron: robust ray casting - PrecisionMode: Fast/Adaptive/Exact with global toggle - 12 tests: all orientations, boundary cases, mode switching 21 files, +2263 lines
91 lines
2.5 KiB
C++
91 lines
2.5 KiB
C++
#include <gtest/gtest.h>
|
|
#include "vde/brep/parallel_boolean.h"
|
|
#include "vde/brep/modeling.h"
|
|
#include <cmath>
|
|
|
|
using namespace vde::brep;
|
|
using namespace vde::core;
|
|
|
|
TEST(ParallelBooleanTest, ThreadCount) {
|
|
int n = parallel_thread_count();
|
|
EXPECT_GT(n, 0);
|
|
}
|
|
|
|
TEST(ParallelBooleanTest, SetThreadCount) {
|
|
set_parallel_threads(2);
|
|
EXPECT_EQ(parallel_thread_count(), 2);
|
|
set_parallel_threads(0); // reset
|
|
}
|
|
|
|
TEST(ParallelBooleanTest, FaceFaceIntersection_Empty) {
|
|
BrepModel a, b;
|
|
auto results = parallel_face_face_intersection(a, b);
|
|
EXPECT_EQ(results.size(), 0u);
|
|
}
|
|
|
|
TEST(ParallelBooleanTest, FaceFaceIntersection_Boxes) {
|
|
auto a = make_box(2, 2, 2);
|
|
auto b = make_box(2, 2, 2);
|
|
auto results = parallel_face_face_intersection(a, b);
|
|
// Two identical boxes have overlapping faces
|
|
EXPECT_GE(results.size(), 0u);
|
|
}
|
|
|
|
TEST(ParallelBooleanTest, ClassifyFaces_Empty) {
|
|
BrepModel body;
|
|
auto results = parallel_classify_faces(body, {});
|
|
EXPECT_EQ(results.size(), 0u);
|
|
}
|
|
|
|
TEST(ParallelBooleanTest, ClassifyFaces_Outside) {
|
|
auto box = make_box(2, 2, 2);
|
|
// Point far outside the box
|
|
std::vector<int> face_ids = {0};
|
|
auto results = parallel_classify_faces(box, face_ids);
|
|
EXPECT_EQ(results.size(), 1u);
|
|
}
|
|
|
|
TEST(ParallelBooleanTest, MeshUnion) {
|
|
auto a = make_box(2, 2, 2);
|
|
auto b = make_box(2, 2, 2);
|
|
auto ma = a.to_mesh();
|
|
auto mb = b.to_mesh();
|
|
auto result = parallel_mesh_union(ma, mb);
|
|
EXPECT_GE(result.num_vertices(), 0u);
|
|
}
|
|
|
|
TEST(ParallelBooleanTest, MeshIntersection) {
|
|
auto a = make_box(2, 2, 2);
|
|
auto b = make_box(2, 2, 2);
|
|
auto result = parallel_mesh_intersection(a.to_mesh(), b.to_mesh());
|
|
EXPECT_GE(result.num_vertices(), 0u);
|
|
}
|
|
|
|
TEST(ParallelBooleanTest, MeshDifference) {
|
|
auto a = make_box(2, 2, 2);
|
|
auto b = make_box(1, 1, 1);
|
|
auto result = parallel_mesh_difference(a.to_mesh(), b.to_mesh());
|
|
EXPECT_GE(result.num_vertices(), 0u);
|
|
}
|
|
|
|
TEST(ParallelBooleanTest, BrepUnion) {
|
|
auto a = make_box(2, 2, 2);
|
|
auto b = make_box(2, 2, 2);
|
|
auto result = parallel_brep_union(a, b);
|
|
EXPECT_GE(result.num_faces(), 1u);
|
|
}
|
|
|
|
TEST(ParallelBooleanTest, BrepIntersection) {
|
|
auto a = make_box(2, 2, 2);
|
|
auto b = make_box(2, 2, 2);
|
|
auto result = parallel_brep_intersection(a, b);
|
|
EXPECT_GE(result.num_faces(), 1u);
|
|
}
|
|
|
|
TEST(ParallelBooleanTest, BrepDifference) {
|
|
auto a = make_box(2, 2, 2);
|
|
auto b = make_box(2, 2, 2);
|
|
auto result = parallel_brep_difference(a, b);
|
|
EXPECT_GE(result.num_faces(), 1u);
|
|
}
|