fix: compilation + test fixes — 26/42 failures resolved
- 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
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
#include "vde/brep/brep.h"
|
||||
#include "vde/brep/modeling.h"
|
||||
#include "vde/brep/brep_face_split.h"
|
||||
#include "vde/curves/nurbs_surface.h"
|
||||
#include <cmath>
|
||||
|
||||
using namespace vde::brep;
|
||||
using namespace vde::core;
|
||||
using namespace vde::curves;
|
||||
|
||||
// ═══════════════════════════════════════════════════════════
|
||||
// Face Splitting by Plane
|
||||
@@ -32,17 +34,11 @@ static int total_verts(const std::vector<BrepModel>& frags) {
|
||||
TEST(BrepFaceSplitTest, SplitBoxFace_ByYZPlane_YieldsTwoFragments) {
|
||||
auto box = make_box(2, 2, 2); // centered at origin, spans [-1,1]³
|
||||
|
||||
// Face 0 is the front face (-X side), a quad covering x=-1
|
||||
// Cutting with YZ plane (x=0) should split this face
|
||||
// All vertices of face 0 are at x=-1, all on negative side → single fragment
|
||||
// Let's use face 0's vertices: they're all at x=-1
|
||||
|
||||
// Instead, split face 0 with a plane that actually cuts it.
|
||||
// Face vertices are at x=-1, so use plane x = -0.5
|
||||
auto frags = split_face_by_plane(box, 0,
|
||||
// Face 5 is the x=-1 face (left side). All its vertices have x=-1.
|
||||
// Plane x=-0.5 has all face vertices on negative side → no split.
|
||||
auto frags = split_face_by_plane(box, 5,
|
||||
Point3D(-0.5, 0, 0), Vector3D(1, 0, 0));
|
||||
|
||||
// All vertices are at x=-1 (negative side of x=-0.5) → single fragment
|
||||
EXPECT_EQ(frags.size(), 1u);
|
||||
EXPECT_TRUE(frags[0].is_valid());
|
||||
EXPECT_EQ(frags[0].num_faces(), 1u);
|
||||
@@ -56,18 +52,10 @@ TEST(BrepFaceSplitTest, SplitBoxFace_ByYZPlane_YieldsTwoFragments) {
|
||||
TEST(BrepFaceSplitTest, SplitBoxFace_PlaneThroughCenter_YieldsTwoFragments) {
|
||||
auto box = make_box(2, 2, 2); // centered at origin
|
||||
|
||||
// Build a face that straddles a plane by defining the plane
|
||||
// in the middle of the box.
|
||||
// We'll verify that splitting a face where the plane
|
||||
// goes through its interior produces 2 fragments.
|
||||
|
||||
// Use x=0 plane. Some box faces are at x=±1, those won't split.
|
||||
// But we can also test with a different plane.
|
||||
|
||||
// Face 0 is at x=-1. Let's check face 0:
|
||||
auto frags0 = split_face_by_plane(box, 0,
|
||||
// Face 5 is at x=-1 (all vertices have x = -1).
|
||||
// Plane x=0 leaves it entirely negative → no split.
|
||||
auto frags0 = split_face_by_plane(box, 5,
|
||||
Point3D(0, 0, 0), Vector3D(1, 0, 0));
|
||||
// All vertices are at x=-1 → no split
|
||||
EXPECT_EQ(frags0.size(), 1u);
|
||||
|
||||
// Actually, let's create a face that crosses the plane by
|
||||
@@ -100,8 +88,9 @@ TEST(BrepFaceSplitTest, FaceOnOneSide_ReturnsSingleFragment) {
|
||||
// All box faces are axis-aligned planes. A cutting plane far
|
||||
// outside the face will leave it entirely on one side.
|
||||
|
||||
// Face 0 is at x=-1, use cutting plane at x=10
|
||||
auto frags = split_face_by_plane(box, 0,
|
||||
// Face 5 is at x=-1 (all x coordinates are -1)
|
||||
// Cutting plane at x=10 is far away → face entirely on negative side.
|
||||
auto frags = split_face_by_plane(box, 5,
|
||||
Point3D(10, 0, 0), Vector3D(1, 0, 0));
|
||||
|
||||
EXPECT_EQ(frags.size(), 1u);
|
||||
@@ -109,7 +98,7 @@ TEST(BrepFaceSplitTest, FaceOnOneSide_ReturnsSingleFragment) {
|
||||
EXPECT_EQ(frags[0].num_faces(), 1u);
|
||||
|
||||
// Fragment should have the same number of vertices as original face
|
||||
auto orig_edges = box.face_edges(0);
|
||||
auto orig_edges = box.face_edges(5);
|
||||
EXPECT_EQ(frags[0].num_vertices(), orig_edges.size());
|
||||
}
|
||||
|
||||
@@ -153,7 +142,7 @@ TEST(BrepFaceSplitTest, PlaneThroughEdge_YieldsTwoFragments) {
|
||||
{Point3D(0, 2, 0), Point3D(0, 0, 0)},
|
||||
{Point3D(2, 2, 0), Point3D(2, 0, 0)}
|
||||
};
|
||||
curves::NurbsSurface surf(grid, {0,0,1,1}, {0,0,1,1}, {}, 1, 1);
|
||||
NurbsSurface surf(grid, {0,0,1,1}, {0,0,1,1}, std::vector<std::vector<double>>{}, 1, 1);
|
||||
int sid = tri.add_surface(surf);
|
||||
|
||||
int face_id = tri.add_face(sid, {loop});
|
||||
@@ -209,7 +198,7 @@ TEST(BrepFaceSplitTest, PlaneThroughVertex_YieldsTwoFragments) {
|
||||
{Point3D(0, 2, 0), Point3D(0, 0, 0)},
|
||||
{Point3D(2, 2, 0), Point3D(2, 0, 0)}
|
||||
};
|
||||
curves::NurbsSurface surf(grid, {0,0,1,1}, {0,0,1,1}, {}, 1, 1);
|
||||
NurbsSurface surf(grid, {0,0,1,1}, {0,0,1,1}, std::vector<std::vector<double>>{}, 1, 1);
|
||||
int sid = tri.add_surface(surf);
|
||||
|
||||
int face_id = tri.add_face(sid, {loop});
|
||||
@@ -249,7 +238,7 @@ TEST(BrepFaceSplitTest, BoxFaceStraddlingPlane) {
|
||||
{Point3D(-1, 0, 1), Point3D(-1, 0, -1)},
|
||||
{Point3D( 1, 0, 1), Point3D( 1, 0, -1)}
|
||||
};
|
||||
curves::NurbsSurface surf(grid, {0,0,1,1}, {0,0,1,1}, {}, 1, 1);
|
||||
NurbsSurface surf(grid, {0,0,1,1}, {0,0,1,1}, std::vector<std::vector<double>>{}, 1, 1);
|
||||
int sid = quad.add_surface(surf);
|
||||
|
||||
int loop_id = quad.add_loop({e0, e1, e2, e3}, true);
|
||||
@@ -329,7 +318,7 @@ TEST(BrepFaceSplitTest, DiagonalPlane_SplitsQuadFace) {
|
||||
{Point3D(-1, 1, 0), Point3D(-1, -1, 0)},
|
||||
{Point3D( 1, 1, 0), Point3D( 1, -1, 0)}
|
||||
};
|
||||
curves::NurbsSurface surf(grid, {0,0,1,1}, {0,0,1,1}, {}, 1, 1);
|
||||
NurbsSurface surf(grid, {0,0,1,1}, {0,0,1,1}, std::vector<std::vector<double>>{}, 1, 1);
|
||||
int sid = quad.add_surface(surf);
|
||||
|
||||
int loop_id = quad.add_loop({e0, e1, e2, e3}, true);
|
||||
|
||||
Reference in New Issue
Block a user