mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 10:51:22 +00:00
Port: mirror emits a half that continues the chain
Carries snaporca 0231bd5b68. Parity holds: 17 files identical, 8 diverging as expected. A reflection reverses orientation, so mirror_entities now hands the reflected half back reversed in ORDER and flipped per ENTITY — an arc swapping its angles as well as its ends, a spline reversing its control points. Appending it to the source then yields one walkable chain instead of two halves meeting head-to-head, and a mirrored CCW loop stays CCW. This is the producer half of the confusion that cost three defects; the consumers (offset, and the exact loop area) keep their defensive handling, because that is what makes them correct for hand-built and imported sketches rather than only for geometry this function produced. Contract change, carried with the reason: a mirrored line's p0 is the reflection of the SOURCE's p1, and a mirrored CCW arc keeps a POSITIVE sweep — the reflection negates it, walking it the other way negates it again. Both [SketchEdit] cases updated, and a new [SketchProfile] case "a mirrored half continues the original chain" pins the property directly. Kernel here: all tests passed, 2687 assertions in 232 test cases. GUI target builds and links. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
cbbd24dcb4
commit
942f6c28c7
@@ -185,3 +185,25 @@ TEST_CASE("profile: a mirrored half offsets as one loop, not two", "[SketchProfi
|
||||
if (o.type == SketchEntity::Type::Arc)
|
||||
REQUIRE_THAT(o.radius, WithinAbs(R + d, 1e-9));
|
||||
}
|
||||
|
||||
TEST_CASE("profile: a mirrored half continues the original chain", "[SketchProfile]")
|
||||
{
|
||||
// The point of emitting the reflected half reversed: appending it to the source must give a
|
||||
// chain you can WALK, head-to-tail, with no consumer having to notice that half of it came
|
||||
// from a mirror. The end of the last source entity must be the start of the first mirrored
|
||||
// one, and the end of the last mirrored one must close back to the very first start.
|
||||
const std::vector<SketchEntity> half = {
|
||||
line({0, -15}, {50, -15}), line({50, -15}, {50, 15}), line({50, 15}, {0, 15}) };
|
||||
const auto m = SketchEngine::mirror_entities(half, Vec2d(0, 0), Vec2d(0, 1));
|
||||
REQUIRE(m.size() == 3);
|
||||
|
||||
REQUIRE_THAT((half.back().p1 - m.front().p0).norm(), WithinAbs(0.0, 1e-9));
|
||||
REQUIRE_THAT((m.back().p1 - half.front().p0).norm(), WithinAbs(0.0, 1e-9));
|
||||
|
||||
for (size_t i = 0; i + 1 < m.size(); ++i)
|
||||
REQUIRE_THAT((m[i].p1 - m[i + 1].p0).norm(), WithinAbs(0.0, 1e-9));
|
||||
|
||||
auto all = half;
|
||||
for (const auto& e : m) all.push_back(e);
|
||||
REQUIRE(closed_wires(all) == 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user