Layer split stage 1: the B-rep record, native body file and Vec/Plane come from solidcore-record (#11496)

* Kernel: the B-rep record and the native body file come from solidcore-record

SolidCraft's portable B-rep record (`solidcraft_geom::brep`: brep.rs, topology, history,
envelope, part, curve2) and the native body file (`solidcraft_kernel::native`: the tagged binary
codec and the container) move to solidcore's `solidcore-record` crate: geometry as data, with
structural validation and no maths (solidcore's docs/layers.md, stage 1). Every caller uses
`solidcore_record::brep` and `solidcore_record::native`; the old copies are deleted.

What computes from coordinates stays with the kernel, in geom's `brep`:
- `brep::check`: the record's geometric checks (orthonormal frames, non-degenerate planes,
  unit revolution axes, non-singular placements). `check::validate` and
  `check::validate_built` are the record's validation and these together, and every caller of
  `Brep::validate` uses them, so what is accepted is unchanged;
- `brep::label`: a surface's natural ranges (a cone's apex), `curve_interval`,
  `edge_curve_interval` and `form_turns`;
- `brep::pcurve::eval`: a pcurve's point;
- `geometry::check`, `placement::moved` and `split_edges` become functions on the record.

The kernel's native module keeps the conversion between a body and its saved record
(metadata.rs) and checks the decoded record's geometry. `native/analytic.rs`, which no module
declared, is deleted.

solidcore-record is pinned to its rev on solidcore's `layer-record` branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NvoxKMbMFSQU8tzRtoJhtT

* Geometry: Vec2, Vec3, Plane and the profile types come from solidcore-record

The plain data of vectors and points, sketch planes and planar profiles (`Seg2`, `Loop2`,
`Region2`) moves to `solidcore-record`, with its constants and component-wise operators only
(owner decision, solidcore layer split). Their geometry stays in geom as traits:
`Vec2Geom`, `Vec3Geom`, `PlaneGeom`, `Seg2Geom`, `Loop2Geom`, `Region2Geom`, `Seg2ArcFit`,
`Loop2ArcFit` and `Region2ArcFit`, in scope with `use solidcraft_geom::prelude::*`. Every caller
names the types from `solidcore_record`; geom no longer defines or re-exports them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NvoxKMbMFSQU8tzRtoJhtT

* Kernel: pin solidcore-record to solidcore main f5e8e9a29

