Skip to main content

clipper2_sys/clipper64/
paths.rs

1use crate::cxx_bridge::clipper2_sys_cxx::PathsBlob64;
2use crate::paths_blob::{paths64_from_blob, PathsBlob64Iter};
3use crate::Path64;
4
5define_lazy_paths! {
6    /// Lazy view of multiple `Path64` from a C++ `PathsBlob64` (one path per `next()`).
7    ///
8    /// 来自 C++ `PathsBlob64` 的多条 [`Path64`] 惰性视图(每次 `next` 构造一条路径)。
9    LazyPaths64,
10    blob = PathsBlob64,
11    paths = Paths64,
12    path = Path64,
13    iter = PathsBlob64Iter,
14    from_blob = paths64_from_blob,
15}
16
17/// Owned collection of closed/open paths in integer space.
18///
19/// 整数空间下的多条路径集合。
20#[derive(Clone, Debug, Default)]
21pub struct Paths64(pub(crate) Vec<Path64>);
22
23impl_paths_collection!(int64, Paths64, Path64);
24
25#[cfg(test)]
26mod tests {
27    use crate::{Path64, Paths64, Point64};
28
29    #[test]
30    fn new_add_path_len() {
31        let mut ps = Paths64::default();
32        assert!(ps.is_empty());
33        ps.add_path(Path64::new(vec![Point64::new(0, 0), Point64::new(1, 0)]));
34        assert_eq!(ps.len(), 1);
35        let t = ps.translate(10, 0);
36        let q = t.path(0).get_point(0);
37        assert_eq!(q.x, 10);
38        assert_eq!(q.y, 0);
39    }
40}