Skip to main content

clipper2_sys/clipperd/
paths.rs

1use crate::cxx_bridge::clipper2_sys_cxx::PathsBlobD;
2use crate::paths_blob::{pathsd_from_blob, PathsBlobDIter};
3use crate::PathD;
4
5define_lazy_paths! {
6    /// Lazy iterators over `PathD` entries from a `PathsBlobD`.
7    ///
8    /// 由 `PathsBlobD` 惰性产出多条 [`PathD`]。
9    LazyPathsD,
10    blob = PathsBlobD,
11    paths = PathsD,
12    path = PathD,
13    iter = PathsBlobDIter,
14    from_blob = pathsd_from_blob,
15}
16
17/// Collection of double-precision paths.
18///
19/// 双精度路径集合。
20#[derive(Clone, Debug, Default)]
21pub struct PathsD(pub(crate) Vec<PathD>);
22
23impl_paths_collection!(float, PathsD, PathD);
24
25#[cfg(test)]
26mod tests {
27    use crate::{PathD, PathsD, PointD};
28
29    #[test]
30    fn paths_d_append_and_translate() {
31        let mut ps = PathsD::default();
32        ps.add_path(PathD::new(vec![PointD::new(0.0, 0.0), PointD::new(1.0, 0.0)]));
33        let u = ps.translate(1.0, 2.0);
34        assert!((u.path(0).get_point(0).x - 1.0).abs() < 1e-9);
35    }
36}