solidcore-record is merged on solidcore main (tangency-labs/solidcore#2519); its crate there is
identical to the rev pinned before but for its clippy configuration. The lock is regenerated
against the merged rev.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NvoxKMbMFSQU8tzRtoJhtT

---------

Co-authored-by: jyviko <2501648+jyviko@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jyviko
2026-11-03 09:04:26 -05:00
committed by GitHub
parent bd2dc3fade
commit dc38349cbf
806 changed files with 4281 additions and 6434 deletions
+1 -1
View File
@@ -2166,7 +2166,7 @@ mod tests {
assert!(s.camera.is_none());
let r = run(&mut s, "view.apply", json!({"view": "Photo"}));
let c = s.camera.expect("a camera for the view");
assert_eq!((c.target, c.yaw, c.pitch, c.distance), (solidcraft_geom::Vec3::new(1.0, 2.0, 3.0), 0.5, -0.6, 150.0));
assert_eq!((c.target, c.yaw, c.pitch, c.distance), (solidcore_record::Vec3::new(1.0, 2.0, 3.0), 0.5, -0.6, 150.0));
assert_eq!(r["camera"]["yaw"], 0.5);
// A standard view looks from its direction and frames the model.
run(&mut s, "view.apply", json!({"view": "top"}));
+2 -1
View File
@@ -10,8 +10,9 @@
//! size), and the decoder itself runs under the same limit.
use serde_json::{Value, json};
use solidcore_record::Vec2;
use solidcraft_doc::canvas::{Canvas, base64_decode, image_info};
use solidcraft_geom::Vec2;
use solidcraft_geom::prelude::*;
use solidcraft_io::Geom2;
use super::CommandSpec;
+7 -6
View File
@@ -11,6 +11,7 @@ use std::sync::Arc;
use serde_json::{Value, json};
use solidcraft_geom::mesh_distance::box_gap;
use solidcraft_geom::prelude::*;
use solidcraft_geom::{Aabb3, Mesh};
use solidcraft_kernel::{BodyDistance, DistanceShape};
@@ -58,7 +59,7 @@ pub(crate) struct PairCache(HashMap<(u64, u64, [u64; 3]), PairResult>);
#[derive(Clone, Default)]
struct PairResult {
/// Shared volume, area, box and centre.
overlap: Option<(f64, f64, Aabb3, solidcraft_geom::Vec3)>,
overlap: Option<(f64, f64, Aabb3, solidcore_record::Vec3)>,
distance: Option<BodyDistance>,
unchecked: Option<String>,
}
@@ -190,7 +191,7 @@ fn clearance(s: &mut Session, p: &Value) -> Result<Value> {
p.into_iter().for_each(|v| bx.add(v));
}
let chord = b.display_tol();
let g = solidcraft_geom::Vec3::new(1.0, 1.0, 1.0) * if chord.is_finite() && chord > 0.0 { chord } else { 0.0 };
let g = solidcore_record::Vec3::new(1.0, 1.0, 1.0) * if chord.is_finite() && chord > 0.0 { chord } else { 0.0 };
if bx.is_empty() { bx } else { Aabb3 { min: bx.min - g, max: bx.max + g } }
}
_ => Aabb3::EMPTY,
@@ -198,7 +199,7 @@ fn clearance(s: &mut Session, p: &Value) -> Result<Value> {
.collect();
// Pairs whose boxes, grown by half the clearance each, meet.
let half = solidcraft_geom::Vec3::new(1.0, 1.0, 1.0) * (gap / 2.0);
let half = solidcore_record::Vec3::new(1.0, 1.0, 1.0) * (gap / 2.0);
let grown: Vec<Aabb3> = boxes.iter().map(|b| if b.is_empty() { *b } else { Aabb3 { min: b.min - half, max: b.max + half } }).collect();
let (close, truncated) = super::joints::overlapping_pairs(&grown, MAX_PAIRS);
let has_mesh = |i: usize| meshes.get(i).is_some_and(Option::is_some);
@@ -406,14 +407,14 @@ fn shared_region(a: &DistanceShape, b: &DistanceShape) -> Aabb3 {
return Aabb3::EMPTY;
}
let grow = 1.0 + 0.05 * min.dist(max);
let g = solidcraft_geom::Vec3::new(grow, grow, grow);
let g = solidcore_record::Vec3::new(grow, grow, grow);
Aabb3 { min: min - g, max: max + g }
}
/// [`solidcraft_kernel::measure`] of `body` moved by `-at` and back: far from the origin, the
/// centre of a thin part loses its precision (its moments are large numbers that nearly cancel).
fn measure_near_origin(body: &solidcraft_kernel::Body, at: solidcraft_geom::Vec3) -> solidcraft_kernel::Result<solidcraft_kernel::BodyMeasure> {
let moved = solidcraft_kernel::transform(body, -at, solidcraft_geom::Vec3::ZERO, solidcraft_geom::Vec3::Z, 0.0)?;
fn measure_near_origin(body: &solidcraft_kernel::Body, at: solidcore_record::Vec3) -> solidcraft_kernel::Result<solidcraft_kernel::BodyMeasure> {
let moved = solidcraft_kernel::transform(body, -at, solidcore_record::Vec3::ZERO, solidcore_record::Vec3::Z, 0.0)?;
let mut m = solidcraft_kernel::measure(&moved)?;
m.centroid += at;
m.bbox = Aabb3 { min: m.bbox.min + at, max: m.bbox.max + at };
+3 -2
View File
@@ -41,7 +41,7 @@ fn copy(s: &mut Session, p: &Value) -> Result<Value> {
pub(in crate::cmd) fn explicit_planes(p: &mut PlaneRef) {
match p {
PlaneRef::Origin { name } => {
if let Some(plane) = solidcraft_geom::Plane::named(name) {
if let Some(plane) = solidcore_record::Plane::named(name) {
*p = PlaneRef::Custom { plane };
}
}
@@ -243,6 +243,7 @@ fn paste(s: &mut Session, p: &Value) -> Result<Value> {
#[cfg(test)]
mod tests {
use serde_json::{Value, json};
use solidcraft_geom::prelude::*;
use crate::Session;
@@ -309,7 +310,7 @@ mod tests {
#[test]
fn foreign_sketch_paste_preserves_world_position_in_a_placed_component() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let mut source = dimensioned_sketch();
let arc = [Vec3::new(1., 0., 0.), Vec3::new(0., 0., 1.), Vec3::new(-1., 0., 0.)];
+1 -1
View File
@@ -32,7 +32,7 @@ fn independent_links(sketch: &solidcraft_sketch::Sketch, features: &BTreeSet<u64
L::Text { .. } | L::SketchAxis { .. } => true,
L::SketchCurve { sketch, .. } | L::SketchPoint { sketch, .. } => features.contains(sketch),
L::Origin | L::Axis { .. } => !moved,
L::Plane { name } => !moved && solidcraft_geom::Plane::named(name).is_some(),
L::Plane { name } => !moved && solidcore_record::Plane::named(name).is_some(),
_ => false,
};
if !supported {
+3 -1
View File
@@ -6,8 +6,10 @@
//! the two cuts a − b and b − a that lie there, as `inspect.measure` measures a body.
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_geom::Aabb3;
use solidcraft_geom::compare::{self, CompareOptions, Side};
use solidcraft_geom::{Aabb3, Vec3};
use solidcraft_geom::prelude::*;
use super::CommandSpec;
use crate::params::bad;
+2 -1
View File
@@ -3,11 +3,12 @@
//! belong to their feature's component unless moved; occurrences place components (instances
//! share contents, "paste new" copies them) and can be grounded and moved.
use solidcraft_geom::prelude::*;
use std::collections::HashMap;
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::{Feature, FeatureKind, Mat, Occurrence};
use solidcraft_geom::Vec3;
use super::CommandSpec;
use crate::params::{bad, bool_, str_, string_list, vec3};
+2 -1
View File
@@ -3,8 +3,9 @@
//! without modifying shared component geometry across other instances.
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::{IDENTITY, mat_inverse, mat_mul, rigid};
use solidcraft_geom::Vec3;
use solidcraft_geom::prelude::*;
use super::{occurrence, occurrence_path, valid_position};
use crate::params::{bad, vec3};
+5 -4
View File
@@ -1,5 +1,6 @@
//! Independent copies of a component definition graph, assembled and evaluated atomically.
use solidcraft_doc::BodyName;
use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
use crate::params::bad;
@@ -10,7 +11,7 @@ use solidcraft_doc::{Document, Feature, FeatureKind, Mat, Occurrence};
const CMD: &str = "component.paste_new";
const MAX_WORK: usize = 10_000;
fn mesh_distance(mesh: &solidcraft_geom::Mesh, point: solidcraft_geom::Vec3) -> f64 {
fn mesh_distance(mesh: &solidcraft_geom::Mesh, point: solidcore_record::Vec3) -> f64 {
mesh.triangles
.iter()
.filter_map(|triangle| mesh.tri(triangle))
@@ -33,7 +34,7 @@ fn mesh_distance(mesh: &solidcraft_geom::Mesh, point: solidcraft_geom::Vec3) ->
.fold(f64::INFINITY, f64::min)
}
fn material_probe_matches(a: &solidcraft_geom::Mesh, b: &solidcraft_geom::Mesh, point: solidcraft_geom::Vec3, tol_a: f64, tol_b: f64) -> bool {
fn material_probe_matches(a: &solidcraft_geom::Mesh, b: &solidcraft_geom::Mesh, point: solidcore_record::Vec3, tol_a: f64, tol_b: f64) -> bool {
if !point.is_finite() || !tol_a.is_finite() || !tol_b.is_finite() || tol_a <= 0. || tol_b <= 0. {
return false;
}
@@ -48,7 +49,7 @@ fn material_probe_matches(a: &solidcraft_geom::Mesh, b: &solidcraft_geom::Mesh,
let offset = 4. * tol_a.max(tol_b);
let mut material = false;
let mut void = false;
for axis in [solidcraft_geom::Vec3::X, solidcraft_geom::Vec3::Y, solidcraft_geom::Vec3::Z] {
for axis in [solidcore_record::Vec3::X, solidcore_record::Vec3::Y, solidcore_record::Vec3::Z] {
for sign in [-1., 1.] {
let q = point + axis * (sign * offset);
if !q.is_finite() {
@@ -767,7 +768,7 @@ pub(super) fn build(
for y in [0.2, 0.5, 0.8] {
for z in [0.2, 0.5, 0.8] {
let d = ma.bbox.max - ma.bbox.min;
let p = ma.bbox.min + solidcraft_geom::Vec3::new(d.x * x, d.y * y, d.z * z);
let p = ma.bbox.min + solidcore_record::Vec3::new(d.x * x, d.y * y, d.z * z);
let roundoff = 64. * f64::EPSILON * (1. + p.len());
material_matches &= material_probe_matches(&mesh_a, &mesh_b, p, tol_a + roundoff, tol_b + roundoff);
}
@@ -1,9 +1,9 @@
#![allow(clippy::unwrap_used, clippy::panic)]
use super::*;
use solidcore_record::Vec3;
use solidcraft_doc::joints::{Coupling, Joint, JointKind, MotionLink, NamedOrigin, Size, Snap, XRef};
use solidcraft_doc::motion::{ContactSet, ExplodedView, MotionStudy, StudyKey};
use solidcraft_doc::{IDENTITY, Occurrence};
use solidcraft_geom::Vec3;
fn at(occurrence: u64) -> JointOrigin {
JointOrigin { occurrence, snap: Snap::Point { point: Vec3::ZERO, z: None, x: None } }
@@ -1,6 +1,7 @@
#![allow(clippy::unwrap_used)]
use crate::Session;
use serde_json::{Value, json};
use solidcraft_geom::prelude::*;
fn run(s: &mut Session, cmd: &str, p: Value) -> Value {
s.execute(cmd, &p).unwrap()
}
@@ -256,7 +257,7 @@ fn configuration_rows_follow_copied_parameters_material_and_strict_face_lineage(
body: "Cube".into(),
origin_feature: source,
name: format!("F{source}:+z"),
point: solidcraft_geom::Vec3::new(1.0, 1.0, 2.0),
point: solidcore_record::Vec3::new(1.0, 1.0, 2.0),
certificate: None,
};
run(&mut s, "config.configure", json!({"params":[length],"materials":["Cube"],"component_appearances":[part],"face_appearances":[target]}));
@@ -294,7 +295,7 @@ fn configured_extrude_cap_copy_keeps_independent_semantic_lineage() {
body: body_name,
origin_feature: feature,
name: format!("F{feature}:top"),
point: solidcraft_geom::Vec3::new(1.0, 1.0, 2.0),
point: solidcore_record::Vec3::new(1.0, 1.0, 2.0),
certificate: None,
};
run(&mut s, "config.configure", json!({"face_appearances":[target]}));
@@ -358,7 +359,7 @@ fn reassigned_sample_plate_paste_new_preserves_complex_frozen_geometry() {
run(&mut s, "occurrence.ground", json!({"occurrence":occurrence,"grounded":true}));
let original_volume = volume(&mut s, part);
let source_mesh = s.model.state().body(&body).unwrap().mesh();
let boss_probe = solidcraft_geom::Vec3::new(40.0, 35.0, 12.0);
let boss_probe = solidcore_record::Vec3::new(40.0, 35.0, 12.0);
let source_boss = source_mesh.contains(boss_probe);
let copied = run(&mut s, "component.paste_new", json!({"component":part,"translate":[10,10,0]}));
assert_eq!(s.doc.components.len(), 2);
@@ -373,7 +374,7 @@ fn reassigned_sample_plate_paste_new_preserves_complex_frozen_geometry() {
for (point, expected) in
[([5.0, 25.0, 4.0], true), ([12.0, 25.0, 4.0], false), ([68.0, 25.0, 4.0], false), ([40.0, 25.0, 12.0], false), ([0.0, 0.0, 4.0], false)]
{
assert_eq!(mesh.contains(solidcraft_geom::Vec3::new(point[0], point[1], point[2])), expected, "{point:?}");
assert_eq!(mesh.contains(solidcore_record::Vec3::new(point[0], point[1], point[2])), expected, "{point:?}");
}
assert_eq!(mesh.contains(boss_probe), source_boss);
assert_eq!(state.body(&body).unwrap().mesh().contains(boss_probe), source_boss);
@@ -473,7 +474,7 @@ fn transferred_frozen_face_paint_ignores_consumed_legacy_offset() {
run(&mut s, "appearance.assign", json!({"body":"Foreign","faces":[[1,1,2]],"color":"#00ff00"}));
s.doc_mut().body_offsets.insert(
"Foreign".into(),
solidcraft_doc::rigid(solidcraft_geom::Vec3::new(7.0, 0.0, 0.0), solidcraft_geom::Vec3::ZERO, solidcraft_geom::Vec3::Z, 0.0),
solidcraft_doc::rigid(solidcore_record::Vec3::new(7.0, 0.0, 0.0), solidcore_record::Vec3::ZERO, solidcore_record::Vec3::Z, 0.0),
);
s.refresh();
let part = component(&mut s, "Part");
@@ -487,7 +488,7 @@ fn transferred_frozen_face_paint_ignores_consumed_legacy_offset() {
#[test]
fn boundary_material_proof_requires_resolvable_stock_and_void() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let a = solidcraft_kernel::box_solid(Vec3::ZERO, Vec3::new(10., 10., 10.)).unwrap().mesh(&solidcraft_kernel::MeshTolerance::chord(1e-3)).unwrap();
let b = solidcraft_kernel::box_solid(Vec3::new(1e-5, 0., 0.), Vec3::new(10.00001, 10., 10.))
.unwrap()
@@ -516,7 +517,7 @@ fn boundary_material_proof_requires_resolvable_stock_and_void() {
#[test]
fn frozen_bore_boundary_copy_preserves_stock_void_and_reopen() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let bore = |center: f64| {
let mut s = Session::default();
run(&mut s, "solid.box", json!({"length":30,"width":20,"height":10,"body_name":"Drilled"}));
@@ -552,7 +553,7 @@ fn frozen_bore_boundary_copy_preserves_stock_void_and_reopen() {
#[test]
fn frozen_r6_bore_copy_uses_current_geometry_despite_mesh_measure_bias() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let mut s = Session::default();
run(&mut s, "solid.box", json!({"length":20,"width":20,"height":10,"body_name":"Drilled"}));
run(&mut s, "solid.cylinder", json!({"base":[10,10,0],"radius":6,"height":10,"operation":"cut"}));
+2 -1
View File
@@ -10,12 +10,13 @@
//! as it did before. Anything that crosses the component's boundary (a feature outside that uses
//! its sketches, bodies moved in or out, a joint to one of its subcomponents) is refused.
use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
use std::path::Path;
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::{DesignLink, Document, FeatureKind, ModelBody, ModelState};
use solidcraft_geom::Vec3;
use super::{absolute, component_key, file_sha256, inherit_properties, resolve, session_bodies, stored};
use crate::params::{bad, str_};
@@ -1,6 +1,7 @@
#![allow(clippy::unwrap_used)]
use crate::{ForeignCopy, Session};
use serde_json::{Value, json};
use solidcraft_geom::prelude::*;
use std::sync::Arc;
fn run(s: &mut Session, cmd: &str, p: Value) -> Value {
+2 -1
View File
@@ -8,6 +8,7 @@
//! the design gives them (`Feature::link_faces`), so a joint on a linked face stays on that face
//! when the design changes, as it would inside the design, and reports it when the face is gone.
use solidcraft_geom::prelude::*;
use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf};
use std::sync::Mutex;
@@ -496,7 +497,7 @@ fn insert_design(s: &mut Session, p: &Value) -> Result<Value> {
let cmd = "component.insert_design";
let given = str_(p, "path").filter(|x| !x.trim().is_empty() && x.len() < 4096).ok_or_else(|| bad(cmd, "`path` is required"))?;
let translate = match p.get("translate") {
None => solidcraft_geom::Vec3::ZERO,
None => solidcore_record::Vec3::ZERO,
Some(v) => vec3(v).filter(|t| t.is_finite() && t.len() < 1e9).ok_or_else(|| bad(cmd, "`translate` must be [x, y, z] in mm"))?,
};
// A network or device path is judged from its text, as given, before anything reads it.
@@ -1,10 +1,12 @@
//! Physical properties of an assembly placement, with original body material assignments.
use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::{Document, Mat};
use solidcraft_geom::Aabb3;
use solidcraft_geom::inertia::{self, Tensor3};
use solidcraft_geom::{Aabb3, Vec3};
use crate::params::bad;
use crate::{Result, Session};
@@ -1,5 +1,6 @@
use crate::Session;
use serde_json::{Value, json};
use solidcraft_geom::prelude::*;
fn run(s: &mut Session, cmd: &str, params: Value) -> Value {
s.execute(cmd, &params).unwrap()
@@ -456,7 +457,7 @@ fn repeated_placements_reuse_one_measurement_of_their_body() {
/// the meshes it is taken from) also when the placement turns it off the axes.
#[test]
fn a_placed_body_measures_as_its_placed_copy() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let mut s = Session::default();
run(&mut s, "solid.cylinder", json!({"diameter": 4, "height": 30}));
run(&mut s, "solid.box", json!({"length": 10, "width": 20, "height": 5}));
@@ -278,8 +278,8 @@ fn linked_design_properties_update_density_without_geometry_and_keep_edited_card
#[test]
fn linked_design_properties_keep_opaque_pbr_and_face_color_after_reload() {
use solidcore_record::Vec3;
use solidcraft_doc::appearance::{FaceLook, Look};
use solidcraft_geom::Vec3;
let dir = folder("properties-optics");
let file = dir.join("source.solidcraft");
let mut part = properties_part(&file, "Steel", None, [12, 34, 56]);
@@ -321,8 +321,8 @@ fn linked_design_properties_keep_opaque_pbr_and_face_color_after_reload() {
#[test]
fn linked_face_overrides_update_independently_and_preserve_local_edits_and_removals() {
use solidcore_record::Vec3;
use solidcraft_doc::appearance::{FaceLook, Look};
use solidcraft_geom::Vec3;
let dir = folder("properties-faces");
let file = dir.join("source.solidcraft");
let mut part = properties_part(&file, "Steel", None, [12, 34, 56]);
@@ -416,7 +416,7 @@ fn linked_face_removal_without_a_body_look_does_not_reveal_baked_source_paint()
part.doc_mut().appearances.bodies.clear();
part.doc_mut().appearances.faces.push(FaceLook {
body: "Cube".into(),
point: solidcraft_geom::Vec3::new(5.0, 5.0, 10.0),
point: solidcore_record::Vec3::new(5.0, 5.0, 10.0),
look: Look::custom([190, 20, 30], 0.65),
name: None,
strict_name: false,
@@ -444,7 +444,7 @@ fn unchanged_linked_face_overrides_do_not_reorder_assignments_or_report_updates(
let mut part = properties_part(&file, "Steel", None, [12, 34, 56]);
part.doc_mut().appearances.faces.push(FaceLook {
body: "Cube".into(),
point: solidcraft_geom::Vec3::new(5.0, 5.0, 10.0),
point: solidcore_record::Vec3::new(5.0, 5.0, 10.0),
look: Look::custom([190, 20, 30], 0.65),
name: None,
strict_name: false,
@@ -644,7 +644,7 @@ fn relink_keeps_joint_definitions_and_reports_solver_diagnostics() {
// requiring relink to guess which face of a different design was intended.
let joint = s.doc_mut().assembly.joints.first_mut().unwrap();
joint.b.snap =
solidcraft_doc::joints::Snap::FaceCenter { pick: solidcraft_geom::Vec3::ZERO, face: Some("no-such-linked-face".to_string()), x: None };
solidcraft_doc::joints::Snap::FaceCenter { pick: solidcore_record::Vec3::ZERO, face: Some("no-such-linked-face".to_string()), x: None };
s.refresh();
let result = run(&mut s, "component.relink", json!({"component": component, "path": replacement}));
assert!(result["joint_errors"].as_array().unwrap().iter().any(|e| e["name"] == "Seat"));
@@ -2,8 +2,9 @@
//! keeps its place on the face, and `component.move_sketches.to_parts` (#10218) moves sketches
//! to the part whose face they are drawn on.
use serde_json::{Value, json};
use solidcore_record::Plane;
use solidcraft_doc::{EmbossFace, FeatureKind, PlaneRef, apply_point, apply_vector, mat_inverse, mat_mul};
use solidcraft_geom::Plane;
use solidcraft_geom::prelude::*;
use crate::params::{bad, name_or_id_list};
use crate::schema::component::{MoveSketchesToPartsResult, SketchKeptInPlace, SketchMovedToPart};
@@ -1,10 +1,11 @@
use crate::Session;
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::{
FeatureKind,
config::{Column, FaceCertificate},
};
use solidcraft_geom::Vec3;
use solidcraft_geom::prelude::*;
fn run(session: &mut Session, command: &str, params: Value) -> Value {
session.execute(command, &params).unwrap_or_else(|error| panic!("{command} {params}: {error}"))
+5 -4
View File
@@ -1,6 +1,7 @@
use crate::Session;
use serde_json::{Value, json};
use solidcraft_doc::config::{Column, ConfigFaceTarget};
use solidcraft_geom::prelude::*;
fn run(s: &mut Session, command: &str, params: Value) -> Value {
s.execute(command, &params).unwrap_or_else(|error| panic!("{command} {params}: {error}"))
}
@@ -130,7 +131,7 @@ fn strict_face_missing_lineage_never_retargets_and_rolls_back() {
let look = solidcraft_doc::appearance::library("ABS - Red").unwrap();
s.doc_mut().appearances.faces.push(solidcraft_doc::appearance::FaceLook {
body: body.clone(),
point: solidcraft_geom::Vec3::new(5., 5., 10.),
point: solidcore_record::Vec3::new(5., 5., 10.),
name: Some(format!("F{other}:+z")),
strict_name: true,
certificate: None,
@@ -150,11 +151,11 @@ fn face_occurrence_pick_uses_definition_identity_and_coordinates() {
let world = s.world_state().unwrap();
let placed = world.bodies.iter().find(|body| body.name != body.definition_name()).unwrap();
let placed_name = placed.name.clone();
let point = solidcraft_doc::apply_point(&placed.source_transform, solidcraft_geom::Vec3::new(5., 5., 10.));
let point = solidcraft_doc::apply_point(&placed.source_transform, solidcore_record::Vec3::new(5., 5., 10.));
let key = face_column(&mut s, &placed_name, json!(point));
let Column::FaceAppearance(target) = &s.doc.configs.columns[0] else { panic!() };
assert_eq!(target.body, body);
assert!(target.point.dist(solidcraft_geom::Vec3::new(5., 5., 10.)) < 1e-8);
assert!(target.point.dist(solidcore_record::Vec3::new(5., 5., 10.)) < 1e-8);
run(&mut s, "config.row", json!({"name":"Paint","values":{key:"ABS - Blue"}}));
run(&mut s, "config.activate", json!({"row":"Paint"}));
assert!(s.world_state().unwrap().bodies.iter().all(|body| s.doc.face_colors(body).len() == 1));
@@ -216,7 +217,7 @@ fn hostile_and_uncertified_face_targets_are_rejected() {
body: body.clone(),
origin_feature: id,
name: format!("F{id}:face:0"),
point: solidcraft_geom::Vec3::ZERO,
point: solidcore_record::Vec3::ZERO,
certificate: None,
};
assert!(s.doc.certify_config_face(&target).is_err());
+1 -1
View File
@@ -7,9 +7,9 @@
//! persistent names.
use serde_json::Value;
use solidcore_record::Vec3;
use solidcraft_doc::construct::{AxisDef, GeoRef, PointDef};
use solidcraft_doc::{FeatureKind, PlaneRef};
use solidcraft_geom::Vec3;
use super::CommandSpec;
use super::features::{add_feature, check_expr, plane_param, sketch_id};
+3 -1
View File
@@ -3,13 +3,15 @@
//! into each other at a sample ([`ContactGeometry::overlaps`]) and closes in on where they first
//! touch through placements known to be clear ([`ContactGeometry::gap`]); gaps and interference
//! depths are measured on the bodies' contact meshes.
use solidcraft_geom::prelude::*;
use std::cell::Cell;
use std::collections::{BTreeMap, BTreeSet, HashMap};
use std::sync::Arc;
use solidcore_record::Vec3;
use solidcraft_doc::joints;
use solidcraft_doc::{Document, IDENTITY, Mat, apply_point, mat_mul};
use solidcraft_geom::{Aabb3, Bvh, Mesh, Vec3};
use solidcraft_geom::{Aabb3, Bvh, Mesh};
use crate::params::bad;
use crate::{Result, Session};
+1 -1
View File
@@ -1,6 +1,6 @@
use crate::Session;
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
fn run(s: &mut Session, command: &str, p: Value) -> Value {
s.execute(command, &p).unwrap()
+2 -2
View File
@@ -5,8 +5,8 @@
//! changing anything, so the UI can ask first.
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::FeatureKind;
use solidcraft_geom::Vec3;
use super::{CommandSpec, sketch_store};
use crate::params::{bad, bool_};
@@ -597,7 +597,7 @@ mod tests {
run(&mut s, "sketch.circle.center", json!({"center": [10, 10], "radius": 3, "id": "hole"}));
let index = {
let st = s.model.state();
solidcraft_sketch::profile_at_point(&st.sketch(sk).unwrap().profiles, solidcraft_geom::Vec2::new(30.0, 10.0)).unwrap()
solidcraft_sketch::profile_at_point(&st.sketch(sk).unwrap().profiles, solidcore_record::Vec2::new(30.0, 10.0)).unwrap()
};
let before = curves(&s, sk);
assert_eq!(before.len(), 5, "four lines and a circle: {before:?}");
+2 -1
View File
@@ -1,5 +1,6 @@
//! Undo/redo, the timeline, deletion and selection.
use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
use serde_json::{Value, json};
@@ -1276,7 +1277,7 @@ fn edit_feature(s: &mut Session, p: &Value) -> Result<Value> {
/// an existing index-and-point pair. Unlike Measure, selection keeps the exact face/edge index:
/// it must not merge a cylinder's patches or a circular rim's arcs into a different item.
fn selection_item(s: &Session, value: Value) -> Result<Sel> {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let kind = value.get("type").and_then(Value::as_str);
if !matches!(kind, Some("face" | "edge")) || (value.get("index").is_some() && value.get("point").is_some()) {
+4 -4
View File
@@ -10,7 +10,7 @@ fn run(s: &mut Session, id: &str, params: Value) -> Value {
#[test]
fn select_geometry_resolves_points_and_indices_without_changing_history() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let mut s = Session::default();
run(&mut s, "solid.box", json!({"body_name":"Block", "corner":[20,30,40], "length":10, "width":10, "height":10}));
@@ -47,7 +47,7 @@ fn select_geometry_curved_picks_round_trip_and_add_without_duplicates() {
let index = serde_json::to_value(&s.selection[0]).unwrap()["index"].clone();
run(&mut s, "select.set", json!({"items":[{"type":kind,"body":"Round","index":index}]}));
let complete = serde_json::to_value(&s.selection[0]).unwrap();
let pick: solidcraft_geom::Vec3 = serde_json::from_value(complete["point"].clone()).unwrap();
let pick: solidcore_record::Vec3 = serde_json::from_value(complete["point"].clone()).unwrap();
assert!((pick.x.hypot(pick.y) - 5.0).abs() < 1e-6, "the inferred point lies on the cylinder: {complete}");
let mut partial = complete.clone();
partial.as_object_mut().unwrap().remove("index");
@@ -73,7 +73,7 @@ fn select_geometry_uses_the_placed_body_in_world_coordinates() {
assert_eq!(complete["body"], name);
run(&mut s, "select.set", json!({"items":[{"type":kind,"body":name,"index":complete["index"]}]}));
let inferred = serde_json::to_value(&s.selection[0]).unwrap();
let pick: solidcraft_geom::Vec3 = serde_json::from_value(inferred["point"].clone()).unwrap();
let pick: solidcore_record::Vec3 = serde_json::from_value(inferred["point"].clone()).unwrap();
assert!((pick.z - 4.0).abs() < 1e-9 && (7.0..=10.0).contains(&pick.x) && (20.0..=22.0).contains(&pick.y), "{inferred}");
assert!(s.execute("select.set", &json!({"items":[{"type":kind,"body":name,"point":[1,1,4]}]})).is_err());
assert_eq!(serde_json::to_value(&s.selection[0]).unwrap(), inferred);
@@ -1515,7 +1515,7 @@ fn select_same_look_uses_resolved_looks_without_document_history_edits_and_refus
let history = (s.undo.len(), s.redo.len(), s.evaluations);
run(&mut s, "select.same_look", json!({"body":"A"}));
assert_eq!(s.selection.len(), 3);
let point = solidcraft_geom::Vec3::new(40.0, 5.0, 5.0);
let point = solidcore_record::Vec3::new(40.0, 5.0, 5.0);
let face = solidcraft_doc::appearance::face_index_at(s.world_state().unwrap().body("C").unwrap(), point).unwrap();
run(&mut s, "select.set", json!({"items":[Sel::Face {body:"C".into(),index:face,point}]}));
run(&mut s, "select.same_look", json!({}));
+4 -2
View File
@@ -3,8 +3,10 @@
//! edges become lines, circular edges circles or arcs, anything else a chain of lines.
use serde_json::{Value, json};
use solidcore_record::{Vec2, Vec3};
use solidcraft_doc::{EmbossFace, apply_point, mat_inverse, mat_mul};
use solidcraft_geom::{Mesh, Vec2, Vec3};
use solidcraft_geom::Mesh;
use solidcraft_geom::prelude::*;
use crate::params::{bad, vec3};
use crate::{Result, Session};
@@ -254,7 +256,7 @@ pub(super) fn sketch_of_faces(s: &mut Session, points: &[Vec3], cmd: &str, face_
}
let state = s.model.state();
let mut picked = Vec::new();
let mut common: Option<(String, solidcraft_geom::Plane)> = None;
let mut common: Option<(String, solidcore_record::Plane)> = None;
for &point in points {
if !point.is_finite() {
return Err(bad(cmd, "faces must be finite points"));
+2 -1
View File
@@ -3,8 +3,9 @@
use crate::Session;
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::{Document, FeatureKind};
use solidcraft_geom::Vec3;
use solidcraft_geom::prelude::*;
fn run(s: &mut Session, command: &str, params: Value) -> Value {
s.execute(command, &params).unwrap_or_else(|error| panic!("{command}: {error}"))
+2 -1
View File
@@ -1,8 +1,9 @@
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
use crate::Session;
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::{Document, FeatureKind, PlaneRef};
use solidcraft_geom::Vec3;
use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
fn run(s: &mut Session, command: &str, params: Value) -> Value {
+9 -8
View File
@@ -1,13 +1,14 @@
//! Solid feature commands: extrude, revolve, fillet, chamfer, primitives, combine, move.
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::{
AxisRef, Direction, Expr, Extent, FeatureKind, Operation, PointExpr, ProfileSel, RailFit, SweepOrientation, SweepRail, ThinSide, ThinWall,
Touching, expr::Kind, point_expr,
};
use solidcraft_doc::{BodyName, FeatureName, SketchId};
use solidcraft_doc::{Dir, FacePick, Position};
use solidcraft_geom::Vec3;
use solidcraft_geom::prelude::*;
use super::{CommandSpec, not_in_sketch};
use crate::params::{UNKNOWN_COMMAND, bad, bool_, expr, expr_problem, req_expr, str_, string_list, string_list_or_default, vec2, vec3};
@@ -1181,7 +1182,7 @@ fn thin_param(s: &Session, p: &Value, sketch: u64, cmd: &str) -> Result<ThinWall
}
/// The regions of a thin wall in its (solved) sketch, with the current parameter values.
fn thin_regions(s: &Session, ss: &solidcraft_doc::SolvedSketch, thin: &ThinWall) -> std::result::Result<Vec<solidcraft_geom::Region2>, String> {
fn thin_regions(s: &Session, ss: &solidcraft_doc::SolvedSketch, thin: &ThinWall) -> std::result::Result<Vec<solidcore_record::Region2>, String> {
let length = |e: &str| s.doc.eval(&s.doc.with_design_unit(e, Kind::Length), Kind::Length).map_err(|e| e.to_string());
let t = length(&thin.thickness)?;
let (inside, outside) = match thin.side {
@@ -1190,7 +1191,7 @@ fn thin_regions(s: &Session, ss: &solidcraft_doc::SolvedSketch, thin: &ThinWall)
ThinSide::Outside => (0.0, t),
ThinSide::TwoSides => (t, length(thin.thickness2.as_deref().unwrap_or("0"))?),
};
let curves: Vec<Vec<solidcraft_geom::Seg2>> = thin
let curves: Vec<Vec<solidcore_record::Seg2>> = thin
.curves
.iter()
.filter_map(|id| ss.sketch.curve_index(id))
@@ -2379,7 +2380,7 @@ pub(super) fn check_plane_name(name: &str, cmd: &str) -> Result<()> {
/// What [`check_plane_name`] says about `name`, or `None` when a construction plane may take it.
pub(crate) fn plane_name_problem(name: &str) -> Option<String> {
solidcraft_geom::Plane::named(name.trim()).map(|_| {
solidcore_record::Plane::named(name.trim()).map(|_| {
format!("`{}` is reserved for an origin plane (XY, XZ, YZ, Top, Front, Right); give the construction plane another name", name.trim())
})
}
@@ -2390,10 +2391,10 @@ pub(crate) const PLANE_FORMS: &str =
/// The plane an explicit plane object gives through `origin`, as [`plane_param`] reads it: from
/// `x_dir` and `y_dir` when both are points, else from `normal`; `None` when they don't make one.
pub(crate) fn explicit_plane(o: &Value, origin: Vec3) -> Option<solidcraft_geom::Plane> {
pub(crate) fn explicit_plane(o: &Value, origin: Vec3) -> Option<solidcore_record::Plane> {
match (o.get("x_dir").and_then(vec3), o.get("y_dir").and_then(vec3), o.get("normal").and_then(vec3)) {
(Some(x), Some(y), _) => solidcraft_geom::Plane::new(origin, x, y),
(_, _, Some(n)) => solidcraft_geom::Plane::from_normal(origin, n),
(Some(x), Some(y), _) => solidcore_record::Plane::new(origin, x, y),
(_, _, Some(n)) => solidcore_record::Plane::from_normal(origin, n),
_ => None,
}
}
@@ -2411,7 +2412,7 @@ pub(super) fn plane_param(s: &Session, v: Option<&Value>, cmd: &str) -> Result<s
None => Err(bad(cmd, format!("no plane `{r}` (a plane is {WANT})"))),
};
match v {
Some(Value::String(n)) if solidcraft_geom::Plane::named(n.trim()).is_some() => {
Some(Value::String(n)) if solidcore_record::Plane::named(n.trim()).is_some() => {
if let Some(f) = s.doc.find_feature(n.trim())
&& matches!(f.kind, FeatureKind::ConstructionPlane { .. })
{
+4 -3
View File
@@ -1,11 +1,12 @@
//! Rib, Web, Emboss, Replace Face, Align and Remove.
use serde_json::Value;
use solidcore_record::Vec3;
use solidcraft_doc::FeatureKind;
use solidcraft_doc::expr::Kind;
use solidcraft_doc::{BodyName, SketchId};
use solidcraft_doc::{Dir, FacePick, Position};
use solidcraft_geom::Vec3;
use solidcraft_geom::prelude::*;
use super::CommandSpec;
use super::features::{
@@ -349,7 +350,7 @@ fn infer_emboss_selection(
let body_frame = face.body_frame(&placed, raw).map_err(|e| bad(cmd, e.to_string()))?;
let inverse = solidcraft_doc::mat_inverse(&body_frame).ok_or_else(|| bad(cmd, "invalid cylinder body frame"))?;
let displayed = world.sketch(sketch).ok_or_else(|| bad(cmd, "the profile sketch is not displayed"))?;
let plane = solidcraft_geom::Plane::new(
let plane = solidcore_record::Plane::new(
solidcraft_doc::apply_point(&inverse, displayed.plane.origin),
solidcraft_doc::apply_vector(&inverse, displayed.plane.x),
solidcraft_doc::apply_vector(&inverse, displayed.plane.y),
@@ -389,7 +390,7 @@ fn replace_face(s: &mut Session, p: &Value) -> Result<Value> {
let target = match p.get("target_face").and_then(vec3) {
Some(tp) => {
let n = super::face::face_normal(s, tp).ok_or_else(|| bad(cmd, "the target face must be planar"))?;
let plane = solidcraft_geom::Plane::from_normal(tp, n).ok_or_else(|| bad(cmd, "the target face's plane"))?;
let plane = solidcore_record::Plane::from_normal(tp, n).ok_or_else(|| bad(cmd, "the target face's plane"))?;
solidcraft_doc::PlaneRef::Custom { plane }
}
None => plane_param(s, p.get("target"), cmd)?,
+19 -18
View File
@@ -1,4 +1,5 @@
use serde_json::{Value, json};
use solidcraft_geom::prelude::*;
use crate::Session;
@@ -193,7 +194,7 @@ fn turned_part(base: bool) -> (Session, solidcraft_doc::Mat) {
}
/// A sketch on the face at world point `at`, with `draw` given the point's place in the sketch.
fn sketch_on_face(s: &mut Session, at: solidcraft_geom::Vec3, draw: impl FnOnce(&mut Session, solidcraft_geom::Vec2, solidcraft_geom::Plane)) {
fn sketch_on_face(s: &mut Session, at: solidcore_record::Vec3, draw: impl FnOnce(&mut Session, solidcore_record::Vec2, solidcore_record::Plane)) {
run(s, "sketch.create", json!({"plane": {"face": [at.x, at.y, at.z]}, "project_edges": false}));
let plane = s
.doc
@@ -223,7 +224,7 @@ fn a_sketch_on_a_turned_sub_components_face_cuts_and_joins_it_from_the_top_level
let hole = std::f64::consts::PI * 4.0 * 3.0;
for base in [false, true] {
let (mut s, placed) = turned_part(base);
let top = solidcraft_doc::apply_point(&placed, solidcraft_geom::Vec3::new(5.0, 5.0, 10.0));
let top = solidcraft_doc::apply_point(&placed, solidcore_record::Vec3::new(5.0, 5.0, 10.0));
sketch_on_face(&mut s, top, |s, c, _| {
run(s, "sketch.circle.center", json!({"center": [c.x, c.y], "radius": 2}));
});
@@ -239,7 +240,7 @@ fn a_sketch_on_a_turned_sub_components_face_cuts_and_joins_it_from_the_top_level
assert!((body_volume(&t, "Stock") - want).abs() < 1e-3 * hole, "{case}: {}", body_volume(&t, "Stock"));
// In the part's own frame: through the middle of its top, not beside it.
let stock = t.model.state().body("Stock").unwrap().mesh();
let at = |x: f64, y: f64, z: f64| stock.contains(solidcraft_geom::Vec3::new(x, y, z));
let at = |x: f64, y: f64, z: f64| stock.contains(solidcore_record::Vec3::new(x, y, z));
if expected == "cut" {
assert!(!at(5.0, 5.0, 8.0) && at(5.0, 5.0, 6.0) && at(1.0, 1.0, 9.0), "{case}");
} else {
@@ -261,7 +262,7 @@ fn a_revolve_from_a_turned_sub_components_face_joins_and_cuts_it_from_the_top_le
let half = std::f64::consts::PI * 3.0;
for (operation, want) in [("join", 1000.0 + half), ("cut", 1000.0 - half)] {
let (mut s, placed) = turned_part(true);
let top = solidcraft_doc::apply_point(&placed, solidcraft_geom::Vec3::new(5.0, 5.0, 10.0));
let top = solidcraft_doc::apply_point(&placed, solidcore_record::Vec3::new(5.0, 5.0, 10.0));
let mut axis = json!(null);
sketch_on_face(&mut s, top, |s, c, plane| {
run(s, "sketch.rectangle.two_point", json!({"p0": [c.x - 3.0, c.y], "p1": [c.x + 3.0, c.y + 1.0]}));
@@ -281,8 +282,8 @@ fn a_revolve_from_a_turned_sub_components_face_joins_and_cuts_it_from_the_top_le
#[test]
fn a_loft_from_a_turned_sub_components_face_joins_it_from_the_top_level() {
let (mut s, placed) = turned_part(true);
let top = solidcraft_doc::apply_point(&placed, solidcraft_geom::Vec3::new(5.0, 5.0, 10.0));
let mut centre = solidcraft_geom::Vec2::new(0.0, 0.0);
let top = solidcraft_doc::apply_point(&placed, solidcore_record::Vec3::new(5.0, 5.0, 10.0));
let mut centre = solidcore_record::Vec2::new(0.0, 0.0);
sketch_on_face(&mut s, top, |s, c, _| {
run(s, "sketch.circle.center", json!({"center": [c.x, c.y], "radius": 2}));
centre = c;
@@ -307,7 +308,7 @@ fn a_loft_from_a_turned_sub_components_face_joins_it_from_the_top_level() {
fn a_cut_from_the_top_level_shows_in_every_placement_and_a_later_placement_is_refused() {
let (mut s, placed) = turned_part(true);
let second = run(&mut s, "occurrence.copy", json!({"component": "Part", "translate": [0, 40, 0]}))["occurrence"].as_u64().unwrap();
let top = solidcraft_doc::apply_point(&placed, solidcraft_geom::Vec3::new(5.0, 5.0, 10.0));
let top = solidcraft_doc::apply_point(&placed, solidcore_record::Vec3::new(5.0, 5.0, 10.0));
let mut first = s.scratch();
sketch_on_face(&mut first, top, |s, c, _| {
run(s, "sketch.circle.center", json!({"center": [c.x, c.y], "radius": 2}));
@@ -321,7 +322,7 @@ fn a_cut_from_the_top_level_shows_in_every_placement_and_a_later_placement_is_re
assert!(placements.iter().all(|v| (v - want).abs() < 1e-2), "{placements:?}");
let (_, moved) = s.doc.path_placement(&[second]).unwrap();
let top = solidcraft_doc::apply_point(&moved, solidcraft_geom::Vec3::new(5.0, 5.0, 10.0));
let top = solidcraft_doc::apply_point(&moved, solidcore_record::Vec3::new(5.0, 5.0, 10.0));
sketch_on_face(&mut s, top, |s, c, _| {
run(s, "sketch.circle.center", json!({"center": [c.x, c.y], "radius": 2}));
});
@@ -339,7 +340,7 @@ fn a_cut_from_the_top_level_shows_in_every_placement_and_a_later_placement_is_re
#[test]
fn a_sketch_on_a_top_level_body_beside_a_turned_part_cuts_only_that_body() {
let (mut s, _) = turned_part(true);
sketch_on_face(&mut s, solidcraft_geom::Vec3::new(-30.0, -30.0, 5.0), |s, c, _| {
sketch_on_face(&mut s, solidcore_record::Vec3::new(-30.0, -30.0, 5.0), |s, c, _| {
run(s, "sketch.circle.center", json!({"center": [c.x, c.y], "radius": 2}));
});
assert_eq!(crate::auto_operation(&s, &json!({"distance": -2})).unwrap(), Some("cut"));
@@ -534,7 +535,7 @@ fn exact_cylinder_volume(s: &Session) -> f64 {
#[test]
fn cylinder_emboss_persists_selection_and_replays_radial_depth() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let mut s = cylinder_badge();
let before = exact_cylinder_volume(&s);
run(
@@ -632,7 +633,7 @@ fn cylinder_cross_component_emboss_keeps_source_owner_and_placements() {
.bodies
.iter()
.find(|b| {
b.body.mesh(&solidcraft_kernel::MeshTolerance::chord(0.001)).unwrap().contains(solidcraft_geom::Vec3::new(
b.body.mesh(&solidcraft_kernel::MeshTolerance::chord(0.001)).unwrap().contains(solidcore_record::Vec3::new(
40.5 + pick_offset,
0.,
7.5,
@@ -666,7 +667,7 @@ fn cylinder_cross_component_emboss_keeps_source_owner_and_placements() {
.body
.mesh(&solidcraft_kernel::MeshTolerance::chord(0.001))
.unwrap()
.contains(solidcraft_geom::Vec3::new(x, 0., 7.5)))
.contains(solidcore_record::Vec3::new(x, 0., 7.5)))
);
}
let mut loaded = Session { doc: solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap().into(), ..Default::default() };
@@ -823,7 +824,7 @@ fn check_body_offset(auto: bool) {
.body
.mesh(&solidcraft_kernel::MeshTolerance::chord(0.001))
.unwrap()
.contains(solidcraft_geom::Vec3::new(0., 10.5, 7.5))
.contains(solidcore_record::Vec3::new(0., 10.5, 7.5))
);
}
@@ -1036,7 +1037,7 @@ fn loft_cut_through_a_shelled_basin_in_either_order() {
#[test]
fn cylinder_auto_inference_saves_a_profile_anchor_and_replays_both_depth_signs() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
for mode in ["emboss", "deboss"] {
let mut s = cylinder_badge();
let before = exact_cylinder_volume(&s);
@@ -1108,7 +1109,7 @@ fn cylinder_auto_inference_ignores_remote_finite_tangent_walls_in_each_body_orde
#[test]
fn cylinder_auto_inference_retains_selected_holes_and_nested_islands() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
for mode in ["emboss", "deboss"] {
let mut s = cylinder_badge();
run(&mut s, "sketch.edit", json!({"sketch":"Badge"}));
@@ -1396,7 +1397,7 @@ fn cutting_a_text_removes_each_letter_whether_its_letters_stand_apart_or_touch()
/// corners rounded and reflex ones trimmed where the offsets cross, a region's area is
/// A + P e + C e² while the offset meets nothing, C being half each loop's turning (π for an
/// outer loop, −π for a hole) less tan(t/2) − t/2 at each reflex corner of turn t.
fn steiner(regions: &[&solidcraft_geom::Region2]) -> (f64, f64, f64) {
fn steiner(regions: &[&solidcore_record::Region2]) -> (f64, f64, f64) {
let (mut a, mut p, mut c) = (0.0, 0.0, 0.0);
for r in regions {
a += r.area();
@@ -1419,7 +1420,7 @@ fn steiner(regions: &[&solidcraft_geom::Region2]) -> (f64, f64, f64) {
}
/// The text's letters (its profiles less their counters, a counter being a profile too).
fn letters(s: &Session) -> Vec<solidcraft_geom::Region2> {
fn letters(s: &Session) -> Vec<solidcore_record::Region2> {
let state = s.world_state().unwrap();
let ss = state.sketch(s.active_sketch.unwrap()).unwrap();
let sorted = |ids: &[String]| {
@@ -1492,7 +1493,7 @@ fn a_tapered_text_joins_a_block_on_its_face_or_hanging_over_its_edge() {
for i in 0..8 {
let q = seg.point_at(f64::from(i) / 8.0);
assert!(
mesh.contains(solidcraft_geom::Vec3::new(q.x, q.y, h / 2.0)),
mesh.contains(solidcore_record::Vec3::new(q.x, q.y, h / 2.0)),
"{what}: ({}, {}) outside the letter half-way up",
q.x,
q.y
+2 -2
View File
@@ -181,7 +181,7 @@ fn exporter_up(import: &solidcraft_kernel::StepImport) -> Option<(&'static str,
/// A quarter turn about X through the origin: a file's Y up becomes Z up.
fn quarter_turn_x() -> solidcraft_doc::Mat {
solidcraft_doc::rigid(solidcraft_geom::Vec3::ZERO, solidcraft_geom::Vec3::ZERO, solidcraft_geom::Vec3::X, std::f64::consts::FRAC_PI_2)
solidcraft_doc::rigid(solidcore_record::Vec3::ZERO, solidcore_record::Vec3::ZERO, solidcore_record::Vec3::X, std::f64::consts::FRAC_PI_2)
}
/// Add an Import feature for a STEP file to the session's design, in a new component named
@@ -1290,7 +1290,7 @@ mod tests {
assert_eq!(s.doc.features.len(), 1);
let id = s.active_sketch.unwrap();
let sketch = s.doc.sketch(id).unwrap();
assert_eq!(s.model.state().sketch(id).unwrap().plane, solidcraft_geom::Plane::XY);
assert_eq!(s.model.state().sketch(id).unwrap().plane, solidcore_record::Plane::XY);
assert_eq!(sketch.curves.len(), 3);
assert_eq!(s.doc.name, "outline");
assert!(s.path.is_none(), "Save must ask for a design path");
+1 -1
View File
@@ -10,10 +10,10 @@ use std::collections::HashMap;
use std::hash::{Hash, Hasher};
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::joints::{Joint, JointKind, JointOrigin, Snap};
use solidcraft_doc::kernel::{StepImport, StepNode};
use solidcraft_doc::{FeatureKind, IDENTITY, Mat};
use solidcraft_geom::Vec3;
use crate::{EngineError, Result, Session};
+2 -1
View File
@@ -3,13 +3,14 @@
//! the built-in profiles, `frame.profile.properties` works out a profile's section, and
//! `frame.profile.insert` draws one into a sketch.
use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
use serde_json::{Value, json};
use solidcore_record::{Loop2, Seg2, Vec2};
use solidcraft_doc::expr::Kind;
use solidcraft_doc::frame::{self, Anchor, MemberProfile, Profile, ProfileSpec};
use solidcraft_doc::{FeatureKind, SketchId};
use solidcraft_geom::{Loop2, Seg2, Vec2};
use solidcraft_sketch::Sketch;
use super::features::{add_feature, check_expr, sketch_id};
+6 -5
View File
@@ -1,5 +1,6 @@
//! Inspection: measure bodies, describe the document, sketches and model topology.
use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
use std::hash::{BuildHasher, RandomState};
use std::sync::atomic::{AtomicU64, Ordering};
@@ -464,7 +465,7 @@ fn model_faces(s: &mut Session, p: &Value) -> Result<Value> {
let spot = spots.get(f.index).copied().flatten();
let cylinder = match spot.and_then(|x| x.surface) {
Some(solidcraft_kernel::FaceSurface::Cylinder { origin, axis, radius }) => {
Some(FaceCylinder { origin: origin.into(), axis: solidcraft_geom::Vec3::from(axis).into(), radius })
Some(FaceCylinder { origin: origin.into(), axis: solidcore_record::Vec3::from(axis).into(), radius })
}
_ => None,
};
@@ -554,7 +555,7 @@ pub(super) fn appearance(s: &mut Session, p: &Value) -> Result<Value> {
return Err(bad(cmd, "`bodies` must list existing bodies"));
}
// Faces: a point on each, on the named body or the nearest one.
let mut faces: Vec<(String, solidcraft_geom::Vec3)> = Vec::new();
let mut faces: Vec<(String, solidcore_record::Vec3)> = Vec::new();
if let Some(list) = p.get("faces") {
let list = list.as_array().filter(|a| a.len() <= 10_000).ok_or_else(|| bad(cmd, "`faces` must list points [x, y, z]"))?;
for v in list {
@@ -578,7 +579,7 @@ pub(super) fn appearance(s: &mut Session, p: &Value) -> Result<Value> {
return Err(bad(cmd, "give `bodies`, `faces` or `components`"));
}
// Persistent names of the picked faces.
let st_names: Vec<(String, solidcraft_geom::Vec3, Option<String>)> = faces
let st_names: Vec<(String, solidcore_record::Vec3, Option<String>)> = faces
.iter()
.map(|(b, pt)| {
let n = st.body(b).and_then(|mb| {
@@ -715,9 +716,9 @@ pub(super) fn appearance_look(cmd: &str, p: &Value) -> Result<Option<solidcraft_
Ok(look)
}
fn dist_to(b: &solidcraft_doc::ModelBody, p: solidcraft_geom::Vec3) -> f64 {
fn dist_to(b: &solidcraft_doc::ModelBody, p: solidcore_record::Vec3) -> f64 {
let bb = b.mesh().bounds();
let c = solidcraft_geom::Vec3::new(p.x.clamp(bb.min.x, bb.max.x), p.y.clamp(bb.min.y, bb.max.y), p.z.clamp(bb.min.z, bb.max.z));
let c = solidcore_record::Vec3::new(p.x.clamp(bb.min.x, bb.max.x), p.y.clamp(bb.min.y, bb.max.y), p.z.clamp(bb.min.z, bb.max.z));
c.dist(p)
}
+2 -1
View File
@@ -14,8 +14,9 @@ use std::collections::HashSet;
use std::sync::Arc;
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_geom::mesh_distance::TriangleSet;
use solidcraft_geom::{Aabb3, Mesh, Vec3};
use solidcraft_geom::{Aabb3, Mesh};
use solidcraft_kernel::Body;
use solidcraft_kernel::profile::KernelTimes;
+1
View File
@@ -3,6 +3,7 @@
//! result OK makes, and with the warning a Join apart gets (#4434).
use serde_json::Value;
use solidcraft_geom::prelude::*;
use crate::Session;
+2 -1
View File
@@ -1,7 +1,8 @@
//! Joint origins on an edge of a face (its middle, or a corner) follow the face as it changes size.
use serde_json::json;
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use super::tests::{place, run};
use crate::Session;
+2 -1
View File
@@ -1,7 +1,8 @@
//! A joint origin on a face or a hole keeps its turn about z as the geometry tilts.
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use super::tests::{occ, run};
use crate::Session;
+3 -1
View File
@@ -3,13 +3,15 @@
//! joint graph and moves the occurrences it places; the session re-solves after any edit too,
//! so joints follow the geometry their origins snap to.
use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::expr::{self, Kind};
use solidcraft_doc::joints::cam::{self, Cam, CamProfile, Follower};
use solidcraft_doc::joints::{self, Coupling, Joint, JointExprs, JointKind, JointOrigin, MotionLink, NamedOrigin, Size, Snap, XRef};
use solidcraft_geom::{Aabb3, Vec3};
use solidcraft_geom::Aabb3;
use super::CommandSpec;
use crate::params::{bad, bool_, num, str_, vec3};
@@ -2,7 +2,8 @@
//! the design changes, instead of holding the frame where it was made.
use serde_json::json;
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use super::tests::{occ, place, run};
use crate::Session;
+2 -1
View File
@@ -1,7 +1,8 @@
//! Joints whose offset, angle or values are typed as expressions follow the parameters they name.
use serde_json::json;
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use super::tests::{occ, place, run};
use crate::Session;
+2 -1
View File
@@ -2,8 +2,9 @@
//! side and turned the same way, as the design's parameters change.
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::joints::{Snap, XRef};
use solidcraft_geom::Vec3;
use solidcraft_geom::prelude::*;
use super::tests::{occ, place, run};
use crate::Session;
@@ -2,7 +2,8 @@
//! and x meet as they are, whichever way their parts are turned.
use serde_json::json;
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use super::tests::{occ, place, run};
use crate::Session;
+2 -1
View File
@@ -2,7 +2,8 @@
//! out of reach, limits, and a four-bar reached through its rocker.
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use super::tests::{four_bar, meet, occ, part, pin, place, run};
use crate::Session;
@@ -3,7 +3,8 @@
//! parts are, and they keep holding as the parts change size.
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use super::tests::{occ, place, run};
use crate::Session;
+2 -1
View File
@@ -1,7 +1,8 @@
use solidcraft_geom::prelude::*;
use std::f64::consts::FRAC_PI_2;
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use crate::Session;
+2 -1
View File
@@ -2,7 +2,8 @@
//! already meet stay as they are instead of the part spinning a half turn about their normal.
use serde_json::json;
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use super::tests::{occ, place, run};
use crate::Session;
+2 -1
View File
@@ -1,4 +1,5 @@
use super::*;
use solidcraft_geom::prelude::*;
use solidcraft_io::catalog::{Definition, Entry, FORMAT, LibraryLook, LibraryMaterial, Provenance};
use std::sync::{
Arc,
@@ -87,7 +88,7 @@ fn catalog_world_instance_targets_map_once_and_invalid_targets_are_atomic() {
assert_eq!(s.doc.appearances.bodies[&source], look.to_look());
let face = &s.doc.appearances.faces[0];
assert_eq!(face.body, source);
assert!(face.point.dist(solidcraft_geom::Vec3::new(1., 1., 2.)) < 1e-9);
assert!(face.point.dist(solidcore_record::Vec3::new(1., 1., 2.)) < 1e-9);
assert_eq!(face.look, look.to_look());
assert_eq!(s.undo.len(), history.0 + 1);
let world = s.world_state().unwrap();
+4 -3
View File
@@ -7,6 +7,7 @@ use crate::Session;
use serde_json::{Value, json};
use solidcraft_doc::FaceAttachmentStatus;
use solidcraft_doc::config::FaceCertificate;
use solidcraft_geom::prelude::*;
fn run(s: &mut Session, command: &str, params: Value) -> Value {
s.execute(command, &params).unwrap_or_else(|e| panic!("{command} {params}: {e}"))
@@ -22,7 +23,7 @@ fn status(s: &Session, sketch: &str) -> FaceAttachmentStatus {
s.placed_document().sketch_face_attachment(id, &s.model)
}
fn healthy(s: &Session, sketch: &str) -> (solidcraft_geom::Plane, Option<FaceCertificate>) {
fn healthy(s: &Session, sketch: &str) -> (solidcore_record::Plane, Option<FaceCertificate>) {
match status(s, sketch) {
FaceAttachmentStatus::Healthy { plane, target, .. } => (plane, target.certificate),
other => panic!("{sketch}: {other:?}"),
@@ -107,7 +108,7 @@ fn a_chamfer_face_takes_a_sketch_that_follows_the_chamfer() {
let n = std::f64::consts::FRAC_1_SQRT_2;
assert!((plane.normal().x - n).abs() < 1e-9 && (plane.normal().z - n).abs() < 1e-9, "{plane:?}");
// A bigger chamfer moves the face inward: the sketch goes with it.
let height = |p: &solidcraft_geom::Plane| (p.origin - solidcraft_geom::Vec3::new(40., 0., 10.)).dot(p.normal());
let height = |p: &solidcore_record::Plane| (p.origin - solidcore_record::Vec3::new(40., 0., 10.)).dot(p.normal());
assert!((height(&plane) + 3. * n).abs() < 1e-9, "{plane:?}");
run(&mut s, "parameters.change", json!({"name": "bevel", "expression": "5 mm"}));
no_errors(&s);
@@ -248,7 +249,7 @@ fn counterbore_floors_and_their_pattern_copies_take_a_sketch() {
}
/// The middle of the largest triangle of each flat face of the first body.
fn flat_faces(s: &Session) -> Vec<(usize, solidcraft_geom::Vec3)> {
fn flat_faces(s: &Session) -> Vec<(usize, solidcore_record::Vec3)> {
let state = s.model.state();
let body = &state.bodies[0].body;
let mesh = body.mesh(&solidcraft_kernel::MeshTolerance::chord(0.01)).unwrap();
+2 -1
View File
@@ -15,12 +15,13 @@
//! an occurrence inside a subassembly placed more than once is listed at the subassembly's first
//! placement (a warning says so).
use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, HashMap, HashSet};
use serde_json::Value;
use solidcore_record::Vec3;
use solidcraft_doc::joints::{self, JointKind, MAX_JOINTS};
use solidcraft_doc::{Document, IDENTITY, MAX_PLACEMENTS, Mat, ModelState, apply_point, mat_inverse, mat_mul};
use solidcraft_geom::Vec3;
use solidcraft_geom::inertia::{self, Tensor3};
use super::CommandSpec;
@@ -7,7 +7,7 @@ use serde_json::{Value, json};
use super::MassBody;
use crate::Session;
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::inertia::Tensor3 as Tensor;
fn run(s: &mut Session, cmd: &str, params: Value) -> Value {
+4 -2
View File
@@ -5,7 +5,9 @@
//! have a direction (planar faces, straight edges), the angle.
use serde_json::{Value, json};
use solidcraft_geom::{Mesh, UnitVec3, Vec3};
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use solidcraft_geom::{Mesh, UnitVec3};
use super::measure_shape::{Shape, Slot, add_round, centre};
use crate::params::bad;
@@ -216,7 +218,7 @@ fn sketch_curve(ss: &solidcraft_doc::SolvedSketch, id: &str) -> Option<Item> {
/// A profile (closed region of a sketch): its area, and when it is a circle or a slot, its
/// sizes.
fn profile(ss: &solidcraft_doc::SolvedSketch, index: usize) -> Option<Item> {
use solidcraft_geom::{Seg2, Vec2};
use solidcore_record::{Seg2, Vec2};
let pr = ss.profiles.get(index)?;
let outline: Vec<Vec3> = pr.region.outer.polyline(1e-3).iter().map(|p| ss.plane.to_world(*p)).collect();
let mut json = json!({"type": "profile", "area_mm2": pr.region.area()});
+8 -6
View File
@@ -4,7 +4,9 @@
//! round item measures from its centre or axis, with the closest and farthest distances too.
use serde_json::{Value, json};
use solidcraft_geom::{UnitVec3, Vec3};
use solidcore_record::Vec3;
use solidcraft_geom::UnitVec3;
use solidcraft_geom::prelude::*;
use std::f64::consts::{PI, TAU};
@@ -288,9 +290,9 @@ impl Slot {
/// sides. `arcs` are (centre, radius, swept angle) with pieces of one end already merged,
/// `lines` the straight pieces (2D, in the sketch plane).
pub(crate) fn slot_outline(
arcs: &[(solidcraft_geom::Vec2, f64, f64)],
lines: &[(solidcraft_geom::Vec2, solidcraft_geom::Vec2)],
) -> Option<(solidcraft_geom::Vec2, solidcraft_geom::Vec2, f64)> {
arcs: &[(solidcore_record::Vec2, f64, f64)],
lines: &[(solidcore_record::Vec2, solidcore_record::Vec2)],
) -> Option<(solidcore_record::Vec2, solidcore_record::Vec2, f64)> {
let [(c1, r1, s1), (c2, r2, s2)] = arcs else { return None };
let tol = 1e-6 * (1.0 + r1.abs() + c1.dist(*c2));
if (r1 - r2).abs() > tol || (s1.abs() - PI).abs() > 1e-4 || (s2.abs() - PI).abs() > 1e-4 || c1.dist(*c2) <= tol || lines.is_empty() {
@@ -298,7 +300,7 @@ pub(crate) fn slot_outline(
}
let along = (*c2 - *c1).normalized()?;
// Every straight piece runs along the slot, `r` to one side of the centre line.
let side = |p: solidcraft_geom::Vec2| (p - *c1).cross(along);
let side = |p: solidcore_record::Vec2| (p - *c1).cross(along);
let ok = lines.iter().all(|(a, b)| {
let d = *b - *a;
d.cross(along).abs() <= tol * (1.0 + d.len()) && (side(*a).abs() - r1).abs() <= tol && (side(*b).abs() - r1).abs() <= tol
@@ -359,7 +361,7 @@ pub(crate) fn slot_from_faces(picked: &Shape, picked_pts: &[Vec3], faces: &[(sol
#[cfg(test)]
mod tests {
use super::*;
use solidcraft_geom::Vec2;
use solidcore_record::Vec2;
fn circle(c: Vec3, r: f64) -> Shape {
Shape::Round { center: c, axis: UnitVec3::Z, radius: r, angle: TAU, planar: true, lo: 0.0, hi: 0.0 }
+2 -1
View File
@@ -2,10 +2,11 @@
//! Revolve, Circular Pattern and Plane at Angle turn about a circular edge's or a cylinder's
//! axis, and follow it when a parameter moves the cylinder.
use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use crate::Session;
use crate::view::construction_planes;
+3 -1
View File
@@ -1,12 +1,14 @@
//! Contact Sets, Motion Study and Exploded views.
use solidcraft_geom::prelude::*;
use std::collections::BTreeSet;
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::Mat;
use solidcraft_doc::joints::{self, JointKind};
use solidcraft_doc::motion::{ContactSet, ExplodedView, MotionStudy, StudyKey};
use solidcraft_geom::{Aabb3, Vec3};
use solidcraft_geom::Aabb3;
use solidcraft_kernel::Body;
use super::CommandSpec;
+3 -1
View File
@@ -3,13 +3,15 @@
//! joint values and a point's path with their velocities and accelerations; `motion.interference`
//! answers the pairs of parts that pass through each other along the way.
use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::joints;
use solidcraft_doc::motion::MotionStudy;
use solidcraft_doc::{Document, Mat, apply_point, mat_mul};
use solidcraft_geom::{Aabb3, Vec3};
use solidcraft_geom::Aabb3;
use super::contact_sweep::{ContactGeometry, Member};
use super::{drive_with_contact, joint_id, keyed, occurrences, path_world, study_index, traced_point, values_at};
@@ -2,7 +2,7 @@
//! `motion.interference` on two blocks pushed through each other at a known step.
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use super::{four_bar, occ, part, pin, rocker_pin, run, slider_crank};
use crate::Session;
+1 -1
View File
@@ -6,8 +6,8 @@
use std::collections::BTreeSet;
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::Mat;
use solidcraft_geom::Vec3;
use super::{Plan, drive_with_contact, explode_moves, exploded_at, motion_plan, sample_count, view_index};
use crate::capture::{self, Renderer};
+1 -1
View File
@@ -9,9 +9,9 @@ use std::collections::{BTreeMap, BTreeSet};
use std::sync::Arc;
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::Document;
use solidcraft_doc::joints::JointKind;
use solidcraft_geom::Vec3;
use super::analysis::checked_pairs;
use super::contact_sweep::{ContactGeometry, Gap};
+2 -1
View File
@@ -5,7 +5,8 @@
//! and the Hinge Assembly sample.
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use super::{four_bar, meet, occ, part, pin, run};
use crate::Session;
+2 -1
View File
@@ -1,5 +1,6 @@
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use crate::Session;
+2 -1
View File
@@ -1,14 +1,15 @@
//! Associative trace definitions and dependency checks. Sampling uses the existing motion
//! driver on a scratch session; only a changed generated wire is handed to the evaluator.
use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
use std::sync::Arc;
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::joints::{self, JointOrigin, Snap};
use solidcraft_doc::motion::{MotionTrace, TraceMotion};
use solidcraft_doc::{IDENTITY, apply_point};
use solidcraft_geom::Vec3;
use crate::params::{bad, bool_};
use crate::{Result, Session};
+11 -10
View File
@@ -1,6 +1,7 @@
// Exact occurrence workflows through the same commands used by the Browser.
use crate::Session;
use serde_json::{Value, json};
use solidcraft_geom::prelude::*;
fn run(s: &mut Session, command: &str, p: Value) -> Value {
s.execute(command, &p).unwrap()
@@ -529,7 +530,7 @@ fn isolate_nested_child_hides_ancestor_material_and_sibling() {
.add_occurrence(
child_component,
parent_component,
solidcraft_doc::rigid(crate::geom::Vec3::new(20.0, 0.0, 0.0), crate::geom::Vec3::ZERO, crate::geom::Vec3::Z, 0.0),
solidcraft_doc::rigid(solidcore_record::Vec3::new(20.0, 0.0, 0.0), solidcore_record::Vec3::ZERO, solidcore_record::Vec3::Z, 0.0),
)
.unwrap();
s.refresh();
@@ -615,7 +616,7 @@ fn instance_styles_follow_source_identity_after_collision_rename_and_pending_mov
assert!((measured["bodies"][0]["mass_g"].as_f64().unwrap() - 0.068).abs() < 1e-8);
}
let definition = s.model.state();
assert_eq!(solidcraft_kernel::measure(&definition.body("Shared Renamed").unwrap().body).unwrap().bbox.min, crate::geom::Vec3::ZERO);
assert_eq!(solidcraft_kernel::measure(&definition.body("Shared Renamed").unwrap().body).unwrap().bbox.min, solidcore_record::Vec3::ZERO);
let painted = s.doc.painted(&world);
let secondname = s.occurrence_bodies(&[second], false).unwrap()[0].clone();
let body = painted.body(&secondname).unwrap();
@@ -766,7 +767,7 @@ fn a_cut_or_join_from_the_top_level_into_a_linked_part_is_refused() {
_ => None,
})
.unwrap();
let c = plane.to_local(solidcraft_geom::Vec3::new(55.0, 10.0, 30.0));
let c = plane.to_local(solidcore_record::Vec3::new(55.0, 10.0, 30.0));
run(&mut s, "sketch.circle.center", json!({"center": [c.x, c.y], "radius": 2}));
run(&mut s, "sketch.finish", json!({}));
let features = s.doc.features.len();
@@ -886,7 +887,7 @@ fn a_stood_up_nested_step_part_is_cut_and_joined_from_its_face() {
run(&mut src, "occurrence.move", json!({"occurrence": carrier, "translate": [12, 7, 5], "axis": [0, 0, 1], "angle": "30 deg"}));
run(&mut src, "occurrence.move", json!({"occurrence": nested, "translate": [3, 11, 2], "axis": [0, 1, 0], "angle": "20 deg"}));
// The middle of the top face, in the file's frame: the imported root's.
let top = solidcraft_doc::apply_point(&src.doc.component_transform(part), solidcraft_geom::Vec3::new(20.0, 12.0, 10.0));
let top = solidcraft_doc::apply_point(&src.doc.component_transform(part), solidcore_record::Vec3::new(20.0, 12.0, 10.0));
run(&mut src, "file.export", json!({"path": path, "format": "step"}));
// #5679: the same from the top level, where the part is two moved and turned levels down
@@ -1092,7 +1093,7 @@ fn component_delete_removes_joints_to_its_occurrences_and_undo_restores_them() {
/// opened with its imported root active, and a sketch on the part's top face. Returns the
/// session, the sketch, the middle of the top face in the root's frame, the face's outward
/// normal and that middle in the sketch's coordinates.
fn nested_part_face_sketch() -> (Session, u64, solidcraft_geom::Vec3, solidcraft_geom::Vec3, solidcraft_geom::Vec2) {
fn nested_part_face_sketch() -> (Session, u64, solidcore_record::Vec3, solidcore_record::Vec3, solidcore_record::Vec2) {
let dir = std::env::temp_dir().join(format!("solidcraft-nested-scope-{}-{:?}", std::process::id(), std::thread::current().id()));
std::fs::create_dir_all(&dir).unwrap();
let path = dir.join("nested.step");
@@ -1102,7 +1103,7 @@ fn nested_part_face_sketch() -> (Session, u64, solidcraft_geom::Vec3, solidcraft
run(&mut src, "solid.box", json!({"length": 40, "width": 24, "height": 10, "body_name": "NestedBlock"}));
run(&mut src, "occurrence.move", json!({"occurrence": carrier, "translate": [12, 7, 5], "axis": [0, 0, 1], "angle": "30 deg"}));
run(&mut src, "occurrence.move", json!({"occurrence": nested, "translate": [3, 11, 2], "axis": [0, 1, 0], "angle": "20 deg"}));
let top = solidcraft_doc::apply_point(&src.doc.component_transform(part), solidcraft_geom::Vec3::new(20.0, 12.0, 10.0));
let top = solidcraft_doc::apply_point(&src.doc.component_transform(part), solidcore_record::Vec3::new(20.0, 12.0, 10.0));
run(&mut src, "file.export", json!({"path": path, "format": "step"}));
let mut s = Session::default();
run(&mut s, "doc.open", json!({"path": path, "up": "y"}));
@@ -1541,7 +1542,7 @@ fn join_extrude_to_a_body_of_another_component_leaves_that_body_alone() {
run(&mut s, "solid.cylinder", json!({"radius":6,"height":10,"body_name":"Connector"}));
let sketch = run(&mut s, "sketch.create", json!({"plane":{"face":[0,0,10]},"project_edges":false}))["sketch"].as_u64().unwrap();
let plane = s.model.state().sketch(sketch).unwrap().plane;
let centre = plane.to_local(solidcraft_geom::Vec3::new(0.0, 0.0, 10.0));
let centre = plane.to_local(solidcore_record::Vec3::new(0.0, 0.0, 10.0));
run(&mut s, "sketch.circle.center", json!({"center":[centre.x, centre.y],"radius":4}));
run(&mut s, "sketch.finish", json!({}));
// The boss runs up to the shell's underside and joins the connector it was sketched on.
@@ -1672,7 +1673,7 @@ fn occurrence_align_supports_snaps_planes_flip_nested_paths_and_pending_capture(
}),
);
let at_origin = s.world_state().unwrap().body("Plate").unwrap().mesh().bounds();
assert!(at_origin.min.dist(solidcraft_geom::Vec3::ZERO) < 1e-5, "{at_origin:?}");
assert!(at_origin.min.dist(solidcore_record::Vec3::ZERO) < 1e-5, "{at_origin:?}");
// Hostile / invalid parameters never panic.
for bad_params in [
@@ -1697,7 +1698,7 @@ fn occurrence_align_keeps_every_pick_and_reports_shared_definitions() {
run(&mut s, "solid.box", json!({"length": 10, "width": 10, "height": 4, "body_name": "Plate"}));
run(&mut s, "component.activate", json!({"component": "root"}));
let b = run(&mut s, "occurrence.copy", json!({"component": frame, "translate": [0, 50, 0]}))["occurrence"].as_u64().unwrap();
let origin = |s: &Session, path: &[u64]| solidcraft_doc::apply_point(&s.occurrence_placement(path).unwrap().world, solidcraft_geom::Vec3::ZERO);
let origin = |s: &Session, path: &[u64]| solidcraft_doc::apply_point(&s.occurrence_placement(path).unwrap().world, solidcore_record::Vec3::ZERO);
let (a0, ab0, b0, bb0) = (origin(&s, &[a]), origin(&s, &[a, bracket]), origin(&s, &[b]), origin(&s, &[b, bracket]));
assert!(!s.occurrence_shared(&[a]) && !s.occurrence_shared(&[b]), "top-level placements are their own");
@@ -1707,7 +1708,7 @@ fn occurrence_align_keeps_every_pick_and_reports_shared_definitions() {
assert_eq!(r["paths"], json!([[a, bracket], [b]]), "{r}");
assert_eq!(r["shared"], json!([[a, bracket]]), "{r}");
let shift = solidcraft_geom::Vec3::new(5.0, 0.0, 0.0);
let shift = solidcore_record::Vec3::new(5.0, 0.0, 0.0);
assert!(origin(&s, &[a]).dist(a0) < 1e-9, "A itself stays");
assert!(origin(&s, &[a, bracket]).dist(ab0 + shift) < 1e-9, "the picked Bracket moves");
assert!(origin(&s, &[b]).dist(b0 + shift) < 1e-9, "B moves");
@@ -1,7 +1,8 @@
#![allow(clippy::unwrap_used, clippy::panic)]
use serde_json::{Value, json};
use solidcore_record::Vec2;
use solidcraft_doc::{Document, FeatureKind, ProfileSel};
use solidcraft_geom::Vec2;
use solidcraft_geom::prelude::*;
use solidcraft_sketch::{CurveKind, Sketch};
use crate::{Session, Snapshot};
@@ -2,6 +2,7 @@
//! #2424: curves start at the ends of an associated offset spline, and follow them.
use serde_json::{Value, json};
use solidcraft_doc::Document;
use solidcraft_geom::prelude::*;
use solidcraft_sketch::{ConstraintKind, CurveKind, Sketch};
use crate::Session;
@@ -1,9 +1,10 @@
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
use crate::Session;
use serde_json::{Value, json};
use solidcore_record::Plane;
use solidcraft_doc::construct::ConstructGeom;
use solidcraft_doc::{Document, FeatureKind, PlaneRef};
use solidcraft_geom::Plane;
use solidcraft_geom::prelude::*;
fn run(s: &mut Session, command: &str, params: Value) -> Value {
s.execute(command, &params).unwrap_or_else(|e| panic!("{command} {params}: {e}"))
@@ -1,7 +1,7 @@
#![allow(clippy::unwrap_used, clippy::panic)]
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::{FeatureKind, ProfileSel};
use solidcraft_geom::Vec3;
use crate::Session;
+2 -1
View File
@@ -4,10 +4,11 @@
//! design, many sizes) can be checked across its whole range before it is trusted, and the
//! report says what moved where, so a lost face or a flipped joint is found before a part is.
use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use super::CommandSpec;
use crate::params::{bad, num, str_};
+3 -2
View File
@@ -1,4 +1,5 @@
use serde_json::{Value, json};
use solidcraft_geom::prelude::*;
use crate::{EngineError, Session};
@@ -668,7 +669,7 @@ fn a_failed_auto_constrain_keeps_the_stored_sketch_consistent() {
}
/// The stored sketch's points, by id.
fn stored_points(s: &Session, feature: u64) -> Vec<solidcraft_geom::Vec2> {
fn stored_points(s: &Session, feature: u64) -> Vec<solidcore_record::Vec2> {
s.doc.sketch(feature).unwrap().points.iter().map(|p| p.pos).collect()
}
@@ -699,7 +700,7 @@ fn an_unsolvable_value_edit_is_refused_and_changes_nothing() {
fn value_edits_continue_from_the_last_solved_state() {
// A → B → C, each a small edit solved in one jump; C is solved from B (the stored state),
// and setting both values back reproduces A (the linkage is fully constrained).
let close = |a: &[solidcraft_geom::Vec2], b: &[solidcraft_geom::Vec2], tol: f64| a.iter().zip(b).all(|(p, q)| p.dist(*q) < tol);
let close = |a: &[solidcore_record::Vec2], b: &[solidcore_record::Vec2], tol: f64| a.iter().zip(b).all(|(p, q)| p.dist(*q) < tol);
let (mut s, feature, params) = linkage_session();
run(&mut s, "sketch.finish", json!({}));
let a = stored_points(&s, feature);
+8 -6
View File
@@ -10,7 +10,8 @@
//! washer, the top of a set screw or pin); the shank runs down −z.
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use super::CommandSpec;
use crate::params::{bad, num, str_, vec3};
@@ -892,6 +893,7 @@ fn resize(s: &mut Session, p: &Value) -> Result<Value> {
#[cfg(test)]
mod tests {
use serde_json::{Value, json};
use solidcraft_geom::prelude::*;
use crate::Session;
@@ -902,7 +904,7 @@ mod tests {
}
}
fn bbox(s: &Session, prefix: &str) -> (solidcraft_geom::Vec3, solidcraft_geom::Vec3) {
fn bbox(s: &Session, prefix: &str) -> (solidcore_record::Vec3, solidcore_record::Vec3) {
let st = s.world_state().unwrap();
let comp = s.doc.components.iter().find(|c| c.name.starts_with(prefix)).map(|c| c.id).unwrap_or(0);
let b = st
@@ -1168,8 +1170,8 @@ mod tests {
assert_eq!(Some(joint.a.occurrence), washer["occurrence"].as_u64());
// The seating face is X = 41.6: the 20 mm shank runs along -X and the 8 mm head along +X.
let (lo, hi) = bbox(&s, "SHCS M8x20");
assert!(lo.dist(solidcraft_geom::Vec3::new(21.6, 43.5, 53.5)) < 1e-6, "{lo:?}");
assert!(hi.dist(solidcraft_geom::Vec3::new(49.6, 56.5, 66.5)) < 1e-6, "{hi:?}");
assert!(lo.dist(solidcore_record::Vec3::new(21.6, 43.5, 53.5)) < 1e-6, "{lo:?}");
assert!(hi.dist(solidcore_record::Vec3::new(49.6, 56.5, 66.5)) < 1e-6, "{hi:?}");
}
/// Several holes in one insert: one component placed and seated once per hole, in one undo
@@ -1274,8 +1276,8 @@ mod tests {
assert!(s.model.state().threads.iter().any(|t| t.designation == "M8" && (t.pitch - 1.25).abs() < 1e-9), "{family} {units}");
}
if family == "dowel_pin" {
assert!(b.0.dist(solidcraft_geom::Vec3::new(10., 46., 56.)) < 1e-6, "{b:?}");
assert!(b.1.dist(solidcraft_geom::Vec3::new(40., 54., 64.)) < 1e-6, "{b:?}");
assert!(b.0.dist(solidcore_record::Vec3::new(10., 46., 56.)) < 1e-6, "{b:?}");
assert!(b.1.dist(solidcore_record::Vec3::new(40., 54., 64.)) < 1e-6, "{b:?}");
}
bounds.push(b);
}
+6 -6
View File
@@ -95,9 +95,9 @@ fn rectangular_cut_pattern_counts_only_target_contacts_and_keeps_landing_copies(
assert_eq!(reply["warning"], "2 of 3 cut copies remove no material");
let state = s.world_state().unwrap();
let plate = &state.body("Plate").unwrap().body;
assert_eq!(plate.classify_point(solidcraft_geom::Vec3::new(30., 15., 5.)).unwrap(), solidcraft_kernel::PointClass::Outside);
assert_eq!(plate.classify_point(solidcore_record::Vec3::new(30., 15., 5.)).unwrap(), solidcraft_kernel::PointClass::Outside);
assert_eq!(
state.body("Neighbor").unwrap().body.classify_point(solidcraft_geom::Vec3::new(50., 15., 5.)).unwrap(),
state.body("Neighbor").unwrap().body.classify_point(solidcore_record::Vec3::new(50., 15., 5.)).unwrap(),
solidcraft_kernel::PointClass::Inside
);
assert!(rel(volume(&mut s), 24000.0 - 2.0 * PI * 4.0 * 10.0) < 1e-3);
@@ -105,7 +105,7 @@ fn rectangular_cut_pattern_counts_only_target_contacts_and_keeps_landing_copies(
#[test]
fn feature_rectangular_center_flip_and_oblique_direction_keep_source_and_recompute() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
for flipped in [false, true] {
let mut s = feature_pattern_plate();
let before = s.doc.to_json();
@@ -145,7 +145,7 @@ fn feature_rectangular_center_flip_and_oblique_direction_keep_source_and_recompu
#[test]
fn feature_circular_center_flip_uses_partial_arc_endpoints_and_full_circle_spacing() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
for total in [90.0_f64, 360.0] {
for flipped in [false, true] {
let mut s = feature_pattern_plate();
@@ -828,7 +828,7 @@ fn copies_of_a_join_that_merged_its_targets_join_the_merged_body() {
/// middle; the rib's triangle (8, 5)-(8, 25)-(30, 5) in the XZ plane, 4 thick, is 880 mm³.
#[test]
fn patterns_and_mirrors_of_a_rib() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let rib = 0.5 * 22.0 * 20.0 * 4.0;
let ribbed = || {
let mut s = Session::default();
@@ -872,7 +872,7 @@ fn patterns_and_mirrors_of_a_rib() {
/// box with a hole `H` at (−15, −10) and `Pat`, two more holes along x at 10 mm steps.
#[test]
fn patterns_and_mirrors_of_patterns_and_mirrors() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let hole = PI * 1.5 * 1.5 * 20.0;
let design = || {
let mut s = Session::default();
+6 -4
View File
@@ -1,12 +1,13 @@
//! Plastic (enclosure) features: Boss, Lip / Groove, Snap Fit and Rest, and plastic rules.
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::BodyName;
use solidcraft_doc::FeatureKind;
use solidcraft_doc::expr::Kind;
use solidcraft_doc::plastic::PlasticRule;
use solidcraft_doc::{Dir, FacePick, Position};
use solidcraft_geom::Vec3;
use solidcraft_geom::prelude::*;
use super::CommandSpec;
use super::features::{add_feature, check_expr};
@@ -272,7 +273,8 @@ fn snap_fit(s: &mut Session, p: &Value) -> Result<Value> {
#[cfg(test)]
mod tests {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
use serde_json::{Value, json};
@@ -348,9 +350,9 @@ mod tests {
for groove in [false, true] {
let mut s = Session::default();
let plane = if tilted {
solidcraft_geom::Plane::new(Vec3::new(7., -3., 5.), Vec3::new(1., -1., 0.), Vec3::new(1., 1., -2.)).unwrap()
solidcore_record::Plane::new(Vec3::new(7., -3., 5.), Vec3::new(1., -1., 0.), Vec3::new(1., 1., -2.)).unwrap()
} else {
solidcraft_geom::Plane::XY
solidcore_record::Plane::XY
};
if obround {
run(&mut s, "sketch.create", json!({"plane": plane, "name": "Rim"}));
+2 -1
View File
@@ -6,8 +6,9 @@
//! the slicer arranges them.
use serde_json::Value;
use solidcore_record::Vec3;
use solidcraft_doc::{ModelState, PrintFace};
use solidcraft_geom::Vec3;
use solidcraft_geom::prelude::*;
use super::CommandSpec;
use crate::params::{bad, str_};
+1 -1
View File
@@ -1,7 +1,7 @@
//! Request-only coat overrides on immutable captured geometry; no saved appearance changes.
use crate::{Result, params::bad};
use serde::Deserialize;
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_render::{
ProductScene,
clear_coat::ClearCoat,
+1 -1
View File
@@ -924,7 +924,7 @@ fn native_spatial_aa_preflight_and_host_forwarding_change_actual_edge_png() {
let center = scene.bounds.center();
let mut camera = solidcraft_render::Camera { distance: 2.0, fov: 0.0, ..Default::default() };
camera.set_view(solidcraft_render::StandardView::Top);
camera.target = solidcraft_geom::Vec3::new(scene.bounds.min.x, center.y, center.z);
camera.target = solidcore_record::Vec3::new(scene.bounds.min.x, center.y, center.z);
let doc = s.doc.clone();
let before = (s.revision, s.evaluations, s.is_dirty(), s.undo.len(), s.redo.len());
let mut legacy: Option<Vec<u8>> = None;
@@ -1,5 +1,6 @@
use super::*;
use solidcraft_doc::render_settings::RenderJob;
use solidcraft_geom::prelude::*;
fn save(s: &mut Session, patch: Value) {
s.execute("render.settings.set", &json!({"name":"Studio", "set":patch})).unwrap();
@@ -181,7 +182,7 @@ fn light_fixture(s: &mut Session, method: &str) {
#[test]
fn render_lights_small_area_pose_and_resize_preserve_aspect_and_emitting_side() {
use crate::schema::render_lights::Geometry;
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let mut s = Session::default();
save(
&mut s,
+2 -2
View File
@@ -156,8 +156,8 @@ pub(super) fn backdrop(s: &mut Session, params: &Value) -> Result<Value> {
}
// Camera back projects toward the camera; the stage depth points away.
let yaw = setup.camera.yaw;
let depth = solidcraft_geom::Vec3::new(yaw.sin(), yaw.cos(), 0.);
let horizontal = solidcraft_geom::Vec3::new(yaw.cos(), -yaw.sin(), 0.);
let depth = solidcore_record::Vec3::new(yaw.sin(), yaw.cos(), 0.);
let horizontal = solidcore_record::Vec3::new(yaw.cos(), -yaw.sin(), 0.);
let extent = extent.max(1.0); // minimum one-mm stage envelope, never scales the subject
let radius = extent * 0.5;
let near = -2.5 * extent;
@@ -3,12 +3,12 @@
use crate::{Result, Session, params::bad};
use serde::Deserialize;
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::{
render_resources::HdrId,
render_settings::{RenderJob, RenderSetup},
render_surface::{BuiltinSurfaceSource, RenderBodyTarget, SavedSurface, SurfaceBindings},
};
use solidcraft_geom::Vec3;
use solidcraft_render::{ProductScene, job::textures::PlanarFrame};
use std::{collections::BTreeMap, sync::Arc};
+2 -2
View File
@@ -89,7 +89,7 @@ pub(super) fn validate_targets(scene: &ProductScene, overrides: &[Override], com
for x in [bounds.min.x, bounds.max.x] {
for y in [bounds.min.y, bounds.max.y] {
for z in [bounds.min.z, bounds.max.z] {
input.frame.uv(solidcraft_geom::Vec3::new(x, y, z)).map_err(|e| bad(command, e.to_string()))?;
input.frame.uv(solidcore_record::Vec3::new(x, y, z)).map_err(|e| bad(command, e.to_string()))?;
}
}
}
@@ -156,7 +156,7 @@ mod tests {
color: [255; 3],
opacity: 1.,
surface: None,
transmission: Some(solidcraft_render::transmission::Transmission::new(solidcraft_geom::Vec3::ZERO, Some(1.)).unwrap()),
transmission: Some(solidcraft_render::transmission::Transmission::new(solidcore_record::Vec3::ZERO, Some(1.)).unwrap()),
faces: vec![],
}],
};
+1 -1
View File
@@ -2,7 +2,7 @@
//! Keep wire details here until the CPU contract is published. Never save them.
use crate::{Result, params::bad};
use serde::Deserialize;
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_render::{
ProductScene,
surface::{OpaqueSurface, srgb8_to_linear},
@@ -2,8 +2,9 @@
use crate::Session;
use serde_json::{Value, json};
use solidcore_record::Vec3;
use solidcraft_doc::{Document, FeatureKind, RevolveConvention};
use solidcraft_geom::Vec3;
use solidcraft_geom::prelude::*;
use std::f64::consts::{FRAC_PI_2, PI, SQRT_2};
fn run(s: &mut Session, cmd: &str, p: Value) -> Value {
+2 -1
View File
@@ -2,7 +2,8 @@
//! positive side is hidden). It changes no geometry and is not an undo step.
use serde_json::Value;
use solidcraft_geom::{Plane, Vec3};
use solidcore_record::{Plane, Vec3};
use solidcraft_geom::prelude::*;
use super::CommandSpec;
use crate::params::{bad, bool_, expr, vec3};
+10 -8
View File
@@ -2,12 +2,14 @@
//! the flat pattern (outline, bend lines, bend table) and its DXF export.
use serde_json::{Value, json};
use solidcore_record::{Vec2, Vec3};
use solidcraft_doc::expr::Kind;
use solidcraft_doc::sheet::{self, SheetBody, SheetRule};
use solidcraft_doc::{BodyName, SketchId};
use solidcraft_doc::{FacePick, Position};
use solidcraft_doc::{FeatureKind, FlangeEdge};
use solidcraft_geom::{Aabb2, Ring, Vec2, Vec3};
use solidcraft_geom::prelude::*;
use solidcraft_geom::{Aabb2, Ring};
use super::CommandSpec;
use super::features::{add_feature, check_expr, feature_sketch, profiles, sketch_id};
@@ -526,7 +528,7 @@ fn fold(s: &mut Session, p: &Value) -> Result<Value> {
let ss = st.sketch(sk).ok_or_else(|| bad(cmd, "no such sketch"))?;
let ci = ss.sketch.curve_index(&c).ok_or_else(|| bad(cmd, format!("no curve `{c}` in the sketch")))?;
let (a, b) = match ss.sketch.segs(ci).as_slice() {
[solidcraft_geom::Seg2::Line { a, b }] => (ss.plane.to_world(*a), ss.plane.to_world(*b)),
[solidcore_record::Seg2::Line { a, b }] => (ss.plane.to_world(*a), ss.plane.to_world(*b)),
_ => return Err(bad(cmd, "the fold line must be a sketch line")),
};
(Some(sk), Some(c), a, b)
@@ -720,8 +722,8 @@ fn sheet_of(s: &Session, p: &Value, cmd: &str) -> Result<SheetBody> {
}
/// The centre and radius of a loop that is one whole circle (often two semicircles).
fn loop_circle(lp: &solidcraft_geom::Loop2) -> Option<(Vec2, f64)> {
use solidcraft_geom::Seg2;
fn loop_circle(lp: &solidcore_record::Loop2) -> Option<(Vec2, f64)> {
use solidcore_record::Seg2;
let Some(Seg2::Arc { center, radius, sweep, .. }) = lp.segs.first() else { return None };
let total: f64 = lp.segs.iter().filter_map(|s| if let Seg2::Arc { sweep, .. } = s { Some(*sweep) } else { None }).sum();
let circular = lp.segs.iter().all(
@@ -732,8 +734,8 @@ fn loop_circle(lp: &solidcraft_geom::Loop2) -> Option<(Vec2, f64)> {
/// A loop's exact shape for the flat pattern JSON: a circle, or its lines and arcs (other
/// curves as point lists at the flat pattern's 0.001 mm tolerance).
fn loop_shape(lp: &solidcraft_geom::Loop2) -> Value {
use solidcraft_geom::Seg2;
fn loop_shape(lp: &solidcore_record::Loop2) -> Value {
use solidcore_record::Seg2;
let pt = |v: Vec2| json!([v.x, v.y]);
if let Some((center, radius)) = loop_circle(lp) {
return json!({"circle": {"center": pt(center), "radius": radius}});
@@ -933,7 +935,7 @@ pub fn flat_dxf(sh: &SheetBody, o: &DxfOptions) -> Result<String> {
.iter()
.enumerate()
.map(|(j, r)| {
let probe = r.outer.segs.first().map(solidcraft_geom::Seg2::mid);
let probe = r.outer.segs.first().map(solidcore_record::Seg2::mid);
probe.is_some_and(|p| regions.iter().enumerate().any(|(i, other)| i != j && other.outer.contains(p)))
})
.collect();
@@ -945,7 +947,7 @@ pub fn flat_dxf(sh: &SheetBody, o: &DxfOptions) -> Result<String> {
Pocket,
Outline,
}
let mut loops: Vec<(Pass, &solidcraft_geom::Loop2, String)> = Vec::new();
let mut loops: Vec<(Pass, &solidcore_record::Loop2, String)> = Vec::new();
for (j, r) in regions.iter().enumerate() {
for (k, lp) in std::iter::once(&r.outer).chain(&r.holes).enumerate() {
let (pass, layer) = if k == 0 && !nested.get(j).copied().unwrap_or(false) {
+5 -4
View File
@@ -1,6 +1,7 @@
//! Convert to Sheet Metal: solid and shelled bodies with bend edges (with holes and round edges in
//! their faces), plates read from STEP files whose walls come in pieces, and plates with recesses.
use solidcraft_geom::prelude::*;
use std::f64::consts::{FRAC_PI_2, PI, SQRT_2};
use serde_json::{Value, json};
@@ -1130,7 +1131,7 @@ fn contains(s: &Session, p: [f64; 3]) -> bool {
.state()
.bodies
.first()
.is_some_and(|b| b.body.classify_point(solidcraft_geom::Vec3::new(p[0], p[1], p[2])).unwrap() == solidcraft_kernel::PointClass::Inside)
.is_some_and(|b| b.body.classify_point(solidcore_record::Vec3::new(p[0], p[1], p[2])).unwrap() == solidcraft_kernel::PointClass::Inside)
}
/// The LINE entities a DXF draws on `layer` (group codes and values alternate, a line each).
@@ -1671,18 +1672,18 @@ fn a_converted_trays_corners_are_closed_and_relieved_as_a_flanged_trays_are() {
// corners R + T in from the sharps, 92 and 52 apart.
if shape == "round" {
let dxf = run(&mut s, "sheet.export_dxf", json!({}))["dxf"].as_str().unwrap_or_default().to_string();
let arcs: Vec<(solidcraft_geom::Vec2, f64)> = solidcraft_io::read_dxf(&dxf)
let arcs: Vec<(solidcore_record::Vec2, f64)> = solidcraft_io::read_dxf(&dxf)
.unwrap_or_default()
.iter()
.filter_map(|g| if let solidcraft_io::Geom2::Arc { c, a, .. } = g { Some((*c, a.dist(*c))) } else { None })
.collect();
assert_eq!(arcs.len(), 4, "{arcs:?}");
let lo = solidcraft_geom::Vec2::new(
let lo = solidcore_record::Vec2::new(
arcs.iter().map(|(c, _)| c.x).fold(f64::MAX, f64::min),
arcs.iter().map(|(c, _)| c.y).fold(f64::MAX, f64::min),
);
for (x, y) in [(0.0, 0.0), (92.0, 0.0), (92.0, 52.0), (0.0, 52.0)] {
let at = lo + solidcraft_geom::Vec2::new(x, y);
let at = lo + solidcore_record::Vec2::new(x, y);
assert!(arcs.iter().any(|(c, r)| c.dist(at) < 1e-6 && (r - 4.0).abs() < 1e-6), "({x}, {y}): {arcs:?}");
}
}
+4 -3
View File
@@ -2,10 +2,11 @@
//! a laser-cutting shop can use it as it is: layers by role, bend notes, letters cut or etched,
//! one file per sheet body.
use solidcraft_geom::prelude::*;
use std::f64::consts::{PI, TAU};
use serde_json::{Value, json};
use solidcraft_geom::{Seg2, Vec2};
use solidcore_record::{Seg2, Vec2};
use crate::Session;
@@ -103,7 +104,7 @@ fn point(e: &Entity, code: i32) -> Vec2 {
}
/// All loops of the flat pattern (outlines, cut-outs, islands).
fn loops(s: &Session) -> Vec<solidcraft_geom::Loop2> {
fn loops(s: &Session) -> Vec<solidcore_record::Loop2> {
let regions = s.model.state().sheets[0].flat_regions().unwrap_or_default();
regions.iter().flat_map(|r| std::iter::once(r.outer.clone()).chain(r.holes.clone())).collect()
}
@@ -345,7 +346,7 @@ fn the_flat_pattern_is_on_layers_by_role_and_inner_contours_come_first() {
// OUTLINE: the tray's outer contour alone, one entity for each of its segments (lines and arcs).
let regions = s.model.state().sheets[0].flat_regions().unwrap_or_default();
let plate =
regions.iter().max_by(|a, b| a.area().total_cmp(&b.area())).map(|r| r.outer.clone()).unwrap_or(solidcraft_geom::Loop2 { segs: Vec::new() });
regions.iter().max_by(|a, b| a.area().total_cmp(&b.area())).map(|r| r.outer.clone()).unwrap_or(solidcore_record::Loop2 { segs: Vec::new() });
assert_eq!(on("OUTLINE").len(), solidcraft_io::loop_shapes(&plate).len());
assert!(on("OUTLINE").iter().all(|e| e.0 == "LINE" || e.0 == "ARC"), "{:?}", on("OUTLINE").iter().map(|e| &e.0).collect::<Vec<_>>());
// CUT: what is cut out inside it that is no text: the Ø5 hole as one CIRCLE, the slot's four lines.
@@ -1,5 +1,6 @@
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use crate::Session;
+57 -53
View File
@@ -1,3 +1,4 @@
use solidcraft_geom::prelude::*;
use std::f64::consts::{FRAC_PI_2, PI};
use serde_json::{Value, json};
@@ -60,7 +61,7 @@ fn plain_solid_sheet_operations_explain_how_to_start_sheet_metal() {
#[test]
fn side_edge_flanges_across_a_bend_keep_their_relief_through_rebuild_and_reopen() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
for shape in ["round", "rectangular"] {
for reverse in [false, true] {
@@ -132,8 +133,8 @@ fn shallow_sheet_pocket_preserves_material_depth_export_undo_and_reopen() {
assert!((volume(&mut s) - 14900.0).abs() < 1e-6);
let state = s.model.state();
let body = &state.bodies[0].body;
assert_eq!(body.classify_point(solidcraft_geom::Vec3::new(25.0, 25.0, 0.5)).unwrap(), solidcraft_kernel::PointClass::Outside);
assert_eq!(body.classify_point(solidcraft_geom::Vec3::new(25.0, 25.0, 1.5)).unwrap(), solidcraft_kernel::PointClass::Inside);
assert_eq!(body.classify_point(solidcore_record::Vec3::new(25.0, 25.0, 0.5)).unwrap(), solidcraft_kernel::PointClass::Outside);
assert_eq!(body.classify_point(solidcore_record::Vec3::new(25.0, 25.0, 1.5)).unwrap(), solidcraft_kernel::PointClass::Inside);
}
let mut reopened = Session::new(solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap());
assert!((volume(&mut reopened) - 14900.0).abs() < 1e-6);
@@ -286,10 +287,10 @@ fn intersect_preserves_both_material_regions_of_a_logical_ring_sheet() {
let area: f64 = regions.iter().map(|r| r.area()).sum();
assert!((area - (900.0 - PI * 75.0)).abs() < 1e-8, "area={area}");
let body = &state.bodies[0].body;
assert_eq!(body.classify_point(solidcraft_geom::Vec3::new(50.0, 30.0, 1.0)).unwrap(), solidcraft_kernel::PointClass::Inside);
assert_eq!(body.classify_point(solidcraft_geom::Vec3::new(57.0, 30.0, 1.0)).unwrap(), solidcraft_kernel::PointClass::Outside);
assert_eq!(body.classify_point(solidcraft_geom::Vec3::new(64.0, 30.0, 1.0)).unwrap(), solidcraft_kernel::PointClass::Inside);
assert_eq!(body.classify_point(solidcraft_geom::Vec3::new(70.0, 30.0, 1.0)).unwrap(), solidcraft_kernel::PointClass::Outside);
assert_eq!(body.classify_point(solidcore_record::Vec3::new(50.0, 30.0, 1.0)).unwrap(), solidcraft_kernel::PointClass::Inside);
assert_eq!(body.classify_point(solidcore_record::Vec3::new(57.0, 30.0, 1.0)).unwrap(), solidcraft_kernel::PointClass::Outside);
assert_eq!(body.classify_point(solidcore_record::Vec3::new(64.0, 30.0, 1.0)).unwrap(), solidcraft_kernel::PointClass::Inside);
assert_eq!(body.classify_point(solidcore_record::Vec3::new(70.0, 30.0, 1.0)).unwrap(), solidcraft_kernel::PointClass::Outside);
assert!((volume(&mut s) - (900.0 - PI * 75.0) * 2.5).abs() < 0.2);
}
let dxf = run(&mut s, "sheet.export_dxf", json!({}))["dxf"].as_str().unwrap().to_string();
@@ -298,14 +299,14 @@ fn intersect_preserves_both_material_regions_of_a_logical_ring_sheet() {
#[test]
fn machining_a_folded_parallel_panel_preserves_its_pocket_on_unfold() {
use solidcore_record::Vec3;
use solidcraft_doc::{apply_point, apply_vector};
use solidcraft_geom::Vec3;
let mut s = Session::default();
base(&mut s, 100.0, 60.0);
run(&mut s, "sheet.flange", json!({"edges":[[50,0,2.5]],"height":20}));
let sh = s.model.state().sheets[0].clone();
let points = sh.panel(&sh.flanges[0]).outer.polyline(1e-3);
let c = points.iter().copied().fold(solidcraft_geom::Vec2::ZERO, |sum, p| sum + p) / (points.len() as f64);
let c = points.iter().copied().fold(solidcore_record::Vec2::ZERO, |sum, p| sum + p) / (points.len() as f64);
let w = sh.world(Some(0));
let origin = apply_point(&w, Vec3::ZERO);
let x = apply_vector(&w, Vec3::X);
@@ -343,10 +344,13 @@ fn flipped_sheet_pocket_keeps_depth_in_the_local_thickness_direction() {
assert!((volume(&mut s) - 14900.0).abs() < 1e-6);
let state = s.model.state();
assert_eq!(
state.bodies[0].body.classify_point(solidcraft_geom::Vec3::new(25.0, 25.0, -0.5)).unwrap(),
state.bodies[0].body.classify_point(solidcore_record::Vec3::new(25.0, 25.0, -0.5)).unwrap(),
solidcraft_kernel::PointClass::Outside
);
assert_eq!(state.bodies[0].body.classify_point(solidcraft_geom::Vec3::new(25.0, 25.0, -1.5)).unwrap(), solidcraft_kernel::PointClass::Inside);
assert_eq!(
state.bodies[0].body.classify_point(solidcore_record::Vec3::new(25.0, 25.0, -1.5)).unwrap(),
solidcraft_kernel::PointClass::Inside
);
}
}
@@ -381,17 +385,17 @@ fn multiple_profile_intersect_keeps_tool_union_for_solids_and_sheet_groups() {
state
.bodies
.iter()
.any(|b| b.body.classify_point(solidcraft_geom::Vec3::new(x, 25.0, 1.0)).unwrap() == solidcraft_kernel::PointClass::Inside)
.any(|b| b.body.classify_point(solidcore_record::Vec3::new(x, 25.0, 1.0)).unwrap() == solidcraft_kernel::PointClass::Inside)
);
}
assert!(
!state
.bodies
.iter()
.any(|b| b.body.classify_point(solidcraft_geom::Vec3::new(50.0, 25.0, 1.0)).unwrap() == solidcraft_kernel::PointClass::Inside)
.any(|b| b.body.classify_point(solidcore_record::Vec3::new(50.0, 25.0, 1.0)).unwrap() == solidcraft_kernel::PointClass::Inside)
);
assert!(state.bodies.iter().any(|b| b.name == "Control"
&& b.body.classify_point(solidcraft_geom::Vec3::new(205.0, 5.0, 5.0)).unwrap() == solidcraft_kernel::PointClass::Inside));
&& b.body.classify_point(solidcore_record::Vec3::new(205.0, 5.0, 5.0)).unwrap() == solidcraft_kernel::PointClass::Inside));
}
}
@@ -417,7 +421,7 @@ fn deleting_sheet_material_prunes_cosmetic_threads_and_undo_restores_them() {
#[test]
fn sheet_pocket_transfer_keeps_local_depth_world_pose_and_history() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
fn check(s: &Session, name: &str, owner: u64, local_origin: Vec3, local_y: Vec3, transferred: bool) {
let state = s.model.state();
let mb = state.body(name).unwrap();
@@ -429,8 +433,8 @@ fn sheet_pocket_transfer_keeps_local_depth_world_pose_and_history() {
assert!(sh.frame.y.dist(local_y) < 1e-8);
assert_eq!(sh.pockets.len(), 1);
assert_eq!((sh.pockets[0].z0, sh.pockets[0].z1), (0.0, 1.0));
let cut = sh.frame.to_world(solidcraft_geom::Vec2::new(25.0, 25.0)) + sh.frame.normal() * 0.5;
let floor = sh.frame.to_world(solidcraft_geom::Vec2::new(25.0, 25.0)) + sh.frame.normal() * 1.5;
let cut = sh.frame.to_world(solidcore_record::Vec2::new(25.0, 25.0)) + sh.frame.normal() * 0.5;
let floor = sh.frame.to_world(solidcore_record::Vec2::new(25.0, 25.0)) + sh.frame.normal() * 1.5;
assert_eq!(mb.body.classify_point(cut).unwrap(), solidcraft_kernel::PointClass::Outside);
assert_eq!(mb.body.classify_point(floor).unwrap(), solidcraft_kernel::PointClass::Inside);
let world = s.world_state().unwrap();
@@ -1345,7 +1349,7 @@ fn contains(s: &Session, p: [f64; 3]) -> bool {
.state()
.bodies
.first()
.is_some_and(|b| b.body.classify_point(solidcraft_geom::Vec3::new(p[0], p[1], p[2])).unwrap() == solidcraft_kernel::PointClass::Inside)
.is_some_and(|b| b.body.classify_point(solidcore_record::Vec3::new(p[0], p[1], p[2])).unwrap() == solidcraft_kernel::PointClass::Inside)
}
#[test]
@@ -2152,7 +2156,7 @@ fn malformed_fold_points_are_rejected_atomically() {
#[test]
fn flat_dxf_preserves_exact_cutout_entities() {
use solidcraft_geom::{Loop2, Region2, Seg2, Vec2};
use solidcore_record::{Loop2, Region2, Seg2, Vec2};
let mut s = Session::default();
base(&mut s, 100.0, 60.0);
let mut sh = s.model.state().sheets[0].clone();
@@ -2253,8 +2257,8 @@ fn inherited_round_hole_survives_flange_and_unfold_in_flipped_frames() {
let sh = s.model.state().sheets[0].clone();
let regions = sh.flat_regions().unwrap();
assert_eq!(regions[0].holes[0].segs.len(), 2);
assert!(regions[0].holes[0].segs.iter().all(|s| matches!(s, solidcraft_geom::Seg2::Arc { radius, .. } if (*radius - 5.0).abs() < 1e-9)));
let expected = regions.iter().map(solidcraft_geom::Region2::area).sum::<f64>() * 2.5;
assert!(regions[0].holes[0].segs.iter().all(|s| matches!(s, solidcore_record::Seg2::Arc { radius, .. } if (*radius - 5.0).abs() < 1e-9)));
let expected = regions.iter().map(solidcore_record::Region2::area).sum::<f64>() * 2.5;
run(&mut s, "sheet.unfold", json!({}));
assert!((volume(&mut s) - expected).abs() < 0.1);
run(&mut s, "sheet.refold", json!({}));
@@ -2269,7 +2273,7 @@ fn faces(s: &mut Session) -> (u64, u64) {
#[test]
fn elliptic_cut_out_stays_exact_in_the_flat_pattern_and_follows_arcs_when_folded() {
use solidcraft_geom::Seg2;
use solidcore_record::Seg2;
let mut s = Session::default();
base(&mut s, 100.0, 60.0);
run(&mut s, "sheet.flange", json!({"edges": [[50, 0, 2.5]], "height": 20}));
@@ -2319,7 +2323,7 @@ fn flipped_base_flange_keeps_its_elliptic_outline() {
let regions = s.model.state().sheets[0].flat_regions().unwrap();
let outline = &regions[0].outer.segs;
assert!(
outline.len() == 4 && outline.iter().all(|x| matches!(x, solidcraft_geom::Seg2::Conic { .. })),
outline.len() == 4 && outline.iter().all(|x| matches!(x, solidcore_record::Seg2::Conic { .. })),
"flip {flip}: {} segments",
outline.len()
);
@@ -2457,7 +2461,7 @@ fn a_round_flange_stays_a_circle_and_keeps_a_cut_near_its_rim_through_unfold_ref
let regions = s.model.state().sheets[0].flat_regions().unwrap();
let rim = &regions[0].outer.segs;
assert!(
!rim.is_empty() && rim.iter().all(|seg| matches!(seg, solidcraft_geom::Seg2::Arc { radius, .. } if (*radius - 10.0).abs() < 1e-12)),
!rim.is_empty() && rim.iter().all(|seg| matches!(seg, solidcore_record::Seg2::Arc { radius, .. } if (*radius - 10.0).abs() < 1e-12)),
"{rim:?}"
);
assert_eq!(regions[0].holes.len(), 1);
@@ -2508,8 +2512,8 @@ fn unrelated_box_cut_preserves_logical_ring_sheet_compound() {
assert_eq!(s.model.state().bodies.len(), 2);
let state = s.model.state();
let body = &state.bodies.iter().find(|b| b.name == sheet_name).unwrap().body;
assert_eq!(body.classify_point(solidcraft_geom::Vec3::new(50.0, 30.0, 1.25)).unwrap(), solidcraft_kernel::PointClass::Inside);
assert_eq!(body.classify_point(solidcraft_geom::Vec3::new(57.0, 30.0, 1.25)).unwrap(), solidcraft_kernel::PointClass::Outside);
assert_eq!(body.classify_point(solidcore_record::Vec3::new(50.0, 30.0, 1.25)).unwrap(), solidcraft_kernel::PointClass::Inside);
assert_eq!(body.classify_point(solidcore_record::Vec3::new(57.0, 30.0, 1.25)).unwrap(), solidcraft_kernel::PointClass::Outside);
}
}
@@ -2544,9 +2548,9 @@ fn specialized_sheet_cuts_respect_component_and_explicit_participants() {
fn ring_cut_preserves_retained_island_through_unfold_and_refold() {
fn material_probes(s: &Session) {
let body = &s.model.state().bodies[0].body;
assert_eq!(body.classify_point(solidcraft_geom::Vec3::new(50.0, 30.0, 1.25)).unwrap(), solidcraft_kernel::PointClass::Inside);
assert_eq!(body.classify_point(solidcraft_geom::Vec3::new(57.0, 30.0, 1.25)).unwrap(), solidcraft_kernel::PointClass::Outside);
assert_eq!(body.classify_point(solidcraft_geom::Vec3::new(65.0, 30.0, 1.25)).unwrap(), solidcraft_kernel::PointClass::Inside);
assert_eq!(body.classify_point(solidcore_record::Vec3::new(50.0, 30.0, 1.25)).unwrap(), solidcraft_kernel::PointClass::Inside);
assert_eq!(body.classify_point(solidcore_record::Vec3::new(57.0, 30.0, 1.25)).unwrap(), solidcraft_kernel::PointClass::Outside);
assert_eq!(body.classify_point(solidcore_record::Vec3::new(65.0, 30.0, 1.25)).unwrap(), solidcraft_kernel::PointClass::Inside);
}
let mut s = Session::default();
base(&mut s, 100.0, 60.0);
@@ -2564,9 +2568,9 @@ fn ring_cut_preserves_retained_island_through_unfold_and_refold() {
material_probes(&s);
assert_eq!(flat(&mut s)["outline"].as_array().map(Vec::len), Some(2));
let regions = s.model.state().sheets[0].flat_regions().unwrap();
assert!(regions.iter().any(|r| r.contains(solidcraft_geom::Vec2::new(50.0, 30.0))));
assert!(!regions.iter().any(|r| r.contains(solidcraft_geom::Vec2::new(57.0, 30.0))));
assert!(regions.iter().any(|r| r.contains(solidcraft_geom::Vec2::new(65.0, 30.0))));
assert!(regions.iter().any(|r| r.contains(solidcore_record::Vec2::new(50.0, 30.0))));
assert!(!regions.iter().any(|r| r.contains(solidcore_record::Vec2::new(57.0, 30.0))));
assert!(regions.iter().any(|r| r.contains(solidcore_record::Vec2::new(65.0, 30.0))));
let dxf = run(&mut s, "sheet.export_dxf", json!({}))["dxf"].as_str().unwrap().to_string();
let mut reopened = Session::default();
run(&mut reopened, "sketch.insert_dxf", json!({"text": dxf, "name": "RingBlank"}));
@@ -2582,7 +2586,7 @@ fn ring_cut_preserves_retained_island_through_unfold_and_refold() {
}
fn retained_depth_check(s: &mut Session, want: f64, z0: f64, z1: f64) {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
assert!((volume(s) - want).abs() < 1e-6, "{} vs {want}", volume(s));
let state = s.model.state();
assert_eq!(state.sheets.len(), 1);
@@ -2599,7 +2603,7 @@ fn retained_depth_check(s: &mut Session, want: f64, z0: f64, z1: f64) {
assert!((bounds.min.z - z0).abs() < 1e-8 && (bounds.max.z - z1).abs() < 1e-8, "{bounds:?}");
}
fn depth_step_reopen(s: &mut Session, suffix: &str, want: f64, inside: solidcraft_geom::Vec3, outside: solidcraft_geom::Vec3) {
fn depth_step_reopen(s: &mut Session, suffix: &str, want: f64, inside: solidcore_record::Vec3, outside: solidcore_record::Vec3) {
let path = std::env::temp_dir().join(format!("solidcraft-depth-intersect-{suffix}-{}.step", std::process::id()));
run(s, "file.export", json!({"path":path.to_string_lossy()}));
let mut imported = Session::default();
@@ -2636,7 +2640,7 @@ fn dxf_outline_only(text: &str) -> String {
#[test]
fn partial_depth_intersect_retains_bottom_top_and_middle_material_through_history_and_exports() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
for (offset, z0, z1, layers) in [
(0.0, 0.0, 1.0, vec![("top", 1.0, 2.5)]),
(1.5, 1.5, 2.5, vec![("bottom", 0.0, 1.5)]),
@@ -2684,7 +2688,7 @@ fn partial_depth_intersect_retains_bottom_top_and_middle_material_through_histor
#[test]
fn partial_depth_intersect_preserves_prior_pockets_and_actual_interval_intersections() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let mut s = Session::default();
base(&mut s, 100.0, 60.0);
rectangle_tool(&mut s, "OldPocket", [20.0, 20.0], [25.0, 30.0]);
@@ -2718,7 +2722,7 @@ fn partial_depth_intersect_preserves_prior_pockets_and_actual_interval_intersect
#[test]
fn partial_depth_intersect_keeps_disconnected_tool_islands_and_annular_curves() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let mut s = Session::default();
base(&mut s, 100.0, 60.0);
rectangle_tool(&mut s, "Islands", [20.0, 20.0], [30.0, 30.0]);
@@ -2779,7 +2783,7 @@ fn partial_depth_intersect_of_material_already_removed_by_a_pocket_is_refused()
#[test]
fn partial_depth_intersect_flipped_tool_and_transferred_sheet_keep_depth_side_and_world_pose() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let mut flipped = Session::default();
base(&mut flipped, 100.0, 60.0);
run(&mut flipped, "sketch.create", json!({"name":"FlippedTool","plane":{"origin":[0,0,2.5],"x_dir":[1,0,0],"y_dir":[0,-1,0]}}));
@@ -2836,7 +2840,7 @@ fn partial_depth_intersect_flipped_tool_and_transferred_sheet_keep_depth_side_an
#[test]
fn partial_depth_intersect_full_gauge_in_rotated_frames_does_not_invent_pockets() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
for (angle, translate) in [(37.0, [30.0, 20.0, 10.0]), (121.0, [12345.678, 98765.432, 4321.123])] {
let mut s = Session::default();
base(&mut s, 100.0, 60.0);
@@ -2914,7 +2918,7 @@ fn partial_depth_intersect_full_gauge_in_rotated_frames_does_not_invent_pockets(
#[test]
fn partial_depth_intersect_planar_to_object_retains_current_target_depth() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let mut s = Session::default();
base(&mut s, 100.0, 60.0);
let name = s.model.state().sheets[0].body.clone();
@@ -2962,7 +2966,7 @@ fn partial_depth_intersect_curved_to_object_refuses_unrepresentable_depth_atomic
#[test]
fn partial_depth_intersect_curved_to_object_preserves_current_trimmed_cap_footprint() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let mut s = Session::default();
base(&mut s, 100.0, 60.0);
let name = s.model.state().sheets[0].body.clone();
@@ -3737,7 +3741,7 @@ fn has_round_cutout(f: &Value, c: [f64; 2], r: f64) -> bool {
/// Whether the flat DXF holds the circle of radius `r` about `c` as a `CIRCLE`.
fn dxf_has_circle(s: &mut Session, c: [f64; 2], r: f64) -> bool {
let dxf = run(s, "sheet.export_dxf", json!({}))["dxf"].as_str().unwrap_or_default().to_string();
let centre = solidcraft_geom::Vec2::new(c[0], c[1]);
let centre = solidcore_record::Vec2::new(c[0], c[1]);
solidcraft_io::read_dxf(&dxf)
.unwrap_or_default()
.iter()
@@ -3989,7 +3993,7 @@ fn closed_corners_reach_the_flat_pattern_and_the_dxf() {
#[test]
fn corner_reliefs_of_the_rule_reach_the_part_the_flat_pattern_and_the_dxf() {
use solidcraft_geom::Vec2;
use solidcore_record::Vec2;
// The tray at 72°: its bends meet at the corners of the base, s0 = 3·tan 36° in from the sheet's
// edges, and are BA = 2θ wide in the flat. A relief 8 mm across reaches r = 4 mm along both edges
// and takes, at each corner, r²·π/4 (round) or r² (rectangular) of the base and r of two bends.
@@ -4241,7 +4245,7 @@ fn a_tear_of_the_rule_reaches_the_part_the_flat_pattern_and_the_dxf() {
// The DXF: the outline in straight lines, each cut one of them, and four bend lines.
let dxf = run(&mut s, "sheet.export_dxf", json!({}))["dxf"].as_str().unwrap_or_default().to_string();
assert_eq!(dxf.matches("0\nLINE\n").count(), outline.len() + 4, "{deg}");
let cut_end = solidcraft_geom::Vec2::new(x_end(s0), s0 - ba);
let cut_end = solidcore_record::Vec2::new(x_end(s0), s0 - ba);
let read = solidcraft_io::read_dxf(&dxf).unwrap_or_default();
let at_cut_end = |g: &solidcraft_io::Geom2| matches!(g, solidcraft_io::Geom2::Line(a, b) if a.dist(cut_end) < 1e-6 || b.dist(cut_end) < 1e-6);
assert!(read.iter().any(at_cut_end), "{deg}");
@@ -4317,7 +4321,7 @@ fn two_flange_groups(rule: Value, near: Value, far: Value) -> Session {
/// What the DXF of the flat pattern draws of the corner reliefs: the arcs (centre, radius) and the
/// lines' end points.
fn relief_drawing(s: &mut Session) -> (Vec<(solidcraft_geom::Vec2, f64)>, Vec<solidcraft_geom::Vec2>) {
fn relief_drawing(s: &mut Session) -> (Vec<(solidcore_record::Vec2, f64)>, Vec<solidcore_record::Vec2>) {
let dxf = run(s, "sheet.export_dxf", json!({}))["dxf"].as_str().unwrap_or_default().to_string();
let read = solidcraft_io::read_dxf(&dxf).unwrap_or_default();
let arcs = read.iter().filter_map(|g| if let solidcraft_io::Geom2::Arc { c, a, .. } = g { Some((*c, a.dist(*c))) } else { None }).collect();
@@ -4327,7 +4331,7 @@ fn relief_drawing(s: &mut Session) -> (Vec<(solidcraft_geom::Vec2, f64)>, Vec<so
#[test]
fn each_edge_flange_feature_chooses_the_corner_relief_of_its_own_corners() {
use solidcraft_geom::Vec2;
use solidcore_record::Vec2;
// At 90° the bends of a corner meet at (s0, s0) in from the sheet's edges, s0 = (R + T)·tan 45° = 3,
// and are BA = π/2·(R + K·T) = π wide. A relief d across reaches r = d/2 along both bends and takes,
// at its corner, r²·π/4 (round) or r² (rectangular) of the base and r of each bend, 2 mm thick.
@@ -4373,7 +4377,7 @@ fn each_edge_flange_feature_chooses_the_corner_relief_of_its_own_corners() {
#[test]
fn an_edge_flange_feature_follows_the_rule_for_the_relief_it_leaves_out() {
use solidcraft_geom::Vec2;
use solidcore_record::Vec2;
let s0 = 3.0;
let at = |ends: &[Vec2], x: f64, y: f64| ends.iter().any(|p| p.dist(Vec2::new(x, y)) < 1e-6);
let round8 = json!({"corner_relief_shape": "round", "corner_relief": "8 mm"});
@@ -5445,7 +5449,7 @@ fn fold_fixed_point_must_touch_the_sheet_but_any_face_will_do() {
}
/// The middle of the largest triangle of each flat face of the first body: well inside it.
fn flat_face_points(s: &Session) -> Vec<(usize, solidcraft_geom::Vec3, solidcraft_geom::Vec3)> {
fn flat_face_points(s: &Session) -> Vec<(usize, solidcore_record::Vec3, solidcore_record::Vec3)> {
let state = s.model.state();
let body = &state.bodies[0].body;
let mesh = body.mesh(&solidcraft_kernel::MeshTolerance::chord(0.01)).unwrap();
@@ -5543,7 +5547,7 @@ fn a_hole_drilled_into_a_rim_is_a_bore_the_sheet_keeps_when_it_unfolds() {
assert_eq!(f["bores"].as_array().map(Vec::len), Some(1), "{f}");
assert_eq!(f["cutouts"], json!([]));
let inside = |s: &Session, p: [f64; 3]| {
s.model.state().bodies[0].body.classify_point(solidcraft_geom::Vec3::new(p[0], p[1], p[2])).unwrap() == solidcraft_kernel::PointClass::Inside
s.model.state().bodies[0].body.classify_point(solidcore_record::Vec3::new(p[0], p[1], p[2])).unwrap() == solidcraft_kernel::PointClass::Inside
};
// The flat pattern loses the same bore (the bends unroll to their own length).
let flat_after = unfolded_volume(&mut s);
@@ -5572,7 +5576,7 @@ fn a_rim_hole_in_a_flange_follows_it_into_the_flat_pattern() {
let before = volume(&mut s);
let flat_before = unfolded_volume(&mut s);
let inside = |s: &Session, p: [f64; 3]| {
s.model.state().bodies[0].body.classify_point(solidcraft_geom::Vec3::new(p[0], p[1], p[2])).unwrap() == solidcraft_kernel::PointClass::Inside
s.model.state().bodies[0].body.classify_point(solidcore_record::Vec3::new(p[0], p[1], p[2])).unwrap() == solidcraft_kernel::PointClass::Inside
};
// Halfway up the flange, in the middle of its thickness (whichever way the rule put it).
let mid = [[40.0 - t / 2.0, 15.0], [40.0 - t / 2.0, -15.0], [40.0 + t / 2.0, 15.0], [40.0 + t / 2.0, -15.0]]
@@ -5910,7 +5914,7 @@ fn parted_note(area: f64, at: [f64; 2]) -> String {
}
fn flat_pieces(s: &Session) -> Vec<f64> {
s.model.state().sheets[0].flat_regions().unwrap().iter().map(solidcraft_geom::Region2::area).collect()
s.model.state().sheets[0].flat_regions().unwrap().iter().map(solidcore_record::Region2::area).collect()
}
#[test]
@@ -6048,7 +6052,7 @@ fn flat_exports(s: &mut Session) -> Vec<std::result::Result<Value, String>> {
/// opposite hand's blank, each bend turning the same way, its pocket on the same face.
#[test]
fn a_mirrored_or_patterned_sheet_body_is_sheet_metal_with_its_flat_pattern() {
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
let mut s = Session::default();
run(&mut s, "sheet.manage_rules", json!({"name": "S", "thickness": "2 mm", "active": true, "bend_radius": "2 mm", "k_factor": 0.4}));
base(&mut s, 100.0, 60.0);
@@ -6272,7 +6276,7 @@ fn a_mirrored_sheet_copy_is_the_opposite_hand_with_the_mirror_image_flat_pattern
let in_copy =
|p: [f64; 3]| {
s.model.state().bodies.iter().find(|b| b.name == "Body1 (2)").is_some_and(|b| {
b.body.classify_point(solidcraft_geom::Vec3::new(p[0], p[1], p[2])).unwrap() == solidcraft_kernel::PointClass::Inside
b.body.classify_point(solidcore_record::Vec3::new(p[0], p[1], p[2])).unwrap() == solidcraft_kernel::PointClass::Inside
})
};
assert!(!in_copy([-25.0, 40.0, 1.0]) && in_copy([-35.0, 40.0, 1.0]));
+2 -1
View File
@@ -1,7 +1,8 @@
//! A tightly framed, view-aligned union of the projected body meshes.
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use super::CommandSpec;
use crate::params::bad;
+2 -1
View File
@@ -1,10 +1,11 @@
//! A Single hole at a sketch point follows the point when the sketch changes (#2110), drilled
//! into the face it was placed on, and keeps doing so after the design is saved and reopened.
use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use crate::Session;
+3 -2
View File
@@ -1,8 +1,9 @@
//! Sketch commands: create/edit/finish sketches, draw curves, constraints and dimensions.
use serde_json::{Value, json};
use solidcore_record::{Plane, Vec2, Vec3};
use solidcraft_doc::{FeatureKind, PlaneRef, expr::Kind};
use solidcraft_geom::{Plane, Vec2, Vec3};
use solidcraft_geom::prelude::*;
use solidcraft_sketch::{Analysis, Budget, ConstraintKind, CurveKind, Hold, PointExprs, Sketch, SolveReport, TwoCircles, solve, solve_with};
use super::{CommandSpec, in_sketch};
@@ -3299,7 +3300,7 @@ fn diameter_about(sk: &Sketch, l: usize, ty: &str) -> bool {
fn arc_len(sk: &Sketch, c: usize) -> Option<f64> {
match sk.segs(c).first()? {
solidcraft_geom::Seg2::Arc { radius, sweep, .. } if matches!(sk.curves.get(c)?.kind, CurveKind::Arc { .. }) => Some(radius * sweep),
solidcore_record::Seg2::Arc { radius, sweep, .. } if matches!(sk.curves.get(c)?.kind, CurveKind::Arc { .. }) => Some(radius * sweep),
_ => None,
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
//! point, and usable as sweep and pipe paths.
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_sketch::WireSpace;
use super::sketch::edit;
@@ -1,6 +1,7 @@
use crate::Session;
use serde_json::{Value, json};
use solidcraft_geom::Vec3;
use solidcore_record::Vec3;
use solidcraft_geom::prelude::*;
use solidcraft_sketch::WireSpace;
fn run(s: &mut Session, cmd: &str, params: Value) -> Value {
@@ -3,7 +3,8 @@
//! reported in `created`, and left out of profiles. A real curve with that id wins.
use serde_json::{Value, json};
use solidcraft_geom::{Vec2, Vec3};
use solidcore_record::{Vec2, Vec3};
use solidcraft_geom::prelude::*;
use solidcraft_sketch::{CurveKind, LinkSource, Sketch};
use crate::Session;
+2 -1
View File
@@ -1,8 +1,9 @@
//! Canvases (reference images on planes) and decals (images on planar faces).
use serde_json::{Value, json};
use solidcore_record::Vec2;
use solidcraft_doc::canvas::{Canvas, MAX_CANVAS_BYTES, base64_decode, base64_encode, image_info};
use solidcraft_geom::Vec2;
use solidcraft_geom::prelude::*;
use super::CommandSpec;
use crate::params::{bad, bool_, num, str_, vec2};
@@ -4,7 +4,7 @@
//! acceptance criteria the reporter's manual tool path needed.
use serde_json::{Value, json};
use solidcraft_geom::Vec2;
use solidcore_record::Vec2;
use crate::Session;
@@ -5,7 +5,8 @@
//! reopening.
use serde_json::{Value, json};
use solidcraft_geom::Vec2;
use solidcore_record::Vec2;
use solidcraft_geom::prelude::*;
use crate::Session;
@@ -153,12 +154,12 @@ fn a_tube_keeps_its_bore_when_its_inner_diameter_changes() {
assert!((volume / (100.0 * area) - 1.0).abs() < 0.001, "{m}");
let body = &s.model.state().bodies[0].body;
assert_eq!(
body.classify_point(solidcraft_geom::Vec3::new(0.0, 0.0, 50.0)).unwrap(),
body.classify_point(solidcore_record::Vec3::new(0.0, 0.0, 50.0)).unwrap(),
solidcraft_kernel::PointClass::Outside,
"the bore stays empty"
);
assert_eq!(
body.classify_point(solidcraft_geom::Vec3::new(inner + 5.0, 0.0, 50.0)).unwrap(),
body.classify_point(solidcore_record::Vec3::new(inner + 5.0, 0.0, 50.0)).unwrap(),
solidcraft_kernel::PointClass::Inside,
"the wall stays solid"
);
+2 -1
View File
@@ -8,7 +8,8 @@
use std::collections::BTreeMap;
use serde_json::{Value, json};
use solidcraft_geom::{Aabb2, Vec2};
use solidcore_record::Vec2;
use solidcraft_geom::Aabb2;
use solidcraft_sketch::{ConstraintKind, CurveKind, LinkKind, LinkSource, Sketch};
use super::sketch::edit;
@@ -1,5 +1,6 @@
use serde_json::{Value, json};
use solidcraft_geom::Vec2;
use solidcore_record::Vec2;
use solidcraft_geom::prelude::*;
use solidcraft_sketch::{ConstraintKind, CurveKind, LinkKind, Sketch};
use crate::{Sel, Session};

Some files were not shown because too many files have changed in this diff Show More