1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
//!
//! # Examples cookbook / 示例合集
//!
//! ## `Clipper64`: union + lazy closed / 布尔并 + 惰性闭合解
//!
//! ```
//! use clipper2_sys::{
//! ClipType, Clipper64, FillRule, Paths64, Point64,
//! };
//! # use clipper2_sys::Path64;
//! # fn square_i(x0: i64, y0: i64, s: i64) -> Path64 {
//! # Path64::new(vec![Point64::new(x0, y0), Point64::new(x0 + s, y0),
//! # Point64::new(x0 + s, y0 + s), Point64::new(x0, y0 + s)])
//! # }
//!
//! let mut clip = Clipper64::new();
//! clip.add_subject(&Paths64::new(vec![square_i(0, 0, 100)]));
//! clip.add_clip(&Paths64::new(vec![square_i(50, 50, 100)]));
//! let sol = clip.execute(ClipType::Union, FillRule::NonZero);
//! let (closed, _open) = sol.into_lazy();
//! assert!(!closed.is_empty());
//! ```
//!
//! ## `Clipper64`: iterate closed paths / 逐条遍历闭合路径
//!
//! ```
//! use clipper2_sys::{
//! ClipType, Clipper64, FillRule, Path64, Paths64, Point64,
//! };
//! # fn square_i(x0: i64, y0: i64, s: i64) -> Path64 {
//! # Path64::new(vec![Point64::new(x0, y0), Point64::new(x0 + s, y0),
//! # Point64::new(x0 + s, y0 + s), Point64::new(x0, y0 + s)])
//! # }
//!
//! let mut clip = Clipper64::new();
//! clip.add_subject(&Paths64::new(vec![square_i(0, 0, 100)]));
//! clip.add_clip(&Paths64::new(vec![square_i(50, 50, 100)]));
//! let sol = clip.execute(ClipType::Union, FillRule::NonZero);
//! let all: Paths64 = sol.iter_closed().chain(sol.iter_open()).collect();
//! assert!(!all.is_empty());
//! ```
//!
//! ## `Clipper64`: `execute_tree` + preorder on `PolyPath` / 树形解与前序遍历
//!
//! ```
//! use clipper2_sys::{
//! ClipType, Clipper64, FillRule, Path64, Paths64, Point64,
//! };
//! # fn square_i(x0: i64, y0: i64, s: i64) -> Path64 {
//! # Path64::new(vec![Point64::new(x0, y0), Point64::new(x0 + s, y0),
//! # Point64::new(x0 + s, y0 + s), Point64::new(x0, y0 + s)])
//! # }
//!
//! let mut clip = Clipper64::new();
//! clip.add_subject(&Paths64::new(vec![square_i(0, 0, 100)]));
//! clip.add_clip(&Paths64::new(vec![square_i(50, 50, 100)]));
//! let sol = clip.execute_tree(ClipType::Union, FillRule::NonZero);
//! let (_open_lazy, preorder) = sol.into_open_and_poly_preorder();
//! let n = preorder.count();
//! assert!(n > 0);
//! ```
//!
//! ## `ClipperD`: union / 双精度布尔并
//!
//! ```
//! use clipper2_sys::{
//! ClipType, ClipperD, FillRule, PathD, PathsD, PointD,
//! };
//! # fn square_f(x0: f64, y0: f64, s: f64) -> PathD {
//! # PathD::new(vec![PointD::new(x0, y0), PointD::new(x0 + s, y0),
//! # PointD::new(x0 + s, y0 + s), PointD::new(x0, y0 + s)])
//! # }
//!
//! let mut clip = ClipperD::new(4);
//! clip.add_subject(&PathsD::new(vec![square_f(0.0, 0.0, 100.0)]));
//! clip.add_clip(&PathsD::new(vec![square_f(50.0, 50.0, 100.0)]));
//! let sol = clip.execute(ClipType::Union, FillRule::NonZero);
//! let (closed, _open) = sol.into_lazy();
//! assert!(!closed.is_empty());
//! ```
//!
//! ## `ClipperOffset`: inflate a square / 方形外扩
//!
//! ```
//! use clipper2_sys::{ClipperOffset, EndType, JoinType, Path64, Point64};
//!
//! let path = Path64::new(vec![
//! Point64::new(0, 0),
//! Point64::new(100, 0),
//! Point64::new(100, 100),
//! Point64::new(0, 100),
//! ]);
//! let mut co = ClipperOffset::new(2.0, 0.0, false, false);
//! co.add_path(&path, JoinType::MiterJoin, EndType::PolygonEnd);
//! let out = co.execute(10.0);
//! assert!(!out.is_empty());
//! ```
//!
//! ## `Path64`: area, point-in-polygon, translate, simplify / 面积、点包含、平移、简化
//!
//! ```
//! use clipper2_sys::{Path64, Point64, PointInPolygonResult};
//!
//! let p = Path64::new(vec![
//! Point64::new(0, 0),
//! Point64::new(10, 0),
//! Point64::new(10, 10),
//! Point64::new(0, 10),
//! ]);
//! assert!((p.area().abs() - 100.0).abs() < 1e-3);
//! assert!(matches!(
//! p.point_in_polygon(Point64::new(5, 5)),
//! PointInPolygonResult::Inside
//! ));
//! let t = p.translate(3, -2);
//! assert_eq!(t.get_point(0).x, 3);
//! let collinear = Path64::new(vec![
//! Point64::new(0, 0),
//! Point64::new(5, 0),
//! Point64::new(10, 0),
//! Point64::new(10, 10),
//! ]);
//! let simp = collinear.simplify(1.0, false);
//! assert!(simp.into_first_path().len() <= collinear.len());
//! ```
//!
//! ## `Paths64`: inflate (offset helper) / 多路径偏移
//!
//! ```
//! use clipper2_sys::{EndType, JoinType, Path64, Paths64, Point64};
//!
//! let paths = Paths64::new(vec![Path64::new(vec![
//! Point64::new(0, 0),
//! Point64::new(100, 0),
//! Point64::new(100, 100),
//! Point64::new(0, 100),
//! ])]);
//! let grown = paths.inflate(10.0, JoinType::MiterJoin, EndType::PolygonEnd, 2.0);
//! assert!(!grown.is_empty());
//! ```
//!
//! ## `Path64` / `Paths64`: Minkowski sum / 闵可夫斯基和
//!
//! ```
//! use clipper2_sys::{FillRule, Path64, Paths64, Point64};
//! # fn square_i(x0: i64, y0: i64, s: i64) -> Path64 {
//! # Path64::new(vec![Point64::new(x0, y0), Point64::new(x0 + s, y0),
//! # Point64::new(x0 + s, y0 + s), Point64::new(x0, y0 + s)])
//! # }
//!
//! let a = square_i(0, 0, 50);
//! let b = square_i(0, 0, 30);
//! let ms = a.minkowski_sum(&b, true);
//! assert!(!ms.is_empty());
//!
//! let many = Paths64::new(vec![square_i(0, 0, 40)]);
//! let ms2 = many.minkowski_sum(&b, true, FillRule::NonZero.into());
//! assert!(!ms2.is_empty());
//! ```
//!
//! ## `PathD` ↔ `Path64`: simplify and convert / 双精度简化与转整型
//!
//! ```
//! use clipper2_sys::{LazyPaths64, PathD, PointD};
//!
//! let p = PathD::new(vec![
//! PointD::new(0.0, 0.0),
//! PointD::new(5.0, 0.0),
//! PointD::new(10.0, 0.0),
//! PointD::new(10.0, 10.0),
//! ]);
//! let simplified = p.simplify(1.0, false);
//! let _: LazyPaths64 = p.to_path64();
//! assert!(simplified.into_first_path().len() <= p.len());
//! ```
//!
//! ## `ClipSolution`: `to_closed` / 物化全部闭合多边形
//!
//! ```
//! use clipper2_sys::{
//! ClipType, Clipper64, FillRule, Path64, Paths64, Point64,
//! };
//! # fn square_i(x0: i64, y0: i64, s: i64) -> Path64 {
//! # Path64::new(vec![Point64::new(x0, y0), Point64::new(x0 + s, y0),
//! # Point64::new(x0 + s, y0 + s), Point64::new(x0, y0 + s)])
//! # }
//!
//! let mut clip = Clipper64::new();
//! clip.add_subject(&Paths64::new(vec![square_i(0, 0, 100)]));
//! clip.add_clip(&Paths64::new(vec![square_i(50, 50, 100)]));
//! let sol = clip.execute(ClipType::Union, FillRule::NonZero);
//! let closed: Paths64 = sol.to_closed();
//! assert!(!closed.is_empty());
//! ```
//!
//! ## `ClipTreeSolution`: open-only shortcut / 只要开放解
//!
//! ```
//! use clipper2_sys::{
//! ClipType, Clipper64, FillRule, Path64, Paths64, Point64,
//! };
//! # fn square_i(x0: i64, y0: i64, s: i64) -> Path64 {
//! # Path64::new(vec![Point64::new(x0, y0), Point64::new(x0 + s, y0),
//! # Point64::new(x0 + s, y0 + s), Point64::new(x0, y0 + s)])
//! # }
//!
//! let mut clip = Clipper64::new();
//! clip.add_subject(&Paths64::new(vec![square_i(0, 0, 100)]));
//! clip.add_clip(&Paths64::new(vec![square_i(50, 50, 100)]));
//! let sol = clip.execute_tree(ClipType::Union, FillRule::NonZero);
//! let _open = sol.into_open_lazy();
//! ```
//!
//! # Module map / 模块结构
//!
//! - `clipper64` (logic in `src/clipper64/`, types re-exported here) — integer paths and
//! [`Clipper64`]. / 整数路径与 [`Clipper64`],实现位于 `clipper64` 子目录。
//! - `clipperd` — double paths and [`ClipperD`]. / 双精度路径与 [`ClipperD`]。
//! - [`ClipperOffset`] — path offset (inflate/deflate). / 路径偏移。
pub use ;
pub use ;
pub use *;
pub use *;
pub use *;
/// Polygon fill rule (non-zero, even-odd, …), maps to Clipper2 `FillRule`.
///
/// 多边形填充规则,对应 Clipper2 `FillRule`。
/// Boolean clip operation between subject and clip paths.
///
/// Subject 与 Clip 之间的裁剪运算类型。
/// Vertex join style for offsets and offset-like operations.
///
/// 顶点连接样式,用于偏移等运算。
/// End cap / polygon closure mode for open paths in offsetting.
///
/// 开放路径在偏移时的端点与闭合模式。
/// Point-in-polygon classification result.
///
/// 点在多边形内外的判定结果。
/// Maps our [`ClipType`] to the cxx bridge enum. / [`ClipType`] → cxx 枚举。
/// Maps our [`FillRule`] to the cxx bridge enum. / [`FillRule`] → cxx。
/// Maps our [`JoinType`] to the cxx bridge enum. / [`JoinType`] → cxx。
/// Maps our [`EndType`] to the cxx bridge enum. / [`EndType`] → cxx。
/// Maps cxx point-in-polygon result to [`PointInPolygonResult`]. / cxx 判定结果 → [`PointInPolygonResult`]。