// GENERATED by scripts/workbench/schemas.mjs from packages/domain/3d-core/types.ts; edit the types, then run it.
//
// THE 3D ELEMENTS' TYPES — the Rust form of the TypeScript SDK's `threed-elements.ts`. Each feature tag has its props
// struct (`ExtrudeProps` for `extrude`), each sketch element too (`SketchPointProps`, `LineProps` …), and `.el()`
// makes the element, at the caller's line, with the fields under their TypeScript names. A required field is its
// type; an optional one, or one with a default (the reader fills it), an `Option`; a definition is a struct (`ProfileRef { sketch, regions }`), a union an enum of
// them (`PlaneRef::Datum(PlaneRefDatum { plane })`), a string enum an enum (`BooleanMode::New`).
//
// The reader checks the same fields against `threed_schema.json` and refuses a wrong one with the sentence the op
// panel shows (`distance: must be greater than 0 (got -1)`). A field this file holds as `Json` is a map, a mixed
// union or a value the editor builds (`json(r#"…"#)` writes one).
#![allow(clippy::all)]
use super::element::Child;
use super::{El, Json};
/// A value as the JSON of its field.
pub trait ToJson {
fn to_json(&self) -> Json;
}
impl ToJson for String {
fn to_json(&self) -> Json {
Json::from(self.as_str())
}
}
impl ToJson for f64 {
fn to_json(&self) -> Json {
Json::Num(*self)
}
}
impl ToJson for i64 {
fn to_json(&self) -> Json {
Json::Num(*self as f64)
}
}
impl ToJson for bool {
fn to_json(&self) -> Json {
Json::Bool(*self)
}
}
impl ToJson for Json {
fn to_json(&self) -> Json {
self.clone()
}
}
impl<T: ToJson> ToJson for Box<T> {
fn to_json(&self) -> Json {
(**self).to_json()
}
}
impl<T: ToJson> ToJson for Vec<T> {
fn to_json(&self) -> Json {
Json::Arr(self.iter().map(ToJson::to_json).collect())
}
}
impl<T: ToJson, const N: usize> ToJson for [T; N] {
fn to_json(&self) -> Json {
Json::Arr(self.iter().map(ToJson::to_json).collect())
}
}
impl<T: ToJson> ToJson for Vec<(String, T)> {
fn to_json(&self) -> Json {
Json::Obj(self.iter().map(|(k, v)| (k.clone(), v.to_json())).collect())
}
}
/// The feature types a 3D document holds, by tag: the schema's roots (the `Feature` union of `packages/domain/3d-core/types.ts`).
pub const THREED_FEATURES: &[&str] = &[
"code",
"sketch",
"extrude",
"revolve",
"sweep",
"curve",
"rod",
"loft",
"fillet",
"chamfer",
"shell",
"box",
"import",
"externalPart",
"cylinder",
"sphere",
"cone",
"makeHuman",
"linearPattern",
"circularPattern",
"pathPattern",
"mirror",
"datumPlane",
"datumAxis",
"datumPoint",
"draft",
"hole",
"transform",
"sheetMetal",
"sheetCorner",
"sheetConvert",
"sheetBase",
"sheetFlange",
"sheetHem",
"sheetFold",
"unfold",
"sheetRefold",
"frameMember",
"endCap",
"wrapText",
"deleteFace",
"fullRound",
"dome",
"copyBody",
"thread",
"coil",
"combine",
"offsetFaces",
"thicken",
"trimSurface",
"untrimSurface",
"extendSurface",
"stitch",
"replaceFace",
"offsetSurface",
"split",
"scale",
"rib",
"subdivBody",
"meshModifier",
"meshBody",
"generate",
"pointCloud",
"gaussianSplat",
"molecule",
"skeleton",
"volume",
"graph",
"pcbTrace",
"generateVia",
"platedHole",
"copperPour",
];
/// Each element tag and its props struct (the TypeScript `ThreeDFeatureElements` and `SketchElements`).
pub const THREED_PROPS: &[(&str, &str)] = &[
("code", "CodeProps"),
("sketch", "SketchProps"),
("extrude", "ExtrudeProps"),
("revolve", "RevolveProps"),
("sweep", "SweepProps"),
("curve", "CurveProps"),
("rod", "RodProps"),
("loft", "LoftProps"),
("fillet", "FilletProps"),
("chamfer", "ChamferProps"),
("shell", "ShellProps"),
("box", "BoxProps"),
("import", "ImportProps"),
("externalPart", "ExternalPartProps"),
("cylinder", "CylinderProps"),
("sphere", "SphereProps"),
("cone", "ConeProps"),
("makeHuman", "MakeHumanProps"),
("linearPattern", "LinearPatternProps"),
("circularPattern", "CircularPatternProps"),
("pathPattern", "PathPatternProps"),
("mirror", "MirrorProps"),
("datumPlane", "DatumPlaneProps"),
("datumAxis", "DatumAxisProps"),
("datumPoint", "DatumPointProps"),
("draft", "DraftProps"),
("hole", "HoleProps"),
("transform", "TransformProps"),
("sheetMetal", "SheetMetalProps"),
("sheetCorner", "SheetCornerProps"),
("sheetConvert", "SheetConvertProps"),
("sheetBase", "SheetBaseProps"),
("sheetFlange", "SheetFlangeProps"),
("sheetHem", "SheetHemProps"),
("sheetFold", "SheetFoldProps"),
("unfold", "UnfoldProps"),
("sheetRefold", "SheetRefoldProps"),
("frameMember", "FrameMemberProps"),
("endCap", "EndCapProps"),
("wrapText", "WrapTextProps"),
("deleteFace", "DeleteFaceProps"),
("fullRound", "FullRoundProps"),
("dome", "DomeProps"),
("copyBody", "CopyBodyProps"),
("thread", "ThreadProps"),
("coil", "CoilProps"),
("combine", "CombineProps"),
("offsetFaces", "OffsetFacesProps"),
("thicken", "ThickenProps"),
("trimSurface", "TrimSurfaceProps"),
("untrimSurface", "UntrimSurfaceProps"),
("extendSurface", "ExtendSurfaceProps"),
("stitch", "StitchProps"),
("replaceFace", "ReplaceFaceProps"),
("offsetSurface", "OffsetSurfaceProps"),
("split", "SplitProps"),
("scale", "ScaleProps"),
("rib", "RibProps"),
("subdivBody", "SubdivBodyProps"),
("meshModifier", "MeshModifierProps"),
("meshBody", "MeshBodyProps"),
("generate", "GenerateProps"),
("pointCloud", "PointCloudProps"),
("gaussianSplat", "GaussianSplatProps"),
("molecule", "MoleculeProps"),
("skeleton", "SkeletonProps"),
("volume", "VolumeProps"),
("graph", "GraphProps"),
("pcbTrace", "PcbTraceProps"),
("generateVia", "GenerateViaProps"),
("platedHole", "PlatedHoleProps"),
("copperPour", "CopperPourProps"),
("point", "SketchPointProps"),
("constraint", "SketchConstraintProps"),
("projection", "SketchProjectionProps"),
("equation", "SketchEquationProps"),
("text", "SketchTextProps"),
("line", "LineProps"),
("circle", "CircleProps"),
("arc", "ArcProps"),
("spline", "SplineProps"),
("ellipse", "EllipseProps"),
("ellipseArc", "EllipseArcProps"),
];
/// One value of a host code part's JSON output that drives a field of a feature.
#[derive(Clone, Debug)]
pub struct HostCodeBinding {
/// The JSON output, as `outputs` names it.
pub output: String,
/// The value's dot path in that JSON (`boards.front.x`, `poses.0.z`).
pub key: String,
/// The feature whose field it drives.
pub target: String,
/// The field's dot path, as a parameter's binding names it (`placement.position.2`).
pub field: String,
}
impl ToJson for HostCodeBinding {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("output", self.output.to_json());
o.set("key", self.key.to_json());
o.set("target", self.target.to_json());
o.set("field", self.field.to_json());
o
}
}
/// What a host code part writes and reads (`<code host={…}>`; docs/formats.md § a host code part).
#[derive(Clone, Debug)]
pub struct HostCode {
/// The files the program writes, relative to the document: `.step` (each one body, the first takes the code part's id) and `.json` (values `bind` reads). At least one `.step`.
pub outputs: Vec<String>,
/// Other files the program reads, relative to the document: their bytes are part of the cache key.
pub reads: Option<Vec<String>>,
/// Secrets the program is given as environment variables, by name: each must be named by the grant too.
pub secrets: Option<Vec<String>>,
/// The longest the program may run, in seconds (default 300).
pub timeout: Option<f64>,
/// Values of the JSON outputs that drive the document's fields, as a parameter's bindings do.
pub bind: Option<Vec<HostCodeBinding>>,
}
impl ToJson for HostCode {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("outputs", self.outputs.to_json());
if let Some(v) = &self.reads {
o.set("reads", v.to_json());
}
if let Some(v) = &self.secrets {
o.set("secrets", v.to_json());
}
if let Some(v) = &self.timeout {
o.set("timeout", v.to_json());
}
if let Some(v) = &self.bind {
o.set("bind", v.to_json());
}
o
}
}
/// A PART AUTHORED AS CODE (docs/wave-h.md §3): a `.ts` / `.tsx` / `.js` / `.jsx` / `.py` file, beside the document, that declares features with the CommandAGI SDK (or JSCAD, replicad or CadQuery through its importers). Opening the part runs the file in the sandbox with `inputs` and puts what it declares in this feature's place: the file's result takes this feature's id, so a feature that `consumes` it follows the code part. It is the one feature of its file that is saved.
#[derive(Clone, Debug)]
pub struct CodeProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The file, relative to the document.
pub source: String,
/// What the file runs with (its declared `params` by name).
pub inputs: Option<Json>,
/// RUN BY THE LOCAL HOST in the folder's own environment (its `.venv` or uv project), not in the sandbox: the file is a program that writes files (docs/code-sandbox.md § a host code part). Its STEP outputs are this part's bodies, its JSON outputs drive fields through `bind`. Absent: the file declares features in the sandbox.
pub host: Option<HostCode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for CodeProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("source", self.source.to_json());
if let Some(v) = &self.inputs {
o.set("inputs", v.to_json());
}
if let Some(v) = &self.host {
o.set("host", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl CodeProps {
/// The `code` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("code");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct PlaneRefDatum {
pub plane: String,
}
impl ToJson for PlaneRefDatum {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "datum");
o.set("plane", self.plane.to_json());
o
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TopoRefKind {
/// `"face"`
Face,
/// `"edge"`
Edge,
/// `"vertex"`
Vertex,
}
impl ToJson for TopoRefKind {
fn to_json(&self) -> Json {
Json::from(match self {
TopoRefKind::Face => "face",
TopoRefKind::Edge => "edge",
TopoRefKind::Vertex => "vertex",
})
}
}
/// A point or vector in 3D.
pub type Vec3 = [f64; 3];
/// A box in model coordinates, by two opposite corners.
#[derive(Clone, Debug)]
pub struct TopoBox {
/// The least corner.
/// Unit: mm.
pub min: Vec3,
/// The greatest corner.
/// Unit: mm.
pub max: Vec3,
}
impl ToJson for TopoBox {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("min", self.min.to_json());
o.set("max", self.max.to_json());
o
}
}
#[derive(Clone, Debug)]
pub struct TopoSignature {
/// Faces: a point on the face (anywhere on it) or its centre; the face nearest to it wins. Edges: the midpoint. Vertices: the position.
pub point: Vec3,
/// Face normal (faces only): its outward sense, which tells two touching faces apart.
pub normal: Option<Vec3>,
/// Face area (faces only).
pub area: Option<f64>,
/// Faces: the box of its boundary, when its surface does not tell it from a neighbour's (a STEP file's freeform face: a fillet's torus, a B-spline). The face whose boundary has this box wins.
pub box_: Option<TopoBox>,
/// Edge length (edges only).
pub length: Option<f64>,
/// Edge chord direction, normalized (edges only).
pub dir: Option<Vec3>,
}
impl ToJson for TopoSignature {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("point", self.point.to_json());
if let Some(v) = &self.normal {
o.set("normal", v.to_json());
}
if let Some(v) = &self.area {
o.set("area", v.to_json());
}
if let Some(v) = &self.box_ {
o.set("box", v.to_json());
}
if let Some(v) = &self.length {
o.set("length", v.to_json());
}
if let Some(v) = &self.dir {
o.set("dir", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct TopoRef {
/// The feature whose result body contains this sub-shape (optional hint).
pub feature: Option<String>,
pub kind: TopoRefKind,
pub signature: TopoSignature,
/// Human label, e.g. "Top face of Extrude1".
pub label: Option<String>,
}
impl ToJson for TopoRef {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.feature {
o.set("feature", v.to_json());
}
o.set("kind", self.kind.to_json());
o.set("signature", self.signature.to_json());
if let Some(v) = &self.label {
o.set("label", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct PlaneRefFace {
pub ref_: TopoRef,
}
impl ToJson for PlaneRefFace {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "face");
o.set("ref", self.ref_.to_json());
o
}
}
#[derive(Clone, Debug)]
pub struct PlaneRefUnwrap {
/// The atlas `buildUnwrapDomain` made from an `UnwrapDomainSpec` (the unwrap mode builds it; a person or an agent does not write it).
pub domain: Json,
}
impl ToJson for PlaneRefUnwrap {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "unwrap");
o.set("domain", self.domain.to_json());
o
}
}
/// WHERE A SKETCH LIVES. Three kinds, and the third is not a plane at all.
#[derive(Clone, Debug)]
pub enum PlaneRef {
Datum(PlaneRefDatum),
Face(PlaneRefFace),
Unwrap(PlaneRefUnwrap),
}
impl ToJson for PlaneRef {
fn to_json(&self) -> Json {
match self {
PlaneRef::Datum(x) => x.to_json(),
PlaneRef::Face(x) => x.to_json(),
PlaneRef::Unwrap(x) => x.to_json(),
}
}
}
impl From<PlaneRefDatum> for PlaneRef {
fn from(x: PlaneRefDatum) -> PlaneRef {
PlaneRef::Datum(x)
}
}
impl From<PlaneRefFace> for PlaneRef {
fn from(x: PlaneRefFace) -> PlaneRef {
PlaneRef::Face(x)
}
}
impl From<PlaneRefUnwrap> for PlaneRef {
fn from(x: PlaneRefUnwrap) -> PlaneRef {
PlaneRef::Unwrap(x)
}
}
#[derive(Clone, Debug)]
pub struct SketchProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
pub plane: PlaneRef,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SketchProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("plane", self.plane.to_json());
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SketchProps {
/// The `sketch` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self, children: impl IntoIterator<Item = El>) -> El {
let mut el = El::new("sketch");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el.with_children(children.into_iter().map(Child::El))
}
}
#[derive(Clone, Debug)]
pub enum ProfileRefRegionsItem {
Text(String),
Number(f64),
}
impl ToJson for ProfileRefRegionsItem {
fn to_json(&self) -> Json {
match self {
ProfileRefRegionsItem::Text(x) => x.to_json(),
ProfileRefRegionsItem::Number(x) => x.to_json(),
}
}
}
impl From<String> for ProfileRefRegionsItem {
fn from(x: String) -> ProfileRefRegionsItem {
ProfileRefRegionsItem::Text(x)
}
}
impl From<f64> for ProfileRefRegionsItem {
fn from(x: f64) -> ProfileRefRegionsItem {
ProfileRefRegionsItem::Number(x)
}
}
/// A profile drawn from a sketch's solved closed regions.
#[derive(Clone, Debug)]
pub struct ProfileRef {
pub sketch: String,
/// The sketch's closed regions to take: an index into them, or a region's reference (a string built from the ids of its segments, which keeps naming it after an unrelated edit); omit/empty = each outer loop.
pub regions: Option<Vec<ProfileRefRegionsItem>>,
}
impl ToJson for ProfileRef {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("sketch", self.sketch.to_json());
if let Some(v) = &self.regions {
o.set("regions", v.to_json());
}
o
}
}
/// How a solid feature combines with existing bodies.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BooleanMode {
/// `"new"`
New,
/// `"add"`
Add,
/// `"cut"`
Cut,
/// `"intersect"`
Intersect,
}
impl ToJson for BooleanMode {
fn to_json(&self) -> Json {
Json::from(match self {
BooleanMode::New => "new",
BooleanMode::Add => "add",
BooleanMode::Cut => "cut",
BooleanMode::Intersect => "intersect",
})
}
}
#[derive(Clone, Debug)]
pub struct ExtrudeProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The sketch regions to extrude.
pub profile: ProfileRef,
/// How far the profile travels from its plane.
/// Unit: mm.
/// Default: `10`.
pub distance: Option<f64>,
/// Extrude both directions symmetrically about the sketch plane.
pub symmetric: Option<bool>,
/// Reverse the extrude direction.
pub reverse: Option<bool>,
/// Second-direction distance (asymmetric two-sided).
/// Unit: mm.
pub distance2: Option<f64>,
/// Draft angle in radians (0 = none).
/// Unit: rad.
pub draft_angle: Option<f64>,
/// "Through all": extrude far enough to span every existing body (both ways).
pub through: Option<bool>,
/// "Up to face": extrude until the profile reaches this target face's plane.
pub up_to_face: Option<Json>,
/// A SURFACE, not a solid: the profile's edges (the outer edges of its closed regions, or the sketch's open chain when it has no closed region) are moved along the direction, and the faces they sweep are a body of their own with no inside. A surface is always a new body.
/// Default: `false`.
pub surface: Option<bool>,
/// How the solid combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for ExtrudeProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("profile", self.profile.to_json());
if let Some(v) = &self.distance {
o.set("distance", v.to_json());
}
if let Some(v) = &self.symmetric {
o.set("symmetric", v.to_json());
}
if let Some(v) = &self.reverse {
o.set("reverse", v.to_json());
}
if let Some(v) = &self.distance2 {
o.set("distance2", v.to_json());
}
if let Some(v) = &self.draft_angle {
o.set("draftAngle", v.to_json());
}
if let Some(v) = &self.through {
o.set("through", v.to_json());
}
if let Some(v) = &self.up_to_face {
o.set("upToFace", v.to_json());
}
if let Some(v) = &self.surface {
o.set("surface", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl ExtrudeProps {
/// The `extrude` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("extrude");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AxisRefDatumAxisAxis {
/// `"X"`
X,
/// `"Y"`
Y,
/// `"Z"`
Z,
}
impl ToJson for AxisRefDatumAxisAxis {
fn to_json(&self) -> Json {
Json::from(match self {
AxisRefDatumAxisAxis::X => "X",
AxisRefDatumAxisAxis::Y => "Y",
AxisRefDatumAxisAxis::Z => "Z",
})
}
}
#[derive(Clone, Debug)]
pub struct AxisRefDatumAxis {
pub axis: AxisRefDatumAxisAxis,
}
impl ToJson for AxisRefDatumAxis {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "datumAxis");
o.set("axis", self.axis.to_json());
o
}
}
#[derive(Clone, Debug)]
pub struct AxisRefDatum {
pub axis: String,
}
impl ToJson for AxisRefDatum {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "datum");
o.set("axis", self.axis.to_json());
o
}
}
#[derive(Clone, Debug)]
pub struct AxisRefSketchLine {
pub sketch: String,
pub segment: String,
}
impl ToJson for AxisRefSketchLine {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "sketchLine");
o.set("sketch", self.sketch.to_json());
o.set("segment", self.segment.to_json());
o
}
}
#[derive(Clone, Debug)]
pub struct AxisRefEdge {
pub ref_: TopoRef,
}
impl ToJson for AxisRefEdge {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "edge");
o.set("ref", self.ref_.to_json());
o
}
}
#[derive(Clone, Debug)]
pub struct AxisRefPoints {
pub a: Vec3,
pub b: Vec3,
}
impl ToJson for AxisRefPoints {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "points");
o.set("a", self.a.to_json());
o.set("b", self.b.to_json());
o
}
}
#[derive(Clone, Debug)]
pub enum AxisRef {
DatumAxis(AxisRefDatumAxis),
Datum(AxisRefDatum),
SketchLine(AxisRefSketchLine),
Edge(AxisRefEdge),
Points(AxisRefPoints),
}
impl ToJson for AxisRef {
fn to_json(&self) -> Json {
match self {
AxisRef::DatumAxis(x) => x.to_json(),
AxisRef::Datum(x) => x.to_json(),
AxisRef::SketchLine(x) => x.to_json(),
AxisRef::Edge(x) => x.to_json(),
AxisRef::Points(x) => x.to_json(),
}
}
}
impl From<AxisRefDatumAxis> for AxisRef {
fn from(x: AxisRefDatumAxis) -> AxisRef {
AxisRef::DatumAxis(x)
}
}
impl From<AxisRefDatum> for AxisRef {
fn from(x: AxisRefDatum) -> AxisRef {
AxisRef::Datum(x)
}
}
impl From<AxisRefSketchLine> for AxisRef {
fn from(x: AxisRefSketchLine) -> AxisRef {
AxisRef::SketchLine(x)
}
}
impl From<AxisRefEdge> for AxisRef {
fn from(x: AxisRefEdge) -> AxisRef {
AxisRef::Edge(x)
}
}
impl From<AxisRefPoints> for AxisRef {
fn from(x: AxisRefPoints) -> AxisRef {
AxisRef::Points(x)
}
}
#[derive(Clone, Debug)]
pub struct RevolveProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The sketch regions to revolve.
pub profile: ProfileRef,
/// The axis it turns about.
pub axis: AxisRef,
/// Angle in radians.
/// Unit: rad.
/// Default: `6.283185307179586`.
pub angle: Option<f64>,
/// Turn the other way.
pub reverse: Option<bool>,
/// A SURFACE, not a solid: the profile's edges (the outer edges of its closed regions, or the sketch's open chain) turned about the axis, a body of their own with no inside. A surface is always a new body.
/// Default: `false`.
pub surface: Option<bool>,
/// How the solid combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for RevolveProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("profile", self.profile.to_json());
o.set("axis", self.axis.to_json());
if let Some(v) = &self.angle {
o.set("angle", v.to_json());
}
if let Some(v) = &self.reverse {
o.set("reverse", v.to_json());
}
if let Some(v) = &self.surface {
o.set("surface", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl RevolveProps {
/// The `revolve` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("revolve");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// How the profile turns along the path. "minimal": only as much as the path turns, with no roll about it (a rotation-minimizing frame); "frenet": it keeps its place against the path's principal normal (a flat yarn stays flat on a helix's cylinder; not defined where the path is straight); "up": its frame keeps `up` as the binormal (a level path stays level); "guide": its frame points at the `guide` curve.
/// Default: `"minimal"`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SweepPropsFrame {
/// `"minimal"`
Minimal,
/// `"frenet"`
Frenet,
/// `"up"`
Up,
/// `"guide"`
Guide,
}
impl ToJson for SweepPropsFrame {
fn to_json(&self) -> Json {
Json::from(match self {
SweepPropsFrame::Minimal => "minimal",
SweepPropsFrame::Frenet => "frenet",
SweepPropsFrame::Up => "up",
SweepPropsFrame::Guide => "guide",
})
}
}
#[derive(Clone, Debug)]
pub struct SweepProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The cross-section that is swept. A region with holes sweeps a hollow solid (a hose, a tube).
pub profile: ProfileRef,
/// What the profile follows: a sketch's open or closed chain on its plane (`{ sketch }`), or a curve in space (`{ curve }`, the id of a `curve` feature). The profile stays where it is drawn and turns with the path: draw it on the curve's own plane (`plane={{ type: "datum", plane: <the curve's id> }}`) to start where the curve starts.
pub path: Json,
/// How the profile turns along the path. "minimal": only as much as the path turns, with no roll about it (a rotation-minimizing frame); "frenet": it keeps its place against the path's principal normal (a flat yarn stays flat on a helix's cylinder; not defined where the path is straight); "up": its frame keeps `up` as the binormal (a level path stays level); "guide": its frame points at the `guide` curve.
/// Default: `"minimal"`.
pub frame: Option<SweepPropsFrame>,
/// The direction the profile's frame keeps as its binormal.
/// Default: `[0,0,1]`.
pub up: Option<Vec3>,
/// The `curve` feature the profile's frame points at, by id.
pub guide: Option<String>,
/// How far the profile turns about the path from its start to its end, evenly along its length (a twisted bar, a cable's lay), on top of the frame: "minimal", "frenet" or "up". For a path that is an open, smooth curve.
/// Unit: rad.
pub twist: Option<f64>,
/// A SURFACE, not a solid: the profile's outer edges (or the sketch's open chain) swept along the path, a body of its own with no inside and no end caps. A surface is always a new body.
/// Default: `false`.
pub surface: Option<bool>,
/// How the solid combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SweepProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("profile", self.profile.to_json());
o.set("path", self.path.to_json());
if let Some(v) = &self.frame {
o.set("frame", v.to_json());
}
if let Some(v) = &self.up {
o.set("up", v.to_json());
}
if let Some(v) = &self.guide {
o.set("guide", v.to_json());
}
if let Some(v) = &self.twist {
o.set("twist", v.to_json());
}
if let Some(v) = &self.surface {
o.set("surface", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SweepProps {
/// The `sweep` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("sweep");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// What the curve is. "spline": a smooth cubic through `points` (C2, interpolated); "polyline": straight lines through `points`, each corner rounded to `bendRadius` (sharp without it); "helix": `turns` turns of `radius` and `pitch` about `axis`.
/// Default: `"spline"`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CurvePropsKind {
/// `"spline"`
Spline,
/// `"polyline"`
Polyline,
/// `"helix"`
Helix,
}
impl ToJson for CurvePropsKind {
fn to_json(&self) -> Json {
Json::from(match self {
CurvePropsKind::Spline => "spline",
CurvePropsKind::Polyline => "polyline",
CurvePropsKind::Helix => "helix",
})
}
}
/// A spline's direction at one of its inner points.
#[derive(Clone, Debug)]
pub struct SplineTangent {
/// Which point, by its index in `points` (not the first or the last: those are `startTangent` and `endTangent`).
pub at: i64,
/// The direction there (only the direction counts).
pub direction: Vec3,
}
impl ToJson for SplineTangent {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("at", self.at.to_json());
o.set("direction", self.direction.to_json());
o
}
}
/// How hard a given tangent holds (build123d's tangent scalars): its speed, in lengths of the chord-length parameter. 1 is the natural spline; more holds the direction longer (a looser end), less lets the curve turn sooner (a tighter one). One number for every given tangent, or one per given tangent in order along the spline: the start's, the inner ones' (by point), the end's.
/// Default: `1`.
#[derive(Clone, Debug)]
pub enum CurvePropsTangentScale {
Number(f64),
Numbers(Vec<f64>),
}
impl ToJson for CurvePropsTangentScale {
fn to_json(&self) -> Json {
match self {
CurvePropsTangentScale::Number(x) => x.to_json(),
CurvePropsTangentScale::Numbers(x) => x.to_json(),
}
}
}
impl From<f64> for CurvePropsTangentScale {
fn from(x: f64) -> CurvePropsTangentScale {
CurvePropsTangentScale::Number(x)
}
}
impl From<Vec<f64>> for CurvePropsTangentScale {
fn from(x: Vec<f64>) -> CurvePropsTangentScale {
CurvePropsTangentScale::Numbers(x)
}
}
/// A CURVE IN SPACE: a path that is not drawn on one plane (a hose, a wire lead, a tendon housing, a braid yarn), what a sweep follows (`path={{ curve: <id> }}`) or points its profile at (`guide`). It makes no body. It is also a plane, under its own id: the plane normal to the curve at its start (origin: the start; normal: the curve's direction there; x-axis: `xAxis`), so a profile sketch drawn on it (`plane={{ type: "datum", plane: <id> }}`) starts the sweep where the curve starts.
#[derive(Clone, Debug)]
pub struct CurveProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// What the curve is. "spline": a smooth cubic through `points` (C2, interpolated); "polyline": straight lines through `points`, each corner rounded to `bendRadius` (sharp without it); "helix": `turns` turns of `radius` and `pitch` about `axis`.
/// Default: `"spline"`.
pub kind: Option<CurvePropsKind>,
/// The points it passes through, in order.
/// Unit: mm.
pub points: Option<Vec<Vec3>>,
/// The direction it leaves the first point (only the direction counts).
pub start_tangent: Option<Vec3>,
/// The direction it arrives at the last point (only the direction counts).
pub end_tangent: Option<Vec3>,
/// The directions it passes inner points in (only the direction counts): the spline is cut there into C2 pieces that meet in that direction at one speed (C1). Not for a closed spline.
pub tangents: Option<Vec<SplineTangent>>,
/// How hard a given tangent holds (build123d's tangent scalars): its speed, in lengths of the chord-length parameter. 1 is the natural spline; more holds the direction longer (a looser end), less lets the curve turn sooner (a tighter one). One number for every given tangent, or one per given tangent in order along the spline: the start's, the inner ones' (by point), the end's.
/// Default: `1`.
pub tangent_scale: Option<CurvePropsTangentScale>,
/// Back to the first point: a periodic spline, a closed polyline.
pub closed: Option<bool>,
/// The radius each corner of the polyline is rounded to.
/// Unit: mm.
pub bend_radius: Option<f64>,
/// Where the helix's axis starts: the helix starts at this height.
/// Unit: mm.
/// Default: `[0,0,0]`.
pub origin: Option<Vec3>,
/// The helix's axis: it rises along it.
/// Default: `[0,0,1]`.
pub axis: Option<Vec3>,
/// The helix's radius (from the axis to the curve).
/// Unit: mm.
/// Default: `10`.
pub radius: Option<f64>,
/// How far the helix rises in one turn.
/// Unit: mm.
/// Default: `5`.
pub pitch: Option<f64>,
/// How many turns.
/// Default: `3`.
pub turns: Option<f64>,
/// Right-handed (the default) or left-handed.
/// Default: `true`.
pub right_handed: Option<bool>,
/// The direction from the axis to where the helix starts.
/// Default: `[1,0,0]`.
pub start: Option<Vec3>,
/// The x-axis of the curve's start plane (projected onto it): which way a profile drawn there faces. Absent: world z projected onto the plane, or world x where the curve starts along z.
pub x_axis: Option<Vec3>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for CurveProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.kind {
o.set("kind", v.to_json());
}
if let Some(v) = &self.points {
o.set("points", v.to_json());
}
if let Some(v) = &self.start_tangent {
o.set("startTangent", v.to_json());
}
if let Some(v) = &self.end_tangent {
o.set("endTangent", v.to_json());
}
if let Some(v) = &self.tangents {
o.set("tangents", v.to_json());
}
if let Some(v) = &self.tangent_scale {
o.set("tangentScale", v.to_json());
}
if let Some(v) = &self.closed {
o.set("closed", v.to_json());
}
if let Some(v) = &self.bend_radius {
o.set("bendRadius", v.to_json());
}
if let Some(v) = &self.origin {
o.set("origin", v.to_json());
}
if let Some(v) = &self.axis {
o.set("axis", v.to_json());
}
if let Some(v) = &self.radius {
o.set("radius", v.to_json());
}
if let Some(v) = &self.pitch {
o.set("pitch", v.to_json());
}
if let Some(v) = &self.turns {
o.set("turns", v.to_json());
}
if let Some(v) = &self.right_handed {
o.set("rightHanded", v.to_json());
}
if let Some(v) = &self.start {
o.set("start", v.to_json());
}
if let Some(v) = &self.x_axis {
o.set("xAxis", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl CurveProps {
/// The `curve` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("curve");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// How an end is held: soldered to a pad or a joint, crimped, inserted in a socket, or pinned at a point (free to turn).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RodHold {
/// `"solder"`
Solder,
/// `"crimp"`
Crimp,
/// `"insert"`
Insert,
/// `"pin"`
Pin,
}
impl ToJson for RodHold {
fn to_json(&self) -> Json {
Json::from(match self {
RodHold::Solder => "solder",
RodHold::Crimp => "crimp",
RodHold::Insert => "insert",
RodHold::Pin => "pin",
})
}
}
/// Where a rod's end is held.
#[derive(Clone, Debug)]
pub struct RodEnd {
/// A port: one of this document's (`<port>`; a member of a row of them by its id and number, `a12`), a placed file's (`<placement id>/<port>`) or a placed component's pad (`<placement id>/<pad number>`). The port says how it holds.
pub port: Option<String>,
/// Or a body, by id: the end is held on it where it is drawn (a lead in its part's body, a hair in the scalp).
pub body: Option<String>,
/// How a body holds it.
/// Default: `"solder"`.
pub hold: Option<RodHold>,
}
impl ToJson for RodEnd {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.port {
o.set("port", v.to_json());
}
if let Some(v) = &self.body {
o.set("body", v.to_json());
}
if let Some(v) = &self.hold {
o.set("hold", v.to_json());
}
o
}
}
/// A point of a rod held still: the point `along` its strand from its first point, held at `at`.
#[derive(Clone, Debug)]
pub struct RodPin {
/// Which strand (its index).
/// Default: `0`.
pub strand: Option<i64>,
/// How far along the strand from its first point.
/// Unit: mm.
pub along: f64,
/// Where it is held.
/// Unit: mm.
pub at: Vec3,
}
impl ToJson for RodPin {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.strand {
o.set("strand", v.to_json());
}
o.set("along", self.along.to_json());
o.set("at", self.at.to_json());
o
}
}
/// A ROD: a wire, a component's lead, a string, a hair, a cable, a flat flex, a spring: an elastic body much longer than it is wide, with a bend that springs back below its yield and sets beyond it (docs/formats.md § a 3D document's rods). It makes no solid body: it is drawn as its section along its points, and the `rod` family of the dynamics simulates it (live in editing with `activation: { rod: "always" }`). Its shape is its rest shape: a permanent bend made in the editor is written back as its points. What it connects (a conductor joining two ports' nets) is read from its ends and its material, not stated on it.
#[derive(Clone, Debug)]
pub struct RodProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Its points at rest, in order (one rod). Absent with `from` and `to`: laid between its two ends with its slack.
/// Unit: mm.
pub points: Option<Vec<Vec3>>,
/// Many rods of one material and section (a head of hair, a brush, a harness's strands), each its points at rest.
/// Unit: mm.
pub strands: Option<Vec<Vec<Vec3>>>,
/// What it is made of: a row of the rods tables along the search path (`materials/rods.csv`: a wire, its conductor and insulation and their diameters; it gives the section too), or a grade of the engineering tables with `section`.
pub material: Option<String>,
/// Its cross-section, where its material's row states none: a circle, a tube or a rectangle (a ribbon).
/// Unit: mm.
pub section: Option<Json>,
/// Where its first end (each strand's first point) is held, and how. Absent: free.
pub from: Option<RodEnd>,
/// Where its last end (each strand's last point) is held, and how. Absent: free.
pub to: Option<RodEnd>,
/// Its length, laid between `from` and `to` with no points.
/// Unit: mm.
pub length: Option<f64>,
/// Laid between `from` and `to` with no points or length: how much longer than the straight distance it is (0.2: 20 % longer).
/// Default: `0.15`.
pub slack: Option<f64>,
/// The section's first axis at its start (a ribbon's width). Absent: across its first edge, toward world z.
pub up: Option<Vec3>,
/// The distance between its nodes in the simulation. Absent: its length over 24, at least 2 diameters.
/// Unit: mm.
pub segment: Option<f64>,
/// Its strands from a file: an OBJ's polylines (its `l` records), in mm, each from its root (its first point, where `from` holds it) to its tip. A path from this file's folder. A head of hair's guide strands.
pub file: Option<String>,
/// Points of it held still where they are (a middle point a force drag let go of with Shift).
pub pins: Option<Vec<RodPin>>,
/// Its strands are guides, each standing for many (a head of hair): they pass through each other (they still meet bodies, cloths and other rods), and each is stepped once a step, which the direct solve keeps within 0.01 mm of its static answer. 800 guides of 8 points then run in the editor.
/// Default: `false`.
pub guides: Option<bool>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for RodProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.points {
o.set("points", v.to_json());
}
if let Some(v) = &self.strands {
o.set("strands", v.to_json());
}
if let Some(v) = &self.material {
o.set("material", v.to_json());
}
if let Some(v) = &self.section {
o.set("section", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.to {
o.set("to", v.to_json());
}
if let Some(v) = &self.length {
o.set("length", v.to_json());
}
if let Some(v) = &self.slack {
o.set("slack", v.to_json());
}
if let Some(v) = &self.up {
o.set("up", v.to_json());
}
if let Some(v) = &self.segment {
o.set("segment", v.to_json());
}
if let Some(v) = &self.file {
o.set("file", v.to_json());
}
if let Some(v) = &self.pins {
o.set("pins", v.to_json());
}
if let Some(v) = &self.guides {
o.set("guides", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl RodProps {
/// The `rod` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("rod");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct LoftProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The sections the solid passes through, in order.
pub profiles: Vec<ProfileRef>,
/// Straight faces between the sections instead of a smooth skin.
pub ruled: Option<bool>,
/// Join the last section back to the first.
pub closed: Option<bool>,
/// A SURFACE, not a solid: a skin through the sections' outer edges (or each sketch's open chain), with no end caps and no inside, a body of its own. A surface is always a new body.
/// Default: `false`.
pub surface: Option<bool>,
/// How the solid combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for LoftProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("profiles", self.profiles.to_json());
if let Some(v) = &self.ruled {
o.set("ruled", v.to_json());
}
if let Some(v) = &self.closed {
o.set("closed", v.to_json());
}
if let Some(v) = &self.surface {
o.set("surface", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl LoftProps {
/// The `loft` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("loft");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct FilletProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The edges to round.
pub edges: Vec<Json>,
/// The radius of the round.
/// Unit: mm.
/// Default: `2`.
pub radius: Option<f64>,
/// Optional end radius — when set and ≠ radius, the fillet varies along each edge.
/// Unit: mm.
pub radius2: Option<f64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for FilletProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("edges", self.edges.to_json());
if let Some(v) = &self.radius {
o.set("radius", v.to_json());
}
if let Some(v) = &self.radius2 {
o.set("radius2", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl FilletProps {
/// The `fillet` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("fillet");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct ChamferProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The edges to bevel.
pub edges: Vec<Json>,
/// The bevel's distance from the edge.
/// Unit: mm.
/// Default: `2`.
pub distance: Option<f64>,
/// Second distance for an asymmetric chamfer (measured from the other face).
/// Unit: mm.
pub distance2: Option<f64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for ChamferProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("edges", self.edges.to_json());
if let Some(v) = &self.distance {
o.set("distance", v.to_json());
}
if let Some(v) = &self.distance2 {
o.set("distance2", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl ChamferProps {
/// The `chamfer` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("chamfer");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct ShellProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The faces to open.
pub faces: Vec<Json>,
/// The wall thickness.
/// Unit: mm.
/// Default: `2`.
pub thickness: Option<f64>,
/// Shell outward instead of inward.
pub outward: Option<bool>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for ShellProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("faces", self.faces.to_json());
if let Some(v) = &self.thickness {
o.set("thickness", v.to_json());
}
if let Some(v) = &self.outward {
o.set("outward", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl ShellProps {
/// The `shell` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("shell");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct BoxProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The centre of the box.
/// Unit: mm.
/// Default: `[0,0,0]`.
pub center: Option<Vec3>,
/// Its size along X, Y and Z.
/// Unit: mm.
/// Default: `[20,20,20]`.
pub size: Option<Vec3>,
/// How the solid combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for BoxProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.center {
o.set("center", v.to_json());
}
if let Some(v) = &self.size {
o.set("size", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl BoxProps {
/// The `box` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("box");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// Source format of the embedded file content: STEP, IGES, or an OpenCASCADE BRep (a FreeCAD document's shape).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ImportPropsFormat {
/// `"step"`
Step,
/// `"iges"`
Iges,
/// `"brep"`
Brep,
}
impl ToJson for ImportPropsFormat {
fn to_json(&self) -> Json {
Json::from(match self {
ImportPropsFormat::Step => "step",
ImportPropsFormat::Iges => "iges",
ImportPropsFormat::Brep => "brep",
})
}
}
#[derive(Clone, Debug)]
pub struct ImportProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Source format of the embedded file content: STEP, IGES, or an OpenCASCADE BRep (a FreeCAD document's shape).
pub format: ImportPropsFormat,
/// Raw STEP/IGES/BRep file content.
pub data: String,
/// How the imported solid combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for ImportProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("format", self.format.to_json());
o.set("data", self.data.to_json());
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl ImportProps {
/// The `import` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("import");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// How to interpret the linked file: a 3D document in code (`"3d"`, a `.3d.tsx`, `.3d.py` or `.3d.rs` run), a foreign solid imported via the named importer ("step"/"iges"), or a board converted to a 3D solid on open — a KiCad board ("kicad_pcb") or a board in code, in the language it is written in ("pcb.tsx", "pcb.jsx", "pcb.py", "pcb.rs"; a LIVE link, so board edits re-mesh here). Mirrors `FileRef.importer`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ExternalPartPropsImporter {
/// `"step"`
Step,
/// `"iges"`
Iges,
/// `"3d"`
V3d,
/// `"wrl"`
Wrl,
/// `"glb"`
Glb,
/// `"gltf"`
Gltf,
/// `"obj"`
Obj,
/// `"stl"`
Stl,
/// `"ply"`
Ply,
/// `"3mf"`
V3mf,
/// `"fbx"`
Fbx,
/// `"dae"`
Dae,
/// `"usd"`
Usd,
/// `"3dxml"`
V3dxml,
/// `"jt"`
Jt,
/// `"kicad_pcb"`
KicadPcb,
/// `"pcb.tsx"`
PcbTsx,
/// `"pcb.jsx"`
PcbJsx,
/// `"pcb.py"`
PcbPy,
/// `"pcb.rs"`
PcbRs,
}
impl ToJson for ExternalPartPropsImporter {
fn to_json(&self) -> Json {
Json::from(match self {
ExternalPartPropsImporter::Step => "step",
ExternalPartPropsImporter::Iges => "iges",
ExternalPartPropsImporter::V3d => "3d",
ExternalPartPropsImporter::Wrl => "wrl",
ExternalPartPropsImporter::Glb => "glb",
ExternalPartPropsImporter::Gltf => "gltf",
ExternalPartPropsImporter::Obj => "obj",
ExternalPartPropsImporter::Stl => "stl",
ExternalPartPropsImporter::Ply => "ply",
ExternalPartPropsImporter::V3mf => "3mf",
ExternalPartPropsImporter::Fbx => "fbx",
ExternalPartPropsImporter::Dae => "dae",
ExternalPartPropsImporter::Usd => "usd",
ExternalPartPropsImporter::V3dxml => "3dxml",
ExternalPartPropsImporter::Jt => "jt",
ExternalPartPropsImporter::KicadPcb => "kicad_pcb",
ExternalPartPropsImporter::PcbTsx => "pcb.tsx",
ExternalPartPropsImporter::PcbJsx => "pcb.jsx",
ExternalPartPropsImporter::PcbPy => "pcb.py",
ExternalPartPropsImporter::PcbRs => "pcb.rs",
})
}
}
/// A rigid placement of a part in assembly space: a position, an orientation quaternion, and a uniform scale. Mirrors import but is self-contained (no pivot — the part is placed about its own origin) so the pure model has no kernel dependency.
#[derive(Clone, Debug)]
pub struct Placement {
/// Translation in mm.
/// Unit: mm.
/// Default: `[0,0,0]`.
pub position: Option<Vec3>,
/// Orientation as a unit quaternion [x, y, z, w]: it turns the part and never scales it. One within 1e-5 of unit length (written to 6 decimals) is read as the rotation it rounds; one further off is refused.
/// Default: `[0,0,0,1]`.
pub quaternion: Option<[f64; 4]>,
/// Uniform scale factor (1 = identity).
/// Default: `1`.
pub scale: Option<f64>,
/// Optional per-axis scale applied before scale. This is primarily used by linked interchange assets (KiCad WRL/STEP model records carry an XYZ scale). It is additive: documents that omit it retain the historic uniform-scale placement.
pub scale_x_y_z: Option<Vec3>,
}
impl ToJson for Placement {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.position {
o.set("position", v.to_json());
}
if let Some(v) = &self.quaternion {
o.set("quaternion", v.to_json());
}
if let Some(v) = &self.scale {
o.set("scale", v.to_json());
}
if let Some(v) = &self.scale_x_y_z {
o.set("scaleXYZ", v.to_json());
}
o
}
}
/// ONE PAD of a component's footprint, in the copper-layer plane's own (u,v) millimetres relative to the placement origin.
#[derive(Clone, Debug)]
pub struct FootprintPad {
/// The pin this pad is, as the part names it: `1`, `A2`, `GND`.
pub terminal: String,
/// Which copper layer the pad is on.
pub layer: String,
/// Pad centre in the layer plane's (u,v) mm, relative to the placement origin.
pub at: [f64; 2],
/// Pad extent (u,v) in mm. Presentation and clearance; the binding does not read it.
pub size: Option<[f64; 2]>,
}
impl ToJson for FootprintPad {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("terminal", self.terminal.to_json());
o.set("layer", self.layer.to_json());
o.set("at", self.at.to_json());
if let Some(v) = &self.size {
o.set("size", v.to_json());
}
o
}
}
/// WHICH COPPER LAYER a conductor lives on — its name and the datum plane it is drawn in.
#[derive(Clone, Debug)]
pub struct CopperLayerRef {
/// The layer's name as the design's planar geometry refers to it — `F.Cu`, `In1.Cu`, `M1`.
pub name: String,
/// The datum plane this layer's sketches are drawn on. A dependency edge.
pub plane: Option<String>,
}
impl ToJson for CopperLayerRef {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("name", self.name.to_json());
if let Some(v) = &self.plane {
o.set("plane", v.to_json());
}
o
}
}
/// A placed component's footprint — the pads it contributes, and the planes they land on.
#[derive(Clone, Debug)]
pub struct ComponentFootprint {
/// Footprint library id, when the part came from one (`Resistor_SMD:R_0805_2012Metric`).
pub lib_id: Option<String>,
pub pads: Vec<FootprintPad>,
/// The copper layer planes the pads are projected onto. Each is a dependency edge.
pub layers: Vec<CopperLayerRef>,
/// WHICH SCHEMATIC PART THIS PLACEMENT REALISES — declared, and never matched by name.
pub part: Option<String>,
}
impl ToJson for ComponentFootprint {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.lib_id {
o.set("libId", v.to_json());
}
o.set("pads", self.pads.to_json());
o.set("layers", self.layers.to_json());
if let Some(v) = &self.part {
o.set("part", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct ExternalPartPropsEndsValue {
pub from: Option<RodEnd>,
pub to: Option<RodEnd>,
}
impl ToJson for ExternalPartPropsEndsValue {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.to {
o.set("to", v.to_json());
}
o
}
}
/// One body of a placed 3D document moved in its file's frame (`<externalPart moves>`).
#[derive(Clone, Debug)]
pub struct PlacedMove {
/// The body or the placed file, by the id, the name or the part number its own file gives it (`*` matches any text).
pub body: String,
/// Its move, in the placed file's frame.
pub placement: Placement,
}
impl ToJson for PlacedMove {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("body", self.body.to_json());
o.set("placement", self.placement.to_json());
o
}
}
/// A LINKED (not embedded) part reference. Unlike ImportFeature — which copies the foreign STEP/IGES bytes into the document — an `ExternalPartRef` only records *where* to find another Drive file (by id or name) and reloads it on open. This keeps a part reusable across assemblies and lets a part edit propagate to every place it's used. The reference system (`cad/references.ts`) turns these into `FileRef`s (`role:"part"`); the editor resolves + meshes them. Foreign solids carry an `importer` ("step"/"iges") so the resolver knows to run the import path rather than run a `.3d.tsx`.
#[derive(Clone, Debug)]
pub struct ExternalPartProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Host file id of the linked part, when the host has ids (never the reference's locator).
pub file_id: Option<String>,
/// The linked part's path relative to this document's folder — what the reference resolves by.
pub path: Option<String>,
/// Filename of the linked part (fallback locator when no path, or a human label).
pub file_name: Option<String>,
/// How to interpret the linked file: a 3D document in code (`"3d"`, a `.3d.tsx`, `.3d.py` or `.3d.rs` run), a foreign solid imported via the named importer ("step"/"iges"), or a board converted to a 3D solid on open — a KiCad board ("kicad_pcb") or a board in code, in the language it is written in ("pcb.tsx", "pcb.jsx", "pcb.py", "pcb.rs"; a LIVE link, so board edits re-mesh here). Mirrors `FileRef.importer`.
pub importer: Option<ExternalPartPropsImporter>,
/// One node of the linked file, where the file holds several things a placement may place: for a 3DXML (`importer: "3dxml"`), the ReferenceRep it draws, `<structure file>#<id>` (`Product.3dxml#4`; docs/formats.md § 3DXML); for a JT file (`importer: "jt"`), the shape node it draws, by its object id in the file's scene graph (`49`; docs/formats.md § JT). Absent: the whole file.
pub node: Option<String>,
/// Millimetres represented by one source coordinate for unitless/scene formats. Defaults are format-aware (glTF/VRML standard metres → 1000 mm; OBJ/STL → 1 mm). KiCad WRL adapters set 2.54.
pub unit_scale_mm: Option<f64>,
/// Where to place the linked part's bodies in this document's space.
/// Default: `{"position":[0,0,0],"quaternion":[0,0,0,1],"scale":1}`.
pub placement: Option<Placement>,
/// THE COMPONENT THIS BODY BELONGS TO — the placement feature whose footprint owns it.
pub component: Option<String>,
/// THIS BODY'S POSE IN ITS COMPONENT'S FRAME. Present exactly when component is.
pub local_placement: Option<Placement>,
/// THE PADS THIS PLACEMENT PRODUCES, when it is a placed electronic component.
pub footprint: Option<ComponentFootprint>,
/// A placed 3D document: what of it is left out here, each by the id, the name or the part number its own file gives it (`*` matches any text): a body it makes, a file it places (its id names everything placed under it), a fastener stack, an `<item>`. What its file says of a body left out (an `<accept>`, a `<permitted>`, the stacks that hold it) goes with it. An entry that names nothing of the file is an error. One frame in every station, each station with its own deck: `omit={["deck"]}`.
pub omit: Option<Vec<String>>,
/// A placed 3D document: where its rods' ends are held here, by the rod's id in its file (a resistor's leads in a breadboard's sockets: `ends={{ leg1: { to: { port: "bb/e12" } } }}`). Each end stated here is held so, over its file's.
pub ends: Option<Vec<(String, ExternalPartPropsEndsValue)>>,
/// A placed 3D document: bodies it makes or files it places, each moved in its file's frame before the placement (a lid opened, a ram lowered), by the id, the name or the part number its own file gives it (a placed file's id moves everything placed under it). What its file says of the body (an `<accept>` or `<permitted>` region, in the body's own frame) moves with it, and so do its spare holes and the fastener stacks that hold only what one move moves. An entry that names nothing of the file is an error.
pub moves: Option<Vec<PlacedMove>>,
/// A placed 3D document at other values of its `<parameter>`s, each by its name: a library profile at its cut length (`inputs={{ length: 2830 }}`), a screw at its length. The file is built at those values for this placement alone; a name the file does not declare is an error of the placement.
pub inputs: Option<Vec<(String, f64)>>,
/// How the linked part's bodies combine with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for ExternalPartProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.file_id {
o.set("fileId", v.to_json());
}
if let Some(v) = &self.path {
o.set("path", v.to_json());
}
if let Some(v) = &self.file_name {
o.set("fileName", v.to_json());
}
if let Some(v) = &self.importer {
o.set("importer", v.to_json());
}
if let Some(v) = &self.node {
o.set("node", v.to_json());
}
if let Some(v) = &self.unit_scale_mm {
o.set("unitScaleMm", v.to_json());
}
if let Some(v) = &self.placement {
o.set("placement", v.to_json());
}
if let Some(v) = &self.component {
o.set("component", v.to_json());
}
if let Some(v) = &self.local_placement {
o.set("localPlacement", v.to_json());
}
if let Some(v) = &self.footprint {
o.set("footprint", v.to_json());
}
if let Some(v) = &self.omit {
o.set("omit", v.to_json());
}
if let Some(v) = &self.ends {
o.set("ends", v.to_json());
}
if let Some(v) = &self.moves {
o.set("moves", v.to_json());
}
if let Some(v) = &self.inputs {
o.set("inputs", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl ExternalPartProps {
/// The `externalPart` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("externalPart");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct CylinderProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The centre of its base, not of the solid (a box's `center` is its middle): it runs `height` from here along `axis`.
/// Unit: mm.
/// Default: `[0,0,0]`.
pub center: Option<Vec3>,
/// The direction it rises along.
/// Default: `[0,0,1]`.
pub axis: Option<Vec3>,
/// Unit: mm.
/// Default: `10`.
pub radius: Option<f64>,
/// Unit: mm.
/// Default: `20`.
pub height: Option<f64>,
/// How the solid combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for CylinderProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.center {
o.set("center", v.to_json());
}
if let Some(v) = &self.axis {
o.set("axis", v.to_json());
}
if let Some(v) = &self.radius {
o.set("radius", v.to_json());
}
if let Some(v) = &self.height {
o.set("height", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl CylinderProps {
/// The `cylinder` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("cylinder");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct SphereProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Unit: mm.
/// Default: `[0,0,0]`.
pub center: Option<Vec3>,
/// Unit: mm.
/// Default: `10`.
pub radius: Option<f64>,
/// How the solid combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SphereProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.center {
o.set("center", v.to_json());
}
if let Some(v) = &self.radius {
o.set("radius", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SphereProps {
/// The `sphere` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("sphere");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct ConeProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The centre of its base, not of the solid (a box's `center` is its middle): it runs `height` from here along `axis`.
/// Unit: mm.
/// Default: `[0,0,0]`.
pub center: Option<Vec3>,
/// The direction it rises along.
/// Default: `[0,0,1]`.
pub axis: Option<Vec3>,
/// The radius at the base.
/// Unit: mm.
/// Default: `10`.
pub radius1: Option<f64>,
/// The radius at the top (0: a point).
/// Unit: mm.
/// Default: `0`.
pub radius2: Option<f64>,
/// Unit: mm.
/// Default: `20`.
pub height: Option<f64>,
/// How the solid combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for ConeProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.center {
o.set("center", v.to_json());
}
if let Some(v) = &self.axis {
o.set("axis", v.to_json());
}
if let Some(v) = &self.radius1 {
o.set("radius1", v.to_json());
}
if let Some(v) = &self.radius2 {
o.set("radius2", v.to_json());
}
if let Some(v) = &self.height {
o.set("height", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl ConeProps {
/// The `cone` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("cone");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// A REAL human body: MakeHuman's hm08 basemesh morphed by its macro targets.
#[derive(Clone, Debug)]
pub struct MakeHumanProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Catmull-Clark refinement levels applied to the body surface. Absent or 0 = the control cage itself.
pub subdivision: Option<i64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
/// Default: `0.5`.
pub gender: Option<f64>,
/// Default: `0.5`.
pub age: Option<f64>,
/// Default: `0.5`.
pub muscle: Option<f64>,
/// Default: `0.5`.
pub weight: Option<f64>,
/// Default: `0.5`.
pub height: Option<f64>,
/// Default: `0.5`.
pub proportions: Option<f64>,
/// Default: `0.5`.
pub cupsize: Option<f64>,
/// Default: `0.5`.
pub firmness: Option<f64>,
/// One third of the ethnicity simplex (the three sum to 1).
/// Default: `0.3333333333333333`.
pub african: Option<f64>,
/// Default: `0.3333333333333333`.
pub asian: Option<f64>,
/// Default: `0.3333333333333333`.
pub caucasian: Option<f64>,
}
impl ToJson for MakeHumanProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.subdivision {
o.set("subdivision", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
if let Some(v) = &self.gender {
o.set("gender", v.to_json());
}
if let Some(v) = &self.age {
o.set("age", v.to_json());
}
if let Some(v) = &self.muscle {
o.set("muscle", v.to_json());
}
if let Some(v) = &self.weight {
o.set("weight", v.to_json());
}
if let Some(v) = &self.height {
o.set("height", v.to_json());
}
if let Some(v) = &self.proportions {
o.set("proportions", v.to_json());
}
if let Some(v) = &self.cupsize {
o.set("cupsize", v.to_json());
}
if let Some(v) = &self.firmness {
o.set("firmness", v.to_json());
}
if let Some(v) = &self.african {
o.set("african", v.to_json());
}
if let Some(v) = &self.asian {
o.set("asian", v.to_json());
}
if let Some(v) = &self.caucasian {
o.set("caucasian", v.to_json());
}
o
}
}
impl MakeHumanProps {
/// The `makeHuman` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("makeHuman");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct LinearPatternProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Features whose bodies are patterned.
pub seed_feature: String,
/// The direction of the copies.
/// Default: `[1,0,0]`.
pub direction: Option<Vec3>,
/// The distance between copies.
/// Unit: mm.
/// Default: `20`.
pub spacing: Option<f64>,
/// How many there are, the original included.
/// Default: `3`.
pub count: Option<i64>,
/// Optional second direction.
pub direction2: Option<Vec3>,
/// The distance between copies in the second direction.
/// Unit: mm.
pub spacing2: Option<f64>,
/// How many there are in the second direction.
pub count2: Option<i64>,
/// How the copies combine with the bodies they act on. Absent: the repeated feature's own operation. A pattern of a cut cuts only the bodies it consumes (`consumes`; absent: the bodies the repeated feature consumes).
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for LinearPatternProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("seedFeature", self.seed_feature.to_json());
if let Some(v) = &self.direction {
o.set("direction", v.to_json());
}
if let Some(v) = &self.spacing {
o.set("spacing", v.to_json());
}
if let Some(v) = &self.count {
o.set("count", v.to_json());
}
if let Some(v) = &self.direction2 {
o.set("direction2", v.to_json());
}
if let Some(v) = &self.spacing2 {
o.set("spacing2", v.to_json());
}
if let Some(v) = &self.count2 {
o.set("count2", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl LinearPatternProps {
/// The `linearPattern` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("linearPattern");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct CircularPatternProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The feature whose bodies are patterned.
pub seed_feature: String,
/// The axis the copies turn about.
pub axis: AxisRef,
/// How many there are, the original included.
/// Default: `6`.
pub count: Option<i64>,
/// Total sweep angle in radians (default 2π).
/// Unit: rad.
/// Default: `6.283185307179586`.
pub angle: Option<f64>,
/// How the copies combine with the bodies they act on. Absent: the repeated feature's own operation. A pattern of a cut cuts only the bodies it consumes (`consumes`; absent: the bodies the repeated feature consumes).
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for CircularPatternProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("seedFeature", self.seed_feature.to_json());
o.set("axis", self.axis.to_json());
if let Some(v) = &self.count {
o.set("count", v.to_json());
}
if let Some(v) = &self.angle {
o.set("angle", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl CircularPatternProps {
/// The `circularPattern` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("circularPattern");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct PathPatternProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The feature whose bodies are patterned.
pub seed_feature: String,
/// What the copies are placed along, evenly by length from its start: a sketch's open or closed chain (`{ sketch }`), or a curve in space (`{ curve }`, the id of a `curve` feature).
pub path: Json,
/// How many copies along the path.
/// Default: `5`.
pub count: Option<i64>,
/// Turn each copy as the path turns from its start: on a sketch, about the sketch's normal; on a curve in space, by the curve's rotation-minimizing frame (no roll about the path).
pub align_to_path: Option<bool>,
/// How the copies combine with the bodies they act on. Absent: the repeated feature's own operation. A pattern of a cut cuts only the bodies it consumes (`consumes`; absent: the bodies the repeated feature consumes).
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for PathPatternProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("seedFeature", self.seed_feature.to_json());
o.set("path", self.path.to_json());
if let Some(v) = &self.count {
o.set("count", v.to_json());
}
if let Some(v) = &self.align_to_path {
o.set("alignToPath", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl PathPatternProps {
/// The `pathPattern` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("pathPattern");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct MirrorProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Which feature's TOOL to mirror. Absent mirrors the whole body set instead — the two modes the rebuild has always had, said out loud. It used to be a required id that the one body-mirroring caller filled with `""`, so "mirror the bodies" was spelled as "mirror the feature called nothing".
pub seed_feature: Option<String>,
/// The plane it mirrors about.
pub plane: PlaneRef,
/// Keep original in addition to mirror (default true).
/// Default: `true`.
pub keep_original: Option<bool>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for MirrorProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.seed_feature {
o.set("seedFeature", v.to_json());
}
o.set("plane", self.plane.to_json());
if let Some(v) = &self.keep_original {
o.set("keepOriginal", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl MirrorProps {
/// The `mirror` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("mirror");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// How a construction plane is placed: offset `base` moved along its normal (and turned about its x axis by `angle`: a plane at an angle) midplane halfway between `base` and `base2` (two parallel planes: between them; two that meet: the plane that halves the angle between them) twoEdges through two straight edges that lie in one plane (`edge`, `edge2`) axisPoint through an axis (`axis`) and a point off it (`point`) threePoints through three points (`point`, `point2`, `point3`) tangent touching a cylinder, cone or sphere (`face`), at `angle` about its axis from `base`'s normal alongPath at right angles to an edge (`edge`), at the fraction `along` of its length perpendicular through a straight edge (`edge`), at right angles to `base` Every method then moves the plane `offset` along its own normal.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DatumPlaneMethod {
/// `"offset"`
Offset,
/// `"perpendicular"`
Perpendicular,
/// `"midplane"`
Midplane,
/// `"twoEdges"`
TwoEdges,
/// `"axisPoint"`
AxisPoint,
/// `"threePoints"`
ThreePoints,
/// `"tangent"`
Tangent,
/// `"alongPath"`
AlongPath,
}
impl ToJson for DatumPlaneMethod {
fn to_json(&self) -> Json {
Json::from(match self {
DatumPlaneMethod::Offset => "offset",
DatumPlaneMethod::Perpendicular => "perpendicular",
DatumPlaneMethod::Midplane => "midplane",
DatumPlaneMethod::TwoEdges => "twoEdges",
DatumPlaneMethod::AxisPoint => "axisPoint",
DatumPlaneMethod::ThreePoints => "threePoints",
DatumPlaneMethod::Tangent => "tangent",
DatumPlaneMethod::AlongPath => "alongPath",
})
}
}
#[derive(Clone, Debug)]
pub struct PointRefVertex {
pub ref_: TopoRef,
}
impl ToJson for PointRefVertex {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "vertex");
o.set("ref", self.ref_.to_json());
o
}
}
#[derive(Clone, Debug)]
pub struct PointRefDatum {
pub point: String,
}
impl ToJson for PointRefDatum {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "datum");
o.set("point", self.point.to_json());
o
}
}
#[derive(Clone, Debug)]
pub struct PointRefAt {
pub at: Vec3,
}
impl ToJson for PointRefAt {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "at");
o.set("at", self.at.to_json());
o
}
}
/// A point a construction feature goes through: a corner of a body (a vertex picked), a construction point (a `datumPoint` feature, by id), or a fixed point in model coordinates.
#[derive(Clone, Debug)]
pub enum PointRef {
Vertex(PointRefVertex),
Datum(PointRefDatum),
At(PointRefAt),
}
impl ToJson for PointRef {
fn to_json(&self) -> Json {
match self {
PointRef::Vertex(x) => x.to_json(),
PointRef::Datum(x) => x.to_json(),
PointRef::At(x) => x.to_json(),
}
}
}
impl From<PointRefVertex> for PointRef {
fn from(x: PointRefVertex) -> PointRef {
PointRef::Vertex(x)
}
}
impl From<PointRefDatum> for PointRef {
fn from(x: PointRefDatum) -> PointRef {
PointRef::Datum(x)
}
}
impl From<PointRefAt> for PointRef {
fn from(x: PointRefAt) -> PointRef {
PointRef::At(x)
}
}
#[derive(Clone, Debug)]
pub struct DatumPlaneProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// How the plane is placed.
/// Default: `"offset"`.
pub method: Option<DatumPlaneMethod>,
/// The plane it starts from: the plane offset or turned; the first of a midplane's two; the plane a tangent plane's angle and a perpendicular plane's right angle are measured from; else the plane whose x axis it keeps where it can.
pub base: String,
/// The second plane of a midplane.
pub base2: Option<String>,
/// The edge it goes through (two edges, perpendicular), or is at right angles to (along a path).
pub edge: Option<TopoRef>,
/// The second edge it goes through.
pub edge2: Option<TopoRef>,
/// The axis it goes through.
pub axis: Option<AxisRef>,
/// A point it goes through.
pub point: Option<PointRef>,
/// The second point it goes through.
pub point2: Option<PointRef>,
/// The third point it goes through.
pub point3: Option<PointRef>,
/// The cylinder, cone or sphere it touches.
pub face: Option<TopoRef>,
/// Where along the edge, as a fraction of its length from its start.
/// Default: `0.5`.
pub along: Option<f64>,
/// How far the plane is moved along its own normal.
/// Unit: mm.
/// Default: `10`.
pub offset: Option<f64>,
/// Offset: the base turned about its own x axis (through its origin) by this angle, before the offset, which then runs along the turned normal (a plane at an angle). Tangent: where on the face it touches, turned about the face's axis from the base's normal.
/// Unit: rad.
pub angle: Option<f64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for DatumPlaneProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.method {
o.set("method", v.to_json());
}
o.set("base", self.base.to_json());
if let Some(v) = &self.base2 {
o.set("base2", v.to_json());
}
if let Some(v) = &self.edge {
o.set("edge", v.to_json());
}
if let Some(v) = &self.edge2 {
o.set("edge2", v.to_json());
}
if let Some(v) = &self.axis {
o.set("axis", v.to_json());
}
if let Some(v) = &self.point {
o.set("point", v.to_json());
}
if let Some(v) = &self.point2 {
o.set("point2", v.to_json());
}
if let Some(v) = &self.point3 {
o.set("point3", v.to_json());
}
if let Some(v) = &self.face {
o.set("face", v.to_json());
}
if let Some(v) = &self.along {
o.set("along", v.to_json());
}
if let Some(v) = &self.offset {
o.set("offset", v.to_json());
}
if let Some(v) = &self.angle {
o.set("angle", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl DatumPlaneProps {
/// The `datumPlane` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("datumPlane");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// How a construction axis is placed: cylinder the axis of a cylinder, cone or torus (`face`) perpendicular at right angles to a flat face (`face`), through a point (`point`) twoPlanes where two planes meet (`plane`, `plane2`) twoPoints through two points (`point`, `point2`) edge along a straight edge (`edge`)
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DatumAxisMethod {
/// `"edge"`
Edge,
/// `"cylinder"`
Cylinder,
/// `"perpendicular"`
Perpendicular,
/// `"twoPlanes"`
TwoPlanes,
/// `"twoPoints"`
TwoPoints,
}
impl ToJson for DatumAxisMethod {
fn to_json(&self) -> Json {
Json::from(match self {
DatumAxisMethod::Edge => "edge",
DatumAxisMethod::Cylinder => "cylinder",
DatumAxisMethod::Perpendicular => "perpendicular",
DatumAxisMethod::TwoPlanes => "twoPlanes",
DatumAxisMethod::TwoPoints => "twoPoints",
})
}
}
/// A CONSTRUCTION AXIS: a line a revolve, a pattern or a coil turns about, or a plane goes through (`axis={{ type: "datum", axis: <id> }}`). It makes no body.
#[derive(Clone, Debug)]
pub struct DatumAxisProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// How the axis is placed.
/// Default: `"edge"`.
pub method: Option<DatumAxisMethod>,
/// The cylinder, cone or torus whose axis it is; the flat face it is at right angles to.
pub face: Option<TopoRef>,
/// The straight edge it lies along.
pub edge: Option<TopoRef>,
/// The first plane.
pub plane: Option<PlaneRef>,
/// The second plane.
pub plane2: Option<PlaneRef>,
/// The point it goes through (perpendicular), the first of two points.
pub point: Option<PointRef>,
/// The second point.
pub point2: Option<PointRef>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for DatumAxisProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.method {
o.set("method", v.to_json());
}
if let Some(v) = &self.face {
o.set("face", v.to_json());
}
if let Some(v) = &self.edge {
o.set("edge", v.to_json());
}
if let Some(v) = &self.plane {
o.set("plane", v.to_json());
}
if let Some(v) = &self.plane2 {
o.set("plane2", v.to_json());
}
if let Some(v) = &self.point {
o.set("point", v.to_json());
}
if let Some(v) = &self.point2 {
o.set("point2", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl DatumAxisProps {
/// The `datumAxis` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("datumAxis");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// How a construction point is placed: vertex at a point (`point`: a body's corner, another construction point, or coordinates) edgePlane where an edge (`edge`) meets a plane (`plane`); the edge's line where it is straight threePlanes where three planes meet (`plane`, `plane2`, `plane3`) center at the centre of a circle or an arc (`edge`), or of a sphere (`face`)
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DatumPointMethod {
/// `"vertex"`
Vertex,
/// `"edgePlane"`
EdgePlane,
/// `"threePlanes"`
ThreePlanes,
/// `"center"`
Center,
}
impl ToJson for DatumPointMethod {
fn to_json(&self) -> Json {
Json::from(match self {
DatumPointMethod::Vertex => "vertex",
DatumPointMethod::EdgePlane => "edgePlane",
DatumPointMethod::ThreePlanes => "threePlanes",
DatumPointMethod::Center => "center",
})
}
}
/// A CONSTRUCTION POINT: a point a plane or an axis goes through (`{ type: "datum", point: <id> }`). It makes no body.
#[derive(Clone, Debug)]
pub struct DatumPointProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// How the point is placed.
/// Default: `"vertex"`.
pub method: Option<DatumPointMethod>,
/// The point it is at.
pub point: Option<PointRef>,
/// The edge: the one a plane cuts, or the circle or arc whose centre it is.
pub edge: Option<TopoRef>,
/// The sphere whose centre it is (in place of an edge).
pub face: Option<TopoRef>,
/// The (first) plane.
pub plane: Option<PlaneRef>,
/// The second plane.
pub plane2: Option<PlaneRef>,
/// The third plane.
pub plane3: Option<PlaneRef>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for DatumPointProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.method {
o.set("method", v.to_json());
}
if let Some(v) = &self.point {
o.set("point", v.to_json());
}
if let Some(v) = &self.edge {
o.set("edge", v.to_json());
}
if let Some(v) = &self.face {
o.set("face", v.to_json());
}
if let Some(v) = &self.plane {
o.set("plane", v.to_json());
}
if let Some(v) = &self.plane2 {
o.set("plane2", v.to_json());
}
if let Some(v) = &self.plane3 {
o.set("plane3", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl DatumPointProps {
/// The `datumPoint` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("datumPoint");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct DraftProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Faces to taper.
pub faces: Vec<Json>,
/// Draft angle in radians.
/// Unit: rad.
/// Default: `0.08726646259971647`.
pub angle: Option<f64>,
/// Pull direction (the neutral/parting direction).
/// Default: `[0,0,1]`.
pub pull_direction: Option<Vec3>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for DraftProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("faces", self.faces.to_json());
if let Some(v) = &self.angle {
o.set("angle", v.to_json());
}
if let Some(v) = &self.pull_direction {
o.set("pullDirection", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl DraftProps {
/// The `draft` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("draft");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HoleStyle {
/// `"simple"`
Simple,
/// `"counterbore"`
Counterbore,
/// `"countersink"`
Countersink,
/// `"tapped"`
Tapped,
}
impl ToJson for HoleStyle {
fn to_json(&self) -> Json {
Json::from(match self {
HoleStyle::Simple => "simple",
HoleStyle::Counterbore => "counterbore",
HoleStyle::Countersink => "countersink",
HoleStyle::Tapped => "tapped",
})
}
}
/// The thread is cosmetic (the hole is drilled at the tap drill and the thread is drawn and called out, not cut), or modelled (its helix is cut into the wall).
/// Default: `"cosmetic"`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HolePropsThreadKind {
/// `"cosmetic"`
Cosmetic,
/// `"modeled"`
Modeled,
}
impl ToJson for HolePropsThreadKind {
fn to_json(&self) -> Json {
Json::from(match self {
HolePropsThreadKind::Cosmetic => "cosmetic",
HolePropsThreadKind::Modeled => "modeled",
})
}
}
/// A size's tolerance. Give deviations, or a class, or `basic`: one way, never two.
#[derive(Clone, Debug)]
pub struct DimensionTolerance {
/// The upper deviation from the nominal, signed (`0.1`, or `-0.02` for a size wholly under it).
/// Unit: mm.
pub upper: Option<f64>,
/// The lower deviation from the nominal, signed (`-0.1`).
/// Unit: mm.
pub lower: Option<f64>,
/// A tolerance class by name, its deviations at the nominal size: any ISO 286 class, computed from its fundamental deviation and grade over 0 up to 3150 mm (`H7`, `e8`, `E10`, `H13`, `JS7`, `zc11`: capitals for a hole, small letters for a shaft), a general tolerance of ISO 2768-1 (`ISO 2768-m`) or a radial bearing ring's ISO 492 Normal class (`ISO 492 bore`, `ISO 492 outside`, `ISO 492 width`).
pub class: Option<String>,
/// A basic dimension: theoretically exact, boxed on a drawing; the geometric tolerances that refer to it tolerance it.
pub basic: Option<bool>,
}
impl ToJson for DimensionTolerance {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.upper {
o.set("upper", v.to_json());
}
if let Some(v) = &self.lower {
o.set("lower", v.to_json());
}
if let Some(v) = &self.class {
o.set("class", v.to_json());
}
if let Some(v) = &self.basic {
o.set("basic", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct HoleProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Planar face the hole is placed on; the hole goes inward along -normal.
pub face: Json,
/// Where the holes are, in model coordinates: one hole at each point, moved onto the face along its normal. With neither `positions` nor `sketch`, one hole at the face's centre.
/// Unit: mm.
pub positions: Option<Vec<Vec3>>,
/// Where the holes are, as a sketch of points: one hole at each point of it that no segment uses, moved onto the face along its normal.
pub sketch: Option<String>,
/// Unit: mm.
/// Default: `6`.
pub diameter: Option<f64>,
/// Unit: mm.
/// Default: `10`.
pub depth: Option<f64>,
/// Through-all instead of a fixed depth.
/// Default: `true`.
pub through: Option<bool>,
/// Plain, counterbored, countersunk, or tapped (drilled at the thread's tap drill and threaded).
/// Default: `"simple"`.
pub style: Option<HoleStyle>,
/// A tapped hole's thread: an ISO metric coarse thread ("M6") or a Unified one ("1/4-20", "#10-24"), from the shipped tables (`./hole-sizes.ts` tappedHole). It gives `diameter` (the tap drill), the thread's major diameter and its pitch.
pub thread: Option<String>,
/// How deep the thread goes from the face (default: the whole hole).
/// Unit: mm.
pub thread_depth: Option<f64>,
/// The thread is cosmetic (the hole is drilled at the tap drill and the thread is drawn and called out, not cut), or modelled (its helix is cut into the wall).
/// Default: `"cosmetic"`.
pub thread_kind: Option<HolePropsThreadKind>,
/// Counterbore/countersink head diameter.
/// Unit: mm.
/// Default: `12`.
pub head_diameter: Option<f64>,
/// Counterbore depth (counterbore only).
/// Unit: mm.
/// Default: `4`.
pub head_depth: Option<f64>,
/// A standard hole by name: a thread and a fit, "M4 close fit", "M4 normal fit", "M4 loose fit", "M4 tap" (`./hole-sizes.ts`; the sizes are the shipped tables of ISO 273 and ISO 2306). It gives `diameter`, and for a counterbore or a countersink the head. Clear it to give a diameter that is not in the table.
pub size: Option<String>,
/// The diameter's tolerance: an ISO 286 class (`{ class: "H7" }`), deviations (`{ upper: 0.02, lower: 0 }`) or basic (`./tolerances.ts`). The drawing's hole callout writes it; a fit check names the hole by its id.
pub tolerance: Option<DimensionTolerance>,
/// Spare holes, left empty on purpose (a breadboard's grid, a bolt pattern for an option): the holes check does not ask what fills them. It reads them by `positions` and `diameter`.
/// Default: `false`.
pub spare: Option<bool>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for HoleProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("face", self.face.to_json());
if let Some(v) = &self.positions {
o.set("positions", v.to_json());
}
if let Some(v) = &self.sketch {
o.set("sketch", v.to_json());
}
if let Some(v) = &self.diameter {
o.set("diameter", v.to_json());
}
if let Some(v) = &self.depth {
o.set("depth", v.to_json());
}
if let Some(v) = &self.through {
o.set("through", v.to_json());
}
if let Some(v) = &self.style {
o.set("style", v.to_json());
}
if let Some(v) = &self.thread {
o.set("thread", v.to_json());
}
if let Some(v) = &self.thread_depth {
o.set("threadDepth", v.to_json());
}
if let Some(v) = &self.thread_kind {
o.set("threadKind", v.to_json());
}
if let Some(v) = &self.head_diameter {
o.set("headDiameter", v.to_json());
}
if let Some(v) = &self.head_depth {
o.set("headDepth", v.to_json());
}
if let Some(v) = &self.size {
o.set("size", v.to_json());
}
if let Some(v) = &self.tolerance {
o.set("tolerance", v.to_json());
}
if let Some(v) = &self.spare {
o.set("spare", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl HoleProps {
/// The `hole` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("hole");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct TransformProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The feature whose bodies move.
pub seed_feature: String,
/// How far they move.
/// Unit: mm.
pub translate: Option<Vec3>,
/// The axis they turn about.
pub rotate_axis: Option<AxisRef>,
/// How far they turn about it.
/// Unit: rad.
pub rotate_angle: Option<f64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for TransformProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("seedFeature", self.seed_feature.to_json());
if let Some(v) = &self.translate {
o.set("translate", v.to_json());
}
if let Some(v) = &self.rotate_axis {
o.set("rotateAxis", v.to_json());
}
if let Some(v) = &self.rotate_angle {
o.set("rotateAngle", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl TransformProps {
/// The `transform` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("transform");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SheetRelief {
/// `"none"`
None,
/// `"rectangular"`
Rectangular,
/// `"obround"`
Obround,
}
impl ToJson for SheetRelief {
fn to_json(&self) -> Json {
Json::from(match self {
SheetRelief::None => "none",
SheetRelief::Rectangular => "rectangular",
SheetRelief::Obround => "obround",
})
}
}
/// A corner relief: none, a square, a round hole, or a tear (a narrow round).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CornerRelief {
/// `"none"`
None,
/// `"square"`
Square,
/// `"round"`
Round,
/// `"tear"`
Tear,
}
impl ToJson for CornerRelief {
fn to_json(&self) -> Json {
Json::from(match self {
CornerRelief::None => "none",
CornerRelief::Square => "square",
CornerRelief::Round => "round",
CornerRelief::Tear => "tear",
})
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum GaugeTable {
/// `"steel"`
Steel,
/// `"stainless"`
Stainless,
/// `"aluminium"`
Aluminium,
/// `"custom"`
Custom,
}
impl ToJson for GaugeTable {
fn to_json(&self) -> Json {
Json::from(match self {
GaugeTable::Steel => "steel",
GaugeTable::Stainless => "stainless",
GaugeTable::Aluminium => "aluminium",
GaugeTable::Custom => "custom",
})
}
}
/// One gauge of a custom table.
#[derive(Clone, Debug)]
pub struct SheetGauge {
/// Its name ("16", "1/16").
pub gauge: String,
/// Unit: mm.
pub thickness: f64,
/// Unit: mm.
pub bend_radius: Option<f64>,
pub k_factor: Option<f64>,
}
impl ToJson for SheetGauge {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("gauge", self.gauge.to_json());
o.set("thickness", self.thickness.to_json());
if let Some(v) = &self.bend_radius {
o.set("bendRadius", v.to_json());
}
if let Some(v) = &self.k_factor {
o.set("kFactor", v.to_json());
}
o
}
}
/// SHEET-METAL RULES: the sheet's thickness, bend radius, K-factor and bend relief, one element of the part (`<sheetMetal>`). Every sheet-metal feature of the part reads them where it states no value of its own; a part holds at most one. It makes no geometry.
#[derive(Clone, Debug)]
pub struct SheetMetalProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The sheet's thickness.
/// Unit: mm.
/// Default: `2`.
pub thickness: Option<f64>,
/// The inner bend radius.
/// Unit: mm.
/// Default: `2`.
pub bend_radius: Option<f64>,
/// Where the neutral fibre lies through the thickness (0 inside, 1 outside): bend allowance = angle × (radius + K × thickness).
/// Default: `0.44`.
pub k_factor: Option<f64>,
/// The relief cut at each end of a bend that does not run the whole edge: none, a rectangle, or a slot with a round end.
/// Default: `"rectangular"`.
pub relief: Option<SheetRelief>,
/// The relief's width along the bend; the thickness when omitted.
/// Unit: mm.
pub relief_width: Option<f64>,
/// How far the relief runs past the bend; the thickness when omitted.
/// Unit: mm.
pub relief_depth: Option<f64>,
/// The relief cut where two flanges' bends meet at a corner of the sheet.
/// Default: `"none"`.
pub corner_relief: Option<CornerRelief>,
/// The corner relief's size: a square's side, a round's radius, a tear's width; bend radius + thickness when omitted.
/// Unit: mm.
pub corner_relief_size: Option<f64>,
/// The gauge table the sheet's thickness is read from: a material's built-in table (`@commandagi/3d-core/sheet-metal` GAUGES), or `custom`, the rows of `gauges`. With `gauge`, the gauge's row sets the thickness (and the bend radius and K-factor where the row gives them); without, `thickness` holds.
pub gauge_table: Option<GaugeTable>,
/// The gauge, as its table names it ("16").
pub gauge: Option<String>,
/// The rows of a custom gauge table (imported from a CSV: gauge, thickness, bend radius, K-factor).
pub gauges: Option<Vec<SheetGauge>>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SheetMetalProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.thickness {
o.set("thickness", v.to_json());
}
if let Some(v) = &self.bend_radius {
o.set("bendRadius", v.to_json());
}
if let Some(v) = &self.k_factor {
o.set("kFactor", v.to_json());
}
if let Some(v) = &self.relief {
o.set("relief", v.to_json());
}
if let Some(v) = &self.relief_width {
o.set("reliefWidth", v.to_json());
}
if let Some(v) = &self.relief_depth {
o.set("reliefDepth", v.to_json());
}
if let Some(v) = &self.corner_relief {
o.set("cornerRelief", v.to_json());
}
if let Some(v) = &self.corner_relief_size {
o.set("cornerReliefSize", v.to_json());
}
if let Some(v) = &self.gauge_table {
o.set("gaugeTable", v.to_json());
}
if let Some(v) = &self.gauge {
o.set("gauge", v.to_json());
}
if let Some(v) = &self.gauges {
o.set("gauges", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SheetMetalProps {
/// The `sheetMetal` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("sheetMetal");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// A CORNER'S RELIEF, set on one corner: where the bends of two flanges (by their features' ids) meet, this relief in place of the rules'. It makes no geometry of its own.
#[derive(Clone, Debug)]
pub struct SheetCornerProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The two flanges whose bends meet at the corner.
pub flanges: [String; 2],
/// The relief at this corner.
/// Default: `"round"`.
pub relief: Option<CornerRelief>,
/// Its size; the rules' (or bend radius + thickness) when omitted.
/// Unit: mm.
pub size: Option<f64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SheetCornerProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("flanges", self.flanges.to_json());
if let Some(v) = &self.relief {
o.set("relief", v.to_json());
}
if let Some(v) = &self.size {
o.set("size", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SheetCornerProps {
/// The `sheetCorner` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("sheetCorner");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// CONVERT TO SHEET METAL: a thin-walled part (a shelled box, a bent solid) made a sheet-metal part. From the face picked, its wall is the base; each wall joined to the base along a straight edge, by a sharp edge or a cylindrical bend, becomes an edge flange; where two walls meet at a sharp corner, the corner is ripped. The walls must be planar and of one thickness.
#[derive(Clone, Debug)]
pub struct SheetConvertProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// A face of the base wall (its inside or outside).
pub face: Json,
/// The bend radius where a wall meets the base at a sharp edge; the rules' (else the thickness) when omitted. A cylindrical bend keeps its own.
/// Unit: mm.
pub bend_radius: Option<f64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SheetConvertProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("face", self.face.to_json());
if let Some(v) = &self.bend_radius {
o.set("bendRadius", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SheetConvertProps {
/// The `sheetConvert` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("sheetConvert");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// A BASE FLANGE: the first sheet of a sheet-metal part, a closed sketch profile made as thick as the rules' sheet.
#[derive(Clone, Debug)]
pub struct SheetBaseProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The closed sketch regions the sheet takes.
pub profile: ProfileRef,
/// The sheet's thickness; the rules' when omitted.
/// Unit: mm.
pub thickness: Option<f64>,
/// Make the sheet on the other side of the sketch plane.
pub reverse: Option<bool>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SheetBaseProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("profile", self.profile.to_json());
if let Some(v) = &self.thickness {
o.set("thickness", v.to_json());
}
if let Some(v) = &self.reverse {
o.set("reverse", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SheetBaseProps {
/// The `sheetBase` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("sheetBase");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// Where an edge flange's bend sits against the edge it is built on.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FlangePosition {
/// `"outside"`
Outside,
/// `"materialInside"`
MaterialInside,
/// `"materialOutside"`
MaterialOutside,
}
impl ToJson for FlangePosition {
fn to_json(&self) -> Json {
Json::from(match self {
FlangePosition::Outside => "outside",
FlangePosition::MaterialInside => "materialInside",
FlangePosition::MaterialOutside => "materialOutside",
})
}
}
#[derive(Clone, Debug)]
pub struct SheetFlangeProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Straight boundary edge to flange from.
pub edge: Json,
/// Flange wall length (mm).
/// Unit: mm.
/// Default: `15`.
pub length: Option<f64>,
/// Bend angle in radians (π/2 = perpendicular wall).
/// Unit: rad.
/// Default: `1.5707963267948966`.
pub angle: Option<f64>,
/// Sheet thickness (mm); auto-derived from the body when omitted.
/// Unit: mm.
pub thickness: Option<f64>,
/// Inner bend radius (mm); the rules' when omitted, else the thickness.
/// Unit: mm.
pub bend_radius: Option<f64>,
/// Where the bend sits: "outside" adds the bend beyond the edge; "materialInside" sets the edge back so the wall's outer face is where the edge was; "materialOutside" so its inner face is.
/// Default: `"outside"`.
pub position: Option<FlangePosition>,
/// How far the flange starts in from the edge's first end.
/// Unit: mm.
pub start_offset: Option<f64>,
/// How far the flange stops short of the edge's other end.
/// Unit: mm.
pub end_offset: Option<f64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SheetFlangeProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("edge", self.edge.to_json());
if let Some(v) = &self.length {
o.set("length", v.to_json());
}
if let Some(v) = &self.angle {
o.set("angle", v.to_json());
}
if let Some(v) = &self.thickness {
o.set("thickness", v.to_json());
}
if let Some(v) = &self.bend_radius {
o.set("bendRadius", v.to_json());
}
if let Some(v) = &self.position {
o.set("position", v.to_json());
}
if let Some(v) = &self.start_offset {
o.set("startOffset", v.to_json());
}
if let Some(v) = &self.end_offset {
o.set("endOffset", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SheetFlangeProps {
/// The `sheetFlange` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("sheetFlange");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// A HEM: the sheet's edge bent right back on itself (180°), leaving `gap` between the two layers.
#[derive(Clone, Debug)]
pub struct SheetHemProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The straight edge to hem; the side of the sheet it is on is the side the hem folds to.
pub edge: Json,
/// The length of the folded-back layer.
/// Unit: mm.
/// Default: `8`.
pub length: Option<f64>,
/// The gap between the sheet and its folded-back layer (twice the hem's inner radius).
/// Unit: mm.
/// Default: `1`.
pub gap: Option<f64>,
/// Sheet thickness; the rules' when omitted.
/// Unit: mm.
pub thickness: Option<f64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SheetHemProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("edge", self.edge.to_json());
if let Some(v) = &self.length {
o.set("length", v.to_json());
}
if let Some(v) = &self.gap {
o.set("gap", v.to_json());
}
if let Some(v) = &self.thickness {
o.set("thickness", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SheetHemProps {
/// The `sheetHem` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("sheetHem");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// A FOLD: a flat sheet bent along a line of a sketch drawn on it; the bend's middle is on the line.
#[derive(Clone, Debug)]
pub struct SheetFoldProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The sketch whose line the sheet bends along.
pub sketch: String,
/// The line of the sketch, by its id; the sketch's first line when omitted.
pub line: Option<String>,
/// The bend angle.
/// Unit: rad.
/// Default: `1.5707963267948966`.
pub angle: Option<f64>,
/// Inner bend radius; the rules' when omitted.
/// Unit: mm.
pub bend_radius: Option<f64>,
/// Move the sheet on the other side of the line.
pub flip: Option<bool>,
/// Bend to the other face of the sheet.
pub reverse: Option<bool>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SheetFoldProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("sketch", self.sketch.to_json());
if let Some(v) = &self.line {
o.set("line", v.to_json());
}
if let Some(v) = &self.angle {
o.set("angle", v.to_json());
}
if let Some(v) = &self.bend_radius {
o.set("bendRadius", v.to_json());
}
if let Some(v) = &self.flip {
o.set("flip", v.to_json());
}
if let Some(v) = &self.reverse {
o.set("reverse", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SheetFoldProps {
/// The `sheetFold` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("sheetFold");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// THE FLAT PATTERN: every base flange, edge flange, hem and fold of the part developed flat (each bend becomes its bend allowance). Suppressed, the part is folded again.
#[derive(Clone, Debug)]
pub struct UnfoldProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// K-factor for bend-allowance (neutral-fibre) computation; the rules' when omitted, else 0.44.
pub k_factor: Option<f64>,
/// Only these bends (flange, hem, fold or convert features, by id) are flattened; the rest stay bent. Every bend when omitted.
pub bends: Option<Vec<String>>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for UnfoldProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.k_factor {
o.set("kFactor", v.to_json());
}
if let Some(v) = &self.bends {
o.set("bends", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl UnfoldProps {
/// The `unfold` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("unfold");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// REFOLD: the bends an unfold flattened, bent again, with what was cut across them while they were flat.
#[derive(Clone, Debug)]
pub struct SheetRefoldProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The unfold whose bends are bent again.
pub unfold: String,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SheetRefoldProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("unfold", self.unfold.to_json());
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SheetRefoldProps {
/// The `sheetRefold` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("sheetRefold");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// A weldment's structural section (`@commandagi/3d-core/weldment` PROFILES holds the standard sizes).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FrameProfile {
/// `"angle"`
Angle,
/// `"squareTube"`
SquareTube,
/// `"rectTube"`
RectTube,
/// `"channel"`
Channel,
/// `"roundTube"`
RoundTube,
}
impl ToJson for FrameProfile {
fn to_json(&self) -> Json {
Json::from(match self {
FrameProfile::Angle => "angle",
FrameProfile::SquareTube => "squareTube",
FrameProfile::RectTube => "rectTube",
FrameProfile::Channel => "channel",
FrameProfile::RoundTube => "roundTube",
})
}
}
/// How two frame members meet at a corner of the sketch: cut at the bisector, one butting on the other, or untrimmed.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FrameCorner {
/// `"none"`
None,
/// `"butt"`
Butt,
/// `"miter"`
Miter,
}
impl ToJson for FrameCorner {
fn to_json(&self) -> Json {
Json::from(match self {
FrameCorner::None => "none",
FrameCorner::Butt => "butt",
FrameCorner::Miter => "miter",
})
}
}
/// How a member's end meets another member's side.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FrameJoint {
/// `"none"`
None,
/// `"trim"`
Trim,
/// `"cope"`
Cope,
/// `"butt"`
Butt,
}
impl ToJson for FrameJoint {
fn to_json(&self) -> Json {
Json::from(match self {
FrameJoint::None => "none",
FrameJoint::Trim => "trim",
FrameJoint::Cope => "cope",
FrameJoint::Butt => "butt",
})
}
}
/// FRAME MEMBERS: a structural section swept along lines of a sketch, one body per line, trimmed where two meet.
#[derive(Clone, Debug)]
pub struct FrameMemberProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The sketch whose lines the members run along (their centre lines).
pub sketch: String,
/// The lines, by id; every line of the sketch when omitted.
pub segments: Option<Vec<String>>,
/// The section.
/// Default: `"squareTube"`.
pub section: Option<FrameProfile>,
/// The standard size, as the profile library names it (width × height × wall, or diameter × wall).
/// Default: `"40x40x3"`.
pub size: Option<String>,
/// How members meet at a shared end.
/// Default: `"miter"`.
pub corner: Option<FrameCorner>,
/// How a member's end meets members it does not meet end to end: an end on another member's side (a T), or a corner of three or more members, where the first member and any in line with it run through. `trim`: the end is cut flat at the other's near face; `cope`: the other's outer shape is cut out of the end; `butt`: the end stops at the other's near face without reaching into its corner (square, as cut); `none`: untrimmed.
/// Default: `"trim"`.
pub joint: Option<FrameJoint>,
/// The section turned about the member's axis.
/// Unit: rad.
pub rotate: Option<f64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for FrameMemberProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("sketch", self.sketch.to_json());
if let Some(v) = &self.segments {
o.set("segments", v.to_json());
}
if let Some(v) = &self.section {
o.set("section", v.to_json());
}
if let Some(v) = &self.size {
o.set("size", v.to_json());
}
if let Some(v) = &self.corner {
o.set("corner", v.to_json());
}
if let Some(v) = &self.joint {
o.set("joint", v.to_json());
}
if let Some(v) = &self.rotate {
o.set("rotate", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl FrameMemberProps {
/// The `frameMember` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("frameMember");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// Which end of the named line.
/// Default: `"end"`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum EndCapPropsEnd {
/// `"start"`
Start,
/// `"end"`
End,
/// `"both"`
Both,
}
impl ToJson for EndCapPropsEnd {
fn to_json(&self) -> Json {
Json::from(match self {
EndCapPropsEnd::Start => "start",
EndCapPropsEnd::End => "end",
EndCapPropsEnd::Both => "both",
})
}
}
/// AN END CAP: a plate that closes the open end of a frame member, on its end face.
#[derive(Clone, Debug)]
pub struct EndCapProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The member's end face; or name the member below.
pub face: Option<Json>,
/// The frame member feature whose member's end is capped, in place of a picked face.
pub member: Option<String>,
/// Which of its lines (by id); without one, every free end of the frame (an end no other member reaches) is capped.
pub segment: Option<String>,
/// Which end of the named line.
/// Default: `"end"`.
pub end: Option<EndCapPropsEnd>,
/// The plate's thickness.
/// Unit: mm.
/// Default: `3`.
pub thickness: Option<f64>,
/// Set the plate into the tube's opening, flush with the end, instead of on the end.
pub inside: Option<bool>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for EndCapProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.face {
o.set("face", v.to_json());
}
if let Some(v) = &self.member {
o.set("member", v.to_json());
}
if let Some(v) = &self.segment {
o.set("segment", v.to_json());
}
if let Some(v) = &self.end {
o.set("end", v.to_json());
}
if let Some(v) = &self.thickness {
o.set("thickness", v.to_json());
}
if let Some(v) = &self.inside {
o.set("inside", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl EndCapProps {
/// The `endCap` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("endCap");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct SketchPinTargetBody {
pub feature: String,
}
impl ToJson for SketchPinTargetBody {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", "body");
o.set("feature", self.feature.to_json());
o
}
}
#[derive(Clone, Debug)]
pub struct SketchPinTargetFace {
pub ref_: TopoRef,
}
impl ToJson for SketchPinTargetFace {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", "face");
o.set("ref", self.ref_.to_json());
o
}
}
#[derive(Clone, Debug)]
pub struct SketchPinTargetEdge {
pub ref_: TopoRef,
}
impl ToJson for SketchPinTargetEdge {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", "edge");
o.set("ref", self.ref_.to_json());
o
}
}
#[derive(Clone, Debug)]
pub struct SketchPinTargetVertex {
pub ref_: TopoRef,
}
impl ToJson for SketchPinTargetVertex {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", "vertex");
o.set("ref", self.ref_.to_json());
o
}
}
#[derive(Clone, Debug)]
pub struct SketchPinTargetPad {
pub pad: String,
pub producer: String,
}
impl ToJson for SketchPinTargetPad {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", "pad");
o.set("pad", self.pad.to_json());
o.set("producer", self.producer.to_json());
o
}
}
/// WHICH b-rep thing a pin follows. Bodies are named by the FEATURE that produced them (lineage is what survives a parametric edit — a signature match would drift the moment the body moves, which is exactly when a pin has to keep holding). Sub-shapes reuse the document's signature-matched TopoRef, the same handle every other feature uses to say "that face".
#[derive(Clone, Debug)]
pub enum SketchPinTarget {
Body(SketchPinTargetBody),
Face(SketchPinTargetFace),
Edge(SketchPinTargetEdge),
Vertex(SketchPinTargetVertex),
Pad(SketchPinTargetPad),
}
impl ToJson for SketchPinTarget {
fn to_json(&self) -> Json {
match self {
SketchPinTarget::Body(x) => x.to_json(),
SketchPinTarget::Face(x) => x.to_json(),
SketchPinTarget::Edge(x) => x.to_json(),
SketchPinTarget::Vertex(x) => x.to_json(),
SketchPinTarget::Pad(x) => x.to_json(),
}
}
}
impl From<SketchPinTargetBody> for SketchPinTarget {
fn from(x: SketchPinTargetBody) -> SketchPinTarget {
SketchPinTarget::Body(x)
}
}
impl From<SketchPinTargetFace> for SketchPinTarget {
fn from(x: SketchPinTargetFace) -> SketchPinTarget {
SketchPinTarget::Face(x)
}
}
impl From<SketchPinTargetEdge> for SketchPinTarget {
fn from(x: SketchPinTargetEdge) -> SketchPinTarget {
SketchPinTarget::Edge(x)
}
}
impl From<SketchPinTargetVertex> for SketchPinTarget {
fn from(x: SketchPinTargetVertex) -> SketchPinTarget {
SketchPinTarget::Vertex(x)
}
}
impl From<SketchPinTargetPad> for SketchPinTarget {
fn from(x: SketchPinTargetPad) -> SketchPinTarget {
SketchPinTarget::Pad(x)
}
}
/// WHICH POINT of the target, once it is flattened onto the sketch plane.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SketchPinAnchor {
/// `"vertex"`
Vertex,
/// `"center"`
Center,
/// `"centroid"`
Centroid,
/// `"minU"`
MinU,
/// `"maxU"`
MaxU,
/// `"minV"`
MinV,
/// `"maxV"`
MaxV,
/// `"minU_minV"`
MinUMinV,
/// `"maxU_minV"`
MaxUMinV,
/// `"minU_maxV"`
MinUMaxV,
/// `"maxU_maxV"`
MaxUMaxV,
}
impl ToJson for SketchPinAnchor {
fn to_json(&self) -> Json {
Json::from(match self {
SketchPinAnchor::Vertex => "vertex",
SketchPinAnchor::Center => "center",
SketchPinAnchor::Centroid => "centroid",
SketchPinAnchor::MinU => "minU",
SketchPinAnchor::MaxU => "maxU",
SketchPinAnchor::MinV => "minV",
SketchPinAnchor::MaxV => "maxV",
SketchPinAnchor::MinUMinV => "minU_minV",
SketchPinAnchor::MaxUMinV => "maxU_minV",
SketchPinAnchor::MinUMaxV => "minU_maxV",
SketchPinAnchor::MaxUMaxV => "maxU_maxV",
})
}
}
#[derive(Clone, Debug)]
pub struct SketchPin {
pub target: SketchPinTarget,
pub anchor: SketchPinAnchor,
/// Sketch-space offset applied AFTER projection, in mm. Lets a pin sit a known gap off a corner.
pub offset: Option<[f64; 2]>,
/// Human label for the panel/tooltip, captured when the pin was made ("Extrude1", "Top face").
pub label: Option<String>,
}
impl ToJson for SketchPin {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("target", self.target.to_json());
o.set("anchor", self.anchor.to_json());
if let Some(v) = &self.offset {
o.set("offset", v.to_json());
}
if let Some(v) = &self.label {
o.set("label", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct SketchPoint {
/// PINNED TO THE MODEL. When present, this point's (u,v) is not an authored value at all — it is DERIVED, every rebuild, by projecting a b-rep entity onto this sketch's plane (see `resolveSketchPins`). `x`/`y` still hold the last resolved coordinates so the sketch is drawable before a rebuild lands, but they are an echo, not the source.
pub pin: Option<SketchPin>,
pub id: String,
pub x: f64,
pub y: f64,
/// Construction point (not part of profile geometry).
pub construction: Option<bool>,
/// Held in place by the solver.
pub fixed: Option<bool>,
/// Set when this point was GENERATED from something outside the sketch (in app-3d-design, a projection of a model edge). How a regenerator finds its own previous output to replace, and how a UI tells "you drew this" from "the model did". Absent on everything the user authored.
pub from: Option<String>,
}
impl ToJson for SketchPoint {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.pin {
o.set("pin", v.to_json());
}
o.set("id", self.id.to_json());
o.set("x", self.x.to_json());
o.set("y", self.y.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.fixed {
o.set("fixed", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
o
}
}
/// A LIVE PROJECTION of one model edge onto this sketch's plane — "use that hole's circle here".
#[derive(Clone, Debug)]
pub struct SketchProjection {
pub id: String,
/// The model edge this follows, signature-matched across rebuilds like every other reference. On a section, the one FACE it cuts (the curves where that face crosses the sketch's plane), or absent: the whole body.
pub ref_: Option<TopoRef>,
/// The feature that built the body — the timeline dependency, exactly as for a pin.
pub feature: Option<String>,
/// AN INTERSECTION, not a projection: the curves where the body `feature` built (or the face of it `ref` names) crosses the sketch's plane, cut again on every rebuild. It needs `feature`.
pub section: Option<bool>,
/// Generate as construction (reference) geometry rather than profile geometry.
pub construction: Option<bool>,
/// Human label captured at creation, for the panel ("Extrude1 edge").
pub label: Option<String>,
}
impl ToJson for SketchProjection {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.ref_ {
o.set("ref", v.to_json());
}
if let Some(v) = &self.feature {
o.set("feature", v.to_json());
}
if let Some(v) = &self.section {
o.set("section", v.to_json());
}
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.label {
o.set("label", v.to_json());
}
o
}
}
/// AN EQUATION CURVE: x(t) and y(t), arithmetic of `t` in the document's expression grammar (`../expressions.ts`: + - * / ^, sin, cos, sqrt, pi …), drawn as the spline through `points` even steps of t from `from` to `to`. The record is what the file holds; the spline and its points are made from it on every rebuild (their `from` names it), so editing the equation redraws the curve. A curve whose last point meets its first is closed.
#[derive(Clone, Debug)]
pub struct SketchEquation {
pub id: String,
/// The horizontal coordinate as arithmetic of `t`, in millimetres.
pub x: String,
/// The vertical coordinate as arithmetic of `t`, in millimetres.
pub y: String,
/// The first value of t.
pub from: f64,
/// The last value of t.
pub to: f64,
/// How many points the curve passes through, its ends included.
pub points: i64,
/// Drawn as construction (reference) geometry.
pub construction: Option<bool>,
}
impl ToJson for SketchEquation {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
o.set("x", self.x.to_json());
o.set("y", self.y.to_json());
o.set("from", self.from.to_json());
o.set("to", self.to.to_json());
o.set("points", self.points.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
o
}
}
/// A TEXT: the outlines of `text` in the typeface `font`, placed by two of the sketch's own points: `anchor`, the start of its baseline, and `along`, a letter height further along the baseline. The text's place, angle and size are then those points' (a dimension between them is the size; one on the line between them, the angle). `contours` are the outlines at a letter height of 1, baseline from the origin along +x, kept so the outlines are made again from the two points on every rebuild with no font at hand; the outline lines and points are made from them (their `from` names it). Changing the words or the typeface writes new contours.
#[derive(Clone, Debug)]
pub struct SketchText {
pub id: String,
/// The words.
pub text: String,
/// The typeface: a bundled face's id (`liberation-sans`, `noto-serif`, `noto-sans-mono`), or a font file in the design's folder by its path from there (`.ttf`, `.otf` or `.woff`). The outlines are kept in `contours`: the face is read only to make or change the text.
pub font: String,
/// The point the baseline starts at.
pub anchor: String,
/// The point one letter height along the baseline from `anchor`.
pub along: String,
/// Each closed outline as flat `[x0, y0, x1, y1, …]` at a letter height of 1.
pub contours: Vec<Vec<f64>>,
}
impl ToJson for SketchText {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
o.set("text", self.text.to_json());
o.set("font", self.font.to_json());
o.set("anchor", self.anchor.to_json());
o.set("along", self.along.to_json());
o.set("contours", self.contours.to_json());
o
}
}
#[derive(Clone, Debug)]
pub struct SketchSegmentLine {
pub id: String,
pub a: String,
pub b: String,
pub construction: Option<bool>,
pub from: Option<String>,
/// The segment this one is a piece of, when a split cut it from that segment: a region's reference keeps naming the source.
pub of: Option<String>,
}
impl ToJson for SketchSegmentLine {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "line");
o.set("id", self.id.to_json());
o.set("a", self.a.to_json());
o.set("b", self.b.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.of {
o.set("of", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct SketchSegmentCircle {
pub id: String,
pub center: String,
pub radius: f64,
pub construction: Option<bool>,
pub from: Option<String>,
/// The segment this one is a piece of, when a split cut it from that segment: a region's reference keeps naming the source.
pub of: Option<String>,
}
impl ToJson for SketchSegmentCircle {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "circle");
o.set("id", self.id.to_json());
o.set("center", self.center.to_json());
o.set("radius", self.radius.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.of {
o.set("of", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct SketchSegmentArc {
pub id: String,
pub center: String,
pub start: String,
pub end: String,
/// radius is a solver variable seeded from the points.
pub radius: f64,
pub construction: Option<bool>,
pub from: Option<String>,
/// The segment this one is a piece of, when a split cut it from that segment: a region's reference keeps naming the source.
pub of: Option<String>,
}
impl ToJson for SketchSegmentArc {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "arc");
o.set("id", self.id.to_json());
o.set("center", self.center.to_json());
o.set("start", self.start.to_json());
o.set("end", self.end.to_json());
o.set("radius", self.radius.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.of {
o.set("of", v.to_json());
}
o
}
}
/// The NURBS half of a curve — degree, knots, weights. Stored verbatim as a sketch spline's `nurbs`.
#[derive(Clone, Debug)]
pub struct NurbsSpec {
/// Curve degree. 3 is the usual authoring default; 2 with weights gives exact conics.
pub degree: f64,
/// One weight per control point. Omitted, or all equal, means non-rational.
pub weights: Option<Vec<f64>>,
/// Distinct knot values, strictly ascending. Omitted with `mults` means clamped uniform.
pub knots: Option<Vec<f64>>,
/// Multiplicity per knot.
pub mults: Option<Vec<f64>>,
/// Periodic rather than clamped. A periodic curve closes with full continuity.
pub periodic: Option<bool>,
}
impl ToJson for NurbsSpec {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("degree", self.degree.to_json());
if let Some(v) = &self.weights {
o.set("weights", v.to_json());
}
if let Some(v) = &self.knots {
o.set("knots", v.to_json());
}
if let Some(v) = &self.mults {
o.set("mults", v.to_json());
}
if let Some(v) = &self.periodic {
o.set("periodic", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct SketchSegmentSpline {
pub id: String,
/// The curve's points. WHAT they are depends on `nurbs`: without it they are points the curve passes THROUGH (interpolated with Catmull-Rom, `../geometry/curves/spline.ts`); with it they are the control polygon, and a clamped NURBS touches only the first and the last of them.
pub points: Vec<String>,
pub closed: Option<bool>,
pub construction: Option<bool>,
/// A TRUE NURBS definition. Absent means the historical Catmull-Rom interpolant — which has no degree, no knot vector and no weights, so it can approximate a conic and never be one.
pub nurbs: Option<NurbsSpec>,
pub from: Option<String>,
/// The segment this one is a piece of, when a split cut it from that segment: a region's reference keeps naming the source.
pub of: Option<String>,
}
impl ToJson for SketchSegmentSpline {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "spline");
o.set("id", self.id.to_json());
o.set("points", self.points.to_json());
if let Some(v) = &self.closed {
o.set("closed", v.to_json());
}
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.nurbs {
o.set("nurbs", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.of {
o.set("of", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct SketchSegmentEllipse {
pub id: String,
pub center: String,
/// The first FOCUS, as a real sketch point.
pub focus: String,
/// Minor radius — the one scalar degree of freedom, like a circle's radius.
pub minor_radius: f64,
pub construction: Option<bool>,
pub from: Option<String>,
/// The segment this one is a piece of, when a split cut it from that segment: a region's reference keeps naming the source.
pub of: Option<String>,
}
impl ToJson for SketchSegmentEllipse {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "ellipse");
o.set("id", self.id.to_json());
o.set("center", self.center.to_json());
o.set("focus", self.focus.to_json());
o.set("minorRadius", self.minor_radius.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.of {
o.set("of", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct SketchSegmentEllipseArc {
pub id: String,
pub center: String,
/// See the `ellipse` member.
pub focus: String,
pub minor_radius: f64,
/// Endpoints, CCW from `start` to `end`, exactly as an `arc` names them.
pub start: String,
pub end: String,
pub construction: Option<bool>,
pub from: Option<String>,
/// The segment this one is a piece of, when a split cut it from that segment: a region's reference keeps naming the source.
pub of: Option<String>,
}
impl ToJson for SketchSegmentEllipseArc {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "ellipseArc");
o.set("id", self.id.to_json());
o.set("center", self.center.to_json());
o.set("focus", self.focus.to_json());
o.set("minorRadius", self.minor_radius.to_json());
o.set("start", self.start.to_json());
o.set("end", self.end.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.of {
o.set("of", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub enum SketchSegment {
Line(SketchSegmentLine),
Circle(SketchSegmentCircle),
Arc(SketchSegmentArc),
Spline(SketchSegmentSpline),
Ellipse(SketchSegmentEllipse),
EllipseArc(SketchSegmentEllipseArc),
}
impl ToJson for SketchSegment {
fn to_json(&self) -> Json {
match self {
SketchSegment::Line(x) => x.to_json(),
SketchSegment::Circle(x) => x.to_json(),
SketchSegment::Arc(x) => x.to_json(),
SketchSegment::Spline(x) => x.to_json(),
SketchSegment::Ellipse(x) => x.to_json(),
SketchSegment::EllipseArc(x) => x.to_json(),
}
}
}
impl From<SketchSegmentLine> for SketchSegment {
fn from(x: SketchSegmentLine) -> SketchSegment {
SketchSegment::Line(x)
}
}
impl From<SketchSegmentCircle> for SketchSegment {
fn from(x: SketchSegmentCircle) -> SketchSegment {
SketchSegment::Circle(x)
}
}
impl From<SketchSegmentArc> for SketchSegment {
fn from(x: SketchSegmentArc) -> SketchSegment {
SketchSegment::Arc(x)
}
}
impl From<SketchSegmentSpline> for SketchSegment {
fn from(x: SketchSegmentSpline) -> SketchSegment {
SketchSegment::Spline(x)
}
}
impl From<SketchSegmentEllipse> for SketchSegment {
fn from(x: SketchSegmentEllipse) -> SketchSegment {
SketchSegment::Ellipse(x)
}
}
impl From<SketchSegmentEllipseArc> for SketchSegment {
fn from(x: SketchSegmentEllipseArc) -> SketchSegment {
SketchSegment::EllipseArc(x)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ConstraintKind {
/// `"coincident"`
Coincident,
/// `"parallel"`
Parallel,
/// `"perpendicular"`
Perpendicular,
/// `"distance"`
Distance,
/// `"angle"`
Angle,
/// `"concentric"`
Concentric,
/// `"tangent"`
Tangent,
/// `"horizontal"`
Horizontal,
/// `"vertical"`
Vertical,
/// `"equal"`
Equal,
/// `"pointOnLine"`
PointOnLine,
/// `"midpoint"`
Midpoint,
/// `"pointOnCircle"`
PointOnCircle,
/// `"symmetric"`
Symmetric,
/// `"horizontalDistance"`
HorizontalDistance,
/// `"verticalDistance"`
VerticalDistance,
/// `"radius"`
Radius,
/// `"collinear"`
Collinear,
/// `"diameter"`
Diameter,
/// `"pointLineDistance"`
PointLineDistance,
/// `"arcLength"`
ArcLength,
/// `"conicRho"`
ConicRho,
/// `"ordinateX"`
OrdinateX,
/// `"ordinateY"`
OrdinateY,
/// `"axisAngle"`
AxisAngle,
/// `"chamferDistance"`
ChamferDistance,
}
impl ToJson for ConstraintKind {
fn to_json(&self) -> Json {
Json::from(match self {
ConstraintKind::Coincident => "coincident",
ConstraintKind::Parallel => "parallel",
ConstraintKind::Perpendicular => "perpendicular",
ConstraintKind::Distance => "distance",
ConstraintKind::Angle => "angle",
ConstraintKind::Concentric => "concentric",
ConstraintKind::Tangent => "tangent",
ConstraintKind::Horizontal => "horizontal",
ConstraintKind::Vertical => "vertical",
ConstraintKind::Equal => "equal",
ConstraintKind::PointOnLine => "pointOnLine",
ConstraintKind::Midpoint => "midpoint",
ConstraintKind::PointOnCircle => "pointOnCircle",
ConstraintKind::Symmetric => "symmetric",
ConstraintKind::HorizontalDistance => "horizontalDistance",
ConstraintKind::VerticalDistance => "verticalDistance",
ConstraintKind::Radius => "radius",
ConstraintKind::Collinear => "collinear",
ConstraintKind::Diameter => "diameter",
ConstraintKind::PointLineDistance => "pointLineDistance",
ConstraintKind::ArcLength => "arcLength",
ConstraintKind::ConicRho => "conicRho",
ConstraintKind::OrdinateX => "ordinateX",
ConstraintKind::OrdinateY => "ordinateY",
ConstraintKind::AxisAngle => "axisAngle",
ConstraintKind::ChamferDistance => "chamferDistance",
})
}
}
/// A constraint references entities by id. `entities` holds point/segment ids in the order the kind's `operands` declare (`../geometry/constraints.ts`); `value` holds the dimension for dimensional kinds (distance in the sketch's length unit, angle in radians, radius in the length unit).
#[derive(Clone, Debug)]
pub struct SketchConstraint {
pub id: String,
pub kind: ConstraintKind,
pub entities: Vec<String>,
pub value: Option<f64>,
/// A DRIVEN (reference) dimension: measured from the geometry and shown, never solved. Only a dimensional kind can be one. `solveSketch` does not send it to the backend and lists it in the result's `driven`; absent (the default, and every sketch written before 2026-09-11) means driving.
pub reference: Option<bool>,
}
impl ToJson for SketchConstraint {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
o.set("kind", self.kind.to_json());
o.set("entities", self.entities.to_json());
if let Some(v) = &self.value {
o.set("value", v.to_json());
}
if let Some(v) = &self.reference {
o.set("reference", v.to_json());
}
o
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SketchSolveStatus {
/// `"ok"`
Ok,
/// `"over"`
Over,
/// `"under"`
Under,
/// `"inconsistent"`
Inconsistent,
}
impl ToJson for SketchSolveStatus {
fn to_json(&self) -> Json {
Json::from(match self {
SketchSolveStatus::Ok => "ok",
SketchSolveStatus::Over => "over",
SketchSolveStatus::Under => "under",
SketchSolveStatus::Inconsistent => "inconsistent",
})
}
}
#[derive(Clone, Debug)]
pub struct Sketch {
pub points: Vec<(String, SketchPoint)>,
/// Live projections of model edges. Absent on a sketch that has none.
pub projections: Option<Vec<(String, SketchProjection)>>,
pub projection_order: Option<Vec<String>>,
/// Equation curves. Absent on a sketch that has none.
pub equations: Option<Vec<(String, SketchEquation)>>,
pub equation_order: Option<Vec<String>>,
/// Texts. Absent on a sketch that has none.
pub texts: Option<Vec<(String, SketchText)>>,
pub text_order: Option<Vec<String>>,
pub segments: Vec<(String, SketchSegment)>,
pub constraints: Vec<(String, SketchConstraint)>,
pub point_order: Vec<String>,
pub segment_order: Vec<String>,
pub constraint_order: Vec<String>,
/// Last solve result, populated by the solver.
pub solve_status: Option<SketchSolveStatus>,
/// Remaining degrees of freedom reported by the last solve.
pub dof: Option<f64>,
}
impl ToJson for Sketch {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("points", self.points.to_json());
if let Some(v) = &self.projections {
o.set("projections", v.to_json());
}
if let Some(v) = &self.projection_order {
o.set("projectionOrder", v.to_json());
}
if let Some(v) = &self.equations {
o.set("equations", v.to_json());
}
if let Some(v) = &self.equation_order {
o.set("equationOrder", v.to_json());
}
if let Some(v) = &self.texts {
o.set("texts", v.to_json());
}
if let Some(v) = &self.text_order {
o.set("textOrder", v.to_json());
}
o.set("segments", self.segments.to_json());
o.set("constraints", self.constraints.to_json());
o.set("pointOrder", self.point_order.to_json());
o.set("segmentOrder", self.segment_order.to_json());
o.set("constraintOrder", self.constraint_order.to_json());
if let Some(v) = &self.solve_status {
o.set("solveStatus", v.to_json());
}
if let Some(v) = &self.dof {
o.set("dof", v.to_json());
}
o
}
}
/// Raise the letters, or cut them into the face.
/// Default: `"emboss"`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum WrapTextPropsMode {
/// `"emboss"`
Emboss,
/// `"engrave"`
Engrave,
}
impl ToJson for WrapTextPropsMode {
fn to_json(&self) -> Json {
Json::from(match self {
WrapTextPropsMode::Emboss => "emboss",
WrapTextPropsMode::Engrave => "engrave",
})
}
}
#[derive(Clone, Debug)]
pub struct WrapTextProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Cylindrical face to wrap onto.
pub face: Json,
/// Baked 2D template (text or any closed regions) in u (circumference) / v.
pub sketch: Sketch,
/// Radial depth (mm).
/// Unit: mm.
/// Default: `1`.
pub depth: Option<f64>,
/// Raise the letters, or cut them into the face.
/// Default: `"emboss"`.
pub mode: Option<WrapTextPropsMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for WrapTextProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("face", self.face.to_json());
o.set("sketch", self.sketch.to_json());
if let Some(v) = &self.depth {
o.set("depth", v.to_json());
}
if let Some(v) = &self.mode {
o.set("mode", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl WrapTextProps {
/// The `wrapText` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("wrapText");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct DeleteFaceProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Faces to remove; the body heals around them.
pub faces: Vec<Json>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for DeleteFaceProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("faces", self.faces.to_json());
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl DeleteFaceProps {
/// The `deleteFace` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("deleteFace");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct FullRoundProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Narrow strip face to replace with a rolling-ball blend.
pub face: Json,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for FullRoundProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("face", self.face.to_json());
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl FullRoundProps {
/// The `fullRound` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("fullRound");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct DomeProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Planar face to bulge.
pub face: Json,
/// Apex height along the face normal (negative = inward dimple).
/// Unit: mm.
/// Default: `10`.
pub height: Option<f64>,
/// Profile-ring count (smoothness).
/// Default: `6`.
pub rings: Option<i64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for DomeProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("face", self.face.to_json());
if let Some(v) = &self.height {
o.set("height", v.to_json());
}
if let Some(v) = &self.rings {
o.set("rings", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl DomeProps {
/// The `dome` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("dome");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct CopyBodyProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The body to copy: its id, the feature that made it (`base`, `split:2`).
pub body_id: String,
/// Translation applied to the copy (mm).
/// Unit: mm.
pub translate: Option<Vec3>,
/// Optional rotation of the copy.
pub rotate_axis: Option<AxisRef>,
/// How far the copy turns about that axis.
/// Unit: rad.
pub rotate_angle: Option<f64>,
/// Number of copies to lay out along the translation (default 1).
/// Default: `1`.
pub count: Option<i64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for CopyBodyProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("bodyId", self.body_id.to_json());
if let Some(v) = &self.translate {
o.set("translate", v.to_json());
}
if let Some(v) = &self.rotate_axis {
o.set("rotateAxis", v.to_json());
}
if let Some(v) = &self.rotate_angle {
o.set("rotateAngle", v.to_json());
}
if let Some(v) = &self.count {
o.set("count", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl CopyBodyProps {
/// The `copyBody` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("copyBody");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct ThreadProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Cylindrical face to thread.
pub face: Json,
/// Distance between thread crests (mm).
/// Unit: mm.
/// Default: `1.5`.
pub pitch: Option<f64>,
/// Threaded length along the axis (mm).
/// Unit: mm.
/// Default: `10`.
pub length: Option<f64>,
/// Radial thread depth (mm).
/// Unit: mm.
/// Default: `0.9`.
pub depth: Option<f64>,
/// Internal (tapped hole) vs external (bolt).
pub internal: Option<bool>,
/// Right-handed (default) vs left-handed.
/// Default: `true`.
pub right_handed: Option<bool>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for ThreadProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("face", self.face.to_json());
if let Some(v) = &self.pitch {
o.set("pitch", v.to_json());
}
if let Some(v) = &self.length {
o.set("length", v.to_json());
}
if let Some(v) = &self.depth {
o.set("depth", v.to_json());
}
if let Some(v) = &self.internal {
o.set("internal", v.to_json());
}
if let Some(v) = &self.right_handed {
o.set("rightHanded", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl ThreadProps {
/// The `thread` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("thread");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct CoilProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Cross-section profile (a sketch region), offset from the axis.
pub profile: ProfileRef,
/// Axis the coil winds around.
pub axis: AxisRef,
/// Axial advance per turn (mm).
/// Unit: mm.
/// Default: `8`.
pub pitch: Option<f64>,
/// Number of revolutions.
/// Default: `5`.
pub turns: Option<f64>,
/// Right-handed (default) vs left-handed.
/// Default: `true`.
pub right_handed: Option<bool>,
/// How the solid combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for CoilProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("profile", self.profile.to_json());
o.set("axis", self.axis.to_json());
if let Some(v) = &self.pitch {
o.set("pitch", v.to_json());
}
if let Some(v) = &self.turns {
o.set("turns", v.to_json());
}
if let Some(v) = &self.right_handed {
o.set("rightHanded", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl CoilProps {
/// The `coil` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("coil");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// Union fuses all bodies; subtract cuts the rest from the first; intersect keeps the overlap.
/// Default: `"union"`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CombinePropsOperation {
/// `"intersect"`
Intersect,
/// `"union"`
Union,
/// `"subtract"`
Subtract,
}
impl ToJson for CombinePropsOperation {
fn to_json(&self) -> Json {
Json::from(match self {
CombinePropsOperation::Intersect => "intersect",
CombinePropsOperation::Union => "union",
CombinePropsOperation::Subtract => "subtract",
})
}
}
#[derive(Clone, Debug)]
pub struct CombineProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Union fuses all bodies; subtract cuts the rest from the first; intersect keeps the overlap.
/// Default: `"union"`.
pub operation: Option<CombinePropsOperation>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for CombineProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl CombineProps {
/// The `combine` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("combine");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct OffsetFacesProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Faces to push/pull along their normals.
pub faces: Vec<Json>,
/// How far along their normals (negative: inward).
/// Unit: mm.
/// Default: `1`.
pub distance: Option<f64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for OffsetFacesProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("faces", self.faces.to_json());
if let Some(v) = &self.distance {
o.set("distance", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl OffsetFacesProps {
/// The `offsetFaces` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("offsetFaces");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct ThickenProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The bodies to thicken, by id (a surface becomes a solid of this thickness). Absent: every body, each grown (or, negative, shrunk) evenly.
pub bodies: Option<Vec<String>>,
/// How thick, along the surface's normal (negative: the other side); for a solid, the uniform offset.
/// Unit: mm.
/// Default: `1`.
pub distance: Option<f64>,
/// A surface thickens to both sides of itself, half each way.
pub symmetric: Option<bool>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for ThickenProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.bodies {
o.set("bodies", v.to_json());
}
if let Some(v) = &self.distance {
o.set("distance", v.to_json());
}
if let Some(v) = &self.symmetric {
o.set("symmetric", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl ThickenProps {
/// The `thicken` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("thicken");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// TRIM A SURFACE: cut a surface body by a plane, a flat face or another surface, and keep one side.
#[derive(Clone, Debug)]
pub struct TrimSurfaceProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The surface body to trim, by id.
pub body: String,
/// What cuts it, when it is a plane: a construction plane, a base plane or a flat face.
pub tool: Option<PlaneRef>,
/// What cuts it, when it is another surface body (in place of `tool`), by id.
pub tool_body: Option<String>,
/// Keep the side the tool's normal points to (the other side is kept when false).
/// Default: `true`.
pub keep_front: Option<bool>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for TrimSurfaceProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("body", self.body.to_json());
if let Some(v) = &self.tool {
o.set("tool", v.to_json());
}
if let Some(v) = &self.tool_body {
o.set("toolBody", v.to_json());
}
if let Some(v) = &self.keep_front {
o.set("keepFront", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl TrimSurfaceProps {
/// The `trimSurface` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("trimSurface");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// UNTRIM A SURFACE: fill its openings. With no `edges`, each face's own holes are taken away; with `edges`, each opening whose boundary holds one of them (a loop of open edges, which may run along several faces: a box with no lid) is closed by a face, flat when the loop is, else a filling surface through it.
#[derive(Clone, Debug)]
pub struct UntrimSurfaceProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The surface body, by id.
pub body: String,
/// An open edge of each opening to fill.
pub edges: Option<Vec<TopoRef>>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for UntrimSurfaceProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("body", self.body.to_json());
if let Some(v) = &self.edges {
o.set("edges", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl UntrimSurfaceProps {
/// The `untrimSurface` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("untrimSurface");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// EXTEND A SURFACE: grow a surface body past its open edges, each face continued along its own surface (the natural extension: a plane stays the plane, a cylinder goes on round, a B-spline goes on as its last span), joined to the body. An edge is a side of its face's parameter rectangle.
#[derive(Clone, Debug)]
pub struct ExtendSurfaceProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The open edges to extend.
pub edges: Vec<TopoRef>,
/// How far each is extended.
/// Unit: mm.
/// Default: `5`.
pub distance: Option<f64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for ExtendSurfaceProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("edges", self.edges.to_json());
if let Some(v) = &self.distance {
o.set("distance", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl ExtendSurfaceProps {
/// The `extendSurface` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("extendSurface");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// STITCH SURFACES: join surface bodies that share their edges into one body. When the joined faces close a volume, the body is a solid.
#[derive(Clone, Debug)]
pub struct StitchProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The surface bodies to join, by id.
pub bodies: Vec<String>,
/// How far apart two edges may be and still be joined.
/// Unit: mm.
/// Default: `0.01`.
pub tolerance: Option<f64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for StitchProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("bodies", self.bodies.to_json());
if let Some(v) = &self.tolerance {
o.set("tolerance", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl StitchProps {
/// The `stitch` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("stitch");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// REPLACE A FACE of a solid by a surface: the faces next to it are continued along their own surfaces to the surface, and the surface closes the body there. The body grows to it or is cut back to it.
#[derive(Clone, Debug)]
pub struct ReplaceFaceProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The face replaced.
pub face: Json,
/// The surface body it is replaced by, by id (it stays a body of its own).
pub surface: String,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for ReplaceFaceProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("face", self.face.to_json());
o.set("surface", self.surface.to_json());
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl ReplaceFaceProps {
/// The `replaceFace` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("replaceFace");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// OFFSET A SURFACE: a new surface body at a distance from a surface body, along its normal.
#[derive(Clone, Debug)]
pub struct OffsetSurfaceProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The surface body to offset, by id.
pub body: String,
/// How far along its normal (negative: the other way).
/// Unit: mm.
/// Default: `2`.
pub distance: Option<f64>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for OffsetSurfaceProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("body", self.body.to_json());
if let Some(v) = &self.distance {
o.set("distance", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl OffsetSurfaceProps {
/// The `offsetSurface` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("offsetSurface");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct SplitProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Plane that cuts bodies into separate pieces.
pub plane: PlaneRef,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SplitProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("plane", self.plane.to_json());
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SplitProps {
/// The `split` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("split");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct ScaleProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Scales EVERY body in the document. It carried a `seedFeature` that the rebuild never read and the only authoring path (`scaleModel`) filled with `""` — a required field naming nothing, which reads as a promise that a scale can be aimed at one feature's body. It cannot.
/// Default: `1`.
pub factor: Option<f64>,
/// Scale about this point (defaults to the origin).
/// Unit: mm.
pub center: Option<Vec3>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for ScaleProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.factor {
o.set("factor", v.to_json());
}
if let Some(v) = &self.center {
o.set("center", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl ScaleProps {
/// The `scale` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("scale");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct RibProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Sketch feature whose (open or closed) chain defines the rib path.
pub sketch: String,
/// Wall thickness (mm).
/// Unit: mm.
/// Default: `3`.
pub thickness: Option<f64>,
/// Extrude distance perpendicular to the sketch plane (mm).
/// Unit: mm.
/// Default: `20`.
pub depth: Option<f64>,
/// Thicken symmetrically about the path (default true).
/// Default: `true`.
pub both_sides: Option<bool>,
/// How the solid combines with the bodies before it.
/// Default: `"add"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for RibProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("sketch", self.sketch.to_json());
if let Some(v) = &self.thickness {
o.set("thickness", v.to_json());
}
if let Some(v) = &self.depth {
o.set("depth", v.to_json());
}
if let Some(v) = &self.both_sides {
o.set("bothSides", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl RibProps {
/// The `rib` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("rib");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// A subdivision-surface body (Catmull-Clark). Authored in the **sculpt** mode as an editable control cage — a quad mesh you push/pull/subdivide — and committed into the document as a body. The cage is stored verbatim (control points + quad faces); the surface is computed by subdividing `level` times (pure TS subdivision in `cad/model/subdiv.ts`), then meshed for display. Independent of the OCC kernel (which has no native subdivision), so it works everywhere.
#[derive(Clone, Debug)]
pub struct SubdivBodyProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Control-cage vertices (object space, mm).
pub control_points: Vec<Vec3>,
/// Quad (or tri) faces as indices into controlPoints.
pub faces: Vec<Vec<f64>>,
/// Catmull-Clark subdivision iterations (0 = the raw cage).
pub level: f64,
/// How the resulting solid combines with existing bodies (default "new").
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SubdivBodyProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("controlPoints", self.control_points.to_json());
o.set("faces", self.faces.to_json());
o.set("level", self.level.to_json());
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SubdivBodyProps {
/// The `subdivBody` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("subdivBody");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MeshModifierSpecDisplaceNormalWeighting {
/// `"angle"`
Angle,
/// `"area"`
Area,
}
impl ToJson for MeshModifierSpecDisplaceNormalWeighting {
fn to_json(&self) -> Json {
Json::from(match self {
MeshModifierSpecDisplaceNormalWeighting::Angle => "angle",
MeshModifierSpecDisplaceNormalWeighting::Area => "area",
})
}
}
#[derive(Clone, Debug)]
pub struct MeshModifierSpecDisplace {
pub distance: f64,
pub normal_weighting: Option<MeshModifierSpecDisplaceNormalWeighting>,
}
impl ToJson for MeshModifierSpecDisplace {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", "displace");
o.set("distance", self.distance.to_json());
if let Some(v) = &self.normal_weighting {
o.set("normalWeighting", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct MeshModifierSpecSmooth {
pub iterations: f64,
pub factor: f64,
pub preserve_boundary: Option<bool>,
}
impl ToJson for MeshModifierSpecSmooth {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", "smooth");
o.set("iterations", self.iterations.to_json());
o.set("factor", self.factor.to_json());
if let Some(v) = &self.preserve_boundary {
o.set("preserveBoundary", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct MeshModifierSpecSubdivide {
pub levels: f64,
pub limit_surface: Option<bool>,
}
impl ToJson for MeshModifierSpecSubdivide {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", "subdivide");
o.set("levels", self.levels.to_json());
if let Some(v) = &self.limit_surface {
o.set("limitSurface", v.to_json());
}
o
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MeshModifierSpecSolidifyNormalWeighting {
/// `"angle"`
Angle,
/// `"area"`
Area,
}
impl ToJson for MeshModifierSpecSolidifyNormalWeighting {
fn to_json(&self) -> Json {
Json::from(match self {
MeshModifierSpecSolidifyNormalWeighting::Angle => "angle",
MeshModifierSpecSolidifyNormalWeighting::Area => "area",
})
}
}
#[derive(Clone, Debug)]
pub struct MeshModifierSpecSolidify {
pub thickness: f64,
pub normal_weighting: Option<MeshModifierSpecSolidifyNormalWeighting>,
}
impl ToJson for MeshModifierSpecSolidify {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", "solidify");
o.set("thickness", self.thickness.to_json());
if let Some(v) = &self.normal_weighting {
o.set("normalWeighting", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct MeshModifierSpecShrinkwrap {
pub offset: f64,
}
impl ToJson for MeshModifierSpecShrinkwrap {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", "shrinkwrap");
o.set("offset", self.offset.to_json());
o
}
}
#[derive(Clone, Debug)]
pub enum MeshModifierSpec {
Displace(MeshModifierSpecDisplace),
Smooth(MeshModifierSpecSmooth),
Subdivide(MeshModifierSpecSubdivide),
Solidify(MeshModifierSpecSolidify),
Shrinkwrap(MeshModifierSpecShrinkwrap),
}
impl ToJson for MeshModifierSpec {
fn to_json(&self) -> Json {
match self {
MeshModifierSpec::Displace(x) => x.to_json(),
MeshModifierSpec::Smooth(x) => x.to_json(),
MeshModifierSpec::Subdivide(x) => x.to_json(),
MeshModifierSpec::Solidify(x) => x.to_json(),
MeshModifierSpec::Shrinkwrap(x) => x.to_json(),
}
}
}
impl From<MeshModifierSpecDisplace> for MeshModifierSpec {
fn from(x: MeshModifierSpecDisplace) -> MeshModifierSpec {
MeshModifierSpec::Displace(x)
}
}
impl From<MeshModifierSpecSmooth> for MeshModifierSpec {
fn from(x: MeshModifierSpecSmooth) -> MeshModifierSpec {
MeshModifierSpec::Smooth(x)
}
}
impl From<MeshModifierSpecSubdivide> for MeshModifierSpec {
fn from(x: MeshModifierSpecSubdivide) -> MeshModifierSpec {
MeshModifierSpec::Subdivide(x)
}
}
impl From<MeshModifierSpecSolidify> for MeshModifierSpec {
fn from(x: MeshModifierSpecSolidify) -> MeshModifierSpec {
MeshModifierSpec::Solidify(x)
}
}
impl From<MeshModifierSpecShrinkwrap> for MeshModifierSpec {
fn from(x: MeshModifierSpecShrinkwrap) -> MeshModifierSpec {
MeshModifierSpec::Shrinkwrap(x)
}
}
/// One editable operation over another mesh-producing source node. References are graph edges.
#[derive(Clone, Debug)]
pub struct MeshModifierProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
pub input: String,
/// Required for shrinkwrap; a dependency, never consumed as the modified output.
pub target: Option<String>,
pub modifier: MeshModifierSpec,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for MeshModifierProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("input", self.input.to_json());
if let Some(v) = &self.target {
o.set("target", v.to_json());
}
o.set("modifier", self.modifier.to_json());
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl MeshModifierProps {
/// The `meshModifier` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("meshModifier");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SourceMaterialKind {
/// `"basic"`
Basic,
/// `"phong"`
Phong,
/// `"standard"`
Standard,
/// `"physical"`
Physical,
}
impl ToJson for SourceMaterialKind {
fn to_json(&self) -> Json {
Json::from(match self {
SourceMaterialKind::Basic => "basic",
SourceMaterialKind::Phong => "phong",
SourceMaterialKind::Standard => "standard",
SourceMaterialKind::Physical => "physical",
})
}
}
/// A texture's UV transform, as three.js holds it; a field left out is three.js's own default.
#[derive(Clone, Debug)]
pub struct SourceTextureTransform {
/// Default: `[0,0]`.
pub offset: Option<[f64; 2]>,
/// Default: `[1,1]`.
pub repeat: Option<[f64; 2]>,
/// Default: `[0,0]`.
pub center: Option<[f64; 2]>,
/// Unit: rad.
/// Default: `0`.
pub rotation: Option<f64>,
/// Default: `true`.
pub matrix_auto_update: Option<bool>,
}
impl ToJson for SourceTextureTransform {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.offset {
o.set("offset", v.to_json());
}
if let Some(v) = &self.repeat {
o.set("repeat", v.to_json());
}
if let Some(v) = &self.center {
o.set("center", v.to_json());
}
if let Some(v) = &self.rotation {
o.set("rotation", v.to_json());
}
if let Some(v) = &self.matrix_auto_update {
o.set("matrixAutoUpdate", v.to_json());
}
o
}
}
/// Browser-decodable PNG/JPEG/WebP/etc bytes, kept as a data URL until bundle hoisting.
#[derive(Clone, Debug)]
pub struct SourceImageTexture {
pub data: String,
pub name: Option<String>,
pub color_space: Option<String>,
pub channel: Option<f64>,
pub wrap_s: Option<f64>,
pub wrap_t: Option<f64>,
pub mag_filter: Option<f64>,
pub min_filter: Option<f64>,
pub anisotropy: Option<f64>,
pub flip_y: Option<bool>,
pub transform: Option<SourceTextureTransform>,
}
impl ToJson for SourceImageTexture {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", "image");
o.set("data", self.data.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.color_space {
o.set("colorSpace", v.to_json());
}
if let Some(v) = &self.channel {
o.set("channel", v.to_json());
}
if let Some(v) = &self.wrap_s {
o.set("wrapS", v.to_json());
}
if let Some(v) = &self.wrap_t {
o.set("wrapT", v.to_json());
}
if let Some(v) = &self.mag_filter {
o.set("magFilter", v.to_json());
}
if let Some(v) = &self.min_filter {
o.set("minFilter", v.to_json());
}
if let Some(v) = &self.anisotropy {
o.set("anisotropy", v.to_json());
}
if let Some(v) = &self.flip_y {
o.set("flipY", v.to_json());
}
if let Some(v) = &self.transform {
o.set("transform", v.to_json());
}
o
}
}
/// Universal uncompressed pixel data (for DataTexture and Basis RGBA output).
#[derive(Clone, Debug)]
pub struct SourceDataTexture {
pub width: f64,
pub height: f64,
pub data: String,
pub format: f64,
pub type_: f64,
pub name: Option<String>,
pub color_space: Option<String>,
pub channel: Option<f64>,
pub wrap_s: Option<f64>,
pub wrap_t: Option<f64>,
pub mag_filter: Option<f64>,
pub min_filter: Option<f64>,
pub anisotropy: Option<f64>,
pub flip_y: Option<bool>,
pub transform: Option<SourceTextureTransform>,
}
impl ToJson for SourceDataTexture {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", "data");
o.set("width", self.width.to_json());
o.set("height", self.height.to_json());
o.set("data", self.data.to_json());
o.set("format", self.format.to_json());
o.set("type", self.type_.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.color_space {
o.set("colorSpace", v.to_json());
}
if let Some(v) = &self.channel {
o.set("channel", v.to_json());
}
if let Some(v) = &self.wrap_s {
o.set("wrapS", v.to_json());
}
if let Some(v) = &self.wrap_t {
o.set("wrapT", v.to_json());
}
if let Some(v) = &self.mag_filter {
o.set("magFilter", v.to_json());
}
if let Some(v) = &self.min_filter {
o.set("minFilter", v.to_json());
}
if let Some(v) = &self.anisotropy {
o.set("anisotropy", v.to_json());
}
if let Some(v) = &self.flip_y {
o.set("flipY", v.to_json());
}
if let Some(v) = &self.transform {
o.set("transform", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct SourceCompressedTextureMipmapsItem {
pub width: f64,
pub height: f64,
pub data: String,
}
impl ToJson for SourceCompressedTextureMipmapsItem {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("width", self.width.to_json());
o.set("height", self.height.to_json());
o.set("data", self.data.to_json());
o
}
}
/// GPU-compressed mip payload retained from KTX2 decoding.
#[derive(Clone, Debug)]
pub struct SourceCompressedTexture {
pub width: f64,
pub height: f64,
pub format: f64,
pub type_: f64,
pub mipmaps: Vec<SourceCompressedTextureMipmapsItem>,
pub name: Option<String>,
pub color_space: Option<String>,
pub channel: Option<f64>,
pub wrap_s: Option<f64>,
pub wrap_t: Option<f64>,
pub mag_filter: Option<f64>,
pub min_filter: Option<f64>,
pub anisotropy: Option<f64>,
pub flip_y: Option<bool>,
pub transform: Option<SourceTextureTransform>,
}
impl ToJson for SourceCompressedTexture {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", "compressed");
o.set("width", self.width.to_json());
o.set("height", self.height.to_json());
o.set("format", self.format.to_json());
o.set("type", self.type_.to_json());
o.set("mipmaps", self.mipmaps.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.color_space {
o.set("colorSpace", v.to_json());
}
if let Some(v) = &self.channel {
o.set("channel", v.to_json());
}
if let Some(v) = &self.wrap_s {
o.set("wrapS", v.to_json());
}
if let Some(v) = &self.wrap_t {
o.set("wrapT", v.to_json());
}
if let Some(v) = &self.mag_filter {
o.set("magFilter", v.to_json());
}
if let Some(v) = &self.min_filter {
o.set("minFilter", v.to_json());
}
if let Some(v) = &self.anisotropy {
o.set("anisotropy", v.to_json());
}
if let Some(v) = &self.flip_y {
o.set("flipY", v.to_json());
}
if let Some(v) = &self.transform {
o.set("transform", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub enum SourceTexture {
Image(SourceImageTexture),
Data(SourceDataTexture),
Compressed(SourceCompressedTexture),
}
impl ToJson for SourceTexture {
fn to_json(&self) -> Json {
match self {
SourceTexture::Image(x) => x.to_json(),
SourceTexture::Data(x) => x.to_json(),
SourceTexture::Compressed(x) => x.to_json(),
}
}
}
impl From<SourceImageTexture> for SourceTexture {
fn from(x: SourceImageTexture) -> SourceTexture {
SourceTexture::Image(x)
}
}
impl From<SourceDataTexture> for SourceTexture {
fn from(x: SourceDataTexture) -> SourceTexture {
SourceTexture::Data(x)
}
}
impl From<SourceCompressedTexture> for SourceTexture {
fn from(x: SourceCompressedTexture) -> SourceTexture {
SourceTexture::Compressed(x)
}
}
#[derive(Clone, Debug)]
pub struct SourceMaterialTextures {
pub map: Option<SourceTexture>,
pub normal_map: Option<SourceTexture>,
pub roughness_map: Option<SourceTexture>,
pub metalness_map: Option<SourceTexture>,
pub ao_map: Option<SourceTexture>,
pub emissive_map: Option<SourceTexture>,
pub alpha_map: Option<SourceTexture>,
pub bump_map: Option<SourceTexture>,
pub displacement_map: Option<SourceTexture>,
pub specular_map: Option<SourceTexture>,
pub specular_color_map: Option<SourceTexture>,
pub clearcoat_map: Option<SourceTexture>,
pub clearcoat_normal_map: Option<SourceTexture>,
pub clearcoat_roughness_map: Option<SourceTexture>,
}
impl ToJson for SourceMaterialTextures {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.map {
o.set("map", v.to_json());
}
if let Some(v) = &self.normal_map {
o.set("normalMap", v.to_json());
}
if let Some(v) = &self.roughness_map {
o.set("roughnessMap", v.to_json());
}
if let Some(v) = &self.metalness_map {
o.set("metalnessMap", v.to_json());
}
if let Some(v) = &self.ao_map {
o.set("aoMap", v.to_json());
}
if let Some(v) = &self.emissive_map {
o.set("emissiveMap", v.to_json());
}
if let Some(v) = &self.alpha_map {
o.set("alphaMap", v.to_json());
}
if let Some(v) = &self.bump_map {
o.set("bumpMap", v.to_json());
}
if let Some(v) = &self.displacement_map {
o.set("displacementMap", v.to_json());
}
if let Some(v) = &self.specular_map {
o.set("specularMap", v.to_json());
}
if let Some(v) = &self.specular_color_map {
o.set("specularColorMap", v.to_json());
}
if let Some(v) = &self.clearcoat_map {
o.set("clearcoatMap", v.to_json());
}
if let Some(v) = &self.clearcoat_normal_map {
o.set("clearcoatNormalMap", v.to_json());
}
if let Some(v) = &self.clearcoat_roughness_map {
o.set("clearcoatRoughnessMap", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct SourceMaterial {
pub kind: SourceMaterialKind,
pub name: Option<String>,
pub color: Option<String>,
pub emissive: Option<String>,
pub metalness: Option<f64>,
pub roughness: Option<f64>,
pub opacity: Option<f64>,
pub transparent: Option<bool>,
pub alpha_test: Option<f64>,
pub side: Option<f64>,
pub flat_shading: Option<bool>,
pub depth_write: Option<bool>,
pub vertex_colors: Option<bool>,
pub ior: Option<f64>,
pub clearcoat: Option<f64>,
pub clearcoat_roughness: Option<f64>,
pub specular_intensity: Option<f64>,
pub shininess: Option<f64>,
pub bump_scale: Option<f64>,
pub displacement_scale: Option<f64>,
pub normal_scale: Option<[f64; 2]>,
pub textures: Option<SourceMaterialTextures>,
}
impl ToJson for SourceMaterial {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", self.kind.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.color {
o.set("color", v.to_json());
}
if let Some(v) = &self.emissive {
o.set("emissive", v.to_json());
}
if let Some(v) = &self.metalness {
o.set("metalness", v.to_json());
}
if let Some(v) = &self.roughness {
o.set("roughness", v.to_json());
}
if let Some(v) = &self.opacity {
o.set("opacity", v.to_json());
}
if let Some(v) = &self.transparent {
o.set("transparent", v.to_json());
}
if let Some(v) = &self.alpha_test {
o.set("alphaTest", v.to_json());
}
if let Some(v) = &self.side {
o.set("side", v.to_json());
}
if let Some(v) = &self.flat_shading {
o.set("flatShading", v.to_json());
}
if let Some(v) = &self.depth_write {
o.set("depthWrite", v.to_json());
}
if let Some(v) = &self.vertex_colors {
o.set("vertexColors", v.to_json());
}
if let Some(v) = &self.ior {
o.set("ior", v.to_json());
}
if let Some(v) = &self.clearcoat {
o.set("clearcoat", v.to_json());
}
if let Some(v) = &self.clearcoat_roughness {
o.set("clearcoatRoughness", v.to_json());
}
if let Some(v) = &self.specular_intensity {
o.set("specularIntensity", v.to_json());
}
if let Some(v) = &self.shininess {
o.set("shininess", v.to_json());
}
if let Some(v) = &self.bump_scale {
o.set("bumpScale", v.to_json());
}
if let Some(v) = &self.displacement_scale {
o.set("displacementScale", v.to_json());
}
if let Some(v) = &self.normal_scale {
o.set("normalScale", v.to_json());
}
if let Some(v) = &self.textures {
o.set("textures", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct SourceMaterialGroup {
pub start: f64,
pub count: f64,
pub material_index: f64,
}
impl ToJson for SourceMaterialGroup {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("start", self.start.to_json());
o.set("count", self.count.to_json());
o.set("materialIndex", self.material_index.to_json());
o
}
}
/// Provenance for a generated body — drives ground-truth outcome capture + shows in the feature tree. `fileName` records the source file for imported bodies (GLB/OBJ/USDA/…).
#[derive(Clone, Debug)]
pub struct MeshBodyPropsSource {
pub prompt: Option<String>,
pub expert: Option<String>,
pub generation_id: Option<String>,
pub file_id: Option<String>,
pub file_name: Option<String>,
}
impl ToJson for MeshBodyPropsSource {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.prompt {
o.set("prompt", v.to_json());
}
if let Some(v) = &self.expert {
o.set("expert", v.to_json());
}
if let Some(v) = &self.generation_id {
o.set("generationId", v.to_json());
}
if let Some(v) = &self.file_id {
o.set("fileId", v.to_json());
}
if let Some(v) = &self.file_name {
o.set("fileName", v.to_json());
}
o
}
}
/// A regular grid of heights, read from the body's `positions`.
#[derive(Clone, Debug)]
pub struct WorldHeightfieldCollider {
/// Grid columns (west → east).
pub nx: i64,
/// Grid rows (south → north).
pub ny: i64,
/// The grid's east–west span.
/// Unit: mm.
pub size_x: f64,
/// The grid's south–north span.
/// Unit: mm.
pub size_y: f64,
}
impl ToJson for WorldHeightfieldCollider {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "heightfield");
o.set("nx", self.nx.to_json());
o.set("ny", self.ny.to_json());
o.set("sizeX", self.size_x.to_json());
o.set("sizeY", self.size_y.to_json());
o
}
}
/// The body's exact triangle mesh, as a fixed collider.
#[derive(Clone, Debug)]
pub struct WorldTrimeshCollider {
}
impl ToJson for WorldTrimeshCollider {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("type", "trimesh");
o
}
}
/// The collider of a world body (MeshBodyFeature.worldCollider).
#[derive(Clone, Debug)]
pub enum WorldCollider {
Heightfield(WorldHeightfieldCollider),
Trimesh(WorldTrimeshCollider),
}
impl ToJson for WorldCollider {
fn to_json(&self) -> Json {
match self {
WorldCollider::Heightfield(x) => x.to_json(),
WorldCollider::Trimesh(x) => x.to_json(),
}
}
}
impl From<WorldHeightfieldCollider> for WorldCollider {
fn from(x: WorldHeightfieldCollider) -> WorldCollider {
WorldCollider::Heightfield(x)
}
}
impl From<WorldTrimeshCollider> for WorldCollider {
fn from(x: WorldTrimeshCollider) -> WorldCollider {
WorldCollider::Trimesh(x)
}
}
#[derive(Clone, Debug)]
pub struct MeshBodyProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Original polygon cage. Display indices must be its fan triangulation; modifiers retain it.
pub polygons: Option<Vec<Vec<f64>>>,
/// Interleaved xyz vertex positions (object space, mm): [x0,y0,z0, x1,y1,z1, …].
pub positions: Vec<f64>,
/// Triangle vertex indices into `positions`/3.
pub indices: Vec<f64>,
/// Interleaved xyz vertex normals; recomputed from faces when absent.
pub normals: Option<Vec<f64>>,
/// Baked packed 0..1 atlas UVs (parallel to `positions`), when this body was created with a real UV unwrap already computed (e.g. a sculpt commit, which stores its split geometry + UVs here). Absent ⇒ the rebuild unwraps the geometry on load (see model/meshUnwrap). Makes the body paintable.
pub uv: Option<Vec<f64>>,
/// Authored texture coordinates from the imported asset. Kept separate from `uv`, which belongs to the document's paint atlas and may introduce a different set of seam splits.
pub source_uv: Option<Vec<f64>>,
/// Serializable imported materials, including embedded image/raw/compressed texture payloads.
pub source_materials: Option<Vec<SourceMaterial>>,
/// Contiguous index ranges assigning triangles to entries in `sourceMaterials`.
pub material_groups: Option<Vec<SourceMaterialGroup>>,
/// Provenance for a generated body — drives ground-truth outcome capture + shows in the feature tree. `fileName` records the source file for imported bodies (GLB/OBJ/USDA/…).
pub source: Option<MeshBodyPropsSource>,
/// How a world collides this body: a heightfield grid or the exact triangle mesh. Only a world body has it.
pub world_collider: Option<WorldCollider>,
/// The world body's rest centre (world mm). A heightfield's heights are taken relative to its z.
/// Unit: mm.
pub world_center: Option<[f64; 3]>,
/// The world body's friction coefficient.
pub world_friction: Option<f64>,
/// The world body's restitution (0: no bounce, 1: a perfect bounce).
pub world_restitution: Option<f64>,
/// Where the world body came from (the tile, the vertical datum, the ground resolution): open provenance.
pub world_meta: Option<Json>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for MeshBodyProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.polygons {
o.set("polygons", v.to_json());
}
o.set("positions", self.positions.to_json());
o.set("indices", self.indices.to_json());
if let Some(v) = &self.normals {
o.set("normals", v.to_json());
}
if let Some(v) = &self.uv {
o.set("uv", v.to_json());
}
if let Some(v) = &self.source_uv {
o.set("sourceUv", v.to_json());
}
if let Some(v) = &self.source_materials {
o.set("sourceMaterials", v.to_json());
}
if let Some(v) = &self.material_groups {
o.set("materialGroups", v.to_json());
}
if let Some(v) = &self.source {
o.set("source", v.to_json());
}
if let Some(v) = &self.world_collider {
o.set("worldCollider", v.to_json());
}
if let Some(v) = &self.world_center {
o.set("worldCenter", v.to_json());
}
if let Some(v) = &self.world_friction {
o.set("worldFriction", v.to_json());
}
if let Some(v) = &self.world_restitution {
o.set("worldRestitution", v.to_json());
}
if let Some(v) = &self.world_meta {
o.set("worldMeta", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl MeshBodyProps {
/// The `meshBody` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("meshBody");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct GenNodeRecordOutput {
pub locator: String,
pub digest: Option<String>,
}
impl ToJson for GenNodeRecordOutput {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("locator", self.locator.to_json());
if let Some(v) = &self.digest {
o.set("digest", v.to_json());
}
o
}
}
/// The record a node holds: the output's locator always, the provenance fields when the run returned them. A run that returned only a file still records where its bytes are, in the same slot.
#[derive(Clone, Debug)]
pub struct GenNodeRecord {
/// The SEMANTIC operator — `inpaint`, not a vendor's endpoint name.
pub operator: Option<String>,
pub implementation: Option<String>,
pub implementation_version: Option<String>,
/// Scheme-prefixed model identity: `replicate:owner/slug:hex`, `fal:owner/slug`.
pub artifact_digest: Option<String>,
/// Whether that identity genuinely pins the artifact, or names something the vendor can change.
pub artifact_immutable: Option<bool>,
/// Digest of the input the model saw, so "the inputs moved" is decidable.
pub input_digest: Option<String>,
/// Digest of the authored params, seed included.
pub params_digest: Option<String>,
pub produced_at: Option<String>,
pub output: GenNodeRecordOutput,
}
impl ToJson for GenNodeRecord {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.operator {
o.set("operator", v.to_json());
}
if let Some(v) = &self.implementation {
o.set("implementation", v.to_json());
}
if let Some(v) = &self.implementation_version {
o.set("implementationVersion", v.to_json());
}
if let Some(v) = &self.artifact_digest {
o.set("artifactDigest", v.to_json());
}
if let Some(v) = &self.artifact_immutable {
o.set("artifactImmutable", v.to_json());
}
if let Some(v) = &self.input_digest {
o.set("inputDigest", v.to_json());
}
if let Some(v) = &self.params_digest {
o.set("paramsDigest", v.to_json());
}
if let Some(v) = &self.produced_at {
o.set("producedAt", v.to_json());
}
o.set("output", self.output.to_json());
o
}
}
/// A GENERATE feature — a creative generative model (`@commandagi/core` `GEN_MODELS`) as a re-runnable node in the feature graph. It projects into the op-graph dock as a `gen:<modelId>` GenNode (see ui/model/opgraph-projection): scalar inputs (prompt/enum/…) ride in `params`, wired image/mesh inputs in `refs` (inputKey → upstream featureId), and running it (the dock's async `runNode`) generates an asset that lands as a separate splat/mesh feature (`addSciFeature`) and bakes its `provenance` record here. The generate feature itself produces no geometry — it's the recipe; the landed feature is the result.
#[derive(Clone, Debug)]
pub struct GenerateProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The `GEN_MODELS` model id this node runs (e.g. `image-to-splat.trellis`).
pub model_id: String,
/// Scalar model inputs (prompt/enum/number/seed) — the wireable image/mesh inputs live in `refs`.
pub params: Json,
/// Wired inputs: model input key → upstream feature id (its generated output feeds this model).
pub refs: Option<Vec<(String, String)>>,
/// The last run's one record: where its output landed (downstream chaining, and what renders) and, when the run supplied them, the model's identity and the input and param digests.
pub provenance: Option<GenNodeRecord>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for GenerateProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("modelId", self.model_id.to_json());
o.set("params", self.params.to_json());
if let Some(v) = &self.refs {
o.set("refs", v.to_json());
}
if let Some(v) = &self.provenance {
o.set("provenance", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl GenerateProps {
/// The `generate` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("generate");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct PointCloudPropsSource {
pub format: Option<String>,
pub file_id: Option<String>,
pub file_name: Option<String>,
}
impl ToJson for PointCloudPropsSource {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.format {
o.set("format", v.to_json());
}
if let Some(v) = &self.file_id {
o.set("fileId", v.to_json());
}
if let Some(v) = &self.file_name {
o.set("fileName", v.to_json());
}
o
}
}
/// A raw point cloud — scan points, SWC point sets, or a splat stripped of covariance.
#[derive(Clone, Debug)]
pub struct PointCloudProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Interleaved xyz positions (mm): [x0,y0,z0, …].
pub positions: Vec<f64>,
/// Interleaved rgb per-point colors, 0..1 (optional — falls back to a neutral tint).
pub colors: Option<Vec<f64>>,
/// Screen-space point size (px) hint.
pub point_size: Option<f64>,
pub source: Option<PointCloudPropsSource>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for PointCloudProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("positions", self.positions.to_json());
if let Some(v) = &self.colors {
o.set("colors", v.to_json());
}
if let Some(v) = &self.point_size {
o.set("pointSize", v.to_json());
}
if let Some(v) = &self.source {
o.set("source", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl PointCloudProps {
/// The `pointCloud` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("pointCloud");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// Provenance + roundtrip metadata: the exact source format so export/interop decisions stay sane.
#[derive(Clone, Debug)]
pub struct GaussianSplatPropsSource {
pub format: Option<String>,
pub file_id: Option<String>,
pub file_name: Option<String>,
pub sh_degree: Option<f64>,
pub splat_count: Option<f64>,
}
impl ToJson for GaussianSplatPropsSource {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.format {
o.set("format", v.to_json());
}
if let Some(v) = &self.file_id {
o.set("fileId", v.to_json());
}
if let Some(v) = &self.file_name {
o.set("fileName", v.to_json());
}
if let Some(v) = &self.sh_degree {
o.set("shDegree", v.to_json());
}
if let Some(v) = &self.splat_count {
o.set("splatCount", v.to_json());
}
o
}
}
/// A **3D Gaussian-Splat volume** — the headline volumetric primitive: a cloud of anisotropic translucent gaussians (position + per-axis scale + orientation + color/opacity), the representation of choice for photoreal capture (video/scan → navigable scene) and volumetric science visualization. Imported from a gaussian PLY (or `.splat`); the DC spherical-harmonic term is baked to an RGB color on import.
#[derive(Clone, Debug)]
pub struct GaussianSplatProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Number of gaussians N.
pub count: f64,
/// Means, 3N (mm).
pub positions: Vec<f64>,
/// Per-axis world-space scales, 3N (already exp'd from log-scale on import).
pub scales: Vec<f64>,
/// Orientation quaternions, 4N [x,y,z,w] (normalized on import).
pub rotations: Vec<f64>,
/// Per-splat RGBA, 4N, 0..1 (SH DC → base color via `0.5 + C0·f_dc`, sigmoid(opacity) → alpha). Kept as the tier-1 view-independent color; higher SH bands (view-dependent) live in `sh`.
pub colors: Vec<f64>,
/// Spherical-harmonic degree of the ORIGINAL asset (0..3). 0 = DC only (color is exact); 1..3 = the `f_rest_*` coefficients are preserved in `sh` for a view-dependent renderer. We keep the real 3DGS parameter model rather than collapsing to rgba — see the g-splat fidelity note.
pub sh_degree: Option<f64>,
/// Higher-band SH coefficients (excluding the DC term already baked into `colors.rgb`). Layout: per splat, `restCount = (shDegree+1)² − 1` coefficients, each an RGB triple, interleaved `[s0_c0_r,s0_c0_g,s0_c0_b, s0_c1_r,…]`. Length = N·restCount·3. Absent for degree-0 assets.
pub sh: Option<Vec<f64>>,
/// Provenance + roundtrip metadata: the exact source format so export/interop decisions stay sane.
pub source: Option<GaussianSplatPropsSource>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for GaussianSplatProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("count", self.count.to_json());
o.set("positions", self.positions.to_json());
o.set("scales", self.scales.to_json());
o.set("rotations", self.rotations.to_json());
o.set("colors", self.colors.to_json());
if let Some(v) = &self.sh_degree {
o.set("shDegree", v.to_json());
}
if let Some(v) = &self.sh {
o.set("sh", v.to_json());
}
if let Some(v) = &self.source {
o.set("source", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl GaussianSplatProps {
/// The `gaussianSplat` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("gaussianSplat");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// The bond/atom layer. "ball-stick" (default) = covalent-radius balls + sticks; "spacefill" = van der Waals spheres, no sticks; "wire" = thin sticks + dot atoms; "none" = hide it (for an electron/nucleus layer standing alone).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MoleculeRepresentationBonds {
/// `"none"`
None,
/// `"wire"`
Wire,
/// `"ball-stick"`
BallStick,
/// `"spacefill"`
Spacefill,
}
impl ToJson for MoleculeRepresentationBonds {
fn to_json(&self) -> Json {
Json::from(match self {
MoleculeRepresentationBonds::None => "none",
MoleculeRepresentationBonds::Wire => "wire",
MoleculeRepresentationBonds::BallStick => "ball-stick",
MoleculeRepresentationBonds::Spacefill => "spacefill",
})
}
}
/// The electron layer. "cloud" = a VOLUMETRIC translucent electron-density field, drawn as gaussian splats (a soft fuzzy cloud, not a hard isosurface shell — total density has no surface). "none" (default) draws nothing. (Per-orbital / valence-only clouds are the next rungs — see VISUALIZATION.md.)
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MoleculeRepresentationElectron {
/// `"none"`
None,
/// `"cloud"`
Cloud,
}
impl ToJson for MoleculeRepresentationElectron {
fn to_json(&self) -> Json {
Json::from(match self {
MoleculeRepresentationElectron::None => "none",
MoleculeRepresentationElectron::Cloud => "cloud",
})
}
}
/// The nucleus layer. "nuclei" = tiny bright points at each atomic center; "none" (default) draws nothing.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MoleculeRepresentationNucleus {
/// `"none"`
None,
/// `"nuclei"`
Nuclei,
}
impl ToJson for MoleculeRepresentationNucleus {
fn to_json(&self) -> Json {
Json::from(match self {
MoleculeRepresentationNucleus::None => "none",
MoleculeRepresentationNucleus::Nuclei => "nuclei",
})
}
}
/// The molecular-scale view layers. Composable — the renderer draws every enabled layer.
#[derive(Clone, Debug)]
pub struct MoleculeRepresentation {
/// The bond/atom layer. "ball-stick" (default) = covalent-radius balls + sticks; "spacefill" = van der Waals spheres, no sticks; "wire" = thin sticks + dot atoms; "none" = hide it (for an electron/nucleus layer standing alone).
pub bonds: Option<MoleculeRepresentationBonds>,
/// The electron layer. "cloud" = a VOLUMETRIC translucent electron-density field, drawn as gaussian splats (a soft fuzzy cloud, not a hard isosurface shell — total density has no surface). "none" (default) draws nothing. (Per-orbital / valence-only clouds are the next rungs — see VISUALIZATION.md.)
pub electron: Option<MoleculeRepresentationElectron>,
/// The nucleus layer. "nuclei" = tiny bright points at each atomic center; "none" (default) draws nothing.
pub nucleus: Option<MoleculeRepresentationNucleus>,
}
impl ToJson for MoleculeRepresentation {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.bonds {
o.set("bonds", v.to_json());
}
if let Some(v) = &self.electron {
o.set("electron", v.to_json());
}
if let Some(v) = &self.nucleus {
o.set("nucleus", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct MoleculePropsSource {
pub format: Option<String>,
pub file_id: Option<String>,
pub file_name: Option<String>,
pub title: Option<String>,
pub atom_count: Option<f64>,
}
impl ToJson for MoleculePropsSource {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.format {
o.set("format", v.to_json());
}
if let Some(v) = &self.file_id {
o.set("fileId", v.to_json());
}
if let Some(v) = &self.file_name {
o.set("fileName", v.to_json());
}
if let Some(v) = &self.title {
o.set("title", v.to_json());
}
if let Some(v) = &self.atom_count {
o.set("atomCount", v.to_json());
}
o
}
}
/// A **molecular structure** — atoms + bonds (+ optional periodic cell), the substrate for real molecular maps of cells, protein/DNA assemblies, and atomically-precise nano-engineering. Imported from the chemistry/crystallography format zoo (PDB, mmCIF, SDF/MOL, MOL2, XYZ, CIF). Kernel-free; rendered ball-and-stick / space-filling. Positions are in ÅNGSTRÖM (rendered scaled) — molecules live at a different scale than mm 3D, so the viewport scales atoms into view; we keep the true Å coordinates.
#[derive(Clone, Debug)]
pub struct MoleculeProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Interleaved xyz atom positions (Ångström), 3N.
pub positions: Vec<f64>,
/// Per-atom atomic number (1=H, 6=C, 7=N, 8=O, …), N — drives CPK color + covalent radius.
pub elements: Vec<f64>,
/// Bonds as flat atom-index pairs [a0,b0, a1,b1, …] (may be empty — inferred by distance on render).
pub bonds: Vec<f64>,
/// Optional per-bond order (1/2/3/aromatic=4), length = bonds.length/2.
pub bond_orders: Option<Vec<f64>>,
/// Optional per-atom chain id (small int) for multi-chain coloring (proteins/complexes).
pub chains: Option<Vec<f64>>,
/// Optional periodic unit cell [a,b,c (Å), α,β,γ (deg)] for crystals.
pub cell: Option<[f64; 6]>,
/// Multi-resolution representation — three INDEPENDENT layers that compose (a molecule can show its bonds, its electron cloud, and its nuclei at once). Each axis defaults to the classic ball-and-stick baseline so an untagged molecule renders exactly as before. See the chemistry app's VISUALIZATION.md for the full view-mode ladder this is the first rung of.
pub representation: Option<MoleculeRepresentation>,
pub source: Option<MoleculePropsSource>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for MoleculeProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("positions", self.positions.to_json());
o.set("elements", self.elements.to_json());
o.set("bonds", self.bonds.to_json());
if let Some(v) = &self.bond_orders {
o.set("bondOrders", v.to_json());
}
if let Some(v) = &self.chains {
o.set("chains", v.to_json());
}
if let Some(v) = &self.cell {
o.set("cell", v.to_json());
}
if let Some(v) = &self.representation {
o.set("representation", v.to_json());
}
if let Some(v) = &self.source {
o.set("source", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl MoleculeProps {
/// The `molecule` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("molecule");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct SkeletonPropsSource {
pub format: Option<String>,
pub file_id: Option<String>,
pub file_name: Option<String>,
}
impl ToJson for SkeletonPropsSource {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.format {
o.set("format", v.to_json());
}
if let Some(v) = &self.file_id {
o.set("fileId", v.to_json());
}
if let Some(v) = &self.file_name {
o.set("fileName", v.to_json());
}
o
}
}
/// A **skeleton** — a tree/graph of nodes with radii, the native representation for neuronal & vascular morphology (SWC: soma/axon/dendrite trees) and connectome traces. Rendered as radius-varying tubes.
#[derive(Clone, Debug)]
pub struct SkeletonProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Node positions, 3N (mm).
pub positions: Vec<f64>,
/// Per-node radius, N (mm).
pub radii: Option<Vec<f64>>,
/// Per-node parent index into nodes (-1 = root), N — the SWC/edge tree.
pub parents: Vec<f64>,
/// Per-node SWC structure tag (0 undefined, 1 soma, 2 axon, 3 basal dendrite, 4 apical dendrite, …) — drives per-segment coloring.
pub node_types: Option<Vec<f64>>,
pub source: Option<SkeletonPropsSource>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for SkeletonProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("positions", self.positions.to_json());
if let Some(v) = &self.radii {
o.set("radii", v.to_json());
}
o.set("parents", self.parents.to_json());
if let Some(v) = &self.node_types {
o.set("nodeTypes", v.to_json());
}
if let Some(v) = &self.source {
o.set("source", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl SkeletonProps {
/// The `skeleton` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("skeleton");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// How to display it.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum VolumePropsRender {
/// `"slices"`
Slices,
/// `"iso"`
Iso,
}
impl ToJson for VolumePropsRender {
fn to_json(&self) -> Json {
Json::from(match self {
VolumePropsRender::Slices => "slices",
VolumePropsRender::Iso => "iso",
})
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum VolumePropsSourceKind {
/// `"scalar"`
Scalar,
/// `"label"`
Label,
}
impl ToJson for VolumePropsSourceKind {
fn to_json(&self) -> Json {
Json::from(match self {
VolumePropsSourceKind::Scalar => "scalar",
VolumePropsSourceKind::Label => "label",
})
}
}
#[derive(Clone, Debug)]
pub struct VolumePropsSource {
pub format: Option<String>,
pub file_id: Option<String>,
pub file_name: Option<String>,
pub kind: Option<VolumePropsSourceKind>,
}
impl ToJson for VolumePropsSource {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.format {
o.set("format", v.to_json());
}
if let Some(v) = &self.file_id {
o.set("fileId", v.to_json());
}
if let Some(v) = &self.file_name {
o.set("fileName", v.to_json());
}
if let Some(v) = &self.kind {
o.set("kind", v.to_json());
}
o
}
}
/// A **scalar/label voxel volume** — CT/MRI/microscopy/segmentation grids (NIfTI/NRRD/DICOM). The field is normalized 0..1 and downsampled to a display-friendly grid on import (large clinical volumes don't fit a JSON doc verbatim). Rendered as three orthogonal MPR slice planes or a marching-cubes isosurface.
#[derive(Clone, Debug)]
pub struct VolumeProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Voxel grid dimensions [nx,ny,nz].
pub dims: [f64; 3],
/// Voxel spacing (mm) [sx,sy,sz].
pub spacing: [f64; 3],
/// World position (mm) of voxel [0,0,0]'s corner.
/// Unit: mm.
/// Default: `[0,0,0]`.
pub origin: Option<Vec3>,
/// Scalar field, length nx·ny·nz, x fastest then y then z, normalized 0..1.
pub data: Vec<f64>,
/// How to display it.
pub render: Option<VolumePropsRender>,
/// Iso threshold (0..1) for the "iso" render.
pub iso: Option<f64>,
/// Named colormap (viridis/gray/hot/…).
pub colormap: Option<String>,
pub source: Option<VolumePropsSource>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for VolumeProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("dims", self.dims.to_json());
o.set("spacing", self.spacing.to_json());
if let Some(v) = &self.origin {
o.set("origin", v.to_json());
}
o.set("data", self.data.to_json());
if let Some(v) = &self.render {
o.set("render", v.to_json());
}
if let Some(v) = &self.iso {
o.set("iso", v.to_json());
}
if let Some(v) = &self.colormap {
o.set("colormap", v.to_json());
}
if let Some(v) = &self.source {
o.set("source", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl VolumeProps {
/// The `volume` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("volume");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct GraphPropsSource {
pub format: Option<String>,
pub file_id: Option<String>,
pub file_name: Option<String>,
pub title: Option<String>,
pub node_count: Option<f64>,
pub edge_count: Option<f64>,
}
impl ToJson for GraphPropsSource {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.format {
o.set("format", v.to_json());
}
if let Some(v) = &self.file_id {
o.set("fileId", v.to_json());
}
if let Some(v) = &self.file_name {
o.set("fileName", v.to_json());
}
if let Some(v) = &self.title {
o.set("title", v.to_json());
}
if let Some(v) = &self.node_count {
o.set("nodeCount", v.to_json());
}
if let Some(v) = &self.edge_count {
o.set("edgeCount", v.to_json());
}
o
}
}
/// A **graph / network** — nodes at 3D positions joined by edges. The substrate for a CONNECTOME (nodes = cells/neurons, edges = synapses/contacts): "a Drosophila brain with exact cell mappings", a C. elegans wiring diagram, a protein-interaction net, a pipe/circuit network. Kernel-free; rendered as node spheres + edge lines. Distinct from `skeleton` (a within-cell branching tree) — this is the between-cell wiring.
#[derive(Clone, Debug)]
pub struct GraphProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Node positions, 3N (mm — soma/centroid of each cell).
pub node_positions: Vec<f64>,
/// Optional per-node radius, N.
pub node_sizes: Option<Vec<f64>>,
/// Optional per-node RGB color, 3N (0..1) — e.g. by cell type / region / community.
pub node_colors: Option<Vec<f64>>,
/// Optional per-node group id (small int) for coloring when nodeColors is absent.
pub node_groups: Option<Vec<f64>>,
/// Edges as flat node-index pairs [a0,b0, a1,b1, …].
pub edges: Vec<f64>,
/// Optional per-edge weight (synapse count / strength), length = edges.length/2.
pub edge_weights: Option<Vec<f64>>,
/// Directed (synaptic in→out) vs undirected.
pub directed: Option<bool>,
pub source: Option<GraphPropsSource>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for GraphProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("nodePositions", self.node_positions.to_json());
if let Some(v) = &self.node_sizes {
o.set("nodeSizes", v.to_json());
}
if let Some(v) = &self.node_colors {
o.set("nodeColors", v.to_json());
}
if let Some(v) = &self.node_groups {
o.set("nodeGroups", v.to_json());
}
o.set("edges", self.edges.to_json());
if let Some(v) = &self.edge_weights {
o.set("edgeWeights", v.to_json());
}
if let Some(v) = &self.directed {
o.set("directed", v.to_json());
}
if let Some(v) = &self.source {
o.set("source", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl GraphProps {
/// The `graph` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("graph");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// THE 0D RUNG, as a reference: an ORDERED run of points inside one sketch.
#[derive(Clone, Debug)]
pub struct ConductorPathRef {
pub sketch: String,
/// Sketch point ids, in the order the run passes through them.
pub points: Vec<String>,
/// THE POINTS AFTER WHICH THE DRAWN CURVE ENDS AND THE NEXT BEGINS — a cut in the DOMAIN.
pub break_after: Option<Vec<String>>,
}
impl ToJson for ConductorPathRef {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("sketch", self.sketch.to_json());
o.set("points", self.points.to_json());
if let Some(v) = &self.break_after {
o.set("breakAfter", v.to_json());
}
o
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RoutingRule {
/// `"45"`
V45,
/// `"90"`
V90,
/// `"any"`
Any,
}
impl ToJson for RoutingRule {
fn to_json(&self) -> Json {
Json::from(match self {
RoutingRule::V45 => "45",
RoutingRule::V90 => "90",
RoutingRule::Any => "any",
})
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RouteBias {
/// `"x-first"`
XFirst,
/// `"y-first"`
YFirst,
}
impl ToJson for RouteBias {
fn to_json(&self) -> Json {
Json::from(match self {
RouteBias::XFirst => "x-first",
RouteBias::YFirst => "y-first",
})
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum OffsetJoin {
/// `"round"`
Round,
/// `"miter"`
Miter,
/// `"bevel"`
Bevel,
}
impl ToJson for OffsetJoin {
fn to_json(&self) -> Json {
Json::from(match self {
OffsetJoin::Round => "round",
OffsetJoin::Miter => "miter",
OffsetJoin::Bevel => "bevel",
})
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum OffsetCap {
/// `"square"`
Square,
/// `"round"`
Round,
/// `"butt"`
Butt,
}
impl ToJson for OffsetCap {
fn to_json(&self) -> Json {
Json::from(match self {
OffsetCap::Square => "square",
OffsetCap::Round => "round",
OffsetCap::Butt => "butt",
})
}
}
/// THE ELECTRICAL HALF OF A CONDUCTOR, declared on an ORDINARY 3D body.
#[derive(Clone, Debug)]
pub struct ConductorElectrical {
/// Bulk electrical conductivity, S/m.
pub conductivity_s_per_m: f64,
/// Finished conductor thickness, mm — the distance the body's extrusion travelled.
pub finished_thickness_mm: f64,
/// Relative permittivity of the dielectric SURROUNDING this conductor. Dimensionless.
pub dielectric_eps_r: f64,
}
impl ToJson for ConductorElectrical {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("conductivitySPerM", self.conductivity_s_per_m.to_json());
o.set("finishedThicknessMm", self.finished_thickness_mm.to_json());
o.set("dielectricEpsR", self.dielectric_eps_r.to_json());
o
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MaterialPreset {
/// `"steel"`
Steel,
/// `"custom"`
Custom,
/// `"aluminum"`
Aluminum,
/// `"anodized-aluminum"`
AnodizedAluminum,
/// `"stainless-steel"`
StainlessSteel,
/// `"plastic"`
Plastic,
/// `"abs"`
Abs,
/// `"pbt"`
Pbt,
/// `"pc"`
Pc,
/// `"petg"`
Petg,
/// `"pla"`
Pla,
/// `"brass"`
Brass,
/// `"copper"`
Copper,
/// `"chrome"`
Chrome,
/// `"rubber"`
Rubber,
/// `"glass"`
Glass,
/// `"pcb"`
Pcb,
}
impl ToJson for MaterialPreset {
fn to_json(&self) -> Json {
Json::from(match self {
MaterialPreset::Steel => "steel",
MaterialPreset::Custom => "custom",
MaterialPreset::Aluminum => "aluminum",
MaterialPreset::AnodizedAluminum => "anodized-aluminum",
MaterialPreset::StainlessSteel => "stainless-steel",
MaterialPreset::Plastic => "plastic",
MaterialPreset::Abs => "abs",
MaterialPreset::Pbt => "pbt",
MaterialPreset::Pc => "pc",
MaterialPreset::Petg => "petg",
MaterialPreset::Pla => "pla",
MaterialPreset::Brass => "brass",
MaterialPreset::Copper => "copper",
MaterialPreset::Chrome => "chrome",
MaterialPreset::Rubber => "rubber",
MaterialPreset::Glass => "glass",
MaterialPreset::Pcb => "pcb",
})
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SurfaceTextureKind {
/// `"grain"`
Grain,
/// `"bead-blast"`
BeadBlast,
/// `"brushed"`
Brushed,
/// `"layer-lines"`
LayerLines,
}
impl ToJson for SurfaceTextureKind {
fn to_json(&self) -> Json {
Json::from(match self {
SurfaceTextureKind::Grain => "grain",
SurfaceTextureKind::BeadBlast => "bead-blast",
SurfaceTextureKind::Brushed => "brushed",
SurfaceTextureKind::LayerLines => "layer-lines",
})
}
}
/// A surface's small relief, drawn as a bump and never built as geometry: moulded grain (a VDI 3400 texture), bead blasting, a brushed finish, a printer's layer lines.
#[derive(Clone, Debug)]
pub struct SurfaceTexture {
pub kind: SurfaceTextureKind,
/// The relief's period: a grain's cell, a layer's height, a brush stroke's width.
/// Unit: mm.
pub scale: f64,
/// The relief's height, peak to valley.
/// Unit: mm.
pub depth: f64,
/// The direction of the brush strokes or the build direction of the layers (a unit vector, the body's frame).
/// Default: `[0,0,1]`.
pub direction: Option<[f64; 3]>,
}
impl ToJson for SurfaceTexture {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("kind", self.kind.to_json());
o.set("scale", self.scale.to_json());
o.set("depth", self.depth.to_json());
if let Some(v) = &self.direction {
o.set("direction", v.to_json());
}
o
}
}
/// A surface's photographed maps: a physically based texture set (Poly Haven's CC0 textures, `cloud://home/user-commandagi/assets/polyhaven/textures/<name>/1k/textures/…`), each image by its ref, a path from the document's folder or an address. The images repeat over the body: each face takes them along the axis it is most nearly normal to, in the body's own millimetres, so a box, a wall or a floor needs no unwrap and one copy of the image covers `size` of it. A map multiplies its field: `color` tints the colour map (white when the material states none), and `roughness` and `metalness` scale their maps (1 when it states none). A grey roughness map and Poly Haven's packed `arm` map (occlusion, roughness, metalness in its red, green and blue) are read alike: roughness from green, metalness from blue, occlusion from red.
#[derive(Clone, Debug)]
pub struct SurfaceMaps {
/// The base colour (sRGB): Poly Haven's `diff`.
pub color: Option<String>,
/// The tangent-space normal, OpenGL's convention (green up): Poly Haven's `nor_gl`.
pub normal: Option<String>,
/// The roughness, read from green: Poly Haven's `rough`, or its `arm`.
pub roughness: Option<String>,
/// The metalness, read from blue: Poly Haven's `metal`, or its `arm`.
pub metalness: Option<String>,
/// The ambient occlusion, read from red: Poly Haven's `ao`, or its `arm`.
pub ao: Option<String>,
/// What is there, read from green: white where the surface is, black where it is open (a welded wire mesh's openings, a perforated sheet's holes). The surface is drawn only where the map is over half, on both of its sides.
pub alpha: Option<String>,
/// What one copy of the images covers on the surface, along its two directions.
/// Unit: mm.
/// Default: `[1000,1000]`.
pub size: Option<[f64; 2]>,
}
impl ToJson for SurfaceMaps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.color {
o.set("color", v.to_json());
}
if let Some(v) = &self.normal {
o.set("normal", v.to_json());
}
if let Some(v) = &self.roughness {
o.set("roughness", v.to_json());
}
if let Some(v) = &self.metalness {
o.set("metalness", v.to_json());
}
if let Some(v) = &self.ao {
o.set("ao", v.to_json());
}
if let Some(v) = &self.alpha {
o.set("alpha", v.to_json());
}
if let Some(v) = &self.size {
o.set("size", v.to_json());
}
o
}
}
#[derive(Clone, Debug)]
pub struct MaterialDef {
pub preset: MaterialPreset,
/// Hex color string, e.g. "#9aa6b4": the base colour (a metal's reflectance, a plastic's diffuse colour).
pub color: String,
pub metalness: f64,
/// The microfacet roughness, 0 a mirror.
pub roughness: f64,
/// environment map intensity
pub env_intensity: f64,
/// Surface opacity 0..1 (1 = fully opaque; <1 renders the body translucent). Optional/defaulted.
pub opacity: Option<f64>,
/// The index of refraction of a dielectric (1.5 for most plastics and glass).
/// Default: `1.5`.
pub ior: Option<f64>,
/// The share of light that passes through (glass 1, an opal diffuser between).
/// Default: `0`.
pub transmission: Option<f64>,
/// The thickness a transmissive body's light passes through.
/// Unit: mm.
pub thickness: Option<f64>,
/// A clear lacquer over the base (a solder mask's gloss, a car's clear coat).
/// Default: `0`.
pub clearcoat: Option<f64>,
/// Default: `0`.
pub clearcoat_roughness: Option<f64>,
/// Anisotropy of the highlight along the texture's direction (a brushed metal).
/// Default: `0`.
pub anisotropy: Option<f64>,
/// Hex colour of the light the surface gives off (an LED, a screen).
pub emissive: Option<String>,
/// Default: `0`.
pub emissive_intensity: Option<f64>,
/// The surface's small relief.
pub texture: Option<SurfaceTexture>,
/// The surface's photographed maps: a wood's grain, a carpet's pile, a brick wall.
pub maps: Option<SurfaceMaps>,
}
impl ToJson for MaterialDef {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("preset", self.preset.to_json());
o.set("color", self.color.to_json());
o.set("metalness", self.metalness.to_json());
o.set("roughness", self.roughness.to_json());
o.set("envIntensity", self.env_intensity.to_json());
if let Some(v) = &self.opacity {
o.set("opacity", v.to_json());
}
if let Some(v) = &self.ior {
o.set("ior", v.to_json());
}
if let Some(v) = &self.transmission {
o.set("transmission", v.to_json());
}
if let Some(v) = &self.thickness {
o.set("thickness", v.to_json());
}
if let Some(v) = &self.clearcoat {
o.set("clearcoat", v.to_json());
}
if let Some(v) = &self.clearcoat_roughness {
o.set("clearcoatRoughness", v.to_json());
}
if let Some(v) = &self.anisotropy {
o.set("anisotropy", v.to_json());
}
if let Some(v) = &self.emissive {
o.set("emissive", v.to_json());
}
if let Some(v) = &self.emissive_intensity {
o.set("emissiveIntensity", v.to_json());
}
if let Some(v) = &self.texture {
o.set("texture", v.to_json());
}
if let Some(v) = &self.maps {
o.set("maps", v.to_json());
}
o
}
}
/// A BINDING: this conductor is electrically joined to that pad. L3, and L2.
#[derive(Clone, Debug)]
pub struct TerminalBinding {
/// WHICH POINT OF THE RUN — by the sketch point's own id, never by its position in ConductorPathRef.points.
pub point: String,
/// The pad, by its document-unique import.
pub pad: String,
}
impl ToJson for TerminalBinding {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("point", self.point.to_json());
o.set("pad", self.pad.to_json());
o
}
}
/// A PCB TRACE — the 2D→3D rung. Points → route → centreline → offset → region → extrude.
#[derive(Clone, Debug)]
pub struct PcbTraceProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// Analytic circular arc through exactly three ordered path points; requires rule any.
pub centreline: Option<Json>,
/// The authored points — band ③'s sketch.
pub path: ConductorPathRef,
/// The copper layer this run is on.
pub layer: CopperLayerRef,
/// 45 / 90 / any. A PROPERTY of the op.
pub rule: RoutingRule,
pub bias: Option<RouteBias>,
/// Trace width in mm — the 1D→2D offset, an extrusion WITHIN the plane.
pub width: f64,
pub join: Option<OffsetJoin>,
pub cap: Option<OffsetCap>,
/// The electrical half. σ, finished thickness (which the extrude travels through), surrounding ε_r.
pub conductor: ConductorElectrical,
/// Overrides the copper preset. Absent means copper.
pub material: Option<MaterialDef>,
/// WHICH PADS THIS RUN IS BOUND TO — L3. Written only by `bindTraceEndpoint`, which binds or REFUSES; there is no "visually coincident but unbound" state to represent.
pub bindings: Option<Vec<TerminalBinding>>,
/// How the copper combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for PcbTraceProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
if let Some(v) = &self.centreline {
o.set("centreline", v.to_json());
}
o.set("path", self.path.to_json());
o.set("layer", self.layer.to_json());
o.set("rule", self.rule.to_json());
if let Some(v) = &self.bias {
o.set("bias", v.to_json());
}
o.set("width", self.width.to_json());
if let Some(v) = &self.join {
o.set("join", v.to_json());
}
if let Some(v) = &self.cap {
o.set("cap", v.to_json());
}
o.set("conductor", self.conductor.to_json());
if let Some(v) = &self.material {
o.set("material", v.to_json());
}
if let Some(v) = &self.bindings {
o.set("bindings", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl PcbTraceProps {
/// The `pcbTrace` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("pcbTrace");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// A VIA — sketch points into an op, exactly like a trace, and that sameness is the evidence the decomposition is a real structure rather than a convenient one.
#[derive(Clone, Debug)]
pub struct GenerateViaProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The placement points. One via per point.
pub at: ConductorPathRef,
/// Every copper layer the barrel touches, outermost first. Two for a through via, more for a span.
pub layers: Vec<CopperLayerRef>,
/// Finished hole diameter, mm.
pub drill_mm: f64,
/// Annular pad diameter on each layer it touches, mm.
pub pad_diameter_mm: f64,
pub conductor: ConductorElectrical,
pub material: Option<MaterialDef>,
/// How the copper combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for GenerateViaProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("at", self.at.to_json());
o.set("layers", self.layers.to_json());
o.set("drillMm", self.drill_mm.to_json());
o.set("padDiameterMm", self.pad_diameter_mm.to_json());
o.set("conductor", self.conductor.to_json());
if let Some(v) = &self.material {
o.set("material", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl GenerateViaProps {
/// The `generateVia` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("generateVia");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// A PLATED through-hole — a terminal producer, and a DIFFERENT NODE from the mechanical `hole` it is routinely confused with.
#[derive(Clone, Debug)]
pub struct PlatedHoleProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
pub at: ConductorPathRef,
pub layers: Vec<CopperLayerRef>,
pub drill_mm: f64,
pub pad_diameter_mm: f64,
pub conductor: ConductorElectrical,
pub material: Option<MaterialDef>,
/// How the copper combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for PlatedHoleProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("at", self.at.to_json());
o.set("layers", self.layers.to_json());
o.set("drillMm", self.drill_mm.to_json());
o.set("padDiameterMm", self.pad_diameter_mm.to_json());
o.set("conductor", self.conductor.to_json());
if let Some(v) = &self.material {
o.set("material", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl PlatedHoleProps {
/// The `platedHole` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("platedHole");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// A COPPER POUR — A REGION SWEPT ON A PLANE, and the second special case that disappears.
#[derive(Clone, Debug)]
pub struct CopperPourProps {
/// Its id: letters, digits, `_ . -`; later features and parameter bindings name it.
pub id: String,
/// Its name in the feature list (absent: its id).
pub name: Option<String>,
/// The closed boundary — band ③'s sketch, the run of points the outline passes through.
pub path: ConductorPathRef,
/// The copper layer this pour fills.
pub layer: CopperLayerRef,
/// The angle rule the boundary is routed under — a pour's edge obeys the same rule a trace's does.
pub rule: RoutingRule,
pub bias: Option<RouteBias>,
/// The electrical half. σ, finished thickness (which the extrude travels through), surrounding ε_r.
pub conductor: ConductorElectrical,
/// Overrides the copper preset. Absent means copper.
pub material: Option<MaterialDef>,
/// WHICH PADS THIS POUR IS BOUND TO — L3, and the same door a trace uses.
pub bindings: Option<Vec<TerminalBinding>>,
/// How the copper combines with the bodies before it.
/// Default: `"new"`.
pub operation: Option<BooleanMode>,
pub suppressed: Option<bool>,
/// THE BODY-STATE EDGE — the explicit form of what a timeline used to supply implicitly as "whatever came before".
pub consumes: Option<Vec<String>>,
}
impl ToJson for CopperPourProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.name {
o.set("name", v.to_json());
}
o.set("path", self.path.to_json());
o.set("layer", self.layer.to_json());
o.set("rule", self.rule.to_json());
if let Some(v) = &self.bias {
o.set("bias", v.to_json());
}
o.set("conductor", self.conductor.to_json());
if let Some(v) = &self.material {
o.set("material", v.to_json());
}
if let Some(v) = &self.bindings {
o.set("bindings", v.to_json());
}
if let Some(v) = &self.operation {
o.set("operation", v.to_json());
}
if let Some(v) = &self.suppressed {
o.set("suppressed", v.to_json());
}
if let Some(v) = &self.consumes {
o.set("consumes", v.to_json());
}
o
}
}
impl CopperPourProps {
/// The `copperPour` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("copperPour");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct SketchPointProps {
/// PINNED TO THE MODEL. When present, this point's (u,v) is not an authored value at all — it is DERIVED, every rebuild, by projecting a b-rep entity onto this sketch's plane (see `resolveSketchPins`). `x`/`y` still hold the last resolved coordinates so the sketch is drawable before a rebuild lands, but they are an echo, not the source.
pub pin: Option<SketchPin>,
pub id: String,
pub x: f64,
pub y: f64,
/// Construction point (not part of profile geometry).
pub construction: Option<bool>,
/// Held in place by the solver.
pub fixed: Option<bool>,
/// Set when this point was GENERATED from something outside the sketch (in app-3d-design, a projection of a model edge). How a regenerator finds its own previous output to replace, and how a UI tells "you drew this" from "the model did". Absent on everything the user authored.
pub from: Option<String>,
}
impl ToJson for SketchPointProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
if let Some(v) = &self.pin {
o.set("pin", v.to_json());
}
o.set("id", self.id.to_json());
o.set("x", self.x.to_json());
o.set("y", self.y.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.fixed {
o.set("fixed", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
o
}
}
impl SketchPointProps {
/// The `point` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("point");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// A constraint references entities by id. `entities` holds point/segment ids in the order the kind's `operands` declare (`../geometry/constraints.ts`); `value` holds the dimension for dimensional kinds (distance in the sketch's length unit, angle in radians, radius in the length unit).
#[derive(Clone, Debug)]
pub struct SketchConstraintProps {
pub id: String,
pub kind: ConstraintKind,
pub entities: Vec<String>,
pub value: Option<f64>,
/// A DRIVEN (reference) dimension: measured from the geometry and shown, never solved. Only a dimensional kind can be one. `solveSketch` does not send it to the backend and lists it in the result's `driven`; absent (the default, and every sketch written before 2026-09-11) means driving.
pub reference: Option<bool>,
}
impl ToJson for SketchConstraintProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
o.set("kind", self.kind.to_json());
o.set("entities", self.entities.to_json());
if let Some(v) = &self.value {
o.set("value", v.to_json());
}
if let Some(v) = &self.reference {
o.set("reference", v.to_json());
}
o
}
}
impl SketchConstraintProps {
/// The `constraint` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("constraint");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// A LIVE PROJECTION of one model edge onto this sketch's plane — "use that hole's circle here".
#[derive(Clone, Debug)]
pub struct SketchProjectionProps {
pub id: String,
/// The model edge this follows, signature-matched across rebuilds like every other reference. On a section, the one FACE it cuts (the curves where that face crosses the sketch's plane), or absent: the whole body.
pub ref_: Option<TopoRef>,
/// The feature that built the body — the timeline dependency, exactly as for a pin.
pub feature: Option<String>,
/// AN INTERSECTION, not a projection: the curves where the body `feature` built (or the face of it `ref` names) crosses the sketch's plane, cut again on every rebuild. It needs `feature`.
pub section: Option<bool>,
/// Generate as construction (reference) geometry rather than profile geometry.
pub construction: Option<bool>,
/// Human label captured at creation, for the panel ("Extrude1 edge").
pub label: Option<String>,
}
impl ToJson for SketchProjectionProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
if let Some(v) = &self.ref_ {
o.set("ref", v.to_json());
}
if let Some(v) = &self.feature {
o.set("feature", v.to_json());
}
if let Some(v) = &self.section {
o.set("section", v.to_json());
}
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.label {
o.set("label", v.to_json());
}
o
}
}
impl SketchProjectionProps {
/// The `projection` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("projection");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// AN EQUATION CURVE: x(t) and y(t), arithmetic of `t` in the document's expression grammar (`../expressions.ts`: + - * / ^, sin, cos, sqrt, pi …), drawn as the spline through `points` even steps of t from `from` to `to`. The record is what the file holds; the spline and its points are made from it on every rebuild (their `from` names it), so editing the equation redraws the curve. A curve whose last point meets its first is closed.
#[derive(Clone, Debug)]
pub struct SketchEquationProps {
pub id: String,
/// The horizontal coordinate as arithmetic of `t`, in millimetres.
pub x: String,
/// The vertical coordinate as arithmetic of `t`, in millimetres.
pub y: String,
/// The first value of t.
pub from: f64,
/// The last value of t.
pub to: f64,
/// How many points the curve passes through, its ends included.
pub points: i64,
/// Drawn as construction (reference) geometry.
pub construction: Option<bool>,
}
impl ToJson for SketchEquationProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
o.set("x", self.x.to_json());
o.set("y", self.y.to_json());
o.set("from", self.from.to_json());
o.set("to", self.to.to_json());
o.set("points", self.points.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
o
}
}
impl SketchEquationProps {
/// The `equation` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("equation");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
/// A TEXT: the outlines of `text` in the typeface `font`, placed by two of the sketch's own points: `anchor`, the start of its baseline, and `along`, a letter height further along the baseline. The text's place, angle and size are then those points' (a dimension between them is the size; one on the line between them, the angle). `contours` are the outlines at a letter height of 1, baseline from the origin along +x, kept so the outlines are made again from the two points on every rebuild with no font at hand; the outline lines and points are made from them (their `from` names it). Changing the words or the typeface writes new contours.
#[derive(Clone, Debug)]
pub struct SketchTextProps {
pub id: String,
/// The words.
pub text: String,
/// The typeface: a bundled face's id (`liberation-sans`, `noto-serif`, `noto-sans-mono`), or a font file in the design's folder by its path from there (`.ttf`, `.otf` or `.woff`). The outlines are kept in `contours`: the face is read only to make or change the text.
pub font: String,
/// The point the baseline starts at.
pub anchor: String,
/// The point one letter height along the baseline from `anchor`.
pub along: String,
/// Each closed outline as flat `[x0, y0, x1, y1, …]` at a letter height of 1.
pub contours: Vec<Vec<f64>>,
}
impl ToJson for SketchTextProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
o.set("text", self.text.to_json());
o.set("font", self.font.to_json());
o.set("anchor", self.anchor.to_json());
o.set("along", self.along.to_json());
o.set("contours", self.contours.to_json());
o
}
}
impl SketchTextProps {
/// The `text` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("text");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct LineProps {
pub id: String,
pub a: String,
pub b: String,
pub construction: Option<bool>,
pub from: Option<String>,
/// The segment this one is a piece of, when a split cut it from that segment: a region's reference keeps naming the source.
pub of: Option<String>,
}
impl ToJson for LineProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
o.set("a", self.a.to_json());
o.set("b", self.b.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.of {
o.set("of", v.to_json());
}
o
}
}
impl LineProps {
/// The `line` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("line");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct CircleProps {
pub id: String,
pub center: String,
pub radius: f64,
pub construction: Option<bool>,
pub from: Option<String>,
/// The segment this one is a piece of, when a split cut it from that segment: a region's reference keeps naming the source.
pub of: Option<String>,
}
impl ToJson for CircleProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
o.set("center", self.center.to_json());
o.set("radius", self.radius.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.of {
o.set("of", v.to_json());
}
o
}
}
impl CircleProps {
/// The `circle` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("circle");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct ArcProps {
pub id: String,
pub center: String,
pub start: String,
pub end: String,
/// radius is a solver variable seeded from the points.
pub radius: f64,
pub construction: Option<bool>,
pub from: Option<String>,
/// The segment this one is a piece of, when a split cut it from that segment: a region's reference keeps naming the source.
pub of: Option<String>,
}
impl ToJson for ArcProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
o.set("center", self.center.to_json());
o.set("start", self.start.to_json());
o.set("end", self.end.to_json());
o.set("radius", self.radius.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.of {
o.set("of", v.to_json());
}
o
}
}
impl ArcProps {
/// The `arc` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("arc");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct SplineProps {
pub id: String,
/// The curve's points. WHAT they are depends on `nurbs`: without it they are points the curve passes THROUGH (interpolated with Catmull-Rom, `../geometry/curves/spline.ts`); with it they are the control polygon, and a clamped NURBS touches only the first and the last of them.
pub points: Vec<String>,
pub closed: Option<bool>,
pub construction: Option<bool>,
/// A TRUE NURBS definition. Absent means the historical Catmull-Rom interpolant — which has no degree, no knot vector and no weights, so it can approximate a conic and never be one.
pub nurbs: Option<NurbsSpec>,
pub from: Option<String>,
/// The segment this one is a piece of, when a split cut it from that segment: a region's reference keeps naming the source.
pub of: Option<String>,
}
impl ToJson for SplineProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
o.set("points", self.points.to_json());
if let Some(v) = &self.closed {
o.set("closed", v.to_json());
}
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.nurbs {
o.set("nurbs", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.of {
o.set("of", v.to_json());
}
o
}
}
impl SplineProps {
/// The `spline` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("spline");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct EllipseProps {
pub id: String,
pub center: String,
/// The first FOCUS, as a real sketch point.
pub focus: String,
/// Minor radius — the one scalar degree of freedom, like a circle's radius.
pub minor_radius: f64,
pub construction: Option<bool>,
pub from: Option<String>,
/// The segment this one is a piece of, when a split cut it from that segment: a region's reference keeps naming the source.
pub of: Option<String>,
}
impl ToJson for EllipseProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
o.set("center", self.center.to_json());
o.set("focus", self.focus.to_json());
o.set("minorRadius", self.minor_radius.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.of {
o.set("of", v.to_json());
}
o
}
}
impl EllipseProps {
/// The `ellipse` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("ellipse");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}
#[derive(Clone, Debug)]
pub struct EllipseArcProps {
pub id: String,
pub center: String,
/// See the `ellipse` member.
pub focus: String,
pub minor_radius: f64,
/// Endpoints, CCW from `start` to `end`, exactly as an `arc` names them.
pub start: String,
pub end: String,
pub construction: Option<bool>,
pub from: Option<String>,
/// The segment this one is a piece of, when a split cut it from that segment: a region's reference keeps naming the source.
pub of: Option<String>,
}
impl ToJson for EllipseArcProps {
fn to_json(&self) -> Json {
#[allow(unused_mut)]
let mut o = Json::obj();
o.set("id", self.id.to_json());
o.set("center", self.center.to_json());
o.set("focus", self.focus.to_json());
o.set("minorRadius", self.minor_radius.to_json());
o.set("start", self.start.to_json());
o.set("end", self.end.to_json());
if let Some(v) = &self.construction {
o.set("construction", v.to_json());
}
if let Some(v) = &self.from {
o.set("from", v.to_json());
}
if let Some(v) = &self.of {
o.set("of", v.to_json());
}
o
}
}
impl EllipseArcProps {
/// The `ellipseArc` element of these fields, at the caller's line.
#[track_caller]
pub fn el(self) -> El {
let mut el = El::new("ellipseArc");
if let Json::Obj(entries) = self.to_json() {
for (k, v) in entries {
el = el.with_attr(k, v);
}
}
el
}
}