Skip to main content

SegmentChain

Struct SegmentChain 

Source
pub struct SegmentChain(/* private fields */);
Expand description

A sequence of Segments where each segment is “connected” to its successor (end / stop point of a segment is approximately equal to the start point of the successor).

The approximate equality of start and end point is defined by DEFAULT_EPSILON and DEFAULT_MAX_ULPS:

approx::ulps_eq!(chain[i].stop(), chain[i+1].start(), epsilon = DEFAULT_EPSILON, max_ulps = DEFAULT_MAX_ULPS)

A segment chain can intersect itself (i.e. at least two of its segments intersect each other). This can be tested using its Composite trait implementation:

use planar_geo::prelude::*;

let chain = SegmentChain::from_points(&[[0.0, 0.0], [2.0, 2.0], [0.0, 2.0], [2.0, 0.0]]);
assert_eq!(chain.intersections_segment_chain(&chain, 0.0, 0).count(), 1);

§Constructing a segment chain

A segment chain is essentially a newtype wrapper around a VecDeque<Segment> and therefore exposes many of the same methods. For example, a segment chain can be built via push_front and push_back just like a VecDeque. The extend_front and extend_back methods can be used to implicitly add LineSegments.

There are multiple constructors available:

  • new: A new, empty segment chain with no segment.
  • with_capacity: A new, empty segment chain with a defined space for segments preallocated with no segment.
  • from_points: A segment chain consisting of LineSegments which connect the given points.
  • from_iter: A segment chain consisting of the segments given by an iterator. In case two subsequent segments are not connected, a “filler” LineSegment is introduced between them.

§Modifying a segment chain

To uphold the “connection” property, it is not possible to manipulate arbitrary segments, which is why methods like VecDeque::get_mut are missing. It is however possible to manipulate the whole segment chain via the Transformation implementation. Additionally, individual segments can be removed from the ends of the chain with pop_front and pop_back.

§Access of individual segments

Accessing individual segments is possible via indexing (which panics when out-of-bounds) and the get method (which returns None when out-of-bounds). As in the underlying deque, the segments are not necessarily contiguous in memory and can generally only be accessed via two slices with the as_slices method. SegmentChain does however expose the make_contiguous to store the segments contiguous in memory.

§Serialization and deserialization

When the serde feature is enabled, a segment chain can be serialized and deserialized using the serde crate. It uses the same serialized representation as a VecDeque.

Implementations§

Source§

impl SegmentChain

Source

pub fn new() -> Self

Creates an empty SegmentChain.

§Examples
use planar_geo::prelude::SegmentChain;

let chain = SegmentChain::new();
Source

pub fn with_capacity(capacity: usize) -> Self

Creates an empty SegmentChain with space for at least capacity Segment.

§Examples
use planar_geo::prelude::SegmentChain;

let chain = SegmentChain::with_capacity(10);
Source

pub fn from_points(points: &[[f64; 2]]) -> Self

Creates an SegmentChain of LineSegments from the given points. If two consecutive points are equal (within the tolerances defined by DEFAULT_EPSILON and DEFAULT_MAX_ULPS), they are treated as a single vertex.

§Examples
use planar_geo::prelude::SegmentChain;

// Three points -> Two line segments
let chain = SegmentChain::from_points(&[[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]]);
assert_eq!(chain.len(), 2);

// Two consecutive points are equal
let chain = SegmentChain::from_points(&[[0.0, 0.0], [0.0, 0.0], [0.0, 1.0]]);
assert_eq!(chain.len(), 1);
Source

pub fn close(&mut self)

“Closes” the SegmentChain by connecting the start point of the first / “front” segment with the stop point of the last / “back” segment with a LineSegment (if the two points aren’t already equal).

§Examples
use planar_geo::prelude::SegmentChain;

// Three points -> Two line segments
let mut chain = SegmentChain::from_points(&[[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]]);
assert_eq!(chain.len(), 2);

// Close the chain
chain.close();
assert_eq!(chain.len(), 3);
Source

pub fn vec_deque(&self) -> &VecDeque<Segment>

Returns a reference to the underlying VecDeque.

This allows using all methods of VecDeque which use a shared reference, e.g. its iterators, accessor methods etc.

Source

pub fn as_slices(&self) -> (&[Segment], &[Segment])

Calls the VecDeque::as_slices method of the underlying deque. See its docstring for more.

Source

pub fn make_contiguous(&mut self) -> &[Segment]

