Expand description
Decomposition and tessellation.
The Decompose
iterator uses various traits to decompose and tessellate
iterators of topological structures.
This module provides two kinds of decomposition traits: conversions and
Iterator
extensions. Conversion traits are implemented by topological
types and decompose a single structure into any number of output structures.
Extensions are implemented for iterators of topological structures and
perform the corresponding conversion on the input items to produce flattened
output. For example, IntoTrigons
converts a Polygonal
type into an
iterator of Trigon
s while Triangulate
does the same to the items of
an iterator.
Many of these traits are re-exported in the prelude
module.
Examples
Tessellating a Tetragon
into Trigon
s:
use nalgebra::Point2;
use plexus::prelude::*;
use plexus::primitive::Tetragon;
type E2 = Point2<f64>;
let square = Tetragon::from([
E2::new(1.0, 1.0),
E2::new(-1.0, 1.0),
E2::new(-1.0, -1.0),
E2::new(1.0, -1.0),
]);
let trigons = square.into_trigons();
Tessellating an iterator of Tetragon
s from a generator:
use nalgebra::Point3;
use plexus::prelude::*;
use plexus::primitive::cube::Cube;
use plexus::primitive::generate::Position;
type E3 = Point3<f64>;
let polygons: Vec<_> = Cube::new()
.polygons::<Position<E3>>()
.subdivide()
.triangulate()
.collect();