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
//! GPU-free scene data for drawing CAD geometry.
//!
//! - [`plan`]: [`Plan2d`], a persistent store of 2D lines, polylines, arcs and circles split
//! into fixed-size chunks. Each chunk encodes its curves once into GPU instances
//! ([`layout`]) in f32 coordinates relative to the chunk center; every frame checks the
//! f32 representation error against a screen-space budget and hands chunks that exceed it
//! back to the caller's CPU path.
//! - [`mesh`]: [`Mesh3d`] triangle meshes in f64 world coordinates and
//! [`relative_positions`], the error-checked f64 to f32 conversion for upload.
//!
//! The crate knows how to draw, not what the geometry means: callers map their own objects to
//! [`ObjectId`]s, decide colors and widths, track which objects changed and call
//! [`Plan2d::upsert`] / [`Plan2d::remove`]. `cadkit-gpu` renders the result with `wgpu`.
//! Coordinates are in the caller's model units; screen quantities are in logical pixels
//! unless a name says `physical`.
//!
//! ```
//! use cadkit_geom::{Curve, LineSegment, Point2};
//! use cadkit_scene::{GroupId, ObjectId, Plan2d, Plan2dOptions, PlanItem, PlanView};
//! use std::collections::BTreeSet;
//!
//! let mut plan = Plan2d::new(Plan2dOptions::new());
//! let wall = Curve::Line(LineSegment { start: Point2::new(0., 0.), end: Point2::new(5., 0.) });
//! plan.upsert(ObjectId(1), PlanItem::new(GroupId(0), vec![wall], [40, 40, 40, 255], 1.5));
//!
//! let view = PlanView::new(Point2::new(2.5, 0.), 100., [800., 600.], 800.);
//! plan.prepare(&view, |_| true);
//! let frame = plan.frame(&view, |_| true, &BTreeSet::new(), true);
//! assert_eq!(frame.draws.len(), 1);
//! assert!(frame.cpu.is_empty());
//! ```
pub use ;
pub use ;
/// Identifier of one caller object. The caller assigns it; [`Plan2d`] draws objects of a
/// chunk in ascending id order, so later ids are drawn on top.
;
/// A group the caller can show or hide per frame without rebuilding, such as a storey or a
/// sheet. Chunks never mix groups; groups are drawn in ascending id order.
;
/// Why scene data could not be produced.