Calls the VecDeque::make_contiguous method of the underlying deque. See its docstring for more.

Source

pub fn push_back(&mut self, segment: Segment)

Appends a Segment to the back of the SegmentChain.

If the chain already has a “back” segment (SegmentChain::back returns Some), the start point of segment is compared to the stop point of the back segment. If they aren’t equal within the tolerances defined by DEFAULT_EPSILON and DEFAULT_MAX_ULPS, a filler line segment is inserted between the two.

§Examples
use planar_geo::prelude::*;

let mut chain = SegmentChain::new();
assert_eq!(chain.len(), 0);

chain.push_back(LineSegment::new([0.0, 0.0], [1.0, 0.0], DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into());
assert_eq!(chain.len(), 1);

// The start point of this segment matches the stop point of the already
// inserted segment
chain.push_back(LineSegment::new([1.0, 0.0], [1.0, 1.0], DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into());
assert_eq!(chain.len(), 2);

// Start and stop point don't match -> A filler segment is introduced
chain.push_back(LineSegment::new([2.0, 1.0], [2.0, 0.0], DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into());
assert_eq!(chain.len(), 4);
Source

pub fn push_front(&mut self, segment: Segment)

Prepends a Segment to the front of the SegmentChain.

If the chain already has a “front” segment (SegmentChain::front returns Some), the stop point of segment is compared to the start point of the front segment. If they aren’t equal within the tolerances defined by DEFAULT_EPSILON and DEFAULT_MAX_ULPS, a filler line segment is inserted between the two.

§Examples
use planar_geo::prelude::*;

let mut chain = SegmentChain::new();
assert_eq!(chain.len(), 0);

chain.push_front(LineSegment::new([0.0, 0.0], [1.0, 0.0], DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into());
assert_eq!(chain.len(), 1);

// The stop point of this segment matches the start point of the already
// inserted segment
chain.push_front(LineSegment::new([0.0, 1.0], [0.0, 0.0], DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into());
assert_eq!(chain.len(), 2);

// Start and stop point don't match -> A filler segment is introduced
chain.push_front(LineSegment::new([2.0, 1.0], [2.0, 0.0], DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into());
assert_eq!(chain.len(), 4);
Source

pub fn pop_back(&mut self) -> Option<Segment>

Removes the last / back element from the chain and returns it, or None if it is empty.

§Examples
use planar_geo::prelude::*;

let mut chain = SegmentChain::new();

let ls: Segment = LineSegment::new([0.0, 0.0], [1.0, 0.0], DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into();

chain.push_back(ls.clone());
assert_eq!(chain.len(), 1);

assert_eq!(chain.pop_back(), Some(ls));
assert_eq!(chain.pop_back(), None);
     
Source

pub fn pop_front(&mut self) -> Option<Segment>

Removes the first / front element from the chain and returns it, or None if it is empty.

§Examples
use planar_geo::prelude::*;

let mut chain = SegmentChain::new();

let ls: Segment = LineSegment::new([0.0, 0.0], [1.0, 0.0], DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into();

chain.push_front(ls.clone());
assert_eq!(chain.len(), 1);

assert_eq!(chain.pop_front(), Some(ls));
assert_eq!(chain.pop_front(), None);
     
Source

pub fn back(&self) -> Option<&Segment>

Provides a reference to the back element, or None if the chain is empty.

§Examples
use planar_geo::prelude::*;

let chain = SegmentChain::from_points(&[[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]]);
let ls: Segment = LineSegment::new([1.0, 0.0], [0.0, 1.0], DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into();

assert_eq!(chain.back(), Some(&ls));
Source

pub fn front(&self) -> Option<&Segment>

Provides a reference to the front element, or None if the chain is empty.

§Examples
use planar_geo::prelude::*;

let chain = SegmentChain::from_points(&[[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]]);
let ls: Segment = LineSegment::new([0.0, 0.0], [1.0, 0.0], DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into();

assert_eq!(chain.front(), Some(&ls));
     
Source

pub fn extend_back(&mut self, point: [f64; 2])

Adds a LineSegment to the front of self which stops at point and starts at the current stop point of self - i.e., the stop point of the Segment returned from SegmentChain::back. If self is empty or point is equal to stop, this is a no-op.

§Examples
use planar_geo::prelude::*;

let mut chain = SegmentChain::new();
assert_eq!(chain.len(), 0);

// No-op, since the chain is empty
chain.extend_back([0.0, 0.0]);
assert_eq!(chain.len(), 0);

// Now add a line
chain.push_back(LineSegment::new([1.0, 0.0], [1.0, 1.0], DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into());
assert_eq!(chain.len(), 1);

// Now adding the point works
chain.extend_back([0.0, 0.0]);
assert_eq!(chain.len(), 2);
Source

pub fn extend_front(&mut self, point: [f64; 2])

Adds a LineSegment to the front of self which starts at point and stops at the current start point of self - i.e., the start point of the Segment returned from SegmentChain::front. If self is empty or point is equal to start, this is a no-op.

§Examples
use planar_geo::prelude::*;

let mut chain = SegmentChain::new();
assert_eq!(chain.len(), 0);

// No-op, since the chain is empty
chain.extend_front([0.0, 0.0]);
assert_eq!(chain.len(), 0);

// Now add a line
chain.push_front(LineSegment::new([1.0, 0.0], [1.0, 1.0], DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into());
assert_eq!(chain.len(), 1);

// Now adding the point works
chain.extend_front([0.0, 0.0]);
assert_eq!(chain.len(), 2);
Source

pub fn is_empty(&self) -> bool

Returns whether the chain / the underlying VecDeque is empty or not.

§Examples
 use planar_geo::prelude::*;

let mut chain = SegmentChain::new();
assert!(chain.is_empty());

chain.push_back(LineSegment::new([0.0, 0.0], [1.0, 0.0], 0.0, 0).unwrap().into());
assert!(!chain.is_empty());
Source

pub fn get(&self, index: usize) -> Option<&Segment>

Provides a reference to the Segment at the given index.

The segment at index 0 is the front of the chain.

§Examples
 use planar_geo::prelude::*;

let chain = SegmentChain::from_points(&[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]);
assert!(chain.get(0).is_some());
assert!(chain.get(3).is_none());
Source

pub fn len(&self) -> usize

Returns the number of Segments in self.

§Examples
use planar_geo::prelude::*;

let chain = SegmentChain::from_points(&[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]);
assert_eq!(chain.len(), 2);
Source

pub fn iter(&self) -> Iter<'_, Segment>

Returns a front-to-back iterator over all Segments of self.

§Examples
use planar_geo::prelude::*;

let chain = SegmentChain::from_points(&[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]);
let mut iter = chain.iter();
assert!(iter.next().is_some());
assert!(iter.next().is_some());
assert!(iter.next().is_none());
Source

pub fn par_iter(&self) -> Iter<'_, Segment>

Returns a parallel front-to-back iterator over all Segments of self.

§Examples
use rayon::prelude::*;
use planar_geo::prelude::*;

let chain = SegmentChain::from_points(&[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]);
let vec: Vec<_> = chain.par_iter().collect();
assert_eq!(vec.len(), 2);
Source

pub fn append(&mut self, other: &mut SegmentChain)

Moves all Segments of other into self, leaving other empty.

If the first point of other is not equal to the last point of self, a filler line segment is introduced first

§Panics

Panics if the new number of elements in self overflows an usize.

§Examples
use planar_geo::prelude::*;

let mut chain1 = SegmentChain::from_points(&[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]);
let mut chain2 = SegmentChain::from_points(&[[1.0, 1.0], [0.0, 1.0]]);
let mut chain3 = SegmentChain::from_points(&[[0.0, 2.0], [0.0, 3.0]]);

assert_eq!(chain1.len(), 2);
assert_eq!(chain2.len(), 1);
assert_eq!(chain3.len(), 1);

chain1.append(&mut chain2);
assert_eq!(chain1.len(), 3);

chain1.append(&mut chain3);
assert_eq!(chain1.len(), 5);
Source

pub fn points(&self) -> PointIterator<'_>

Returns an iterator over all points of the chain.

§Examples
use planar_geo::prelude::*;

let chain = SegmentChain::from_points(&[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]);

let mut iter = chain.points();
assert_eq!(iter.next(), Some([0.0, 0.0]));
assert_eq!(iter.next(), Some([1.0, 0.0]));
assert_eq!(iter.next(), Some([1.0, 1.0]));
assert_eq!(iter.next(), None);
Source

pub fn polygonize(&self, polygonizer: Polygonizer) -> PointIterator<'_>

Returns the points of a polygon chain which approximates self. The individual segments are “polygonized” via Segment::polygonize and an [SegmentPolygonizer] specified within Polygonizer. See the docstring of the latter fore more.

Source

pub fn length(&self) -> f64

Returns the combined length of all segments of self.

use planar_geo::prelude::*;
use std::f64::consts::{PI, TAU, SQRT_2};

// Square with a side length of 1
let points = &[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]];
let mut segment_chain = SegmentChain::from_points(points);
segment_chain.close();
assert_eq!(segment_chain.length(), 4.0);

// Circle with a radius of 1
let segment: Segment = ArcSegment::from_center_radius_start_offset_angle([0.0, 0.0], 1.0, 0.0, TAU, DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into();
let segment_chain = SegmentChain::from(segment);
assert_eq!(segment_chain.length(), TAU);

// Half-circle segment
let segment: Segment = ArcSegment::from_center_radius_start_offset_angle([0.0, 0.0], 1.0, 0.0, PI, DEFAULT_EPSILON, DEFAULT_MAX_ULPS).unwrap().into();
let mut segment_chain = SegmentChain::from(segment);
segment_chain.close();
assert_eq!(segment_chain.length(), PI + 2.0);

// Triangle
let points = &[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]];
let mut segment_chain = SegmentChain::from_points(points);
segment_chain.close();
assert_eq!(segment_chain.length(), 2.0 + SQRT_2);
Source

pub fn intersection_cut( &self, other: &SegmentChain, epsilon: f64, max_ulps: u32, ) -> Vec<SegmentChain>

Cuts self into multiple chains by intersecting it with other and returns those them.

The specified tolerances epsilon and max_ulps are used to determine intersections, see documentation of PrimitiveIntersections.

§Examples
use planar_geo::prelude::*;

let points = &[[0.0, 0.0], [2.0, 0.0], [2.0, 2.0], [0.0, 2.0]];
let line = SegmentChain::from_points(points);
let cut = SegmentChain::from_points(&[[-1.0, 1.0], [3.0, 1.0]]);

let separated_lines = line.intersection_cut(&cut, DEFAULT_EPSILON, DEFAULT_MAX_ULPS);

// This cut results in two separate chains
assert_eq!(separated_lines.len(), 2);
Source

pub fn reverse(&mut self)

Reverses all Segments of the chain by switching their start and stop points (see Segment::reverse). To ensure the “connected” property holds true, the ordering of the segments itself is exchanged as well.

This method calls make_contiguous so all segments are in the first slice before reversing it.

§Examples
use planar_geo::prelude::*;

let mut chain = SegmentChain::from_points(&[[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]]);
assert_eq!(chain.front().unwrap().start(), [0.0, 0.0]);
assert_eq!(chain.back().unwrap().stop(), [0.0, 1.0]);

chain.reverse();
assert_eq!(chain.front().unwrap().start(), [0.0, 1.0]);
assert_eq!(chain.back().unwrap().stop(), [0.0, 0.0]);
Source

pub fn rotational_pattern( &mut self, center: [f64; 2], angle: f64, repetitions: usize, )

Creates a rotated pattern from self. For each one of the specified repetitions, the individual segments of self are cloned, rotated around center and then pushed to the back of self. The rotation angle is angle times the index of the current repetition plus one.

§Examples
use planar_geo::prelude::*;
use std::f64::consts::FRAC_PI_2;

let mut chain = SegmentChain::from_points(&[[0.0, 0.0], [1.0, 0.0]]);

// 0 repetitions => The original chain is left unchanged
chain.rotational_pattern([1.0, 1.0], FRAC_PI_2, 0);
let points: Vec<[f64; 2]> = chain.points().collect();
assert_eq!(points.len(), 2);
approx::assert_abs_diff_eq!(points[0], [0.0, 0.0], epsilon = 1e-10);
approx::assert_abs_diff_eq!(points[1], [1.0, 0.0], epsilon = 1e-10);

// Two repetitions: The points are rotated by 90° and 180° respectively.
// The chain has 6 points after the extension
chain.rotational_pattern([1.0, 1.0], FRAC_PI_2, 2);
let points: Vec<[f64; 2]> = chain.points().collect();
assert_eq!(points.len(), 6);
approx::assert_abs_diff_eq!(points[0], [0.0, 0.0], epsilon = 1e-10);
approx::assert_abs_diff_eq!(points[1], [1.0, 0.0], epsilon = 1e-10);
approx::assert_abs_diff_eq!(points[2], [2.0, 0.0], epsilon = 1e-10);
approx::assert_abs_diff_eq!(points[3], [2.0, 1.0], epsilon = 1e-10);
approx::assert_abs_diff_eq!(points[4], [2.0, 2.0], epsilon = 1e-10);
approx::assert_abs_diff_eq!(points[5], [1.0, 2.0], epsilon = 1e-10);
Source

pub fn translational_pattern(&mut self, shift: [f64; 2], repetitions: usize)

Creates a translated pattern from self. For each one of the specified repetitions, the individual segments of self are cloned, shifted and then pushed to the back of self. The shift vector is shift times the index of the current repetition plus one.

§Examples
use planar_geo::prelude::*;
use std::f64::consts::FRAC_PI_2;

let mut chain = SegmentChain::from_points(&[[0.0, 0.0], [1.0, 0.0]]);

// 0 repetitions => The original chain is left unchanged
chain.translational_pattern([1.0, 1.0], 0);
let points: Vec<[f64; 2]> = chain.points().collect();
assert_eq!(points.len(), 2);
approx::assert_abs_diff_eq!(points[0], [0.0, 0.0], epsilon = 1e-10);
approx::assert_abs_diff_eq!(points[1], [1.0, 0.0], epsilon = 1e-10);

// Two repetitions: A "stair" segment chain is created
chain.translational_pattern([1.0, 1.0], 2);
let points: Vec<[f64; 2]> = chain.points().collect();
assert_eq!(points.len(), 6);
approx::assert_abs_diff_eq!(points[0], [0.0, 0.0], epsilon = 1e-10);
approx::assert_abs_diff_eq!(points[1], [1.0, 0.0], epsilon = 1e-10);
approx::assert_abs_diff_eq!(points[2], [1.0, 1.0], epsilon = 1e-10);
approx::assert_abs_diff_eq!(points[3], [2.0, 1.0], epsilon = 1e-10);
approx::assert_abs_diff_eq!(points[4], [2.0, 2.0], epsilon = 1e-10);
approx::assert_abs_diff_eq!(points[5], [3.0, 2.0], epsilon = 1e-10);
Source§

impl SegmentChain

Source

pub fn draw(&self, style: &Style, context: &Context) -> Result<(), Error>

Draws the SegmentChain onto the cairo::Context with the given Style. See the module level documentation.

Trait Implementations§

Source§

impl Clone for SegmentChain

Source§

fn clone(&self) -> SegmentChain

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Composite for SegmentChain

Source§

type SegmentKey = SegmentIdx

The segment key type needed to retrieve a segment from Self via Composite::segment. This type is the “left” part of the Intersection returned by the various intersection methods of the Composite trait and can be used to directly retrieve the segment where the intersection occurred.
Source§

fn segment(&self, key: Self::SegmentKey) -> Option<&Segment>

Returns the segment associated with the given key, if it exists. Read more
Source§

fn num_segments(&self) -> usize

Returns the number of segments in the composite type. Read more
Source§

fn centroid(&self) -> [f64; 2]

Calculates the centroid of self, i.e. its center of mass. Read more
Source§

fn intersections_primitive<'a, T: Primitive + Sync>( &'a self, primitive: &'a T, epsilon: f64, max_ulps: u32, ) -> impl Iterator<Item = Intersection<Self::SegmentKey, ()>> + 'a

Returns an iterator over all intersections of self with the primitive. Read more
Source§

fn intersections_primitive_par<'a, T: Primitive + Sync>( &'a self, primitive: &'a T, epsilon: f64, max_ulps: u32, ) -> impl ParallelIterator<Item = Intersection<Self::SegmentKey, ()>> + 'a

Returns a parallelized iterator over all intersections of self with the primitive. Read more
Source§

fn intersections_segment_chain<'a>( &'a self, other: &'a Self, epsilon: f64, max_ulps: u32, ) -> impl Iterator<Item = Intersection<Self::SegmentKey, SegmentIdx>> + 'a

Returns a iterator over all intersections of self with the segment_chain. Read more
Source§

fn intersections_segment_chain_par<'a>( &'a self, other: &'a Self, epsilon: f64, max_ulps: u32, ) -> impl ParallelIterator<Item = Intersection<Self::SegmentKey, SegmentIdx>> + 'a

Returns a parallelized iterator over all intersections of self with the segment_chain. Read more
Source§

fn intersections_contour<'a>( &'a self, contour: &'a Contour, epsilon: f64, max_ulps: u32, ) -> impl Iterator<Item = Intersection<Self::SegmentKey, SegmentIdx>>

Returns a iterator over all intersections of self with the contour. Read more
Source§

fn intersections_contour_par<'a>( &'a self, contour: &'a Contour, epsilon: f64, max_ulps: u32, ) -> impl ParallelIterator<Item = Intersection<Self::SegmentKey, SegmentIdx>> + 'a

Returns a parallelized iterator over all intersections of self with the contour. Read more
Source§

fn intersections_shape<'a>( &'a self, shape: &'a Shape, epsilon: f64, max_ulps: u32, ) -> impl Iterator<Item = Intersection<Self::SegmentKey, ShapeIdx>>

Returns an iterator over all intersections of self with the shape. Read more
Source§

fn intersections_shape_par<'a>( &'a self, shape: &'a Shape, epsilon: f64, max_ulps: u32, ) -> impl ParallelIterator<Item = Intersection<Self::SegmentKey, ShapeIdx>>

Returns a parallelized iterator over all intersections of self with the contour. Read more
Source§

fn intersections_composite<'a, T: Composite>( &'a self, other: &'a T, epsilon: f64, max_ulps: u32, ) -> impl Iterator<Item = Intersection<Self::SegmentKey, T::SegmentKey>> + 'a
where Self: Sized,

Returns the intersection between self and another type implementing Composite. Read more
Source§

fn intersections_composite_par<'a, T: Composite>( &'a self, other: &'a T, epsilon: f64, max_ulps: u32, ) -> impl ParallelIterator<Item = Intersection<Self::SegmentKey, T::SegmentKey>> + 'a
where Self: Sized, <T as Composite>::SegmentKey: Send,

Returns a parallelized iterator over all intersections of self with other. Read more
Source§

fn contains_point(&self, point: [f64; 2], epsilon: f64, max_ulps: u32) -> bool

Returns whether the given point is contained within the composite or not. Read more
Source§

impl Debug for SegmentChain

Source§

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

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

impl<'de> Deserialize<'de> for SegmentChain

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 From<&BoundingBox> for SegmentChain

Source§

fn from(bounding_box: &BoundingBox) -> Self

Converts to this type from the input type.
Source§

impl From<&SegmentChain> for BoundingBox

Source§

fn from(value: &SegmentChain) -> BoundingBox

Converts to this type from the input type.
Source§

impl From<ArcSegment> for SegmentChain

Source§

fn from(value: ArcSegment) -> Self

Converts to this type from the input type.
Source§

impl From<BoundingBox> for SegmentChain

Source§

fn from(bounding_box: BoundingBox) -> Self

Converts to this type from the input type.
Source§

impl From<Contour> for SegmentChain

Source§

fn from(polygon: Contour) -> Self

Converts to this type from the input type.
Source§

impl From<LineSegment> for SegmentChain

Source§

fn from(value: LineSegment) -> Self

Converts to this type from the input type.
Source§

impl From<Segment> for SegmentChain

Source§

fn from(value: Segment) -> Self

Converts to this type from the input type.
Source§

impl From<SegmentChain> for Contour

Source§

fn from(segment_chain: SegmentChain) -> Self

Converts to this type from the input type.
Source§

impl From<SegmentChain> for VecDeque<Segment>

Source§

fn from(line: SegmentChain) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Segment> for SegmentChain

Source§

fn from_iter<T: IntoIterator<Item = Segment>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl Index<usize> for SegmentChain

Source§

type Output = Segment

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IntoIterator for SegmentChain

Source§

type Item = Segment

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Segment>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for SegmentChain

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for SegmentChain

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
Source§

impl Transformation for SegmentChain

Source§

fn rotate(&mut self, center: [f64; 2], angle: f64)

Rotates self around the center by the given angle (in rad). Read more
Source§

fn translate(&mut self, shift: [f64; 2])

Translates self by the given shift. Read more
Source§

fn scale(&mut self, factor: f64)

Scales self by factor with respect to the origin [0.0, 0.0]. Read more
Source§

fn line_reflection(&mut self, start: [f64; 2], stop: [f64; 2])

Mirrors self about a line defined by two points. Read more
Source§

fn point_reflection(&mut self, point: [f64; 2])

Mirrors self about a point. This operation is equivalent to a rotation around the point with the angle PI. Read more
Source§

impl StructuralPartialEq for SegmentChain

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToBoundingBox for T
where &'a T: for<'a> Into<BoundingBox>,

Source§

fn bounding_box(&self) -> BoundingBox

Returns a bounding box for the implementor. Read more
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.
Source§

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