mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-28 03:11:47 +00:00
Equal radius and Collinear, and one Equal button that knows what it picked
Port of snaporca 9ec6405e2d. Parity OK: 17 files identical, 8 diverging at their
expected counts (DesignPanel.cpp 32, test_slvs_constraints.cpp 3).
Measured on the CAD-1000-hours corpus: 51.5% of observed CAD time is 2D sketch
work, and dimensioning/constraining alone is 31.9% -- the largest single class.
Two constraints every industrial sketcher has were missing here.
EqualRadius fixes a dead end rather than adding a feature. Picking two circles
and pressing Equal emitted EqualLength, which maps to SLVS_C_EQUAL_LENGTH_LINES
and constrains nothing on a curve: a silent no-op with no error. Equal is now
one button with two meanings, as in Onshape and SolidWorks.
Collinear emits PARALLEL plus PT_LINE_DISTANCE=0 rather than PT_ON_LINE, whose
internal valP param this libslvs port leaves at 0, drifting an already-collinear
pair.
Both types are appended at the END of SketchConstraintType: cereal serializes it
positionally, so inserting elsewhere reinterprets every saved recipe.
VERIFICATION LIMIT, stated rather than implied: this fork's kernel suite could
NOT be run. scripts/CAD/run-kernel-tests.sh fails at CMake configure time on
find_package(assimp), before any source compiles -- a pre-existing deps gap
(snaporca-w80c), not this change. The shared sources are byte-identical to
snaporca's, where the full gate passed: kernel 2588/195 and ALL LADDERS HELD
across all seven rungs.
Also fixes two defects in this fork's scripts/CAD/run-all-checks.sh:
- `cd $(dirname $0)/..` landed in scripts/ instead of the repo root, so every
rung looked for itself under scripts/scripts/. Broken since the script moved
into scripts/CAD/; the three sibling scripts were fixed then and this was
missed, so the gate has not run since.
- C defaulted to snaporca-gui, the OTHER fork's rig container, so this fork's
gate would drive snaporca's app and report green about the wrong binary.
run-kernel-tests.sh:31 documents the identical defect being fixed once
already for the build volume; this is the third instance.
This commit is contained in:
@@ -84,7 +84,11 @@ enum class SketchConstraintType {
|
||||
Tangent, Midpoint, Symmetric, Angle,
|
||||
Radius, Diameter,
|
||||
PointOnLine, // a point lies on a line (or at signed perpendicular distance `value`)
|
||||
PointOnObject // a point lies on an entity edge (line -> PT_ON_LINE, circle -> PT_ON_CIRCLE)
|
||||
PointOnObject, // a point lies on an entity edge (line -> PT_ON_LINE, circle -> PT_ON_CIRCLE)
|
||||
// Append-only: cereal serializes this enum positionally as its underlying int, so
|
||||
// inserting anywhere but the end reinterprets every constraint in every saved recipe.
|
||||
EqualRadius,
|
||||
Collinear
|
||||
};
|
||||
|
||||
// Constraint on a SketchProfile, referencing profile point indices (a,b,c,d).
|
||||
|
||||
@@ -173,6 +173,9 @@ static SketchSolveResult solve_system(std::vector<SketchEntity>& entities,
|
||||
ref_ok = ptOf(c.ea, c.ra) && ptOf(c.eb, c.rb) && primOf(c.ec); break;
|
||||
case CT::PointOnLine: case CT::PointOnObject:
|
||||
ref_ok = ptOf(c.ea, c.ra) && primOf(c.eb); break;
|
||||
case CT::EqualRadius:
|
||||
case CT::Collinear:
|
||||
ref_ok = primOf(c.ea) && primOf(c.eb); break;
|
||||
}
|
||||
if (!ref_ok) continue;
|
||||
switch (c.type) {
|
||||
@@ -280,6 +283,20 @@ static SketchSolveResult solve_system(std::vector<SketchEntity>& entities,
|
||||
else
|
||||
b.C(SLVS_C_PT_ON_LINE, 0, ptOf(c.ea, c.ra), 0, primOf(c.eb), 0);
|
||||
break;
|
||||
case CT::EqualRadius:
|
||||
b.C(SLVS_C_EQUAL_RADIUS, 0, 0, 0, primOf(c.ea), primOf(c.eb));
|
||||
break;
|
||||
case CT::Collinear:
|
||||
// libslvs has no collinear code. Two lines are collinear iff they are parallel
|
||||
// AND a point of one lies on the other's infinite line — emit both.
|
||||
b.C(SLVS_C_PARALLEL, 0, 0, 0, primOf(c.ea), primOf(c.eb));
|
||||
// Point-on-infinite-line via PT_LINE_DISTANCE=0 rather than PT_ON_LINE: the
|
||||
// latter creates an internal `valP` param that this port's Slvs_Solve leaves at
|
||||
// 0 in the working set (ModifyToSatisfy only updates SK.param), so an already
|
||||
// collinear pair drifts. PT_LINE_DISTANCE=0 is the same condition with no extra
|
||||
// parameter, so an already-satisfied solve is a clean no-op.
|
||||
b.C(SLVS_C_PT_LINE_DISTANCE, 0, ptOf(c.eb, Role::P0), 0, primOf(c.ea), 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user