axiolid_primitive/solid.rs
1//! Bounded analytic solid primitives.
2
3use axiolid_core::Scalar;
4
5/// Exact primitive solid; tessellation is a separate operation.
6#[non_exhaustive]
7#[derive(Debug, Clone, Copy, PartialEq)]
8#[cfg_attr(
9 feature = "serde",
10 derive(serde::Serialize, serde::Deserialize),
11 serde(deny_unknown_fields)
12)]
13pub enum Primitive {
14 /// Axis-aligned box in local coordinates.
15 Block {
16 /// Extent along x.
17 x: Scalar,
18 /// Extent along y.
19 y: Scalar,
20 /// Extent along z.
21 z: Scalar,
22 },
23 /// Sphere centered at the local origin.
24 Sphere {
25 /// Radius.
26 radius: Scalar,
27 },
28 /// Cylinder along local +z.
29 Cylinder {
30 /// Radius.
31 radius: Scalar,
32 /// Height.
33 height: Scalar,
34 },
35 /// Cone along local +z.
36 Cone {
37 /// Base radius.
38 radius: Scalar,
39 /// Height.
40 height: Scalar,
41 },
42 /// Rectangular pyramid along local +z.
43 Pyramid {
44 /// Base extent along x.
45 x: Scalar,
46 /// Base extent along y.
47 y: Scalar,
48 /// Height.
49 height: Scalar,
50 },
51 /// Ring torus centred on the local origin, about local +z.
52 ///
53 /// The tube's centre circle has radius `major_radius` in the plane
54 /// z = 0. Only a ring torus, `0 < minor_radius < major_radius`, is a
55 /// valid solid: at `minor == major` (a horn torus) the tube pinches the
56 /// axis to a point, and past it (a spindle torus) the tube overlaps
57 /// itself, so neither bounds a two-manifold solid.
58 Torus {
59 /// Radius of the tube's centre circle.
60 major_radius: Scalar,
61 /// Radius of the tube.
62 minor_radius: Scalar,
63 },
64 /// Wedge: a box whose top face is narrowed or shifted, as OCCT's
65 /// `BRepPrimAPI_MakeWedge(dx, dy, dz, xmin, zmin, xmax, zmax)` with
66 /// OCCT's y (the height) read as local +z here.
67 ///
68 /// The base is the rectangle `[0, x] x [0, y]` at z = 0 and the top is
69 /// `[top_x_min, top_x_max] x [top_y_min, top_y_max]` at z = `height`.
70 /// Every face is planar and the solid is the convex hull of the two
71 /// rectangles. The top may collapse to a segment (`top_x_min ==
72 /// top_x_max` or `top_y_min == top_y_max`, a wedge proper) or to a point
73 /// (a pyramid with its apex anywhere); OCCT's `ltx` form is `top_x_min =
74 /// 0`, `top_x_max = ltx`, `top_y_min = 0`, `top_y_max = y`.
75 Wedge {
76 /// Base extent along x.
77 x: Scalar,
78 /// Base extent along y.
79 y: Scalar,
80 /// Height along z.
81 height: Scalar,
82 /// Top face's least x.
83 top_x_min: Scalar,
84 /// Top face's greatest x.
85 top_x_max: Scalar,
86 /// Top face's least y.
87 top_y_min: Scalar,
88 /// Top face's greatest y.
89 top_y_max: Scalar,
90 },
91}