Skip to content

Commit 0a5355f

Browse files
zmerlynnclaude
andcommitted
fuzz: update harness for CrossSection API break (elalish#1760)
CrossSection::Compose removed - replace with BatchBoolean(Add). CrossSection::FillRule enum removed - drop from constructors (new default uses positive winding, same semantics as FillRule::Positive). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4da787f commit 0a5355f

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

test/cross_section_fuzz.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,8 @@ void PrismBooleanMatchesCrossSection(int sidesA, double radiusA, int sidesB,
593593
void DecomposeComposeAndHull(const std::vector<double>& radii, int copies,
594594
double spacing) {
595595
const auto stars = SeparatedStars(radii, copies, spacing);
596-
const auto input = manifold::CrossSection::Compose(stars);
596+
const auto input =
597+
manifold::CrossSection::BatchBoolean(stars, manifold::OpType::Add);
597598
ExpectCrossSectionValid(input);
598599
if (input.IsEmpty() || std::fabs(input.Area()) <= 1e-9) return;
599600

@@ -607,7 +608,8 @@ void DecomposeComposeAndHull(const std::vector<double>& radii, int copies,
607608
EXPECT_NEAR(componentArea, input.Area(),
608609
1e-6 * (1.0 + std::fabs(input.Area())));
609610

610-
const auto recomposed = manifold::CrossSection::Compose(components);
611+
const auto recomposed =
612+
manifold::CrossSection::BatchBoolean(components, manifold::OpType::Add);
611613
ExpectCrossSectionValid(recomposed);
612614
EXPECT_NEAR(recomposed.Area(), input.Area(),
613615
1e-6 * (1.0 + std::fabs(input.Area())));
@@ -660,7 +662,8 @@ void BatchBooleanSeparated(int sides, double radius, int copies,
660662
void DecomposedExtrusionsRecompose(int sides, double radius, int copies,
661663
double spacing) {
662664
const auto sections = SeparatedRegulars(sides, radius, copies, spacing);
663-
const auto input = manifold::CrossSection::Compose(sections);
665+
const auto input =
666+
manifold::CrossSection::BatchBoolean(sections, manifold::OpType::Add);
664667
ExpectCrossSectionValid(input);
665668

666669
const auto components = input.Decompose();
@@ -903,13 +906,11 @@ void ApexSkipNearLine(double apexPerpDist, double crossOffset) {
903906
{crossOffset - 0.05, 2.0}};
904907

905908
const manifold::Polygons inputAB{tri, quad};
906-
const manifold::CrossSection cs(inputAB,
907-
manifold::CrossSection::FillRule::Positive);
909+
const manifold::CrossSection cs(inputAB);
908910
ExpectCrossSectionValid(cs);
909911

910912
const manifold::Polygons inputABA{tri, quad, tri};
911-
const manifold::CrossSection csDup(
912-
inputABA, manifold::CrossSection::FillRule::Positive);
913+
const manifold::CrossSection csDup(inputABA);
913914
ExpectCrossSectionValid(csDup);
914915
EXPECT_NEAR(cs.Area(), csDup.Area(), 1e-6 * (1.0 + std::fabs(cs.Area())));
915916
}
@@ -1410,8 +1411,7 @@ void WindingFilterStarburstStress(int numStrips, double angleSpread,
14101411
{10.0 * cosA + stripWidth * sinA, 10.0 * sinA - stripWidth * cosA}};
14111412
strips.push_back(rect);
14121413
}
1413-
const manifold::CrossSection cs(strips,
1414-
manifold::CrossSection::FillRule::Positive);
1414+
const manifold::CrossSection cs(strips);
14151415
ExpectCrossSectionValid(cs);
14161416
if (cs.IsEmpty() || std::fabs(cs.Area()) <= 1e-9) return;
14171417

@@ -1993,11 +1993,11 @@ TEST(CrossSectionFuzz, DISABLED_GauntletIndependentAreaAnchors) {
19931993
/*expectDisjointSum=*/true);
19941994
}
19951995

1996-
// Decompose/Compose round-trip on a HOLED CrossSection. The existing
1996+
// Decompose/BatchBoolean(Add) round-trip on a HOLED CrossSection. The existing
19971997
// DecomposeComposeAndHull covers separated stars (no negative-orientation
19981998
// rings), which doesn't exercise hole containment in the decompose
19991999
// path. Build a holed shape via outer - inner_translated_subtract, then
2000-
// Decompose -> Compose and assert area + NumContour preservation.
2000+
// Decompose -> BatchBoolean(Add) and assert area + NumContour preservation.
20012001
void DecomposeRecomposeWithHoles(const std::vector<double>& outerRadii,
20022002
const std::vector<double>& holeRadii,
20032003
double holeOffsetX, double holeOffsetY) {
@@ -2035,12 +2035,13 @@ void DecomposeRecomposeWithHoles(const std::vector<double>& outerRadii,
20352035
EXPECT_EQ(componentContourSum, holed.NumContour())
20362036
<< "Decompose split or merged contours unexpectedly";
20372037

2038-
const auto recomposed = manifold::CrossSection::Compose(components);
2038+
const auto recomposed =
2039+
manifold::CrossSection::BatchBoolean(components, manifold::OpType::Add);
20392040
ExpectCrossSectionValid(recomposed);
20402041
EXPECT_NEAR(recomposed.Area(), holed.Area(), tol)
2041-
<< "Compose(Decompose(holed)) changed area";
2042+
<< "BatchBoolean(Add, Decompose(holed)) changed area";
20422043
EXPECT_EQ(recomposed.NumContour(), holed.NumContour())
2043-
<< "Compose(Decompose(holed)) changed contour count";
2044+
<< "BatchBoolean(Add, Decompose(holed)) changed contour count";
20442045
}
20452046

20462047
// Offset round-trip on convex inputs: input.Offset(d, Miter).Offset(-d,

0 commit comments

Comments
 (0)