pub struct GcsSystem { /* private fields */ }Expand description
The geometric constraint system.
Owns all entities (points, lines, circles) and constraints. Provides CRUD operations and orchestrates the solver.
Implementations§
Source§impl GcsSystem
impl GcsSystem
Sourcepub fn add_point(&mut self, data: PointData) -> Handle<PointData>
pub fn add_point(&mut self, data: PointData) -> Handle<PointData>
Add a point. Returns its handle.
Sourcepub fn point_mut(&mut self, id: Handle<PointData>) -> Option<&mut PointData>
pub fn point_mut(&mut self, id: Handle<PointData>) -> Option<&mut PointData>
Get a mutable reference to a point.
Sourcepub fn remove_point(
&mut self,
id: Handle<PointData>,
) -> Result<PointData, SketchError>
pub fn remove_point( &mut self, id: Handle<PointData>, ) -> Result<PointData, SketchError>
Remove a point. Fails if referenced by any line, circle, or constraint.
§Errors
Returns SketchError::EntityInUse if the point is referenced by a line,
circle, or constraint. Returns SketchError::InvalidHandle if the handle
is stale or invalid.
Sourcepub fn add_line(
&mut self,
p1: Handle<PointData>,
p2: Handle<PointData>,
) -> Result<Handle<LineData>, SketchError>
pub fn add_line( &mut self, p1: Handle<PointData>, p2: Handle<PointData>, ) -> Result<Handle<LineData>, SketchError>
Add a line between two existing points.
§Errors
Returns SketchError::InvalidHandle if either point handle is invalid.
Sourcepub fn remove_line(
&mut self,
id: Handle<LineData>,
) -> Result<LineData, SketchError>
pub fn remove_line( &mut self, id: Handle<LineData>, ) -> Result<LineData, SketchError>
Remove a line. Fails if referenced by any constraint.
§Errors
Returns SketchError::EntityInUse if the line is referenced by a constraint.
Returns SketchError::InvalidHandle if the handle is stale or invalid.
Sourcepub fn add_circle(
&mut self,
center: Handle<PointData>,
radius: f64,
) -> Result<Handle<CircleData>, SketchError>
pub fn add_circle( &mut self, center: Handle<PointData>, radius: f64, ) -> Result<Handle<CircleData>, SketchError>
Add a circle with a center point and radius.
§Errors
Returns SketchError::InvalidHandle if the center point handle is invalid.
Sourcepub fn circle(&self, id: Handle<CircleData>) -> Option<&CircleData>
pub fn circle(&self, id: Handle<CircleData>) -> Option<&CircleData>
Get a circle by handle.
Sourcepub fn remove_circle(
&mut self,
id: Handle<CircleData>,
) -> Result<CircleData, SketchError>
pub fn remove_circle( &mut self, id: Handle<CircleData>, ) -> Result<CircleData, SketchError>
Remove a circle. Fails if referenced by any constraint.
§Errors
Returns SketchError::EntityInUse if the circle is referenced by a constraint.
Returns SketchError::InvalidHandle if the handle is stale or invalid.
Sourcepub fn add_arc(
&mut self,
center: Handle<PointData>,
start: Handle<PointData>,
end: Handle<PointData>,
) -> Result<Handle<ArcData>, SketchError>
pub fn add_arc( &mut self, center: Handle<PointData>, start: Handle<PointData>, end: Handle<PointData>, ) -> Result<Handle<ArcData>, SketchError>
Add an arc defined by center, start, and end points.
Auto-adds an internal PointOnArc(end, arc) constraint so that
dist(center, end) == dist(center, start) is maintained dynamically
as the start point moves.
§Errors
Returns SketchError::InvalidHandle if any point handle is invalid.
Sourcepub fn arc_mut(&mut self, id: Handle<ArcData>) -> Option<&mut ArcData>
pub fn arc_mut(&mut self, id: Handle<ArcData>) -> Option<&mut ArcData>
Get a mutable reference to an arc.
Sourcepub fn remove_arc(
&mut self,
id: Handle<ArcData>,
) -> Result<ArcData, SketchError>
pub fn remove_arc( &mut self, id: Handle<ArcData>, ) -> Result<ArcData, SketchError>
Sourcepub fn add_constraint(
&mut self,
constraint: Constraint,
) -> Result<Handle<ConstraintEntry>, SketchError>
pub fn add_constraint( &mut self, constraint: Constraint, ) -> Result<Handle<ConstraintEntry>, SketchError>
Add a constraint. Validates that all referenced entities exist.
§Errors
Returns SketchError::InvalidHandle if any entity referenced by the
constraint does not exist.
Sourcepub fn remove_constraint(
&mut self,
id: Handle<ConstraintEntry>,
) -> Result<(), SketchError>
pub fn remove_constraint( &mut self, id: Handle<ConstraintEntry>, ) -> Result<(), SketchError>
Remove a constraint by handle.
§Errors
Returns SketchError::InvalidHandle if the handle is stale or invalid.
Sourcepub fn constraint(&self, id: Handle<ConstraintEntry>) -> Option<&Constraint>
pub fn constraint(&self, id: Handle<ConstraintEntry>) -> Option<&Constraint>
Get a constraint by handle.
Sourcepub fn constraint_count(&self) -> usize
pub fn constraint_count(&self) -> usize
Number of constraints (includes internal arc constraints).
Sourcepub fn point_count(&self) -> usize
pub fn point_count(&self) -> usize
Number of points.
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Number of lines.
Sourcepub fn circle_count(&self) -> usize
pub fn circle_count(&self) -> usize
Number of circles.
Sourcepub fn solve(
&mut self,
max_iterations: usize,
tolerance: f64,
) -> Result<SolveResult, SketchError>
pub fn solve( &mut self, max_iterations: usize, tolerance: f64, ) -> Result<SolveResult, SketchError>
Solve the constraint system.
Modifies entity positions in-place to satisfy all constraints.
§Errors
Returns SketchError if the system parameters are in an invalid state.
The Result wrapper is retained for future error paths (e.g. singular
Jacobian detection).
Sourcepub fn dof(&mut self) -> DofAnalysis
pub fn dof(&mut self) -> DofAnalysis
Analyze degrees of freedom in the current system.
Sourcepub fn points(&self) -> impl Iterator<Item = (Handle<PointData>, &PointData)>
pub fn points(&self) -> impl Iterator<Item = (Handle<PointData>, &PointData)>
Iterate over all points.
Sourcepub fn lines(&self) -> impl Iterator<Item = (Handle<LineData>, &LineData)>
pub fn lines(&self) -> impl Iterator<Item = (Handle<LineData>, &LineData)>
Iterate over all lines.
Sourcepub fn circles(&self) -> impl Iterator<Item = (Handle<CircleData>, &CircleData)>
pub fn circles(&self) -> impl Iterator<Item = (Handle<CircleData>, &CircleData)>
Iterate over all circles.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GcsSystem
impl RefUnwindSafe for GcsSystem
impl Send for GcsSystem
impl Sync for GcsSystem
impl Unpin for GcsSystem
impl UnsafeUnpin for GcsSystem
impl UnwindSafe for GcsSystem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more