Skip to main content

Sketch3d

Struct Sketch3d 

Source
pub struct Sketch3d {
    pub points: BTreeMap<PointId, Point3d>,
    pub curves: BTreeMap<CurveId, Curve3d>,
    pub constraints: BTreeMap<ConstraintId, Constraint3d>,
    pub next_id: u64,
    pub references: BTreeMap<CurveId, NurbCurve3D>,
}
Expand description

A 3-D constraint sketch (see the module docs). Ids are handed out once and never reused, as in a planar crate::Sketch.

Fields§

§points: BTreeMap<PointId, Point3d>§curves: BTreeMap<CurveId, Curve3d>§constraints: BTreeMap<ConstraintId, Constraint3d>§next_id: u64

The id the next added entity gets: one counter for all three kinds.

§references: BTreeMap<CurveId, NurbCurve3D>

The geometry of every CurveKind3d::Reference curve: given from outside, so not saved with the sketch — its owner hands it in before solving or building.

Implementations§

Source§

impl Sketch3d

Source

pub fn curve_nurbs( &self, curve: CurveId, geometry: &Enclosure3d, ) -> GeopResult<Vec<NurbCurve3D>>

The curve curve as NURBS pieces from its start to its end, each on [0, 1], built from geometry. How many pieces — an arc has one per quarter turn, or two or four, a rational quadratic’s middle weight staying positive — is decided on the sketch as drawn, which is design data, so the pieces’ names do not depend on how precisely the geometry is known.

Source

pub fn curve_polyline(&self, curve: CurveId) -> GeopResult<Vec<Vector3>>

Points along the curve curve as drawn, from its start to its end — dense enough to draw it.

Source

pub fn drawn_curves(&self) -> impl Iterator<Item = (&CurveId, &Curve3d)>

The curves that become edges, oldest first: those drawn, but for construction curves.

Source

pub fn chains(&self) -> GeopResult<Vec<Chain3d>>

The drawn curves — not construction, not references — joined into chains where they share a point (see Sketch3d::point_classes).

Each chain runs the way its oldest curve (the lowest id) does; a closed one starts at that curve, an open one at its end before it. Chains come oldest first. Fails where three curves or more meet at a point — a branch is no chain — or a single curve closes on itself.

Source§

impl Sketch3d

Source

pub fn solve(&mut self) -> GeopResult<Solve3dReport>

Moves the points so every constraint holds, as little as they allow. The sketch is moved even if they cannot all hold, as near as they come — the report says which do not.

Source

pub fn solve_with_drag( &mut self, drags: &[(PointId, Vector3)], ) -> GeopResult<Solve3dReport>

Like Sketch3d::solve, pulling each (point, target) towards its target as far as the constraints allow: dragging.

Source

pub fn check(&self) -> GeopResult<Solve3dReport>

Which constraints hold where the points are now, and what can still move — without moving anything.

Source

pub fn enclose(&self) -> GeopResult<Enclosure3d>

The sketch’s geometry as the kernel builds on it: an enclosure of the exact solution of its constraints near the solved points, every coordinate they leave free exactly as drawn (see geop_core_math::solvers::system::System::enclose). A sketch whose constraints do not hold is built as drawn. Fails where the solution cannot be proven.

Source§

impl Sketch3d

Source

pub fn wire_edges(&self) -> GeopResult<Vec<WireEdge>>

The edges of the wire (see the module docs): oldest curve first, each curve’s from its start to its end.

Source

pub fn wire_edge_nurbs( &self, curve: CurveId, geometry: &Enclosure3d, ) -> GeopResult<Vec<NurbCurve3D>>

The edges of curve (see Sketch3d::wire_edges) as NURBS on [0, 1], in order, built from geometry: the whole curve, or its pieces between the points it is cut at — a spline split at the knot of each such point, an arc rebuilt from its middle point to each end. An edge of several pieces (an arc’s quarters) is joined into one curve; an edge of one piece is that piece as it is, its weights included: a spline’s weights of one come out of each knot inserted an ulp wide, which is honest and bars nothing.

Source

pub fn point_enclosures( &self, geometry: &Enclosure3d, ) -> BTreeMap<PointId, Vector3>

Every point of the sketch that is one — the lowest id of its class (see Sketch3d::point_classes) — and where it is: the enclosure of all the points made one with it, at geometry.

Source

pub fn check_wire(&self, geometry: &Enclosure3d) -> GeopResult<()>

Checks the wire’s edges meet only at its vertices (see the module docs): two points of the sketch are nowhere at one place unless they are one point, and two drawn curves meet only at points both pass through. Says which points or curves do otherwise, and where.

Source§

impl Sketch3d

Source

pub fn new() -> Self

Source

pub fn point(&self, id: PointId) -> GeopResult<&Point3d>

Source

pub fn curve(&self, id: CurveId) -> GeopResult<&Curve3d>

Source

pub fn add_point(&mut self, at: Vector3) -> PointId

Source

pub fn add_fixed_point(&mut self, at: Vector3) -> PointId

A point given from outside the sketch, at at.

Source

pub fn add_curve(&mut self, kind: CurveKind3d) -> CurveId

Source

pub fn add_line(&mut self, start: PointId, end: PointId) -> CurveId

Source

pub fn add_arc( &mut self, start: PointId, through: PointId, end: PointId, ) -> CurveId

Source

pub fn add_helix( &mut self, start: PointId, base: PointId, top: PointId, turns: Scalar, left: bool, ) -> GeopResult<CurveId>

A helix (see CurveKind3d::Helix) with its end where the rest of it says, a new point.

Source

pub fn add_spline(&mut self, points: Vec<PointId>) -> CurveId

Source

pub fn add_reference(&mut self, curve: NurbCurve3D) -> CurveId

A curve given from outside, curve, to constrain points onto.

Source

pub fn constrain(&mut self, constraint: Constraint3d) -> ConstraintId

Source

pub fn remove( &mut self, points: &[PointId], curves: &[CurveId], constraints: &[ConstraintId], )

Removes points, curves and constraints, and everything that depends on them (see [crate::sketch::remove]) — and the geometry of the reference curves removed.

Source

pub fn point_classes(&self) -> BTreeMap<PointId, PointId>

Union-find representative of every point under Constraint3d::Coincident — the lowest id of its class: points with the same representative are one point.

Source

pub fn shared_end( &self, a: CurveId, b: CurveId, ) -> GeopResult<Option<(End, End)>>

Which ends of a and b are one point, if any.

Source

pub fn validate(&self) -> GeopResult<()>

Checks every reference and every constraint’s operands, so the solver and the curves can rely on them.

Source

pub fn adopts( &self, a: CurveId, b: CurveId, ) -> GeopResult<Option<(CurveId, End)>>

For a Constraint3d::Tangent between a and b, which spline end takes the other curve’s direction there, if one does: a spline’s end meeting a line or an arc; of two splines, the newer one’s (the higher id), so that no spline ever waits on itself. None where neither is a spline: the solver makes those two tangent.

Trait Implementations§

Source§

impl Clone for Sketch3d

Source§

fn clone(&self) -> Sketch3d

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Sketch3d

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Sketch3d

Source§

fn default() -> Sketch3d

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Sketch3d

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Sketch3d

Two sketches are the same design: the same points, curves and constraints — whatever geometry was handed in for their references.

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Sketch3d

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.