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