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: u64The 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
impl Sketch3d
Sourcepub fn curve_nurbs(
&self,
curve: CurveId,
geometry: &Enclosure3d,
) -> GeopResult<Vec<NurbCurve3D>>
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.
Sourcepub fn curve_polyline(&self, curve: CurveId) -> GeopResult<Vec<Vector3>>
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.
Sourcepub fn drawn_curves(&self) -> impl Iterator<Item = (&CurveId, &Curve3d)>
pub fn drawn_curves(&self) -> impl Iterator<Item = (&CurveId, &Curve3d)>
The curves that become edges, oldest first: those drawn, but for construction curves.
Sourcepub fn chains(&self) -> GeopResult<Vec<Chain3d>>
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
impl Sketch3d
Sourcepub fn solve(&mut self) -> GeopResult<Solve3dReport>
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.
Sourcepub fn solve_with_drag(
&mut self,
drags: &[(PointId, Vector3)],
) -> GeopResult<Solve3dReport>
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.
Sourcepub fn check(&self) -> GeopResult<Solve3dReport>
pub fn check(&self) -> GeopResult<Solve3dReport>
Which constraints hold where the points are now, and what can still move — without moving anything.
Sourcepub fn enclose(&self) -> GeopResult<Enclosure3d>
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
impl Sketch3d
Sourcepub fn wire_edges(&self) -> GeopResult<Vec<WireEdge>>
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.
Sourcepub fn wire_edge_nurbs(
&self,
curve: CurveId,
geometry: &Enclosure3d,
) -> GeopResult<Vec<NurbCurve3D>>
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.
Sourcepub fn point_enclosures(
&self,
geometry: &Enclosure3d,
) -> BTreeMap<PointId, Vector3>
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.
Sourcepub fn check_wire(&self, geometry: &Enclosure3d) -> GeopResult<()>
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
impl Sketch3d
pub fn new() -> Self
pub fn point(&self, id: PointId) -> GeopResult<&Point3d>
pub fn curve(&self, id: CurveId) -> GeopResult<&Curve3d>
pub fn add_point(&mut self, at: Vector3) -> PointId
Sourcepub fn add_fixed_point(&mut self, at: Vector3) -> PointId
pub fn add_fixed_point(&mut self, at: Vector3) -> PointId
A point given from outside the sketch, at at.
pub fn add_curve(&mut self, kind: CurveKind3d) -> CurveId
pub fn add_line(&mut self, start: PointId, end: PointId) -> CurveId
pub fn add_arc( &mut self, start: PointId, through: PointId, end: PointId, ) -> CurveId
Sourcepub fn add_helix(
&mut self,
start: PointId,
base: PointId,
top: PointId,
turns: Scalar,
left: bool,
) -> GeopResult<CurveId>
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.
pub fn add_spline(&mut self, points: Vec<PointId>) -> CurveId
Sourcepub fn add_reference(&mut self, curve: NurbCurve3D) -> CurveId
pub fn add_reference(&mut self, curve: NurbCurve3D) -> CurveId
A curve given from outside, curve, to constrain points onto.
pub fn constrain(&mut self, constraint: Constraint3d) -> ConstraintId
Sourcepub fn remove(
&mut self,
points: &[PointId],
curves: &[CurveId],
constraints: &[ConstraintId],
)
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.
Sourcepub fn point_classes(&self) -> BTreeMap<PointId, PointId>
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.
Which ends of a and b are one point, if any.
Sourcepub fn validate(&self) -> GeopResult<()>
pub fn validate(&self) -> GeopResult<()>
Checks every reference and every constraint’s operands, so the solver and the curves can rely on them.
Sourcepub fn adopts(
&self,
a: CurveId,
b: CurveId,
) -> GeopResult<Option<(CurveId, End)>>
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.