Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions assets/locales/pending/sheet-bead.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"ar": { "cmd.sheet_bead": "ضلع تقوية" },
"de": { "cmd.sheet_bead": "Sicke" },
"en": { "cmd.sheet_bead": "Bead" },
"he": { "cmd.sheet_bead": "צלע חיזוק" },
"ja": { "cmd.sheet_bead": "ビード" },
"ko": { "cmd.sheet_bead": "비드" },
"vi": { "cmd.sheet_bead": "Gân tăng cứng" },
"zh": { "cmd.sheet_bead": "压筋" }
}
16 changes: 16 additions & 0 deletions crates/develop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,26 @@
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
#![forbid(unsafe_code)]

pub use solidcore_ops::develop::BeadAgainst;
pub use solidcore_ops::develop::BeadRefusal;
pub use solidcore_ops::develop::Bent;
pub use solidcore_ops::develop::Fold;
pub use solidcore_ops::develop::MIN_BEAD_RADIUS;
pub use solidcore_ops::develop::bead_against;
pub use solidcore_ops::develop::bead_flank_angle;
pub use solidcore_ops::develop::bead_footprint;
pub use solidcore_ops::develop::crossings;
pub use solidcore_ops::develop::curve_through;
pub use solidcore_ops::develop::hermite;
pub use solidcore_ops::develop::segment_in_region;
pub use solidcore_ops::query::Query;
pub use solidcore_record::develop::Anchor;
pub use solidcore_record::develop::Bead;
pub use solidcore_record::develop::BeadFace;
pub use solidcore_record::develop::BeadForm;
pub use solidcore_record::develop::BeadOutline;
pub use solidcore_record::develop::BeadPart;
pub use solidcore_record::develop::BeadSection;
pub use solidcore_record::develop::Bend;
pub use solidcore_record::develop::Corner;
pub use solidcore_record::develop::CornerRelief;
Expand All @@ -34,6 +47,9 @@ pub use solidcore_record::develop::Datum;
pub use solidcore_record::develop::Development;
pub use solidcore_record::develop::EdgeFrom;
pub use solidcore_record::develop::FlatPanel;
pub use solidcore_record::develop::FormEdge;
pub use solidcore_record::develop::FormFace;
pub use solidcore_record::develop::FormSurface;
pub use solidcore_record::develop::Joint;
pub use solidcore_record::develop::JointKind;
pub use solidcore_record::develop::Lap;
Expand Down
45 changes: 45 additions & 0 deletions crates/doc/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,46 @@ pub enum FeatureKind {
#[serde(default, skip_serializing_if = "Option::is_none")]
body: Option<BodyName>,
},
/// Formed beads (stiffening ribs): a bead pressed into a planar panel of a sheet along each of
/// `curves` (straight sketch lines on one of its faces), standing out of that face (the other
/// one with `flip`). Across, a trapezoid: `width` and `depth` on the side it stands out of, at
/// the virtual sharps, flanks at `angle` (or the angle that leaves `crown_width`), bends of
/// inner radius `base_radius` and `crown_radius` (default: the rule's bend radius); along, each
/// end ramps up over `end_length` (default: 3 × the depth). `margin` (default: 3 × the
/// thickness) is how near the bead may come to edges, cut-outs, bends and other beads before a
/// warning.
SheetBead {
sketch: SketchId,
curves: Vec<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
shape: Option<String>,
#[walk(length = "Depth")]
depth: Expr,
#[walk(length = "Width")]
width: Expr,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[walk(angle = "Angle")]
angle: Option<Expr>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[walk(length = "Crown width")]
crown_width: Option<Expr>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[walk(length = "Base radius")]
base_radius: Option<Expr>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[walk(length = "Crown radius")]
crown_radius: Option<Expr>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[walk(length = "End length")]
end_length: Option<Expr>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[walk(length = "Margin")]
margin: Option<Expr>,
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
flip: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
body: Option<BodyName>,
},
/// Unfold a sheet body flat (all bends), or refold it.
SheetUnfold {
#[serde(default, skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -3524,6 +3564,7 @@ impl FeatureKind {
| FeatureKind::SheetFold { .. }
| FeatureKind::SheetPath { .. }
| FeatureKind::SheetTab { .. }
| FeatureKind::SheetBead { .. }
| FeatureKind::SheetUnfold { .. }
| FeatureKind::SheetConvert { .. }
| FeatureKind::SheetSurfaceConvert { .. }
Expand Down Expand Up @@ -3602,6 +3643,7 @@ impl FeatureKind {
FeatureKind::SheetFold { .. } => "FoldFeature",
FeatureKind::SheetPath { .. } => "PathFlangeFeature",
FeatureKind::SheetTab { .. } => "TabFeature",
FeatureKind::SheetBead { .. } => "BeadFeature",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
FeatureKind::SheetUnfold { refold: false, .. } => "UnfoldFeature",
FeatureKind::SheetUnfold { .. } => "RefoldFeature",
FeatureKind::SheetConvert { .. } => "ConvertToSheetMetalFeature",
Expand Down Expand Up @@ -3693,6 +3735,7 @@ impl FeatureKind {
FeatureKind::SheetFold { .. } => "sheet_fold",
FeatureKind::SheetPath { .. } => "sheet_path",
FeatureKind::SheetTab { .. } => "sheet_tab",
FeatureKind::SheetBead { .. } => "sheet_bead",
FeatureKind::SheetUnfold { .. } => "sheet_unfold",
FeatureKind::SheetConvert { .. } => "sheet_convert",
FeatureKind::SheetSurfaceConvert { .. } => "sheet_surface_convert",
Expand Down Expand Up @@ -3787,6 +3830,7 @@ impl FeatureKind {
"FoldFeature" => "sheet_fold",
"PathFlangeFeature" => "sheet_path",
"TabFeature" => "sheet_tab",
"BeadFeature" => "sheet_bead",
"UnfoldFeature" | "RefoldFeature" => "sheet_unfold",
"ConvertToSheetMetalFeature" => "sheet_convert",
"ConvertBodyToSheetMetalFeature" => "sheet_surface_convert",
Expand Down Expand Up @@ -3881,6 +3925,7 @@ impl FeatureKind {
FeatureKind::SheetFold { .. } => "Fold",
FeatureKind::SheetPath { .. } => "PathFlange",
FeatureKind::SheetTab { .. } => "Tab",
FeatureKind::SheetBead { .. } => "Bead",
FeatureKind::SheetUnfold { refold: false, .. } => "Unfold",
FeatureKind::SheetUnfold { .. } => "Refold",
FeatureKind::SheetConvert { .. } | FeatureKind::SheetSurfaceConvert { .. } => "ConvertToSheetMetal",
Expand Down
1 change: 1 addition & 0 deletions crates/doc/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14122,6 +14122,7 @@ fn eval_feature_kind(
| FeatureKind::SheetFold { .. }
| FeatureKind::SheetPath { .. }
| FeatureKind::SheetTab { .. }
| FeatureKind::SheetBead { .. }
| FeatureKind::SheetUnfold { .. }
| FeatureKind::SheetConvert { .. }
| FeatureKind::SheetSurfaceConvert { .. }
Expand Down
124 changes: 124 additions & 0 deletions crates/doc/src/eval_more.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,130 @@ pub(super) fn sheet_eval(
Err(_) => Err(first_error.unwrap_or_else(|| DocError::Invalid(sheet::TAB_OFF_SHEET.into()))),
}
}
FeatureKind::SheetBead {
sketch,
curves,
shape,
depth,
width,
angle,
crown_width,
base_radius,
crown_radius,
end_length,
margin,
flip,
body,
} => {
if !matches!(shape.as_deref(), None | Some("trapezoid")) {
return Err(DocError::Invalid(format!(
"not supported yet: a bead of shape {:?} (only \"trapezoid\")",
shape.as_deref().unwrap_or_default()
)));
}
let ss = st.sketch(sketch.0).ok_or_else(|| DocError::Unknown(format!("sketch {sketch}")))?.clone();
if curves.is_empty() || curves.len() > crate::sheet_surface_bead::MAX_BEADS {
return Err(DocError::Invalid(format!("a bead feature needs 1…{} centrelines", crate::sheet_surface_bead::MAX_BEADS)));
}
let mut lines = Vec::with_capacity(curves.len());
for id in curves {
let ci = ss.sketch.curve_index(id).ok_or_else(|| DocError::Unknown(format!("curve `{id}`")))?;
match ss.sketch.segs(ci).as_slice() {
[Seg2::Line { a, b }] => lines.push((id, ss.plane.to_world(*a), ss.plane.to_world(*b))),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
_ => return Err(DocError::Invalid(format!("not supported yet: a bead along `{id}`, which is not a straight line"))),
}
}
// A bead is a form on a planar panel of a sheet: the named sheet's, else the one sheet
// with a planar panel the first centreline lies on. Which is never a matter of the
// sheets' order, so a centreline two sheets would take is refused.
let Some(&(_, a0, b0)) = lines.first() else {
return Err(DocError::Invalid("a bead feature needs a centreline".into()));
};
// A line of the sketch on sheet `s`, read from the sketch's component into the sheet's
// (its body's), as a fold's line is.
let source = doc.feature(sketch.0).map(|x| x.component).unwrap_or(f.component);
let on = |s: &crate::SurfaceSheet, a: Vec3, b: Vec3| {
let comp = st.body(&s.body).map(|m| doc.model_body_component(m)).unwrap_or(source);
let m = relative_transform(doc, source, comp).unwrap_or(crate::IDENTITY);
let (origin, normal) = (crate::apply_point(&m, ss.plane.origin), crate::apply_vector(&m, ss.plane.normal()));
s.bead_line(origin, normal, crate::apply_point(&m, a), crate::apply_point(&m, b))
};
let i = match body {
Some(n) => st
.surface_sheets
.iter()
.position(|s| &s.body == n)
.ok_or_else(|| DocError::Invalid(format!("`{n}` is not a sheet metal body")))?,
None => {
let on: Vec<usize> =
(0..st.surface_sheets.len()).filter(|&i| st.surface_sheets.get(i).is_some_and(|s| on(s, a0, b0).is_ok())).collect();
match on.as_slice() {
[i] => *i,
[] => return Err(DocError::Invalid("a bead's centreline must lie on a planar panel of a sheet".into())),
_ => return Err(DocError::Invalid("a bead's centreline lies on more than one sheet: name the sheet with `body`".into())),
}
}
};
let sk = st.surface_sheets.get(i).ok_or_else(|| DocError::Invalid("sheet".into()))?;
if sk.unfolded {
return Err(DocError::Invalid("refold the sheet before adding beads".into()));
}
let rv = doc.rule_values_at(vals, &doc.sheet_rule(Some(&sk.rule)), Some(sk.thickness))?;
let t = sk.sheet.thickness;
let d = val(vals, depth, Kind::Length)?;
let w = val(vals, width, Kind::Length)?;
let a = match (angle, crown_width) {
(Some(_), Some(_)) => return Err(DocError::Invalid("a bead takes its flanks' angle or its crown width, not both".into())),
(Some(e), None) => val(vals, e, Kind::Angle)?,
(None, Some(e)) => {
let c = val(vals, e, Kind::Length)?;
solidcraft_develop::bead_flank_angle(d, w, c)
.map_err(|_| DocError::Invalid(format!("a bead's crown width ({c}) must be at least 0 and less than its width ({w})")))?
}
(None, None) => std::f64::consts::FRAC_PI_4,
};
let or = |e: &Option<crate::Expr>, default: f64| -> Result<f64> {
match e {
Some(e) => val(vals, e, Kind::Length),
None => Ok(default),
}
};
let (rb, rc) = (or(base_radius, rv.bend_radius)?, or(crown_radius, rv.bend_radius)?);
let (el, m) = (or(end_length, 3.0 * d)?, or(margin, 3.0 * t)?);
if sk.beads.len().saturating_add(lines.len()) > crate::sheet_surface_bead::MAX_BEADS {
return Err(DocError::Invalid(format!("a sheet takes at most {} beads", crate::sheet_surface_bead::MAX_BEADS)));
}
let mut sk = sk.clone();
let mut notes = Vec::new();
for (curve, pa, pb) in lines {
let (panel, qa, qb, far) = on(&sk, pa, pb)?;
let bead = crate::SurfaceBead {
feature: f.id,
curve: curve.clone(),
panel,
a: qa,
b: qb,
// Out of the face it is sketched on; with `flip`, out of the other one.
far: far != *flip,
depth: d,
width: w,
angle: a,
base_radius: rb,
crown_radius: rc,
end_length: el,
};
sk.check_new_bead(&bead, m, &mut notes)?;
sk.beads.push(bead);
}
notes.dedup();
if !notes.is_empty() {
append_warning(warning, notes.join("; "));
}
if let Some(slot) = st.surface_sheets.get_mut(i) {
*slot = sk;
}
rebuild_surface_sheet(st, i)
}
FeatureKind::SheetUnfold { body, refold, fixed } => {
let i = surface_sheet_for(st, body, |s| s.unfolded == *refold).ok_or_else(|| match body {
Some(_) => no_sheet(body),
Expand Down
8 changes: 8 additions & 0 deletions crates/doc/src/feature_walk_tests/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ pub(super) fn fixtures() -> Vec<(&'static str, Value)> {
),
("sheet_path", json!({"type": "sheet_path", "edge": o, "sketch": 1, "curves": ["l1"], "radius": "path.radius"})),
("sheet_tab", json!({"type": "sheet_tab", "sketch": 1, "profiles": {"type": "all"}})),
(
"sheet_bead",
json!({
"type": "sheet_bead", "sketch": 1, "curves": ["l1"], "depth": "bead.depth", "width": "bead.width", "angle": "bead.angle",
"crown_width": "bead.crown", "base_radius": "bead.rb", "crown_radius": "bead.rc", "end_length": "bead.end", "margin": "bead.margin"
}),
),
("sheet_unfold", json!({"type": "sheet_unfold"})),
("sheet_convert", json!({"type": "sheet_convert", "body": "B", "face": o, "engrave": [o]})),
("sheet_surface_convert", json!({"type": "sheet_surface_convert", "body": "B", "skip": [o], "engrave": [o]})),
Expand Down Expand Up @@ -290,6 +297,7 @@ pub(super) fn with_refs(name: &str, mut v: Value) -> Value {
| "sheet_unfold" | "boss" | "lip" | "snap_fit" | "rest" | "surface_offset" => {
json!({"body": "B"})
}
"sheet_bead" => json!({"body": "B"}),
"combine" => json!({"target": "B", "tools": ["B"]}),
"pattern_rectangular" | "pattern_circular" | "pattern_path" | "mirror" => json!({"bodies": ["B"]}),
"hole_simple" | "hole_drilled" | "hole_counterbore" | "hole_countersink" => json!({"points": {"sketch": 3, "ids": ["p"]}}),
Expand Down
11 changes: 11 additions & 0 deletions crates/doc/src/feature_walk_tests/golden_exprs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,17 @@ sheet_path
Bend radius = path.radius (Length)
expressions: path.radius
sheet_tab
sheet_bead
inputs:
Depth = bead.depth (Length)
Width = bead.width (Length)
Angle = bead.angle (Angle)
Crown width = bead.crown (Length)
Base radius = bead.rb (Length)
Crown radius = bead.rc (Length)
End length = bead.end (Length)
Margin = bead.margin (Length)
expressions: bead.depth, bead.width, bead.angle, bead.crown, bead.rb, bead.rc, bead.end, bead.margin
sheet_unfold
sheet_convert
sheet_surface_convert
Expand Down
1 change: 1 addition & 0 deletions crates/doc/src/feature_walk_tests/golden_geometry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ sheet_path
moves: edge[0], edge[1], edge[2]
sheet_tab
profiles: 1 all
sheet_bead
sheet_unfold
sheet_convert
moves: bends[0][0], bends[0][1], bends[0][2], engrave[0][0], engrave[0][1], engrave[0][2], face[0], face[1], face[2]
Expand Down
4 changes: 4 additions & 0 deletions crates/doc/src/feature_walk_tests/golden_refs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ sheet_tab
sketches: [1]
remap_refs: sketch
remap_bodies: body
sheet_bead
sketches: [1]
remap_refs: sketch
remap_bodies: body
sheet_unfold
remap_bodies: body
sheet_convert
Expand Down
5 changes: 5 additions & 0 deletions crates/doc/src/format/pending/sheet-bead.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! Formed beads: a `sheet_bead` feature (Bead: `sketch`, `curves`, `depth`, `width`, optional
//! `shape`, `angle` or `crown_width`, `base_radius`, `crown_radius`, `end_length`, `margin`, `flip`
//! and `body`), and a sheet's beads in its panels' charts (`beads`). Older designs need no
//! transformation: they have no beads. The last release refuses a design saved with them (the newer
//! format number) instead of meeting a feature it can't read.
3 changes: 3 additions & 0 deletions crates/doc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pub mod render_texture_resources;
pub mod sheet;
pub mod sheet_library;
mod sheet_surface;
mod sheet_surface_bead;
mod sheet_surface_convert;
mod sheet_surface_cuts;
mod sheet_surface_features;
Expand All @@ -125,6 +126,8 @@ mod sheet_surface_perforation;
mod sheet_surface_shadow;
mod sheet_surface_tab;
pub mod sketch_equation;
pub use sheet_surface_bead::MAX_BEADS;
pub use sheet_surface_bead::SurfaceBead;
pub use sheet_surface_convert::ConvertRule;
pub use sheet_surface_convert::RollEdge;
pub use sheet_surface_convert::RollInfo;
Expand Down
8 changes: 6 additions & 2 deletions crates/doc/src/lineage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,9 @@ pub(crate) fn sheet_lineage(before: Option<SheetBefore<'_>>, sheet: &crate::Surf
/// and its side is the face of the body its panel away from the corner was, the one the corner's
/// two bends do not share. Each corner's walls are so named apart from every other corner's, and
/// numbered among themselves (see `FaceNamer::part`). Where a side is not known, the walls are
/// `relief` alone. A hole's wall is `side:<curve>` of the cut that made it. None for a panel
/// nothing says what made.
/// `relief` alone. A hole's wall is `side:<curve>` of the cut that made it, and a bead's face
/// `<face>:<curve>` of the bead feature, after its centreline (`crown.top:<curve>`, see
/// `sheet_surface_bead::face_role`). None for a panel nothing says what made.
fn sheet_role(
part: &crate::sheet_surface_convert::SheetPart,
place: Option<usize>,
Expand Down Expand Up @@ -1003,6 +1004,9 @@ fn sheet_role(
SheetPart::Drill { feature, role } => {
Some(GrownFace { role: role.clone(), feature: Some(*feature), on: Vec::new(), across: Vec::new(), ordinal: place })
}
SheetPart::Bead { feature, curve, face } => {
Some(GrownFace { role: format!("{face}:{curve}"), feature: Some(*feature), on: Vec::new(), across: Vec::new(), ordinal: place })
}
}
}

Expand Down
Loading
Loading