forked from 1b-agent/opencadstudio-upstream
Add 8 geometric constraint kinds and an opt-in DWG-native persistence toggle
New ConstraintKind variants — Concentric, CenterPoint, Colinear, Midpoint, Fixed, PointOnCurve, EqualDistance, Symmetric — each built entirely from existing ocs_gcs (FreeCAD planegcs) primitives, no new solver math needed. build_constraint now returns Vec<Rc<dyn Constraint>> instead of Option<Rc<...>>, generalizing the old Coincident-only "needs a second system-level constraint" special case to every kind that needs one. Wired into the ribbon (7 new buttons), a new point+pre-selected-entity command for CenterPoint/Midpoint/PointOnCurve, a new 4-point command for EqualDistance, and the existing DWG-native class-name mapping (all 8 reuse the same generic "plain Geometrical node" path already built for Coincident/Horizontal/etc.). Deliberately not modeled: Normal and EqualCurvature, which for this app's Line/Circle-only entity model would just be Perpendicular and Equal wearing different DWG class names. Also makes DWG-native constraint persistence opt-in (Options > General, off by default) rather than unconditional: a scope that doesn't yet have the native graph is only given one when the setting is on, but a scope that already has one — from an earlier save, or a file that came from real AutoCAD — keeps getting it resynced regardless of the setting, so toggling it off never freezes a stale graph in place. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cf33a1d019
commit
31b5ef4ec3
18 files changed
+1076
-106
No files matched your search
@@ -79,6 +79,41 @@ pub enum ConstraintKind {
|
||||
Angle,
|
||||
Radius,
|
||||
Tangent,
|
||||
/// Two circles/arcs share a center — `refs`: `[center(a), center(b)]`.
|
||||
/// Solves identically to `Coincident` (`sketch_solve.rs` broadens that
|
||||
/// match arm rather than duplicating it) — only the DWG-native class
|
||||
/// name (`ACCONCENTRICCONSTRAINT` vs `ACPOINTCOINCIDENCECONSTRAINT`)
|
||||
/// and the UI entry point differ.
|
||||
Concentric,
|
||||
/// A point sits at a circle/arc's center — `refs`: `[point, center(circle)]`.
|
||||
/// Same solver math as `Coincident`/`Concentric`, different DWG class
|
||||
/// name (`ACCENTERPOINTCONSTRAINT`).
|
||||
CenterPoint,
|
||||
/// Two lines share the same infinite line — `refs`: `[whole(a), whole(b)]`.
|
||||
Colinear,
|
||||
/// A point sits at another line's midpoint — `refs`: `[point, whole(line)]`.
|
||||
Midpoint,
|
||||
/// Locks a whole entity at its current position — `refs`: `[whole(entity)]`.
|
||||
/// No `driving_param`: the target is the entity's own live geometry at
|
||||
/// solve time, not a typed value (see `sketch_solve.rs`'s `Fixed` arm).
|
||||
Fixed,
|
||||
/// A point lies anywhere along a line's or circle's curve (not
|
||||
/// restricted to an endpoint/center) — `refs`: `[point, whole(entity)]`.
|
||||
PointOnCurve,
|
||||
/// The distance between one point pair equals the distance between
|
||||
/// another — `refs`: `[p1, p2, p3, p4]` (`dist(p1,p2) == dist(p3,p4)`).
|
||||
/// AutoCAD's fourth `Equal` sub-kind (`ACEQUALDISTANCECONSTRAINT`) —
|
||||
/// see the design doc for why `EqualCurvature`, the other missing
|
||||
/// sub-kind, isn't modeled: for the only entity types this system
|
||||
/// solves (Line, Circle), it would be mathematically identical to this
|
||||
/// `Equal`'s existing circle/circle (radius) branch.
|
||||
EqualDistance,
|
||||
/// Two circles/arcs are mirror images of each other across a line —
|
||||
/// `refs`: `[center(a), center(b), whole(mirror_line)]`. Scoped to the
|
||||
/// circle-center-pair case (unambiguous with whole-entity selection);
|
||||
/// point-symmetry about a point, and symmetry between two lines, aren't
|
||||
/// modeled.
|
||||
Symmetric,
|
||||
}
|
||||
|
||||
pub type ConstraintId = u32;
|
||||
@@ -345,6 +380,14 @@ impl ConstraintKind {
|
||||
ConstraintKind::Angle => "∠",
|
||||
ConstraintKind::Radius => "R",
|
||||
ConstraintKind::Tangent => "T",
|
||||
ConstraintKind::Concentric => "◎",
|
||||
ConstraintKind::CenterPoint => "⊕",
|
||||
ConstraintKind::Colinear => "L",
|
||||
ConstraintKind::Midpoint => "M",
|
||||
ConstraintKind::Fixed => "F",
|
||||
ConstraintKind::PointOnCurve => "∈",
|
||||
ConstraintKind::EqualDistance => "≐",
|
||||
ConstraintKind::Symmetric => "S",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user