pub struct Deflection {
pub chord: f64,
pub angular: f64,
pub min_segments: usize,
pub max_segments: usize,
}Expand description
How finely to approximate a curve.
Only the chord and the angle subdivide; there is no cap on a segment’s or a triangle’s length. A straight edge is drawn as its two ends and a planar face as the triangulation of its outline, however long either is. A curved edge or face is subdivided until it meets both tolerances. Inside a curved face the grid the tolerances chose may also be spread so that no cell is many times longer than it is wide: a ratio of that grid’s own spacing, which keeps the triangles between its rows from bridging columns, not a length.
Fields§
§chord: f64The greatest allowed distance from the polyline to the curve.
angular: f64The greatest allowed turn in the tangent across one segment, in radians.
min_segments: usizeA floor on the number of segments for a curve that bends.
A closed curve needs at least three to enclose anything, and a nearly straight arc of one would otherwise collapse to a chord that misses the bulge entirely: the midpoint test is a sample, and one sample can be placed exactly where the curve happens to cross its own chord.
It does not apply to a straight curve, which is exactly represented by its endpoints. Splitting a line adds points that no tolerance asked for, and every one of them becomes a vertex in every face the edge bounds.
max_segments: usizeA ceiling, so a pathological curve cannot exhaust memory.
Reaching it is reported rather than passed off as success; see
Polyline::deflection_met.
Implementations§
Source§impl Deflection
impl Deflection
Sourcepub fn with_chord(chord: f64) -> OgeomResult<Self>
pub fn with_chord(chord: f64) -> OgeomResult<Self>
A deflection with a given chord tolerance and the default angular one.
§Errors
OgeomError::Construction if chord is
not finite and positive.
Sourcepub fn curvature_only(chord: f64, angular: f64) -> OgeomResult<Self>
pub fn curvature_only(chord: f64, angular: f64) -> OgeomResult<Self>
A deflection held to chord and angular alone, with the default
segment bounds.
The tessellation a measurement is taken against: flat faces stay as
few triangles as their outlines allow, and curved ones are drawn to
the chord. Every deflection subdivides this way (see Deflection);
this names both tolerances and checks them.
§Errors
OgeomError::Construction if chord or
angular is not finite and positive.
Sourcepub fn relative(size: f64, fraction: f64) -> OgeomResult<Self>
pub fn relative(size: f64, fraction: f64) -> OgeomResult<Self>
A deflection scaled to a model of the given size.
Relative tolerances are what a caller usually means: “a thousandth of the part” is a statement that survives the part being modelled in metres rather than millimetres, and an absolute default does not.
§Errors
OgeomError::Construction if size or
fraction is not finite and positive.
Sourcepub fn validate(&self) -> OgeomResult<()>
pub fn validate(&self) -> OgeomResult<()>
Check that the settings are usable.
§Errors
OgeomError::Construction if a tolerance
is not positive, or the segment bounds are inconsistent.
Trait Implementations§
Source§impl Clone for Deflection
impl Clone for Deflection
impl Copy for Deflection
Source§impl Debug for Deflection
impl Debug for Deflection
Source§impl Default for Deflection
impl Default for Deflection
Source§impl PartialEq for Deflection
impl PartialEq for Deflection
impl StructuralPartialEq for Deflection
Auto Trait Implementations§
impl Freeze for Deflection
impl RefUnwindSafe for Deflection
impl Send for Deflection
impl Sync for Deflection
impl Unpin for Deflection
impl UnsafeUnpin for Deflection
impl UnwindSafe for Deflection
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> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.