pub struct SketchData {
pub points: Vec<SketchPoint>,
pub entities: Vec<SketchEntity>,
pub constraints: Vec<SketchConstraint>,
pub next_id: u32,
}Expand description
A 2D sketch: points, entities, and the constraints between them.
Fields§
§points: Vec<SketchPoint>§entities: Vec<SketchEntity>§constraints: Vec<SketchConstraint>§next_id: u32Next unallocated SketchId.
Implementations§
Source§impl SketchData
impl SketchData
pub fn point(&self, id: u32) -> Option<&SketchPoint>
pub fn point_mut(&mut self, id: u32) -> Option<&mut SketchPoint>
pub fn point_pos(&self, id: u32) -> Option<DVec2>
pub fn entity(&self, id: u32) -> Option<&SketchEntity>
pub fn entity_mut(&mut self, id: u32) -> Option<&mut SketchEntity>
Sourcepub fn set_construction(&mut self, id: u32, construction: bool) -> bool
pub fn set_construction(&mut self, id: u32, construction: bool) -> bool
Mark an entity as construction (or geometry again). Returns whether the entity was found.
pub fn add_point(&mut self, pos: DVec2) -> u32
pub fn add_circle(&mut self, center: DVec2, radius: f64) -> u32
Sourcepub fn add_circle_with_center(&mut self, center: u32, radius: f64) -> u32
pub fn add_circle_with_center(&mut self, center: u32, radius: f64) -> u32
Add a circle about an existing center point.
Sourcepub fn add_arc(&mut self, center: u32, start: u32, end: u32) -> u32
pub fn add_arc(&mut self, center: u32, start: u32, end: u32) -> u32
Add a counter-clockwise arc through existing points.
Sourcepub fn add_rect(&mut self, corner_a: DVec2, corner_b: DVec2) -> [u32; 4]
pub fn add_rect(&mut self, corner_a: DVec2, corner_b: DVec2) -> [u32; 4]
Add an axis-aligned rectangle as 4 points + 4 lines with horizontal/vertical constraints (the standard sketcher decomposition).
Sourcepub fn delete_entity(&mut self, id: u32)
pub fn delete_entity(&mut self, id: u32)
Delete an entity, cascading to constraints that reference it and to points no longer used by any entity.
pub fn delete_constraint(&mut self, index: usize)
Sourcepub fn delete_point(&mut self, id: u32)
pub fn delete_point(&mut self, id: u32)
Delete a point, cascading to entities that use it (as endpoint or center) and to constraints that reference it — the entity cascade in turn prunes any points and constraints it orphans.
Sourcepub fn connected_components(&self) -> Vec<Vec<u32>>
pub fn connected_components(&self) -> Vec<Vec<u32>>
Group entities into maximally connected shapes.
Two entities belong to the same component when they share a point or
their points are pinned together by a SketchConstraint::Coincident
— the same reachability profile_loops chains through. Value
constraints between shapes (Distance, Parallel, …) do not merge
them. Components are returned in first-appearance order; each lists
its entity ids in sketch order.
Sourcepub fn entity_subset(&self, entity_ids: &[u32]) -> SketchData
pub fn entity_subset(&self, entity_ids: &[u32]) -> SketchData
Clone a profile-extraction view restricted to entity_ids: entities
are filtered (sketch order kept); points, constraints and next_id
are copied verbatim — unused ones are inert for profile_loops.
Not a real partition; see Self::split_off_entities for that.
Sourcepub fn geometric_components(&self, arc_segments: usize) -> Vec<Vec<u32>>
pub fn geometric_components(&self, arc_segments: usize) -> Vec<Vec<u32>>
Group entities into geometrically independent shapes: the connected components, merged (transitively) whenever their closed profile loops interact — one nested inside the other (it renders as a hole) or boundaries properly crossing (the profile is their union) — so extruding one shape never tears a hole off its outer. Components without closed loops (open chains) never merge. Groups are returned in first-appearance order, each listing its entity ids. Construction entities stay in their component’s group (they travel with the shape they’re attached to) but contribute no loops, so they never cause a merge on their own.
Sourcepub fn split_off_entities(&mut self, entity_ids: &[u32]) -> SketchData
pub fn split_off_entities(&mut self, entity_ids: &[u32]) -> SketchData
Move the given entities — with their points and every constraint fully contained in the moved set — out of this sketch into a new one.
Intended for whole components from [connected_components], where the
halves share no points. Constraints referencing both halves (e.g. a
Distance between two shapes) are dropped: they can live in neither.
next_id is carried over so ids stay unique across both halves.
Source§impl SketchData
impl SketchData
Sourcepub fn nearest_intersection(
&self,
cursor: DVec2,
tolerance: f64,
) -> Option<SketchIntersection>
pub fn nearest_intersection( &self, cursor: DVec2, tolerance: f64, ) -> Option<SketchIntersection>
The supported-pair intersection nearest cursor, within tolerance.
Supported pairs: line×line, line×circle, line×arc — construction entities included. O(pairs); sketches are small.
Sourcepub fn split_at(
&mut self,
a: u32,
b: u32,
pos: DVec2,
tolerance: f64,
) -> Result<Vec<u32>, &'static str>
pub fn split_at( &mut self, a: u32, b: u32, pos: DVec2, tolerance: f64, ) -> Result<Vec<u32>, &'static str>
Split entities a and b at their intersection nearest pos.
Exactly one shared point is created at the split, so the fragments
stay joined. First fragments keep the original entity ids (constraint,
selection and hover references stay valid); new fragments get fresh
ids and inherit construction. A fragment shorter than tolerance
is not created: that entity is left whole, while the other may still
split. A circle needs the line to cross it twice (a secant); it
becomes two arcs — one boundary per crossing — while the line still
splits only at the crossing nearest pos. Constraints referencing a
split entity are retargeted: direction/radius constraints are
duplicated onto both fragments; Tangent/PointOnCurve move to the
fragment nearest their referenced geometry.
Returns the newly created entity ids; the sketch is untouched on
Err.
Trait Implementations§
Source§impl Clone for SketchData
impl Clone for SketchData
Source§fn clone(&self) -> SketchData
fn clone(&self) -> SketchData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SketchData
impl Debug for SketchData
Source§impl Default for SketchData
impl Default for SketchData
Source§fn default() -> SketchData
fn default() -> SketchData
Source§impl<'de> Deserialize<'de> for SketchData
impl<'de> Deserialize<'de> for SketchData
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SketchData, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SketchData, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for SketchData
impl PartialEq for SketchData
Source§fn eq(&self, other: &SketchData) -> bool
fn eq(&self, other: &SketchData) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for SketchData
impl Serialize for SketchData
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for SketchData
Auto Trait Implementations§
impl Freeze for SketchData
impl RefUnwindSafe for SketchData
impl Send for SketchData
impl Sync for SketchData
impl Unpin for SketchData
impl UnsafeUnpin for SketchData
impl UnwindSafe for SketchData
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,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].