Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

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

jyvikodc38349cbfe0
diff --git a/Cargo.lock b/Cargo.lock
index efcd6f5dac..6c3be32fa5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4059,6 +4059,16 @@ dependencies = [
"thiserror 2.0.21",
]
+[[package]]
+name = "solidcore-record"
+version = "0.1.0"
+source = "git+https://github.com/tangency-labs/solidcore?rev=f5e8e9a29e0c9b7cf6c4040a5bc8878382b3c62f#f5e8e9a29e0c9b7cf6c4040a5bc8878382b3c62f"
+dependencies = [
+ "serde",
+ "serde_json",
+ "thiserror 2.0.21",
+]
+
[[package]]
name = "solidcraft"
version = "0.40.0-rc.1"
@@ -4107,6 +4117,7 @@ dependencies = [
"image",
"log",
"serde_json",
+ "solidcore-record",
"solidcraft-engine",
"solidcraft-gpu",
"solidcraft-kernel",
@@ -4130,6 +4141,7 @@ dependencies = [
"serde",
"serde_json",
"sha2 0.10.9",
+ "solidcore-record",
"solidcraft-derive",
"solidcraft-geom",
"solidcraft-kernel",
@@ -4150,6 +4162,7 @@ dependencies = [
"serde",
"serde_json",
"serde_path_to_error",
+ "solidcore-record",
"solidcraft-doc",
"solidcraft-geom",
"solidcraft-io",
@@ -4168,6 +4181,7 @@ version = "0.40.0-rc.1"
dependencies = [
"serde",
"serde_json",
+ "solidcore-record",
"thiserror 2.0.21",
]
@@ -4182,6 +4196,7 @@ dependencies = [
"robust",
"serde",
"serde_json",
+ "solidcore-record",
"solidcraft-engine",
"solidcraft-geom",
"solidcraft-io",
@@ -4208,6 +4223,7 @@ dependencies = [
"serde",
"serde_json",
"sha2 0.10.9",
+ "solidcore-record",
"solidcraft-doc",
"solidcraft-geom",
"solidcraft-kernel",
@@ -4226,6 +4242,7 @@ dependencies = [
"rayon",
"serde",
"serde_json",
+ "solidcore-record",
"solidcraft-geom",
"solidcraft-profile",
"solidcraft-smlib",
@@ -4263,6 +4280,7 @@ dependencies = [
"serde",
"serde_json",
"sha2 0.10.9",
+ "solidcore-record",
"solidcraft-geom",
"web-time",
"weezl",
@@ -4275,6 +4293,7 @@ dependencies = [
"harfrust",
"serde",
"serde_json",
+ "solidcore-record",
"solidcraft-geom",
"thiserror 2.0.21",
"ttf-parser",
@@ -4289,6 +4308,7 @@ dependencies = [
"log",
"serde_json",
"solidcore",
+ "solidcore-record",
"solidcraft-geom",
"solidcraft-profile",
]
@@ -4304,6 +4324,7 @@ dependencies = [
name = "solidcraft-step"
version = "0.40.0-rc.1"
dependencies = [
+ "solidcore-record",
"solidcraft-geom",
"solidcraft-profile",
]
@@ -4329,6 +4350,7 @@ dependencies = [
"serde",
"serde_json",
"sha2 0.10.9",
+ "solidcore-record",
"solidcraft-engine",
"solidcraft-gpu",
"solidcraft-space-mouse",
diff --git a/Cargo.toml b/Cargo.toml
index b1319b4d2c..328440f10c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,6 +36,9 @@ solidcraft-3dx-client = { path = "crates/threedx-client" }
# local checkout, add `[patch."https://github.com/tangency-labs/solidcore"] solidcore = { path =
# "../solidcore/crates/solidcore" }` to a `.cargo/config.toml` outside the repository.
solidcore = { git = "https://github.com/tangency-labs/solidcore", rev = "8ddce901671f1cebd9214a31d21895d725e886c8" }
+# Geometry as data (solidcore's layers §1, "Record"): the B-rep record, its structural validation
+# and the native body file. Pinned like solidcore; for a local checkout, patch it as above.
+solidcore-record = { git = "https://github.com/tangency-labs/solidcore", rev = "f5e8e9a29e0c9b7cf6c4040a5bc8878382b3c62f" }
# test tooling: a dev-dependency only (xtask/src/layers.rs)
solidcraft-testkit = { path = "crates/testkit" }
diff --git a/apps/solidcraft-cli/Cargo.toml b/apps/solidcraft-cli/Cargo.toml
index 3e97990023..e06584e273 100644
--- a/apps/solidcraft-cli/Cargo.toml
+++ b/apps/solidcraft-cli/Cargo.toml
@@ -28,6 +28,7 @@ raytrace-cpu = ["solidcraft-engine/raytrace-cpu"]
profile = ["solidcraft-engine/profile"]
[dependencies]
+solidcore-record = { workspace = true }
solidcraft-engine = { workspace = true }
solidcraft-gpu = { workspace = true }
solidcraft-mcp = { workspace = true }
diff --git a/apps/solidcraft-cli/src/kernel_cases.rs b/apps/solidcraft-cli/src/kernel_cases.rs
index 47fe521312..d320b3a6e0 100644
--- a/apps/solidcraft-cli/src/kernel_cases.rs
+++ b/apps/solidcraft-cli/src/kernel_cases.rs
@@ -5,6 +5,7 @@
//! are never compared with each other. See tests/kernel-cases/README.md.
use serde_json::{Value, json};
+use solidcraft_engine::geom::prelude::*;
use crate::oracle::{ABS_FRAC, Checks, REL_TOL, totals, v3};
use crate::{read_json, recipe};
@@ -62,10 +63,10 @@ const MESH_TOL: f64 = 0.01;
/// A mesh's edges used by one triangle only (open) and by more than two (over-shared). Vertices
/// closer than `weld` (mm) are one vertex: a mesh repeats a vertex for each face, and faces
/// meeting at an edge may place it a rounding error apart.
-fn open_edges(positions: &[solidcraft_engine::geom::Vec3], triangles: &[[u32; 3]], weld: f64) -> (usize, usize) {
+fn open_edges(positions: &[solidcore_record::Vec3], triangles: &[[u32; 3]], weld: f64) -> (usize, usize) {
use std::collections::HashMap;
let weld = if weld.is_finite() && weld > 0.0 { weld } else { 1e-4 };
- let cell = |p: &solidcraft_engine::geom::Vec3| [p.x, p.y, p.z].map(|x| (x / weld).floor() as i64);
+ let cell = |p: &solidcore_record::Vec3| [p.x, p.y, p.z].map(|x| (x / weld).floor() as i64);
// Union-find over positions, joining each vertex with any within `weld` in the 27 cells round it.
let mut parent: Vec<usize> = (0..positions.len()).collect();
fn find(parent: &mut [usize], mut i: usize) -> usize {
@@ -125,7 +126,7 @@ const SEAM_ANGLE_DEG: f64 = 1.0;
/// the patch's boundary, where its neighbours' own G1 seams end and no surface is G2 to both),
/// with how many seams and stations clear there were. An error where the seams can't be measured.
fn curvature_jumps(body: &solidcraft_engine::kernel::Body, near: [f64; 3], within: f64, clear: f64) -> Result<Value, String> {
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
let tol =
solidcraft_engine::kernel::ContinuityTolerances { gap_mm: 1e-3, angle_deg: SEAM_ANGLE_DEG, curvature_per_mm: 0.0, ..Default::default() };
let report = solidcraft_engine::kernel::seam_diagnostics(body, &[], SEAM_SAMPLES, tol).map_err(|e| e.to_string())?;
@@ -182,7 +183,7 @@ fn continuity_seams(b: &solidcraft_engine::doc::ModelBody, edges: &Value) -> Res
if let Some(points) = edges.as_array() {
let picks = points
.iter()
- .map(|p| v3(p).map(|[x, y, z]| solidcraft_engine::kernel::EdgePick::Point(solidcraft_engine::geom::Vec3::new(x, y, z))))
+ .map(|p| v3(p).map(|[x, y, z]| solidcraft_engine::kernel::EdgePick::Point(solidcore_record::Vec3::new(x, y, z))))
.collect::<Option<Vec<_>>>()
.ok_or("continuity `edges` points must each be [x,y,z]")?;
let picked = solidcraft_engine::kernel::pick_edges(&b.body, &picks).map_err(|e| e.to_string())?;
@@ -480,8 +481,8 @@ fn output_checks(c: &mut Checks, want: &Value, out: &str, results: &[Value], rel
/// The word a `surface_types` check names a face's surface by, as the record holds it: an
/// analytic kind, `ball_patch` (a corner's patch on a sphere), `bspline` (a B-spline or NURBS
/// surface) or `revolution` (a revolved curve).
-fn surface_word(s: &solidcraft_engine::geom::brep::Surface) -> &'static str {
- use solidcraft_engine::geom::brep::Surface as S;
+fn surface_word(s: &solidcore_record::brep::Surface) -> &'static str {
+ use solidcore_record::brep::Surface as S;
match s {
S::Plane { .. } | S::PlaneThrough { .. } => "plane",
S::Cylinder { .. } => "cylinder",
@@ -497,8 +498,8 @@ fn surface_word(s: &solidcraft_engine::geom::brep::Surface) -> &'static str {
/// A B-spline face's two directions as `[degree, spans]` (spans: the distinct knot intervals of
/// the modelled range), the lower first, so a surface parameterised the other way round reads the
/// same. `None` for a surface that is not a B-spline.
-fn spline_shape(s: &solidcraft_engine::geom::brep::Surface) -> Option<[[u64; 2]; 2]> {
- use solidcraft_engine::geom::brep::Surface as S;
+fn spline_shape(s: &solidcore_record::brep::Surface) -> Option<[[u64; 2]; 2]> {
+ use solidcore_record::brep::Surface as S;
let (u, v, nu, nv) = match s {
S::Spline { u_knots, v_knots, points } => (u_knots, v_knots, points.len(), points.first().map_or(0, Vec::len)),
S::RationalSpline { u_knots, v_knots, homogeneous } => (u_knots, v_knots, homogeneous.len(), homogeneous.first().map_or(0, Vec::len)),
@@ -553,7 +554,7 @@ const CONSTRUCT_DIR_TOL: f64 = 1e-6;
/// parallel to `normal` (either way) and which passes within `tol` of `through`. An axis or plane
/// is graded as the line or plane it is, never by the origin it happens to keep.
fn check_construction(s: &solidcraft_engine::Session, want: &Value, tol: f64, c: &mut Checks) {
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
use solidcraft_engine::view::{construction_axes, construction_planes, construction_points};
let Some(named) = want.as_object() else {
c.push("construction", json!("`construction` must map names to {point} | {axis} | {plane}"), json!("an object"), false);
@@ -1071,7 +1072,7 @@ mod tests {
/// either order of directions, spans only where given, and every face must be accounted for.
#[test]
fn splines_match_degrees_and_spans_in_either_order() {
- use solidcraft_engine::geom::brep::Surface;
+ use solidcore_record::brep::Surface;
let knots = |p: usize, spans: usize| -> Vec<f64> {
let mut k = vec![0.0; p + 1];
k.extend((1..spans).map(|i| i as f64));
diff --git a/apps/solidcraft-cli/src/oracle.rs b/apps/solidcraft-cli/src/oracle.rs
index c27b102c80..dace772d0c 100644
--- a/apps/solidcraft-cli/src/oracle.rs
+++ b/apps/solidcraft-cli/src/oracle.rs
@@ -5,7 +5,7 @@
#![allow(clippy::needless_range_loop)]
use serde_json::{Value, json};
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
use crate::spatial::{self, Tri};
use crate::{read_json, recipe};
diff --git a/apps/solidcraft-cli/tests/action_matrix.rs b/apps/solidcraft-cli/tests/action_matrix.rs
index 1a5029642c..cacfc68940 100644
--- a/apps/solidcraft-cli/tests/action_matrix.rs
+++ b/apps/solidcraft-cli/tests/action_matrix.rs
@@ -21,6 +21,7 @@
//! Each design runs in a child process (this test binary, [`action_matrix_worker`]) so an action
//! that hangs or aborts is recorded as such and the rest of the design still runs.
+use solidcraft_engine::geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
use std::io::{BufRead, Write};
use std::path::{Path, PathBuf};
@@ -28,10 +29,10 @@ use std::process::{Command, Stdio};
use std::time::{Duration, Instant};
use serde_json::{Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::Session;
use solidcraft_engine::doc::kernel::{FaceSurface, face_surface};
use solidcraft_engine::doc::{FaceAttachmentStatus, ModelBody, naming};
-use solidcraft_engine::geom::Vec3;
/// One in this many actions runs on pull requests (by a stable hash of its key).
const PR_SAMPLE: u64 = 40;
@@ -1656,7 +1657,7 @@ impl TipConstruction {
other => panic!("expected an axis, got {other:?}"),
}
}
- fn plane(&self) -> solidcraft_engine::geom::Plane {
+ fn plane(&self) -> solidcore_record::Plane {
match &self.0 {
solidcraft_engine::doc::construct::ConstructGeom::Plane(p) => *p,
other => panic!("expected a plane, got {other:?}"),
diff --git a/apps/solidcraft-cli/tests/bracket_example.rs b/apps/solidcraft-cli/tests/bracket_example.rs
index 3a028e04d3..d0da8187a7 100644
--- a/apps/solidcraft-cli/tests/bracket_example.rs
+++ b/apps/solidcraft-cli/tests/bracket_example.rs
@@ -4,7 +4,7 @@
use std::f64::consts::PI;
use serde_json::Value;
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_engine::{Session, io, kernel};
fn assert_two_through_holes(session: &Session, stage: &str) {
diff --git a/apps/solidcraft-cli/tests/design_corpus.rs b/apps/solidcraft-cli/tests/design_corpus.rs
index 957eef5d61..a6fe941ced 100644
--- a/apps/solidcraft-cli/tests/design_corpus.rs
+++ b/apps/solidcraft-cli/tests/design_corpus.rs
@@ -2,6 +2,7 @@
//! the current format and evaluate (what they rebuild to today is today's, not what the build
//! that saved them made); damaged and hostile design files never panic.
+use solidcraft_engine::geom::prelude::*;
use std::path::{Path, PathBuf};
use serde_json::{Value, json};
diff --git a/apps/solidcraft-cli/tests/naming_corpus.rs b/apps/solidcraft-cli/tests/naming_corpus.rs
index a78e005089..bb43fbe8b5 100644
--- a/apps/solidcraft-cli/tests/naming_corpus.rs
+++ b/apps/solidcraft-cli/tests/naming_corpus.rs
@@ -16,13 +16,14 @@
//! designs, the engine's design fixtures and the older designs kept by the hole matrix, taper
//! and projection tests.
+use solidcraft_engine::geom::prelude::*;
use std::path::{Path, PathBuf};
use std::process::Command;
use serde_json::{Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::Session;
use solidcraft_engine::doc::{FaceAttachmentStatus, Feature, FeatureKind, ModelBody, ModelState, PlaneRef, naming};
-use solidcraft_engine::geom::Vec3;
fn root() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("../..").canonicalize().unwrap()
diff --git a/apps/solidcraft-cli/tests/rebuild_topology.rs b/apps/solidcraft-cli/tests/rebuild_topology.rs
index ec508dac8e..4fce828990 100644
--- a/apps/solidcraft-cli/tests/rebuild_topology.rs
+++ b/apps/solidcraft-cli/tests/rebuild_topology.rs
@@ -9,6 +9,7 @@ use std::path::{Path, PathBuf};
use serde_json::{Value, json};
use solidcraft_engine::Session;
use solidcraft_engine::doc::kernel::{FaceSurface, face_surface};
+use solidcraft_engine::geom::prelude::*;
fn root() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("../..").canonicalize().unwrap()
diff --git a/apps/solidcraft-cli/tests/snapshot_camera.rs b/apps/solidcraft-cli/tests/snapshot_camera.rs
index f5ad66ab95..b7d6556316 100644
--- a/apps/solidcraft-cli/tests/snapshot_camera.rs
+++ b/apps/solidcraft-cli/tests/snapshot_camera.rs
@@ -288,7 +288,7 @@ fn a_snapshot_shows_the_part_where_the_camera_puts_it() {
let vp = c.view_proj(f64::from(SIZE.0) / f64::from(SIZE.1), 1000.0);
let (mut elo, mut ehi) = ([f64::MAX; 2], [f64::MIN; 2]);
for k in 0..8 {
- let p = solidcraft_engine::geom::Vec3::new(
+ let p = solidcore_record::Vec3::new(
corner[0] + size[0] * f64::from(k & 1),
corner[1] + size[1] * f64::from((k >> 1) & 1),
corner[2] + size[2] * f64::from((k >> 2) & 1),
diff --git a/apps/solidcraft-cli/tests/straight_edges_after_cuts.rs b/apps/solidcraft-cli/tests/straight_edges_after_cuts.rs
index 581259e57c..9aa993cc60 100644
--- a/apps/solidcraft-cli/tests/straight_edges_after_cuts.rs
+++ b/apps/solidcraft-cli/tests/straight_edges_after_cuts.rs
@@ -5,13 +5,14 @@
//! vertices nothing else used, so an edge that is one straight line was drawn (and lit on hover)
//! as many pieces, and a sketch on such a face projected every piece.
+use solidcraft_engine::geom::prelude::*;
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Session;
use solidcraft_engine::doc::kernel::{FaceSurface, face_surface};
-use solidcraft_engine::geom::Vec3;
fn design() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../tests/action_matrix/designs/crazy-geom-cuts.sc")
diff --git a/assets/icons/ui/source/navigation.rs b/assets/icons/ui/source/navigation.rs
index 2a4ac4c00d..986be3e3cc 100644
--- a/assets/icons/ui/source/navigation.rs
+++ b/assets/icons/ui/source/navigation.rs
@@ -1,7 +1,8 @@
//! Navigation drawing definitions. Camera projection and picking remain in the UI widgets.
use crate::theme::Tokens;
use egui::{Color32, FontId, Pos2, Rect, Shape, Stroke, pos2, vec2};
-use solidcraft_engine::geom::{Ring, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_engine::geom::Ring;
pub(crate) struct Facet {
pub(crate) direction: Vec3,
pub(crate) points: Ring<Pos2>,
diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml
index 8093414b36..4af383d323 100644
--- a/crates/doc/Cargo.toml
+++ b/crates/doc/Cargo.toml
@@ -9,6 +9,7 @@ license.workspace = true
workspace = true
[dependencies]
+solidcore-record = { workspace = true }
solidcraft-geom = { workspace = true }
solidcraft-sketch = { workspace = true }
solidcraft-kernel = { workspace = true }
diff --git a/crates/doc/src/appearance.rs b/crates/doc/src/appearance.rs
index 574b4200a5..69f9f9467d 100644
--- a/crates/doc/src/appearance.rs
+++ b/crates/doc/src/appearance.rs
@@ -3,10 +3,11 @@
//! a component's over the physical material's look; a body with none of these keeps the colour
//! it was imported with.
+use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::Document;
diff --git a/crates/doc/src/assembly.rs b/crates/doc/src/assembly.rs
index 0e82f21852..fb567ecf39 100644
--- a/crates/doc/src/assembly.rs
+++ b/crates/doc/src/assembly.rs
@@ -9,7 +9,8 @@
//! and the engine maps a new feature's geometry into the active component's frame.
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Plane, Vec3};
+use solidcore_record::{Plane, Vec3};
+use solidcraft_geom::prelude::*;
use crate::{DocError, Document, FeatureKind, PlaneRef, Result};
diff --git a/crates/doc/src/body_transfer_sheet.rs b/crates/doc/src/body_transfer_sheet.rs
index 5a07847817..82c274c664 100644
--- a/crates/doc/src/body_transfer_sheet.rs
+++ b/crates/doc/src/body_transfer_sheet.rs
@@ -1,5 +1,6 @@
//! World-frame metadata at a timeline body ownership boundary.
-use solidcraft_geom::Plane;
+use solidcore_record::Plane;
+use solidcraft_geom::prelude::*;
use crate::{DocError, Mat, ModelState, Result, apply_point, apply_vector};
diff --git a/crates/doc/src/canvas.rs b/crates/doc/src/canvas.rs
index e1d0fbb92c..dd52be0316 100644
--- a/crates/doc/src/canvas.rs
+++ b/crates/doc/src/canvas.rs
@@ -2,7 +2,8 @@
//! The image bytes travel inside the design file (base64), so it reopens without the original.
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Plane, Vec2, Vec3};
+use solidcore_record::{Plane, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::PlaneRef;
diff --git a/crates/doc/src/config_certificates.rs b/crates/doc/src/config_certificates.rs
index da5b3413a7..5c0fce1ea9 100644
--- a/crates/doc/src/config_certificates.rs
+++ b/crates/doc/src/config_certificates.rs
@@ -1,7 +1,8 @@
//! Certificates are producer identities, never a nearest-surface selection.
use crate::{DocError, Document, FeatureKind, ModelBody, Result, SolvedSketch};
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Seg2;
+use solidcore_record::Seg2;
+use solidcraft_geom::prelude::*;
fn valid_signature(outer: &[String], holes: &[Vec<String>]) -> bool {
let valid = |ids: &[String]| {
@@ -68,11 +69,11 @@ pub(crate) fn cap_key(outer: &[String], holes: &[Vec<String>]) -> String {
}
format!("{:x}", hash.finalize())
}
-fn exact_region_signature(curves: &ExactSketchCurves, region: &solidcraft_geom::Region2) -> Option<solidcraft_kernel::CapSignature> {
+fn exact_region_signature(curves: &ExactSketchCurves, region: &solidcore_record::Region2) -> Option<solidcraft_kernel::CapSignature> {
if region.outer.segs.len() + region.holes.iter().map(|hole| hole.segs.len()).sum::<usize>() > 4096 || region.holes.len() > 128 {
return None;
}
- let signature = |outline: &solidcraft_geom::Loop2| {
+ let signature = |outline: &solidcore_record::Loop2| {
let mut ids = outline.segs.iter().map(|segment| curves.find(segment)).collect::<Option<Vec<_>>>()?;
ids.sort();
ids.dedup();
@@ -116,7 +117,7 @@ pub(crate) fn extrude_cap_bindings(sketch: &SolvedSketch, bodies: &[solidcraft_k
let mut counts = std::collections::BTreeMap::new();
let mut bindings = Vec::with_capacity(bodies.len());
for body in bodies {
- let mut cached: Option<(&solidcraft_geom::Region2, Option<solidcraft_kernel::CapSignature>)> = None;
+ let mut cached: Option<(&solidcore_record::Region2, Option<solidcraft_kernel::CapSignature>)> = None;
let mut values = Vec::new();
for source in body.face_sources().into_iter().flatten() {
let signature = if let Some(FaceSource::ExtrudeCap { region, high, .. }) = source {
@@ -614,7 +615,7 @@ fn exact_segment_contains(original: &Seg2, generated: &Seg2) -> bool {
(Seg2::Line { a, b }, Seg2::Line { a: c, b: d }) => {
let direction = *b - *a;
let scale = direction.len().max((*d - *c).len()).max(1.);
- let interval = |point: solidcraft_geom::Vec2| {
+ let interval = |point: solidcore_record::Vec2| {
let t = (point - *a).dot(direction) / direction.len2();
(-1e-10..=1. + 1e-10).contains(&t)
};
@@ -650,7 +651,12 @@ fn exact_segment_contains(original: &Seg2, generated: &Seg2) -> bool {
}
impl Document {
- pub fn configuration_face_target(&self, body: &ModelBody, index: usize, point: solidcraft_geom::Vec3) -> Result<crate::config::ConfigFaceTarget> {
+ pub fn configuration_face_target(
+ &self,
+ body: &ModelBody,
+ index: usize,
+ point: solidcore_record::Vec3,
+ ) -> Result<crate::config::ConfigFaceTarget> {
let names = crate::naming::face_names(body);
let mut name = names
.get(index)
@@ -719,7 +725,7 @@ impl Document {
certificate.validate()?;
Ok(Some(certificate))
}
- pub fn strong_face_target(&self, body: &ModelBody, index: usize, point: solidcraft_geom::Vec3) -> Result<crate::config::ConfigFaceTarget> {
+ pub fn strong_face_target(&self, body: &ModelBody, index: usize, point: solidcore_record::Vec3) -> Result<crate::config::ConfigFaceTarget> {
let mut target = self.configuration_face_target(body, index, point)?;
match body.body.face_sources().and_then(|sources| sources.get(index)).and_then(Option::as_ref) {
Some(solidcraft_kernel::FaceSource::Box { producer: Some(producer), axis, high, .. }) => {
@@ -752,27 +758,27 @@ impl Document {
/// is), projected onto it. A face that moves along its normal keeps the frame where it was;
/// one that moves within its plane (a Move feature) keeps it too, as a sketch on a face does
/// in the definition's coordinates.
-pub fn lineage_frame(body: &ModelBody, plane: &solidcraft_geom::Plane) -> Option<solidcraft_geom::Plane> {
- use solidcraft_geom::Vec3;
+pub fn lineage_frame(body: &ModelBody, plane: &solidcore_record::Plane) -> Option<solidcore_record::Plane> {
+ use solidcore_record::Vec3;
let n = plane.normal();
let m = &body.source_transform;
let origin = crate::apply_point(m, Vec3::ZERO);
let axis = [Vec3::X, Vec3::Y, Vec3::Z].into_iter().filter_map(|a| crate::apply_vector(m, a).normalized()).find(|a| a.dot(n).abs() < 0.6)?;
let x = axis - n * axis.dot(n);
let origin = origin - n * (origin - plane.origin).dot(n);
- solidcraft_geom::Plane::new(origin, x, n.cross(x))
+ solidcore_record::Plane::new(origin, x, n.cross(x))
}
/// Whether Split Face split `body`'s faces on `plane` (a split line lies on it).
-fn split_on_purpose(body: &ModelBody, plane: &solidcraft_geom::Plane) -> bool {
+fn split_on_purpose(body: &ModelBody, plane: &solidcore_record::Plane) -> bool {
let tolerance = 1e-6 * (1. + body.body.size());
let on_plane =
- |line: &Vec<solidcraft_geom::Vec3>| !line.is_empty() && line.iter().all(|p| (*p - plane.origin).dot(plane.normal()).abs() <= tolerance);
+ |line: &Vec<solidcore_record::Vec3>| !line.is_empty() && line.iter().all(|p| (*p - plane.origin).dot(plane.normal()).abs() <= tolerance);
body.body.split_lines().is_some_and(|lines| lines.iter().any(on_plane))
}
/// Whether two exact planes are one oriented plane (pieces of one face).
-fn same_oriented_plane(a: &solidcraft_geom::Plane, b: &solidcraft_geom::Plane, scale: f64) -> bool {
+fn same_oriented_plane(a: &solidcore_record::Plane, b: &solidcore_record::Plane, scale: f64) -> bool {
a.normal().dot(b.normal()) >= 1. - 1e-8 && (b.origin - a.origin).dot(a.normal()).abs() <= 1e-7 * (1. + scale)
}
@@ -780,7 +786,7 @@ impl Document {
/// The exact plane an anchor on face `index` of `body` is measured in: the construction
/// certificate's plane, or for a [`FaceCertificate::Lineage`] face its current exact plane in
/// the [`lineage_frame`].
- pub fn anchor_face_plane(&self, body: &ModelBody, index: usize, certificate: Option<&FaceCertificate>) -> Option<solidcraft_geom::Plane> {
+ pub fn anchor_face_plane(&self, body: &ModelBody, index: usize, certificate: Option<&FaceCertificate>) -> Option<solidcore_record::Plane> {
match certificate {
Some(FaceCertificate::Lineage) => body.body.planar_face(index).and_then(|plane| lineage_frame(body, &plane)),
_ => body.body.face_plane(index),
@@ -796,7 +802,7 @@ impl Document {
&self,
body: &ModelBody,
index: usize,
- point: solidcraft_geom::Vec3,
+ point: solidcore_record::Vec3,
) -> Option<crate::config::ConfigFaceTarget> {
let names = crate::naming::names(body);
if !names.verified(index) {
@@ -955,7 +961,7 @@ mod tests {
SolvedSketch {
feature: 1,
name: "sources".into(),
- plane: solidcraft_geom::Plane::XY,
+ plane: solidcore_record::Plane::XY,
sketch,
report,
profiles: Vec::new(),
@@ -990,7 +996,7 @@ mod tests {
#[test]
fn prepared_sources_keep_exact_identity_and_reject_ambiguity() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
let mut sketch = solidcraft_sketch::Sketch::new();
sketch.add_line(Vec2::ZERO, Vec2::new(10., 0.), None, None, Some("line")).unwrap();
sketch.add_circle(Vec2::new(20., 0.), 2., None, Some("circle")).unwrap();
@@ -1015,7 +1021,7 @@ mod tests {
#[test]
fn a_curve_drawn_over_a_projected_boundary_is_the_source() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
// A face sketch's live boundary, with a profile edge traced over it (issue #489).
let mut sketch = solidcraft_sketch::Sketch::new();
let projected = sketch.add_line(Vec2::ZERO, Vec2::new(10., 0.), None, None, Some("edge")).unwrap();
@@ -1039,7 +1045,7 @@ mod tests {
#[test]
#[ignore = "manual optimized certification microbenchmark; no timing assertion"]
fn benchmark_prepared_extrude_sources() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
let mut sketch = solidcraft_sketch::Sketch::new();
for i in 0..1000 {
let y = i as f64;
@@ -1092,7 +1098,7 @@ mod tests {
#[test]
fn analytic_arc_interval_refuses_unsampled_gaps_and_accepts_wrap_reversal() {
let radians = |degrees: f64| degrees.to_radians();
- let arc = |start, sweep| Seg2::Arc { center: solidcraft_geom::Vec2::default(), radius: 10., start: radians(start), sweep: radians(sweep) };
+ let arc = |start, sweep| Seg2::Arc { center: solidcore_record::Vec2::default(), radius: 10., start: radians(start), sweep: radians(sweep) };
assert!(!exact_segment_contains(&arc(10., 350.), &arc(20., 360.)), "five point probes missed the missing ten-degree gap");
assert!(!exact_segment_contains(&arc(10., 350.), &arc(20., -360.)));
assert!(exact_segment_contains(&arc(350., 40.), &arc(355., 20.)));
diff --git a/crates/doc/src/config_clone.rs b/crates/doc/src/config_clone.rs
index c85eed89e4..0860271d66 100644
--- a/crates/doc/src/config_clone.rs
+++ b/crates/doc/src/config_clone.rs
@@ -142,7 +142,7 @@ mod tests {
body: "Old".into(),
origin_feature: 3,
name: "F3:+z".into(),
- point: solidcraft_geom::Vec3::new(1., 1., 2.),
+ point: solidcore_record::Vec3::new(1., 1., 2.),
certificate: None,
}),
],
@@ -199,7 +199,7 @@ mod tests {
body: "Foreign".into(),
origin_feature: 3,
name: "F3:+z".into(),
- point: solidcraft_geom::Vec3::ZERO,
+ point: solidcore_record::Vec3::ZERO,
certificate: None,
}),
],
diff --git a/crates/doc/src/config_shell_tests.rs b/crates/doc/src/config_shell_tests.rs
index 06cd00f778..5333ac9b1e 100644
--- a/crates/doc/src/config_shell_tests.rs
+++ b/crates/doc/src/config_shell_tests.rs
@@ -1,7 +1,7 @@
use super::*;
use crate::{FeatureKind, Model, PlaneRef};
use serde_json::json;
-use solidcraft_geom::{Vec2, Vec3};
+use solidcore_record::{Vec2, Vec3};
fn shell_document() -> (Document, u64, u64) {
let mut doc = Document::new("certified shell");
@@ -43,15 +43,15 @@ fn face_index(body: &ModelBody, inner: bool) -> usize {
#[test]
fn shell_planar_raw_bounds_flat_identity_and_clone_remap() {
- let plane = solidcraft_geom::Plane::XY;
- let same = |planes: &[Option<solidcraft_geom::Plane>]| super::super::styles::shell_plane_family(planes.iter().copied());
+ let plane = solidcore_record::Plane::XY;
+ let same = |planes: &[Option<solidcore_record::Plane>]| super::super::styles::shell_plane_family(planes.iter().copied());
assert!(same(&[Some(plane), Some(plane)]));
assert!(!same(&[]));
assert!(!same(&[Some(plane), None]));
for different in [
- solidcraft_geom::Plane { origin: Vec3::X, ..plane },
- solidcraft_geom::Plane { x: -plane.x, y: -plane.y, ..plane },
- solidcraft_geom::Plane { y: -plane.y, ..plane },
+ solidcore_record::Plane { origin: Vec3::X, ..plane },
+ solidcore_record::Plane { x: -plane.x, y: -plane.y, ..plane },
+ solidcore_record::Plane { y: -plane.y, ..plane },
] {
assert!(!same(&[Some(plane), Some(different)]));
}
@@ -355,7 +355,7 @@ fn saved_curved_strip_projection_asks_for_its_face_again_after_exact_wall_coales
sketch.add_link(LinkKind::Project, source, &geometry).unwrap();
sketch.links[0].face_name = Some(former);
let sk = doc
- .add_feature(FeatureKind::Sketch { plane: PlaneRef::Custom { plane: solidcraft_geom::Plane::YZ }, sketch }, Some("Saved corner strip"))
+ .add_feature(FeatureKind::Sketch { plane: PlaneRef::Custom { plane: solidcore_record::Plane::YZ }, sketch }, Some("Saved corner strip"))
.unwrap();
let boss = doc
.add_feature(
@@ -431,7 +431,7 @@ fn saved_stepped_tab_cut_piece_projection_asks_for_its_face_again_without_expand
// the patch y 10..20, z 0..20 by its piece name. The kernel leaves the wall one face now: the
// patch is only that saved name and its rectangle on YZ.
let at = Vec3::new(0., 15., 1.);
- let plane = solidcraft_geom::Plane::YZ;
+ let plane = solidcore_record::Plane::YZ;
let current_state = model.state();
let current = current_state.body("Case").unwrap();
let stem = crate::naming::face_name_at_body(current, at).unwrap();
diff --git a/crates/doc/src/config_styles.rs b/crates/doc/src/config_styles.rs
index 046643b703..246ea13688 100644
--- a/crates/doc/src/config_styles.rs
+++ b/crates/doc/src/config_styles.rs
@@ -3,9 +3,10 @@ use super::Column;
use crate::{DocError, Document, FeatureKind, ModelState, Result};
use serde::{Deserialize, Serialize};
use serde_json::Value;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
-pub(crate) fn shell_plane_family(planes: impl IntoIterator<Item = Option<solidcraft_geom::Plane>>) -> bool {
+pub(crate) fn shell_plane_family(planes: impl IntoIterator<Item = Option<solidcore_record::Plane>>) -> bool {
let mut planes = planes.into_iter();
let Some(Some(first)) = planes.next() else { return false };
first.origin.is_finite() && first.x.is_finite() && first.y.is_finite() && planes.all(|plane| plane == Some(first))
diff --git a/crates/doc/src/construct.rs b/crates/doc/src/construct.rs
index 8ea542be51..d92f0fd055 100644
--- a/crates/doc/src/construct.rs
+++ b/crates/doc/src/construct.rs
@@ -6,10 +6,11 @@
//! vertex the names of the edges that meet there, so they follow the model when earlier features
//! change; the picked point is the fallback.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Plane, Vec2, Vec3};
+use solidcore_record::{Plane, Vec2, Vec3};
use solidcraft_kernel::{self as kernel, FaceSurface};
use crate::eval::{ModelBody, ModelState};
@@ -459,7 +460,7 @@ fn path_segs(ctx: &Ctx, g: &GeoRef) -> Result<Vec<kernel::PathSeg>> {
GeoRef::Edge { at, name } => {
let (b, i, pts) = edge_pick(ctx.st, *at, name)?;
let procedural =
- b.body.record().edges.get(i).is_some_and(|e| matches!(e.parameters(), solidcraft_geom::brep::Curve::SurfaceIntersection { .. }));
+ b.body.record().edges.get(i).is_some_and(|e| matches!(e.parameters(), solidcore_record::brep::Curve::SurfaceIntersection { .. }));
if procedural {
return Ok(lines(&pts));
}
diff --git a/crates/doc/src/display_quality.rs b/crates/doc/src/display_quality.rs
index f46fc1bf03..911cd8637d 100644
--- a/crates/doc/src/display_quality.rs
+++ b/crates/doc/src/display_quality.rs
@@ -164,7 +164,7 @@ mod tests {
/// closer to the surface, and the reference mesh the model reads never changes.
#[test]
fn each_level_has_its_own_plan_and_the_reference_mesh_stays() {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let body = solidcraft_kernel::cylinder(Vec3::ZERO, Vec3::Z, 20.0, 50.0).unwrap();
let mb = crate::ModelBody::new("Body1".into(), body, 1);
let reference = mb.mesh();
diff --git a/crates/doc/src/document.rs b/crates/doc/src/document.rs
index ab17191d05..5a4572f7f7 100644
--- a/crates/doc/src/document.rs
+++ b/crates/doc/src/document.rs
@@ -1,5 +1,6 @@
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Plane, Vec2, Vec3};
+use solidcore_record::{Plane, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use solidcraft_kernel::Continuity;
use solidcraft_sketch::Sketch;
@@ -3186,7 +3187,7 @@ impl Visibility {
pub struct NamedView {
#[serde(default)]
pub name: String,
- pub target: solidcraft_geom::Vec3,
+ pub target: solidcore_record::Vec3,
pub yaw: f64,
pub pitch: f64,
pub distance: f64,
diff --git a/crates/doc/src/eval.rs b/crates/doc/src/eval.rs
index 616515fe5b..3979d38914 100644
--- a/crates/doc/src/eval.rs
+++ b/crates/doc/src/eval.rs
@@ -5,14 +5,16 @@ mod placed_mesh;
#[path = "placement_reuse.rs"]
mod placement_reuse;
+use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
use std::hash::{Hash, Hasher};
use std::sync::{Arc, OnceLock};
use serde::{Deserialize, Serialize};
-use solidcraft_geom::brep::part::Contact;
+use solidcore_record::brep::part::Contact;
+use solidcore_record::{Plane, Region2, Vec2, Vec3};
use solidcraft_geom::tess::TessPlan;
-use solidcraft_geom::{Mesh, Plane, Region2, UnitVec3, Vec2, Vec3, regions_apart};
+use solidcraft_geom::{Mesh, UnitVec3, regions_apart};
use solidcraft_kernel::{self as kernel, Body, BoolOp};
use solidcraft_sketch::{CurveKind, Profile, SolveReport, find_profiles};
@@ -3418,7 +3420,7 @@ fn groups_from_body(mb: &ModelBody, groups: &[Vec<usize>]) -> Option<Vec<bool>>
let holds = |k: usize| {
let shells = regions.get(k).and_then(|&r| record.regions.get(r)).map(|r| r.shells.as_slice()).unwrap_or_default();
shells.iter().any(|&s| match record.shells.get(s as usize) {
- Some(solidcraft_geom::brep::Shell::Faces { faces, .. }) => faces.iter().any(|f| from.get(f.face as usize) == Some(&true)),
+ Some(solidcore_record::brep::Shell::Faces { faces, .. }) => faces.iter().any(|f| from.get(f.face as usize) == Some(&true)),
_ => false,
})
};
@@ -4584,7 +4586,7 @@ fn hole_tools_and_prisms(
let seam = std::cell::Cell::new(0.0);
let disc = |rad: f64| {
seam.set(seam.get() + 0.613);
- Region2 { outer: solidcraft_geom::Loop2::circle_from(Vec2::ZERO, rad, seam.get()), holes: vec![] }
+ Region2 { outer: solidcore_record::Loop2::circle_from(Vec2::ZERO, rad, seam.get()), holes: vec![] }
};
let cyl = |rad: f64, lo: f64, hi: f64, part: &str| -> Result<(Traced, Option<more::PrimitivePrism>)> {
let tool = kernel::extrude(&plane, &[disc(rad)], lo, hi)?.pop().ok_or_else(|| DocError::Invalid("hole tool".into()))?;
@@ -4614,7 +4616,7 @@ fn hole_tools_and_prisms(
let side = up.any_perp();
let rp = Plane::new(*position, side, up).ok_or_else(|| DocError::Invalid("hole axis".into()))?;
let pts = [Vec2::new(0.0, top), Vec2::new(r, top), Vec2::new(r, bottom), Vec2::new(0.0, bottom - tip)];
- let region = Region2 { outer: solidcraft_geom::Loop2::polygon(&pts), holes: vec![] };
+ let region = Region2 { outer: solidcore_record::Loop2::polygon(&pts), holes: vec![] };
return Ok(kernel::revolve(&rp, &[region], Vec2::ZERO, Vec2::Y, std::f64::consts::TAU)?
.into_iter()
.map(|tool| (crate::lineage::part_tool(tool, "bore"), None))
@@ -4650,7 +4652,7 @@ fn hole_tools_and_prisms(
let up = -dir;
let rp = Plane::new(*position, up.any_perp(), up).ok_or_else(|| DocError::Invalid("hole axis".into()))?;
let pts = [Vec2::new(rc, 0.0), Vec2::new(r_end, -len), Vec2::new(0.0, -len), Vec2::new(0.0, top), Vec2::new(rc, top)];
- let region = Region2 { outer: solidcraft_geom::Loop2::polygon(&pts), holes: vec![] };
+ let region = Region2 { outer: solidcore_record::Loop2::polygon(&pts), holes: vec![] };
tools.extend(
kernel::revolve(&rp, &[region], Vec2::ZERO, Vec2::Y, std::f64::consts::TAU)?
.into_iter()
@@ -5098,7 +5100,7 @@ fn feature_tools_with_constructor(
cap_bindings.as_ref().and_then(|bindings| bindings.get(body_index)).cloned().unwrap_or_else(|| vec![None; curves.len()]);
// A cap moved off its designed height (into a Join target, or past a
// curved To face) is not the feature's start or end face.
- let nominal = |plane: &solidcraft_geom::Plane| {
+ let nominal = |plane: &solidcore_record::Plane| {
let height = (plane.origin - ss.plane.origin).dot(n);
let tolerance = 1e-9 * (1.0 + height.abs() + (lo + off).abs() + (hi + off).abs());
(height - (lo + off)).abs() <= tolerance || (height - (hi + off)).abs() <= tolerance
@@ -5302,10 +5304,10 @@ fn feature_tools_with_constructor(
let plane = Plane { origin: *base, x, y: k };
let c = Vec2::new(r, 0.0);
let outer = match section {
- crate::CoilSection::Circular => solidcraft_geom::Loop2::circle(c, s / 2.0),
+ crate::CoilSection::Circular => solidcore_record::Loop2::circle(c, s / 2.0),
crate::CoilSection::Square => {
let h = s / 2.0;
- solidcraft_geom::Loop2::polygon(&[c + Vec2::new(-h, -h), c + Vec2::new(h, -h), c + Vec2::new(h, h), c + Vec2::new(-h, h)])
+ solidcore_record::Loop2::polygon(&[c + Vec2::new(-h, -h), c + Vec2::new(h, -h), c + Vec2::new(h, h), c + Vec2::new(-h, h)])
}
};
let region = Region2 { outer, holes: Vec::new() };
@@ -5503,11 +5505,11 @@ fn pipe_region(vals: &BTreeMap<String, Value>, r: f64, wall: &Option<crate::Expr
if !(wt > 0.0 && wt < r) {
return Err(DocError::Invalid("the wall must be thinner than the radius".into()));
}
- vec![solidcraft_geom::Loop2::circle(Vec2::ZERO, r - wt).reversed()]
+ vec![solidcore_record::Loop2::circle(Vec2::ZERO, r - wt).reversed()]
}
None => Vec::new(),
};
- Ok(Region2 { outer: solidcraft_geom::Loop2::circle(Vec2::ZERO, r), holes })
+ Ok(Region2 { outer: solidcore_record::Loop2::circle(Vec2::ZERO, r), holes })
}
pub fn map_wire(wire: &mut solidcraft_sketch::Wire, matrix: &Mat) {
@@ -5585,8 +5587,8 @@ fn path_points(ps: &SolvedSketch, ids: &[String], start: Vec3) -> Result<Option<
Some(solidcraft_sketch::Wire { arc: Some(arc), .. }) => {
let x = (arc.start - arc.center).normalized().ok_or_else(|| DocError::Invalid("a 3D arc of no radius".into()))?;
let y = arc.normal.cross(x);
- let frame = solidcraft_geom::brep::Frame { origin: arc.center.into(), x_axis: x.into(), y_axis: y.into() };
- let circle = solidcraft_geom::brep::Curve::Circle { frame, radius: arc.radius };
+ let frame = solidcore_record::brep::Frame { origin: arc.center.into(), x_axis: x.into(), y_axis: y.into() };
+ let circle = solidcore_record::brep::Curve::Circle { frame, radius: arc.radius };
kernel::PathPiece::Segs(kernel::curve_path(&circle, [0.0, solidcraft_sketch::arc_sweep(arc)])?)
}
Some(w) if w.fit.len() >= 3 => kernel::PathPiece::Spline { fit: w.fit.clone(), reversed: false },
@@ -5656,14 +5658,14 @@ pub(crate) fn path_segments_at(ps: &SolvedSketch, ids: &[String], start: Vec3, p
}
// Each curve as its exact pieces (Béziers, conics) where it has them, in its own direction
// of travel. A curve is turned round whole: its pieces stay one run.
- let mut curves: Vec<Vec<solidcraft_geom::Seg2>> = Vec::with_capacity(ids.len());
+ let mut curves: Vec<Vec<solidcore_record::Seg2>> = Vec::with_capacity(ids.len());
for id in ids {
let ci = ps.sketch.curve_index(id).ok_or_else(|| DocError::Unknown(format!("path curve `{id}`")))?;
curves.push(ps.sketch.exact_segs(ci).unwrap_or_else(|| ps.sketch.segs(ci)));
}
curves.retain(|c| !c.is_empty());
- let ends = |c: &[solidcraft_geom::Seg2]| c.first().zip(c.last()).map(|(f, l)| (f.start(), l.end()));
- let reversed = |c: Vec<solidcraft_geom::Seg2>| c.into_iter().rev().map(|s| s.reversed()).collect::<Vec<_>>();
+ let ends = |c: &[solidcore_record::Seg2]| c.first().zip(c.last()).map(|(f, l)| (f.start(), l.end()));
+ let reversed = |c: Vec<solidcore_record::Seg2>| c.into_iter().rev().map(|s| s.reversed()).collect::<Vec<_>>();
// Where two curves meet: one tolerance for telling which ends touch and for the joint.
const JOINT: f64 = 1e-5;
// Orient the first curve: it runs toward the second where it meets it at one end only;
@@ -5682,9 +5684,9 @@ pub(crate) fn path_segments_at(ps: &SolvedSketch, ids: &[String], start: Vec3, p
}
}
// Each next curve starts where the previous one ended.
- let mut segs: Vec<solidcraft_geom::Seg2> = Vec::new();
+ let mut segs: Vec<solidcore_record::Seg2> = Vec::new();
for curve in curves {
- let (Some(prev_end), Some((a, b))) = (segs.last().map(solidcraft_geom::Seg2::end), ends(&curve)) else {
+ let (Some(prev_end), Some((a, b))) = (segs.last().map(solidcore_record::Seg2::end), ends(&curve)) else {
segs.extend(curve);
continue;
};
@@ -5704,9 +5706,9 @@ pub(crate) fn path_segments_at(ps: &SolvedSketch, ids: &[String], start: Vec3, p
/// `start`: the curve there split in two, its second part first and its first part last (or the
/// chain begun at the joint there). Unchanged when the chain is open, already starts on the
/// profile's plane, or its point nearest `start` is off that plane.
-fn from_profile_on_closed_path(segs: Vec<solidcraft_geom::Seg2>, path: &Plane, profile: &Plane, start: Vec3) -> Vec<solidcraft_geom::Seg2> {
+fn from_profile_on_closed_path(segs: Vec<solidcore_record::Seg2>, path: &Plane, profile: &Plane, start: Vec3) -> Vec<solidcore_record::Seg2> {
let (Some(first), Some(last)) = (segs.first(), segs.last()) else { return segs };
- let size: f64 = segs.iter().map(solidcraft_geom::Seg2::length).sum();
+ let size: f64 = segs.iter().map(solidcore_record::Seg2::length).sum();
let on_plane = |p: Vec2| profile.height(path.to_world(p)).abs() <= (size * 1e-9).max(1e-9);
if !start.is_finite() || !(size > 0.0 && size.is_finite()) || last.end().dist(first.start()) > 1e-5 || on_plane(first.start()) {
return segs;
@@ -7196,7 +7198,7 @@ fn eval_feature(
(None, Some(sid)) => {
let ss = st.sketch(sid.0).ok_or_else(|| DocError::Unknown(format!("sketch {sid}")))?;
// Each curve's exact segments (lines and arcs split by their own plane and cylinder).
- let curves: Vec<Vec<solidcraft_geom::Seg2>> = (0..ss.sketch.curves.len())
+ let curves: Vec<Vec<solidcore_record::Seg2>> = (0..ss.sketch.curves.len())
.filter(|ci| ss.sketch.curves.get(*ci).is_some_and(|c| !c.construction))
.map(|ci| ss.sketch.segs(ci))
.filter(|segs| !segs.is_empty())
@@ -8664,7 +8666,7 @@ pub fn sketch_line_plane(st: &ModelState, sketch: u64, line: &str) -> Result<Pla
let ss = st.sketch(sketch).ok_or_else(|| DocError::Unknown(format!("sketch {sketch}")))?;
let ci = ss.sketch.curve_index(line).ok_or_else(|| DocError::Unknown(format!("curve `{line}`")))?;
let (a, b) = match ss.sketch.segs(ci).as_slice() {
- [solidcraft_geom::Seg2::Line { a, b }] => (*a, *b),
+ [solidcore_record::Seg2::Line { a, b }] => (*a, *b),
_ => return Err(DocError::Invalid(format!("`{line}` is not a straight line: split by a sketch line"))),
};
let (wa, wb) = (ss.plane.to_world(a), ss.plane.to_world(b));
diff --git a/crates/doc/src/eval_cost_tests.rs b/crates/doc/src/eval_cost_tests.rs
index 6441601de6..0b71254fde 100644
--- a/crates/doc/src/eval_cost_tests.rs
+++ b/crates/doc/src/eval_cost_tests.rs
@@ -4,11 +4,12 @@
//! component into its frame, and every evaluation wrote every imported STEP file out again to
//! fingerprint it, so each sketch command took longer the more parts were inserted.
+use solidcraft_geom::prelude::*;
use std::cell::Cell;
use std::collections::BTreeMap;
use std::sync::Arc;
-use solidcraft_geom::{Plane, Vec2, Vec3};
+use solidcore_record::{Plane, Vec2, Vec3};
use solidcraft_kernel as kernel;
use solidcraft_sketch::Sketch;
diff --git a/crates/doc/src/eval_frame.rs b/crates/doc/src/eval_frame.rs
index 35ab2b0fcc..7abd78ec79 100644
--- a/crates/doc/src/eval_frame.rs
+++ b/crates/doc/src/eval_frame.rs
@@ -1,10 +1,12 @@
//! Frame members (#4003): one body per straight line of a frame sketch, its cross-section a
//! profile laid square to the line (`frame::member_axes`) and run from one end to the other.
+use solidcraft_geom::prelude::*;
use std::borrow::Cow;
use std::collections::{BTreeMap, HashSet};
-use solidcraft_geom::{Aabb2, Plane, Region2, Ring, Vec2, Vec3};
+use solidcore_record::{Plane, Region2, Vec2, Vec3};
+use solidcraft_geom::{Aabb2, Ring};
use solidcraft_kernel as kernel;
use solidcraft_sketch::CurveKind;
diff --git a/crates/doc/src/eval_more.rs b/crates/doc/src/eval_more.rs
index aaf915d03c..4083078e85 100644
--- a/crates/doc/src/eval_more.rs
+++ b/crates/doc/src/eval_more.rs
@@ -5,7 +5,8 @@ use super::*;
use crate::EmbossFace;
use crate::apply_point;
use crate::sheet;
-use solidcraft_geom::{Aabb3, Loop2, Ring, Seg2};
+use solidcore_record::{Loop2, Seg2};
+use solidcraft_geom::{Aabb3, Ring};
pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature, st: &mut ModelState) -> Result<()> {
match &f.kind {
diff --git a/crates/doc/src/eval_surface.rs b/crates/doc/src/eval_surface.rs
index ff94db0e70..090dce4bba 100644
--- a/crates/doc/src/eval_surface.rs
+++ b/crates/doc/src/eval_surface.rs
@@ -4,7 +4,7 @@
use super::*;
use crate::{RuledCorners, RuledMode, SheetSection};
-use solidcraft_geom::Seg2;
+use solidcore_record::Seg2;
pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature, st: &mut ModelState, warning: &mut Option<String>) -> Result<()> {
match &f.kind {
@@ -233,7 +233,7 @@ pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature,
return Err(DocError::Invalid("a match needs a chain of the target's edges".into()));
}
// Picked by a point on the face; without picks, the body's first face.
- let picked: Vec<solidcraft_geom::Vec3> = if faces.is_empty() {
+ let picked: Vec<solidcore_record::Vec3> = if faces.is_empty() {
let faces = mb.body.faces(mb.body.size() * 1e-2)?;
vec![faces.first().ok_or_else(|| DocError::Invalid(format!("`{body}` has no face to match")))?.centroid]
} else {
@@ -434,7 +434,7 @@ pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature,
kernel::loft_sheet_with_rails(&secs, &rails, crate::eval::kernel_rail_fit(*rail_fit))?
};
// Each wall named by the section curves it runs between, as a loft's sides are.
- let loops: Vec<solidcraft_geom::Loop2> = secs.iter().map(|(_, c)| solidcraft_geom::Loop2 { segs: c.clone() }).collect();
+ let loops: Vec<solidcore_record::Loop2> = secs.iter().map(|(_, c)| solidcore_record::Loop2 { segs: c.clone() }).collect();
let traced = crate::lineage::SectionRoles { sections: sketches.iter().zip(&loops).map(|(s, lp)| (s, vec![lp])).collect() }.tool(body);
push_sheet(st, f, traced);
Ok(())
@@ -572,7 +572,7 @@ fn loop_patch(ss: &SolvedSketch, curves: &[String]) -> Result<kernel::Body> {
/// A network curve resolved in the feature's frame, owning what it is built from.
enum NetSource {
- Sketch(solidcraft_geom::Plane, Vec<Seg2>),
+ Sketch(solidcore_record::Plane, Vec<Seg2>),
Points(Vec<Vec3>),
Edges(kernel::Body, Vec<Vec3>),
Point(Vec3),
@@ -662,7 +662,7 @@ fn boundary_frames(
use solidcraft_kernel::{Boundary, Frame};
// The stations along each curve, evenly in its own arclength, so every side carries the same
// number of frames and the patch's net is square.
- let mut sides: Vec<Vec<solidcraft_geom::Vec3>> = Vec::with_capacity(curves.len());
+ let mut sides: Vec<Vec<solidcore_record::Vec3>> = Vec::with_capacity(curves.len());
for id in curves {
let ci = ss.sketch.curve_index(id).ok_or_else(|| DocError::Unknown(format!("sketch curve `{id}`")))?;
let pieces = ss.sketch.exact_pieces(ci);
@@ -690,7 +690,7 @@ fn boundary_frames(
}
// The middle of the loop, so every side leaves towards the inside of the patch.
let count = sides.iter().map(Vec::len).sum::<usize>().max(1) as f64;
- let centre = sides.iter().flatten().fold(solidcraft_geom::Vec3::ZERO, |a, p| a + *p) * (1.0 / count);
+ let centre = sides.iter().flatten().fold(solidcore_record::Vec3::ZERO, |a, p| a + *p) * (1.0 / count);
let mut out = Vec::with_capacity(sides.len());
for (side, pts) in sides.iter().enumerate() {
let mut frames = Vec::with_capacity(pts.len());
@@ -829,8 +829,8 @@ fn loft_blend(
) -> Result<()> {
/// One section: a chain of sketch curves in its plane, or a body's edge chain.
enum Piece {
- Sketch(solidcraft_geom::Plane, Vec<solidcraft_geom::Seg2>),
- Body(String, Vec<solidcraft_geom::Vec3>),
+ Sketch(solidcore_record::Plane, Vec<solidcore_record::Seg2>),
+ Body(String, Vec<solidcore_record::Vec3>),
}
let mut pieces = Vec::with_capacity(sections.len());
let mut centres = Vec::with_capacity(sections.len());
@@ -840,7 +840,7 @@ fn loft_blend(
return Err(DocError::Invalid("a loft section picked from a body needs a chain of its edges".into()));
}
let n = sec.edges.len() as f64;
- centres.push(sec.edges.iter().fold(solidcraft_geom::Vec3::ZERO, |a, p| a + **p) * (1.0 / n));
+ centres.push(sec.edges.iter().fold(solidcore_record::Vec3::ZERO, |a, p| a + **p) * (1.0 / n));
pieces.push(Piece::Body(name.to_string(), crate::plain(&sec.edges)));
continue;
}
@@ -858,7 +858,7 @@ fn loft_blend(
return Err(DocError::Invalid("each loft section must be one chain: one profile without holes, or curves meeting end to end".into()));
};
let pts: Vec<Vec2> = chain.iter().flat_map(|s| s.polyline(1e-2)).collect();
- let centre = pts.iter().fold(solidcraft_geom::Vec3::ZERO, |a, p| a + ss.plane.to_world(*p)) * (1.0 / pts.len().max(1) as f64);
+ let centre = pts.iter().fold(solidcore_record::Vec3::ZERO, |a, p| a + ss.plane.to_world(*p)) * (1.0 / pts.len().max(1) as f64);
centres.push(centre);
pieces.push(Piece::Sketch(ss.plane, chain));
}
@@ -870,7 +870,7 @@ fn loft_blend(
let (from, to) = if i < last { (i, i + 1) } else { (last, last.saturating_sub(1)) };
let leave = match (centres.get(from), centres.get(to)) {
(Some(a), Some(b)) => *b - *a,
- _ => solidcraft_geom::Vec3::ZERO,
+ _ => solidcore_record::Vec3::ZERO,
};
match piece {
Piece::Body(name, edges) => {
@@ -889,9 +889,9 @@ fn loft_blend(
/// The frames of one sketch chain, sampled by arclength at `stations` stations: a sketch has no
/// face behind it, so the surface leaves along the run with no curvature to repeat there.
fn chain_frames(
- plane: &solidcraft_geom::Plane,
- chain: &[solidcraft_geom::Seg2],
- leave: solidcraft_geom::Vec3,
+ plane: &solidcore_record::Plane,
+ chain: &[solidcore_record::Seg2],
+ leave: solidcore_record::Vec3,
stations: usize,
) -> Vec<kernel::Frame> {
let mut pts: Vec<Vec2> = Vec::new();
@@ -920,14 +920,19 @@ fn chain_frames(
}
let (Some(a), Some(b)) = (pts.get(k).copied(), pts.get(k + 1).copied()) else {
if let Some(p) = pts.get(k).copied() {
- out.push(kernel::Frame { p: plane.to_world(p), leave, bend: solidcraft_geom::Vec3::ZERO, bend_change: solidcraft_geom::Vec3::ZERO });
+ out.push(kernel::Frame {
+ p: plane.to_world(p),
+ leave,
+ bend: solidcore_record::Vec3::ZERO,
+ bend_change: solidcore_record::Vec3::ZERO,
+ });
}
continue;
};
let span = (b - a).len();
let t = if span > 1e-12 { ((want - walked) / span).clamp(0.0, 1.0) } else { 0.0 };
let p = a * (1.0 - t) + b * t;
- out.push(kernel::Frame { p: plane.to_world(p), leave, bend: solidcraft_geom::Vec3::ZERO, bend_change: solidcraft_geom::Vec3::ZERO });
+ out.push(kernel::Frame { p: plane.to_world(p), leave, bend: solidcore_record::Vec3::ZERO, bend_change: solidcore_record::Vec3::ZERO });
}
out
}
diff --git a/crates/doc/src/eval_thread.rs b/crates/doc/src/eval_thread.rs
index 5e63d90ea2..4b4ef3106e 100644
--- a/crates/doc/src/eval_thread.rs
+++ b/crates/doc/src/eval_thread.rs
@@ -674,7 +674,7 @@ fn taper_envelope(t: &ThreadInfo, radius: f64, ends: [End; 2], (d0, from): (f64,
vec![Vec2::new(rc(-e), -e), Vec2::new(rc(len), len), Vec2::new(r_out, len), Vec2::new(r_out, -e)]
}
};
- let region = Region2 { outer: solidcraft_geom::Loop2::polygon(&pts), holes: Vec::new() };
+ let region = Region2 { outer: solidcore_record::Loop2::polygon(&pts), holes: Vec::new() };
let mut ring = kernel::revolve(&plane, &[region], Vec2::new(0.0, 0.0), Vec2::new(0.0, 1.0), std::f64::consts::TAU)?;
Ok(ring.pop())
}
@@ -768,7 +768,7 @@ pub(super) fn cut(st: &mut ModelState, on: ThreadOn, (tip, angle, depth): (Threa
};
let mut grooves = Vec::new();
for g in thread_grooves(&t, radius, (cyl.start, cyl.end), ends, steep, ease, taper)? {
- let section = Region2 { outer: solidcraft_geom::Loop2::polygon(&g.section), holes: Vec::new() };
+ let section = Region2 { outer: solidcore_record::Loop2::polygon(&g.section), holes: Vec::new() };
grooves.push(kernel::sweep_helix_radial(&g.plane, &section, g.base, g.axis, g.pitch, g.turns, &g.law)?);
}
if let Some(taper) = taper
@@ -872,7 +872,7 @@ fn tip_cones(
// In the plane: x radial, y outward along the axis from the end.
let plane = Plane { origin: t.axis_point + k * at, x: u, y: out_dir };
let pts = [Vec2::new(r_f, 0.0), Vec2::new(r_f, e), Vec2::new(r_out, e), Vec2::new(r_out, -(r_out - r_f) / slope)];
- let region = Region2 { outer: solidcraft_geom::Loop2::polygon(&pts), holes: Vec::new() };
+ let region = Region2 { outer: solidcore_record::Loop2::polygon(&pts), holes: Vec::new() };
let mut ring = kernel::revolve(&plane, &[region], Vec2::new(0.0, 0.0), Vec2::new(0.0, 1.0), std::f64::consts::TAU)?;
out.push(ring.pop().ok_or_else(|| DocError::Invalid("chamfer".into()))?);
}
diff --git a/crates/doc/src/face_anchor.rs b/crates/doc/src/face_anchor.rs
index adae44dc45..3472475aec 100644
--- a/crates/doc/src/face_anchor.rs
+++ b/crates/doc/src/face_anchor.rs
@@ -4,7 +4,8 @@ use crate::config::ConfigFaceTarget;
use crate::{DocError, Document, EmbossFace, FeatureKind, Model, ModelBody, ModelState, PlaneRef, Result};
use serde::{Deserialize, Serialize};
use serde_json::Value;
-use solidcraft_geom::Plane;
+use solidcore_record::Plane;
+use solidcraft_geom::prelude::*;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
@@ -499,7 +500,7 @@ pub fn validate_face_anchors_json(value: &Value) -> Result<()> {
#[cfg(test)]
mod tests {
use super::*;
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
fn fixture() -> (Document, ModelBody, usize, Plane) {
let mut doc = Document::default();
let kind: FeatureKind =
@@ -626,7 +627,7 @@ mod tests {
}
#[test]
fn extrude_cap_profile_reordering_never_retargets_an_ordinal_body() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
let mut sketch = solidcraft_sketch::Sketch::new();
for offset in [0., 30.] {
let points: Vec<_> = [(0., 0.), (10., 0.), (10., 10.), (0., 10.)]
@@ -719,7 +720,7 @@ mod tests {
}
#[test]
fn warm_root_body_offset_edit_matches_cold_attached_sketch_and_downstream_bounds() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
let (mut doc, _, _, _) = fixture();
let mut warm = Model::new();
warm.evaluate(&doc);
diff --git a/crates/doc/src/feature_geometry.rs b/crates/doc/src/feature_geometry.rs
index dcf371050d..f5536a2127 100644
--- a/crates/doc/src/feature_geometry.rs
+++ b/crates/doc/src/feature_geometry.rs
@@ -4,7 +4,7 @@
//! The walk (`crate::walk`) is behind `transform_geometry`, `face_points`, `profile_sels` and
//! `point_expr`.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::walk::Walk;
use crate::{FeatureKind, PointExpr, ProfileSel};
diff --git a/crates/doc/src/format.rs b/crates/doc/src/format.rs
index 6af3848c7e..58fe1bf724 100644
--- a/crates/doc/src/format.rs
+++ b/crates/doc/src/format.rs
@@ -1246,6 +1246,7 @@ fn normalise(d: &mut Document) -> Result<()> {
#[cfg(test)]
mod tests {
use super::*;
+ use solidcraft_geom::prelude::*;
/// A pending change that records that its step ran, in `trace`.
fn traced(name: &'static str) -> Part {
@@ -1676,7 +1677,7 @@ mod tests {
#[test]
fn version_twenty_three_designs_open_and_an_edge_flange_relief_is_saved_in_twenty_four() {
let flange = |shape: Option<&str>, size: Option<&str>| crate::FeatureKind::SheetFlange {
- edges: vec![crate::FlangeEdge::at(solidcraft_geom::Vec3::ZERO)],
+ edges: vec![crate::FlangeEdge::at(solidcore_record::Vec3::ZERO)],
height: "10 mm".into(),
angle: "90 deg".into(),
radius: None,
@@ -1782,7 +1783,7 @@ mod tests {
#[test]
fn version_nine_wire_spaces_preserve_saved_points_and_explicit_markers() {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
use solidcraft_sketch::{LinkKind, LinkSource, Sketch, WireSpace};
let mut sketch = Sketch::new();
sketch.add_drawn_wire(&[Vec3::new(12.0, 3.0, 4.0)]).unwrap();
@@ -1896,9 +1897,9 @@ mod tests {
through_all: false,
taper: Some("0 deg".into()),
corner: Default::default(),
- to: Some(crate::FacePick(solidcraft_geom::Vec3::new(0.0, 0.0, 10.0))),
+ to: Some(crate::FacePick(solidcore_record::Vec3::new(0.0, 0.0, 10.0))),
to_offset: Some("offset + 1 mm".into()),
- from: Some(crate::FacePick(solidcraft_geom::Vec3::new(0.0, 0.0, 5.0))),
+ from: Some(crate::FacePick(solidcore_record::Vec3::new(0.0, 0.0, 5.0))),
to_body_apart: false,
},
operation: Operation::NewBody,
@@ -1944,7 +1945,7 @@ mod tests {
#[test]
fn saved_offset_cannot_alias_and_overwrite_its_source_geometry() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::{CurveKind, Sketch};
let mut sketch = Sketch::new();
let center = sketch.add_point(Vec2::ZERO, None).unwrap();
@@ -2083,7 +2084,7 @@ mod tests {
#[test]
fn periodic_file_validation_refuses_damaged_closed_geometry() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::{CurveKind, Sketch};
let mut sketch = Sketch::new();
let mut pts = Vec::new();
@@ -2233,7 +2234,7 @@ mod tests {
#[test]
fn version_seven_origin_sketch_keeps_geometry_dimension_ids_and_expressions() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::{ConstraintKind, Sketch};
let mut d = Document::new("legacy origin dimensions");
d.set_param("reach", "25 mm", Some("mm"), None).unwrap();
@@ -2263,7 +2264,7 @@ mod tests {
#[test]
fn version_eight_persistent_angle_sweep_and_slot_dimensions_roundtrip() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::{ConstraintKind, Sketch};
let mut d = Document::new("persistent typed dimensions");
let heading = d.new_model_param("45 deg", "deg");
@@ -2382,12 +2383,12 @@ mod tests {
let (values, errors) = migrated.param_values();
assert!(errors.is_empty());
let p = migrated.resolve_plane(&values, plane, 0).unwrap();
- assert_eq!(p.y, solidcraft_geom::Vec3::Z);
- assert_eq!(p.normal(), -solidcraft_geom::Vec3::Y);
- assert_eq!(p.origin, solidcraft_geom::Vec3::new(0.0, -7.0, 0.0));
+ assert_eq!(p.y, solidcore_record::Vec3::Z);
+ assert_eq!(p.normal(), -solidcore_record::Vec3::Y);
+ assert_eq!(p.origin, solidcore_record::Vec3::new(0.0, -7.0, 0.0));
assert_eq!(read(&migrated.to_json()).unwrap(), migrated);
let fresh = doc.resolve_plane(&values, &crate::PlaneRef::Origin { name: "XZ".into() }, 0).unwrap();
- assert_eq!(fresh.normal(), solidcraft_geom::Vec3::Y);
+ assert_eq!(fresh.normal(), solidcore_record::Vec3::Y);
}
#[test]
@@ -2435,7 +2436,7 @@ mod tests {
let mut sketch = Sketch::new();
let mut previous = 0;
while sketch.points.len() < MAX_POINTS {
- let i = sketch.add_point(solidcraft_geom::Vec2::new(0.001 * sketch.points.len() as f64, 0.0), None).unwrap();
+ let i = sketch.add_point(solidcore_record::Vec2::new(0.001 * sketch.points.len() as f64, 0.0), None).unwrap();
sketch.add_constraint(solidcraft_sketch::ConstraintKind::Coincident { p: previous, q: i }, None).unwrap();
previous = i;
}
@@ -2547,7 +2548,7 @@ mod tests {
#[test]
fn integer_valued_coordinates_are_range_checked_and_large_ids_still_load() {
let mut sketch = solidcraft_sketch::Sketch::new();
- sketch.add_point(solidcraft_geom::Vec2::new(40.0, 0.0), None).unwrap();
+ sketch.add_point(solidcore_record::Vec2::new(40.0, 0.0), None).unwrap();
let mut d = Document::new("range");
d.add_feature(crate::FeatureKind::Sketch { plane: crate::PlaneRef::Origin { name: "XY".into() }, sketch }, None).unwrap();
let last = |v: &Value| v["features"][0]["sketch"]["points"].as_array().map_or(0, |a| a.len() - 1);
@@ -2604,7 +2605,7 @@ mod tests {
"orientation": {"direction": [0.0, 1.0, 0.0]}, "twist": "90 deg", "scale": "0.5"});
let k: FeatureKind = serde_json::from_value(new.clone()).unwrap();
let FeatureKind::SurfaceSweep { orientation, .. } = &k else { panic!("{k:?}") };
- assert_eq!(*orientation, SweepOrientation::Direction(crate::Dir(solidcraft_geom::Vec3::Y)));
+ assert_eq!(*orientation, SweepOrientation::Direction(crate::Dir(solidcore_record::Vec3::Y)));
assert_eq!(serde_json::to_value(&k).unwrap(), new);
let parallel: SweepOrientation = serde_json::from_value(serde_json::json!("parallel")).unwrap();
assert_eq!(parallel, SweepOrientation::Parallel);
diff --git a/crates/doc/src/format_offsets.rs b/crates/doc/src/format_offsets.rs
index aa6e4b1080..2e398295af 100644
--- a/crates/doc/src/format_offsets.rs
+++ b/crates/doc/src/format_offsets.rs
@@ -411,9 +411,9 @@ mod tests {
#[test]
fn formats_one_through_eleven_keep_legacy_offset_geometry_and_ids() {
let mut sketch = solidcraft_sketch::Sketch::new();
- let center = sketch.add_point(solidcraft_geom::Vec2::new(4., 7.), Some("center")).unwrap();
- sketch.add_circle(solidcraft_geom::Vec2::new(4., 7.), 10., Some(center), Some("source")).unwrap();
- sketch.add_circle(solidcraft_geom::Vec2::new(4., 7.), 9., Some(center), Some("offset")).unwrap();
+ let center = sketch.add_point(solidcore_record::Vec2::new(4., 7.), Some("center")).unwrap();
+ sketch.add_circle(solidcore_record::Vec2::new(4., 7.), 10., Some(center), Some("source")).unwrap();
+ sketch.add_circle(solidcore_record::Vec2::new(4., 7.), 9., Some(center), Some("offset")).unwrap();
sketch.offsets.push(solidcraft_sketch::OffsetChain {
sources: vec![("source".into(), true)],
outputs: vec!["offset".into()],
@@ -447,7 +447,7 @@ mod tests {
fn missing_boundary_or_defining_sketch_reopens_as_a_model_error_without_retarget() {
for missing_sketch in [false, true] {
let mut sketch = solidcraft_sketch::Sketch::new();
- sketch.add_circle(solidcraft_geom::Vec2::new(0., 0.), 10., None, Some("unrelated-circle")).unwrap();
+ sketch.add_circle(solidcore_record::Vec2::new(0., 0.), 10., None, Some("unrelated-circle")).unwrap();
let mut document = Document::new("repairable lost boundary");
let id = document.add_feature(FeatureKind::Sketch { plane: crate::PlaneRef::Origin { name: "XY".into() }, sketch }, None).unwrap();
document
diff --git a/crates/doc/src/frame.rs b/crates/doc/src/frame.rs
index 6040478177..47b9b02d44 100644
--- a/crates/doc/src/frame.rs
+++ b/crates/doc/src/frame.rs
@@ -13,10 +13,11 @@
//! of the profile's bounding box at the origin. The outline runs counter-clockwise and holes
//! clockwise, as [`Region2`] expects.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Loop2, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Region2, Seg2, Vec2, Vec3};
use crate::expr::Kind;
use crate::{DocError, Expr, Result};
diff --git a/crates/doc/src/history_names.rs b/crates/doc/src/history_names.rs
index 1bd4f8605f..2e1f75a1e1 100644
--- a/crates/doc/src/history_names.rs
+++ b/crates/doc/src/history_names.rs
@@ -24,7 +24,7 @@
use std::collections::{BTreeMap, BTreeSet};
use std::sync::{Arc, OnceLock};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_kernel::history::{FaceOrigin, FaceProv, History};
use crate::ModelBody;
diff --git a/crates/doc/src/hole_reference.rs b/crates/doc/src/hole_reference.rs
index fa4bde171e..ff77ff1d19 100644
--- a/crates/doc/src/hole_reference.rs
+++ b/crates/doc/src/hole_reference.rs
@@ -3,7 +3,9 @@
//! measured in the face's plane. The edges are found again by their persistent names, else by
//! their stored points, so the hole follows them when the part changes.
-use solidcraft_geom::{Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Mesh;
+use solidcraft_geom::prelude::*;
use crate::{DocError, ModelBody, ModelState, Result};
diff --git a/crates/doc/src/joints.rs b/crates/doc/src/joints.rs
index 91eaff69bc..147b15f7d2 100644
--- a/crates/doc/src/joints.rs
+++ b/crates/doc/src/joints.rs
@@ -14,10 +14,12 @@
//! linkage, a slider-crank) are met by moving the values of the other joints around the loop;
//! those that still disagree are reported.
+use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet, VecDeque};
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Aabb3, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Aabb3;
use solidcraft_sketch::linalg;
diff --git a/crates/doc/src/joints_cam.rs b/crates/doc/src/joints_cam.rs
index 79c45141e1..230ea800a9 100644
--- a/crates/doc/src/joints_cam.rs
+++ b/crates/doc/src/joints_cam.rs
@@ -12,10 +12,12 @@
//! oscillating one from its arm pointing away from the cam's axis) and stops where it first
//! touches the profile: the follower stays in contact, as a spring would hold it.
+use solidcraft_geom::prelude::*;
use std::f64::consts::TAU;
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Aabb2, Aabb3, Ring, Vec2, Vec3};
+use solidcore_record::{Vec2, Vec3};
+use solidcraft_geom::{Aabb2, Aabb3, Ring};
use super::{JointKind, JointOrigin, MotionLink, Size, component_bodies, component_of, flip_of, occurrence_world, size_of};
use crate::{DocError, Document, IDENTITY, Mat, ModelState, Result, apply_point, apply_vector, mat_inverse, mat_mul};
@@ -486,7 +488,7 @@ pub fn sketch_profile<'a>(sk: &'a crate::SolvedSketch, curves: &[String]) -> Opt
}
/// A loop's polyline within `tol`, segment by segment: `None` past `MAX_PROFILE_POINTS` points.
-fn sampled(lp: &solidcraft_geom::Loop2, tol: f64) -> Option<Vec<Vec2>> {
+fn sampled(lp: &solidcore_record::Loop2, tol: f64) -> Option<Vec<Vec2>> {
let mut out = Vec::new();
for seg in &lp.segs {
let p = seg.polyline(tol);
diff --git a/crates/doc/src/joints_edge.rs b/crates/doc/src/joints_edge.rs
index 836e3f50c9..2c647bc57b 100644
--- a/crates/doc/src/joints_edge.rs
+++ b/crates/doc/src/joints_edge.rs
@@ -8,7 +8,8 @@
//! corner x and y run along the two edges, away from the corner into the face, in the order that
//! makes the frame right-handed.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use super::{EdgeAxis, Snap, component_bodies, frame};
use crate::{DocError, Document, IDENTITY, Mat, ModelBody, ModelState, Result, apply_point, mat_inverse, mat_mul};
diff --git a/crates/doc/src/joints_face.rs b/crates/doc/src/joints_face.rs
index 91b5b0d1c5..fc9d41af9e 100644
--- a/crates/doc/src/joints_face.rs
+++ b/crates/doc/src/joints_face.rs
@@ -4,9 +4,11 @@
//! A round origin's end is kept by the name of the face across the rim at that end, so it is the
//! same end after the design changes; an x reference keeps the origin's turn about its axis.
+use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
-use solidcraft_geom::{Loop2, Mesh, Plane, Ring, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Vec2, Vec3};
+use solidcraft_geom::{Mesh, Ring};
use solidcraft_kernel::CylinderFace;
use super::{Snap, XRef, component_bodies};
diff --git a/crates/doc/src/joints_handles.rs b/crates/doc/src/joints_handles.rs
index 6cc267e78e..a9a3dc29a2 100644
--- a/crates/doc/src/joints_handles.rs
+++ b/crates/doc/src/joints_handles.rs
@@ -1,10 +1,11 @@
//! The instantaneous motion a joint value gives a selected occurrence. Probe the same
//! placement graph and loop solver as a drive, including reversed joints and motion links.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeSet;
use super::{Analysis, Held, MAX_LOOP_VALUES, Solution, apply_links, build, joint_values, link_chains, solve_holding_with_analysis};
use crate::{Document, Mat, ModelState, apply_point, apply_vector, mat_inverse, mat_mul};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
/// A driveable value, expressed as an axis of the selected occurrence in world coordinates.
#[derive(Clone, Debug)]
diff --git a/crates/doc/src/joints_reach.rs b/crates/doc/src/joints_reach.rs
index 7e87749e36..f74f903f89 100644
--- a/crates/doc/src/joints_reach.rs
+++ b/crates/doc/src/joints_reach.rs
@@ -2,10 +2,11 @@
//! point of it reaches a target (and an axis of it points a given way), every value within its
//! limits, motion links followed, and the closed loops those values are in kept closed.
+use solidcraft_geom::prelude::*;
use std::cell::Cell;
use std::collections::BTreeSet;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_sketch::linalg;
use super::{
diff --git a/crates/doc/src/joints_relations.rs b/crates/doc/src/joints_relations.rs
index c3c0f1a0cf..1b8ffb77b0 100644
--- a/crates/doc/src/joints_relations.rs
+++ b/crates/doc/src/joints_relations.rs
@@ -76,7 +76,7 @@ mod tests {
#![allow(clippy::unwrap_used)]
use super::*;
use crate::joints::{JointKind, JointOrigin, Snap};
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
fn joint(kind: JointKind) -> Joint {
let at = |occurrence| JointOrigin { occurrence, snap: Snap::Point { point: Vec3::ZERO, z: None, x: None } };
diff --git a/crates/doc/src/lineage.rs b/crates/doc/src/lineage.rs
index e2a5126d77..4c0b70522c 100644
--- a/crates/doc/src/lineage.rs
+++ b/crates/doc/src/lineage.rs
@@ -9,9 +9,10 @@
//! bodies the feature built itself (whose faces are named by their role: the sketch curve they
//! sweep, the cap they are). Naming (`history_names`) reads it; nothing here samples geometry.
+use solidcraft_geom::prelude::*;
use std::sync::{Arc, OnceLock};
-use solidcraft_geom::{Region2, Vec3};
+use solidcore_record::{Region2, Vec3};
use solidcraft_kernel::Body;
use solidcraft_kernel::history::{BodyHistory, Change, FaceOrigin, FaceProv, History};
@@ -232,7 +233,7 @@ impl<'a> ProfileRoles<'a> {
if history.operands != 0 {
return None;
}
- let segments: Vec<&solidcraft_geom::Seg2> =
+ let segments: Vec<&solidcore_record::Seg2> =
self.region.map(|r| std::iter::once(&r.outer).chain(&r.holes).flat_map(|l| &l.segs).collect()).unwrap_or_default();
let curves = self.sketch.map(crate::config::ExactSketchCurves::new);
// Every curve the segment is drawn on (one, or several coincident or collinear ones).
@@ -294,7 +295,7 @@ impl<'a> ProfileRoles<'a> {
/// numbered through the chains in order. It has no caps.
pub(crate) struct ChainRoles<'a> {
pub sketch: &'a SolvedSketch,
- pub chains: &'a [Vec<solidcraft_geom::Seg2>],
+ pub chains: &'a [Vec<solidcore_record::Seg2>],
}
impl ChainRoles<'_> {
@@ -305,7 +306,7 @@ impl ChainRoles<'_> {
}
fn of(&self, history: &History) -> Vec<Vec<String>> {
- let segments: Vec<&solidcraft_geom::Seg2> = self.chains.iter().flatten().collect();
+ let segments: Vec<&solidcore_record::Seg2> = self.chains.iter().flatten().collect();
let curves = crate::config::ExactSketchCurves::new(self.sketch);
history
.faces
@@ -336,7 +337,7 @@ impl ChainRoles<'_> {
/// answering to the others; its caps `start` and `end`.
pub(crate) struct SectionRoles<'a> {
/// Each section's sketch and loops (outer, then holes), in the order given.
- pub sections: Vec<(&'a SolvedSketch, Vec<&'a solidcraft_geom::Loop2>)>,
+ pub sections: Vec<(&'a SolvedSketch, Vec<&'a solidcore_record::Loop2>)>,
}
impl SectionRoles<'_> {
diff --git a/crates/doc/src/motion.rs b/crates/doc/src/motion.rs
index 8d5dd8302a..c4c342141e 100644
--- a/crates/doc/src/motion.rs
+++ b/crates/doc/src/motion.rs
@@ -3,7 +3,7 @@
//! shown without changing the design).
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
/// The motion retained by an associative trace. Joint bounds keep their expressions, in
/// command units (degrees or millimetres); studies are referenced by their stable identity.
diff --git a/crates/doc/src/name_lookup.rs b/crates/doc/src/name_lookup.rs
index ee675557a9..cec1dfd560 100644
--- a/crates/doc/src/name_lookup.rs
+++ b/crates/doc/src/name_lookup.rs
@@ -10,7 +10,9 @@
//! ([`crate::DocError::Reselect`]). A face whose name was worked out from geometry, found where
//! the reference's point no longer lies, is reported: only geometry decided.
-use solidcraft_geom::{Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Mesh;
+use solidcraft_geom::prelude::*;
use crate::history_names::{Match, Names};
use crate::naming::{self, closest, edge_names, face_names, strip_piece};
diff --git a/crates/doc/src/named_projection_tests.rs b/crates/doc/src/named_projection_tests.rs
index f2de761969..37169c1f68 100644
--- a/crates/doc/src/named_projection_tests.rs
+++ b/crates/doc/src/named_projection_tests.rs
@@ -1,5 +1,6 @@
use crate::{Document, ModelBody, ModelState};
-use solidcraft_geom::{Plane, Vec3};
+use solidcore_record::{Plane, Vec3};
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::{LinkKind, LinkSource, Sketch};
use std::collections::BTreeMap;
use std::sync::Arc;
diff --git a/crates/doc/src/naming.rs b/crates/doc/src/naming.rs
index 56a8bc69e6..3ae234ee20 100644
--- a/crates/doc/src/naming.rs
+++ b/crates/doc/src/naming.rs
@@ -15,9 +15,11 @@
//! are looked up on the input's faces. Those names are marked unverified, and references that
//! resolve through them say so. Names are worked out lazily, on first request.
+use solidcraft_geom::prelude::*;
use std::sync::{Arc, OnceLock};
-use solidcraft_geom::{Aabb3, Mesh, Vec2, Vec3};
+use solidcore_record::{Vec2, Vec3};
+use solidcraft_geom::{Aabb3, Mesh};
use crate::history_names::Names;
use crate::lineage::Lineage;
@@ -1446,7 +1448,7 @@ mod tests {
let ss = crate::SolvedSketch {
feature: 1,
name: "S".into(),
- plane: solidcraft_geom::Plane::XY,
+ plane: solidcore_record::Plane::XY,
sketch,
report,
profiles,
diff --git a/crates/doc/src/pbr_appearance.rs b/crates/doc/src/pbr_appearance.rs
index 4172f57147..d4b967aeca 100644
--- a/crates/doc/src/pbr_appearance.rs
+++ b/crates/doc/src/pbr_appearance.rs
@@ -1,7 +1,7 @@
//! Persistable opaque optical parameters, independent of engineering material data.
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_render::surface::{OpaqueSurface, SurfaceError, srgb8_to_linear};
/// Explicitly selected opaque response. Existing scalar looks have no such record.
diff --git a/crates/doc/src/placed_mesh.rs b/crates/doc/src/placed_mesh.rs
index 54eeb41320..780fffcb6c 100644
--- a/crates/doc/src/placed_mesh.rs
+++ b/crates/doc/src/placed_mesh.rs
@@ -1,9 +1,11 @@
//! Reference triangles belong to a definition, even while its occurrences move. Keep one lazy
//! source mesh and map it into each pose; retain the exact placed B-rep separately in ModelBody.
+use solidcraft_geom::prelude::*;
use std::sync::{Arc, OnceLock};
+use solidcore_record::Vec3;
+use solidcraft_geom::Mesh;
use solidcraft_geom::tess::TessPlan;
-use solidcraft_geom::{Mesh, Vec3};
use solidcraft_kernel::{self as kernel, Body};
use super::ModelBody;
diff --git a/crates/doc/src/point_cloud.rs b/crates/doc/src/point_cloud.rs
index 3e4cb21b61..ab174333de 100644
--- a/crates/doc/src/point_cloud.rs
+++ b/crates/doc/src/point_cloud.rs
@@ -5,10 +5,11 @@
//! cloud's own `origin` (double precision), so a scan far from the design's origin keeps its
//! detail.
+use solidcraft_geom::prelude::*;
use std::sync::Arc;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::canvas::{base64_decode, base64_encode};
pub use crate::point_cloud_complex::{Column, Complex, Filter, Floats, Keep, MAX_COLUMNS, MAX_NAMES, Names};
diff --git a/crates/doc/src/point_cloud_distribution_tests.rs b/crates/doc/src/point_cloud_distribution_tests.rs
index 52beaa86cd..cee5d00448 100644
--- a/crates/doc/src/point_cloud_distribution_tests.rs
+++ b/crates/doc/src/point_cloud_distribution_tests.rs
@@ -1,4 +1,4 @@
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use super::*;
use crate::IDENTITY;
diff --git a/crates/doc/src/points.rs b/crates/doc/src/points.rs
index f8c785f967..8c8f5a98b7 100644
--- a/crates/doc/src/points.rs
+++ b/crates/doc/src/points.rs
@@ -5,7 +5,7 @@
use std::ops::{Deref, DerefMut};
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
macro_rules! point_type {
($(#[$doc:meta])* $name:ident) => {
diff --git a/crates/doc/src/print_face.rs b/crates/doc/src/print_face.rs
index 180443b672..6d61e2a748 100644
--- a/crates/doc/src/print_face.rs
+++ b/crates/doc/src/print_face.rs
@@ -3,7 +3,8 @@
//! sketch on a face holds ([`Document::flat_face_target`]), so a rebuild that adds, removes or
//! reorders faces finds the same face again, or says it is gone.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use crate::config::ConfigFaceTarget;
use crate::{DocError, Document, ModelBody, ModelState, Result};
diff --git a/crates/doc/src/profile_refs.rs b/crates/doc/src/profile_refs.rs
index 7c2bf9839c..ccd4335b01 100644
--- a/crates/doc/src/profile_refs.rs
+++ b/crates/doc/src/profile_refs.rs
@@ -1,4 +1,5 @@
//! Exact profile references through analytic offset topology transitions.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeSet;
use crate::{DocError, ProfileSel, Result, SolvedSketch, WholeProfileBoundary};
@@ -364,7 +365,7 @@ mod tests {
#![allow(clippy::unwrap_used, clippy::panic)]
use super::*;
use serde_json::json;
- use solidcraft_geom::{Plane, Vec2};
+ use solidcore_record::{Plane, Vec2};
use solidcraft_sketch::{Sketch, find_profiles, solve};
fn rounded_source(sketch: &mut Sketch, radius: f64) -> Vec<(String, bool)> {
diff --git a/crates/doc/src/progress.rs b/crates/doc/src/progress.rs
index 5f5b9c8162..5da224c129 100644
--- a/crates/doc/src/progress.rs
+++ b/crates/doc/src/progress.rs
@@ -293,7 +293,7 @@ mod tests {
fn partial_models_go_only_to_a_watcher_that_wants_them() {
let mut doc = crate::Document::new("partial");
let block = crate::FeatureKind::Box {
- corner: crate::point_expr(solidcraft_geom::Vec3::ZERO),
+ corner: crate::point_expr(solidcore_record::Vec3::ZERO),
length: "2 mm".into(),
width: "3 mm".into(),
height: "4 mm".into(),
diff --git a/crates/doc/src/project.rs b/crates/doc/src/project.rs
index 6be942dc45..1ecfed6fb1 100644
--- a/crates/doc/src/project.rs
+++ b/crates/doc/src/project.rs
@@ -10,9 +10,11 @@
//! lines and circular arcs are recovered exactly, the rest (an ellipse from a tilted circle,
//! a spline edge running out of the plane) becomes a chain of lines.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
-use solidcraft_geom::{Mesh, Plane, Seg2, Vec2, Vec3};
+use solidcore_record::{Plane, Seg2, Vec2, Vec3};
+use solidcraft_geom::Mesh;
use solidcraft_sketch::{CurveKind, LinkGeom, LinkKind, LinkSource, Sketch, WireCurve};
use crate::eval::ModelState;
@@ -363,7 +365,7 @@ fn edge_curves(body: Option<&crate::ModelBody>, e: usize) -> Vec<WireCurve> {
record
.edges
.get(e)
- .filter(|edge| !matches!(edge.curve, solidcraft_geom::brep::Curve::SurfaceIntersection { .. }))
+ .filter(|edge| !matches!(edge.curve, solidcore_record::brep::Curve::SurfaceIntersection { .. }))
.map(|edge| vec![WireCurve { curve: edge.parameters().clone(), interval: edge.interval }])
.unwrap_or_default()
}
@@ -394,9 +396,9 @@ fn projected_wires(
/// in front of it.
fn first_hits(
target: &crate::ModelBody,
- curves: Vec<(solidcraft_geom::brep::Curve, [f64; 2])>,
+ curves: Vec<(solidcore_record::brep::Curve, [f64; 2])>,
toward: Vec3,
-) -> Result<Vec<(solidcraft_geom::brep::Curve, [f64; 2])>> {
+) -> Result<Vec<(solidcore_record::brep::Curve, [f64; 2])>> {
let Some(dir) = toward.normalized() else { return Ok(curves) };
let mesh = target.mesh();
let reach = 2.0 * mesh.bounds().diagonal().max(1e-9);
@@ -418,7 +420,7 @@ fn first_hits(
/// direction they come (a projection split at a sphere's pole into two pieces that both end there
/// joins again there, the second run the other way), each wire its points (for display) and its
/// exact curves.
-fn joined_wires(curves: Vec<(solidcraft_geom::brep::Curve, [f64; 2])>, tol: f64) -> Result<(Vec<Vec<Vec3>>, Vec<Vec<WireCurve>>)> {
+fn joined_wires(curves: Vec<(solidcore_record::brep::Curve, [f64; 2])>, tol: f64) -> Result<(Vec<Vec<Vec3>>, Vec<Vec<WireCurve>>)> {
let (mut wires, mut exact): (Vec<Vec<Vec3>>, Vec<Vec<WireCurve>>) = (Vec::new(), Vec::new());
for (curve, interval) in curves {
let pts = crate::kernel::PathPiece::Segs(crate::kernel::curve_path(&curve, interval)?).points();
@@ -466,7 +468,7 @@ fn joined_wires(curves: Vec<(solidcraft_geom::brep::Curve, [f64; 2])>, tol: f64)
/// own knots (a line's `1 - t`, a circle's or ellipse's angle negated with its y axis turned).
/// Exact; `None` for a curve kind it doesn't turn.
fn reversed(c: &WireCurve) -> Option<WireCurve> {
- use solidcraft_geom::brep::{Curve, Frame};
+ use solidcore_record::brep::{Curve, Frame};
let [t0, t1] = c.interval;
let flip = |frame: &Frame| Frame { origin: frame.origin, x_axis: frame.x_axis, y_axis: frame.y_axis.map(|v| -v) };
let (curve, interval) = match &c.curve {
diff --git a/crates/doc/src/project3d.rs b/crates/doc/src/project3d.rs
index 6542c12fa8..cf3b0fbbb5 100644
--- a/crates/doc/src/project3d.rs
+++ b/crates/doc/src/project3d.rs
@@ -1,7 +1,9 @@
//! 3D sketch curves from the model: curves projected onto faces (on their display meshes), the
//! bodies and faces an intersection curve is taken on, and spun profiles.
-use solidcraft_geom::{Mesh, Plane, Vec2, Vec3};
+use solidcore_record::{Plane, Vec2, Vec3};
+use solidcraft_geom::Mesh;
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::LinkSource;
use crate::eval::ModelState;
diff --git a/crates/doc/src/project_order.rs b/crates/doc/src/project_order.rs
index 7131428ab4..29792b4fe6 100644
--- a/crates/doc/src/project_order.rs
+++ b/crates/doc/src/project_order.rs
@@ -1,9 +1,11 @@
//! Stable face projection order: outer boundary first, then holes by geometry.
//! B-rep edge indices depend on face enumeration and must not choose sketch curve IDs.
+use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
-use solidcraft_geom::{Aabb3, Mesh, Plane, Vec3};
+use solidcore_record::{Plane, Vec3};
+use solidcraft_geom::{Aabb3, Mesh};
use crate::{DocError, Result};
@@ -228,7 +230,7 @@ mod tests {
#[test]
fn coarsely_tessellated_round_silhouette_fits_an_arc() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::LinkGeom;
let on = |deg: f64| Vec2::new(5. + 5. * deg.to_radians().cos(), 5. + 5. * deg.to_radians().sin());
let mut chain = vec![Vec2::new(0., -20.)];
@@ -241,7 +243,7 @@ mod tests {
#[test]
fn tangent_snapping_leaves_unrelated_collinear_lines_alone() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::LinkGeom;
let v = Vec2::new;
// A rounded corner of radius 2 meeting the top edge, and an unrelated collinear edge.
@@ -258,7 +260,7 @@ mod tests {
#[test]
fn tangent_snapping_leaves_a_line_further_along_alone() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::LinkGeom;
let v = Vec2::new;
let y = |x: f64| 2.0 - (4.0 - x * x).sqrt();
@@ -279,7 +281,7 @@ mod tests {
#[test]
fn tangent_snapping_gives_one_line_to_one_end_of_an_arc() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::LinkGeom;
let v = Vec2::new;
let y = |x: f64| 2.0 - (4.0 - x * x).sqrt();
@@ -293,7 +295,7 @@ mod tests {
#[test]
fn tangent_snapping_moves_the_other_end_of_an_arc_to_its_next_line() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::LinkGeom;
let v = Vec2::new;
let y = |x: f64| 2.0 - (4.0 - x * x).sqrt();
@@ -312,7 +314,7 @@ mod tests {
#[test]
fn tangent_snapping_closes_a_conic_corner_in_any_order() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::LinkGeom;
// A square of side 150 with a conic round of 10 mm legs at each corner, fitted with lines
// and arcs the way a silhouette is, then snapped with the pieces in each order.
@@ -410,7 +412,7 @@ mod tests {
#[test]
fn family_line_normalization_preserves_corners_arcs_branches_and_retracing() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::LinkGeom;
let line = |a, b| LinkGeom::Line(Vec2::new(a, 0.), Vec2::new(b, 0.));
assert_eq!(super::super::merge_family_lines(vec![line(0., 1.), line(2., 1.)]).unwrap(), vec![line(0., 2.)]);
@@ -498,7 +500,7 @@ mod tests {
#[test]
fn rounded_boundary_arc_sweeps_survive_individual_edge_reversal() {
- use solidcraft_geom::{Seg2, Vec2};
+ use solidcore_record::{Seg2, Vec2};
use solidcraft_sketch::LinkGeom;
let mut mesh = Mesh::default();
for (extent, radius) in [(10.0, 3.0), (8.0, 1.0)] {
@@ -593,7 +595,7 @@ mod tests {
#[test]
fn curve_ends_a_hair_apart_become_one_point_and_distant_ones_stay() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::LinkGeom;
let mut geom = vec![
LinkGeom::Line(Vec2::new(0., 0.), Vec2::new(10., 0.)),
diff --git a/crates/doc/src/render_optics.rs b/crates/doc/src/render_optics.rs
index c6e7db74f8..2915d93983 100644
--- a/crates/doc/src/render_optics.rs
+++ b/crates/doc/src/render_optics.rs
@@ -5,7 +5,7 @@ use crate::{
render_surface::{RenderBodyTarget, bounded_sequence},
};
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_render::{
surface::OpaqueSurface,
transmission::{Transmission, subsurface::Subsurface},
diff --git a/crates/doc/src/render_settings.rs b/crates/doc/src/render_settings.rs
index 1d575648be..d1a62568bf 100644
--- a/crates/doc/src/render_settings.rs
+++ b/crates/doc/src/render_settings.rs
@@ -3,7 +3,7 @@
use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_render::{BackendId, Camera, RenderFormat, RenderLimits, RenderMode, UpAxis};
pub use crate::render_job::{CpuJob, GpuJob, RenderJob, SkyEnvironment};
diff --git a/crates/doc/src/sheet.rs b/crates/doc/src/sheet.rs
index a710b12684..cc444eca49 100644
--- a/crates/doc/src/sheet.rs
+++ b/crates/doc/src/sheet.rs
@@ -10,7 +10,9 @@
//! together; the flat solid is the outline extruded through the thickness.
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Aabb2, LINEAR_TOL, Loop2, Plane, Region2, Ring, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
+use solidcraft_geom::{Aabb2, LINEAR_TOL, Ring};
use solidcraft_kernel::{self as kernel, Body, EdgeSpec, FaceSpec, SurfSpec};
use crate::expr::{self, Kind, Value};
diff --git a/crates/doc/src/sheet_convert.rs b/crates/doc/src/sheet_convert.rs
index 9523d223b5..e5eaa83f54 100644
--- a/crates/doc/src/sheet_convert.rs
+++ b/crates/doc/src/sheet_convert.rs
@@ -47,10 +47,12 @@
//! edges that end at a bend or a cut edge, loops of bends, two faces that meet along more than
//! one edge, a wall on part of an edge of a face other than the fixed one.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
use std::f64::consts::{FRAC_PI_2, PI, TAU};
-use solidcraft_geom::{Loop2, Mesh, Plane, Region2, Ring, Seg2, UnitVec3, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcraft_geom::{Mesh, Ring, UnitVec3};
use solidcraft_kernel::{Body, FaceSurface, face_surface};
use super::{FlatWork, ReliefOverride, RuleValues, SheetBody, SheetFlange, base_flange, polys_cross, signed_area, snap};
diff --git a/crates/doc/src/sheet_face_names.rs b/crates/doc/src/sheet_face_names.rs
index c23149f15c..c761858e09 100644
--- a/crates/doc/src/sheet_face_names.rs
+++ b/crates/doc/src/sheet_face_names.rs
@@ -5,7 +5,8 @@
//! neighbouring flange), the rim along the bend there, `<flange>:rim.ext0` and `rim.ext1`. A panel is `base` or a flange's tag (`F<feature>.<k>`), so the names
//! say what each face is and stay with it when sizes change or other flanges come and go.
-use solidcraft_geom::{Plane, Vec2, Vec3};
+use solidcore_record::{Plane, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use super::SheetBody;
use crate::{ModelBody, ModelState, apply_point, mat_inverse};
diff --git a/crates/doc/src/sketch_equation.rs b/crates/doc/src/sketch_equation.rs
index ce5fe0e2d3..646b07fc60 100644
--- a/crates/doc/src/sketch_equation.rs
+++ b/crates/doc/src/sketch_equation.rs
@@ -5,9 +5,10 @@
//! between the points, up to the most a spline takes. When the parameters change, the same
//! number of points is placed again (`Document::apply_equation_values`), before every solve.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use solidcraft_sketch::{EquationCurve, MAX_COORD, MAX_EQUATION_TEXT, MAX_SPLINE_POINTS, Sketch, VariableUnit, fit_beziers_mode};
use crate::expr::{self, Defaults, Kind, Value};
diff --git a/crates/doc/src/tests.rs b/crates/doc/src/tests.rs
index f48189ac6b..94160eb1ab 100644
--- a/crates/doc/src/tests.rs
+++ b/crates/doc/src/tests.rs
@@ -1,4 +1,4 @@
-use solidcraft_geom::{Vec2, Vec3};
+use solidcore_record::{Vec2, Vec3};
use solidcraft_kernel::measure;
use solidcraft_sketch::{ConstraintKind, Sketch};
diff --git a/crates/doc/src/walk.rs b/crates/doc/src/walk.rs
index 4677bbcd19..90a114681d 100644
--- a/crates/doc/src/walk.rs
+++ b/crates/doc/src/walk.rs
@@ -5,7 +5,7 @@
//! traits here carry the walks through the types the fields have: options, lists, arrays, planes
//! and construction definitions.
-pub(crate) use solidcraft_geom::Vec3;
+pub(crate) use solidcore_record::Vec3;
pub(crate) use crate::ProfileSel;
use crate::construct::{AxisDef, GeoRef, PointDef};
diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml
index 1aff221ef4..604fe4be13 100644
--- a/crates/engine/Cargo.toml
+++ b/crates/engine/Cargo.toml
@@ -35,6 +35,7 @@ name = "sketch_target_bench"
required-features = ["solver-profiling"]
[dependencies]
+solidcore-record = { workspace = true }
solidcraft-geom = { workspace = true }
solidcraft-sketch = { workspace = true }
solidcraft-kernel = { workspace = true }
diff --git a/crates/engine/examples/sketch_analysis_bench.rs b/crates/engine/examples/sketch_analysis_bench.rs
index e7a10daaac..6c29b71944 100644
--- a/crates/engine/examples/sketch_analysis_bench.rs
+++ b/crates/engine/examples/sketch_analysis_bench.rs
@@ -3,8 +3,8 @@
use std::{error::Error, io::Write, path::PathBuf, sync::Arc, time::Instant};
use serde_json::{Value, json};
+use solidcore_record::Vec2;
use solidcraft_engine::Session;
-use solidcraft_geom::Vec2;
use solidcraft_sketch::{ConstraintKind, Sketch, profiling::capture};
type Result<T> = std::result::Result<T, Box<dyn Error>>;
diff --git a/crates/engine/examples/sketch_drag_bench.rs b/crates/engine/examples/sketch_drag_bench.rs
index df15c69759..fff6c4d624 100644
--- a/crates/engine/examples/sketch_drag_bench.rs
+++ b/crates/engine/examples/sketch_drag_bench.rs
@@ -2,8 +2,8 @@
use std::{error::Error, io::Write, path::PathBuf, sync::Arc, time::Instant};
use serde_json::{Value, json};
+use solidcore_record::Vec2;
use solidcraft_engine::Session;
-use solidcraft_geom::Vec2;
use solidcraft_sketch::{Analysis, ConstraintKind, Hold, Sketch, profiling::capture, solve_with};
type Result<T> = std::result::Result<T, Box<dyn Error>>;
diff --git a/crates/engine/examples/sketch_target_bench.rs b/crates/engine/examples/sketch_target_bench.rs
index b07f661262..bc2a210de0 100644
--- a/crates/engine/examples/sketch_target_bench.rs
+++ b/crates/engine/examples/sketch_target_bench.rs
@@ -3,7 +3,7 @@
mod four_bar;
use four_bar::Result;
use serde_json::json;
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use solidcraft_sketch::profiling::capture;
use std::{io::Write, time::Instant};
diff --git a/crates/engine/src/boolean_regression_tests.rs b/crates/engine/src/boolean_regression_tests.rs
index 02f542019c..57773fa9da 100644
--- a/crates/engine/src/boolean_regression_tests.rs
+++ b/crates/engine/src/boolean_regression_tests.rs
@@ -2,6 +2,7 @@
//! `examples/regressions/` (each script's description says what went wrong).
use serde_json::{Value, json};
+use solidcraft_geom::prelude::*;
use crate::Session;
@@ -228,10 +229,10 @@ fn shallow_cuts_rebuild_after_inserting_an_earlier_pocket() {
let actual = volume(&session, "Plate");
assert!((actual - expected).abs() < 0.02, "{actual} vs {expected}");
let mesh = body.mesh(&solidcraft_kernel::MeshTolerance::chord(0.001)).unwrap();
- assert!(!mesh.contains(solidcraft_geom::Vec3::new(12.0, 14.0, 9.0)));
- assert!(mesh.contains(solidcraft_geom::Vec3::new(12.0, 14.0, 8.0)));
- assert!(!mesh.contains(solidcraft_geom::Vec3::new(20.0, 20.0, 9.5)));
- assert!(mesh.contains(solidcraft_geom::Vec3::new(20.0, 20.0, 9.0)));
+ assert!(!mesh.contains(solidcore_record::Vec3::new(12.0, 14.0, 9.0)));
+ assert!(mesh.contains(solidcore_record::Vec3::new(12.0, 14.0, 8.0)));
+ assert!(!mesh.contains(solidcore_record::Vec3::new(20.0, 20.0, 9.5)));
+ assert!(mesh.contains(solidcore_record::Vec3::new(20.0, 20.0, 9.0)));
}
}
@@ -256,7 +257,7 @@ fn eighteen_tabs_join_the_ribs_of_a_chamfered_base() {
println!("#2059 volume {got:.6} / {expected:.6} mm³; one valid shell, eighteen tabs");
for k in 0..6 {
let angle = k as f64 * std::f64::consts::TAU / 6.0;
- let p = |x: f64, y: f64, z| solidcraft_geom::Vec3::new(x * angle.cos() - y * angle.sin(), x * angle.sin() + y * angle.cos(), z);
+ let p = |x: f64, y: f64, z| solidcore_record::Vec3::new(x * angle.cos() - y * angle.sin(), x * angle.sin() + y * angle.cos(), z);
for x in [15.5, 25.5, 35.5] {
assert!(mesh.contains(p(x, 0.0, 12.0)), "tab {k} at {x}");
assert!(!mesh.contains(p(x, 1.2, 12.0)), "tab {k} grew sideways at {x}");
@@ -799,7 +800,7 @@ fn closed_sweep_redefines_to_a_half_turn_torus_cut() {
let mesh = body.mesh(&solidcraft_kernel::MeshTolerance::chord(0.02)).unwrap();
let expected = (std::f64::consts::PI * 64.0 - 64.0) * std::f64::consts::TAU * 30.0;
assert!((mesh.measure().volume - expected).abs() < expected * 0.015);
- for (point, material) in [(solidcraft_geom::Vec3::new(30.0, 0.0, 0.0), false), (solidcraft_geom::Vec3::new(30.0, 0.0, 7.0), true)] {
+ for (point, material) in [(solidcore_record::Vec3::new(30.0, 0.0, 0.0), false), (solidcore_record::Vec3::new(30.0, 0.0, 7.0), true)] {
assert_eq!(mesh.contains(point), material, "material at {point:?}");
}
}
@@ -831,7 +832,7 @@ fn many_extrusion_profiles_preserve_material_and_body_identity() {
assert!((volume(&s, "Stock") - expected).abs() < 1e-6);
let stock = state.body("Stock").unwrap();
for (point, present) in [([3.0, 3.0, 22.0], operation == "join"), ([3.0, 3.0, 18.0], operation != "cut"), ([7.0, 3.0, 18.0], true)] {
- assert_eq!(stock.mesh().contains(solidcraft_geom::Vec3::from(point)), present, "{operation}: {point:?}");
+ assert_eq!(stock.mesh().contains(solidcore_record::Vec3::from(point)), present, "{operation}: {point:?}");
}
assert!(stock.body.validity().is_empty());
assert!(s.revision > before);
@@ -864,10 +865,10 @@ fn many_circular_extrusion_profiles_cut_a_curved_target() {
let stock = state.body("Stock").unwrap();
assert!(stock.body.validity().is_empty());
let mesh = stock.mesh();
- assert!(mesh.contains(solidcraft_geom::Vec3::new(0.0, 0.0, 10.0)));
+ assert!(mesh.contains(solidcore_record::Vec3::new(0.0, 0.0, 10.0)));
for x in [-9.0, -3.0, 3.0, 9.0] {
for y in [-9.0, -3.0, 3.0, 9.0] {
- assert!(!mesh.contains(solidcraft_geom::Vec3::new(x, y, 10.0)), "hole at {x}, {y}");
+ assert!(!mesh.contains(solidcore_record::Vec3::new(x, y, 10.0)), "hole at {x}, {y}");
}
}
}
@@ -927,7 +928,7 @@ fn unsupported_face_groups_are_atomic() {
#[test]
fn imported_rotated_face_extrusions_preserve_other_operations_and_bodies() {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let mut source = Session::default();
source.execute("solid.box", &json!({"corner":[-16,-16,-3],"length":32,"width":32,"height":1,"body_name":"Other"})).unwrap();
source.execute("solid.cylinder", &json!({"radius":14,"height":8,"body_name":"Stock"})).unwrap();
diff --git a/crates/engine/src/cmd/browser.rs b/crates/engine/src/cmd/browser.rs
index d7d472eb15..96389deb5f 100644
--- a/crates/engine/src/cmd/browser.rs
+++ b/crates/engine/src/cmd/browser.rs
@@ -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"}));
diff --git a/crates/engine/src/cmd/canvas_sketch.rs b/crates/engine/src/cmd/canvas_sketch.rs
index 61b4253834..47411a4d68 100644
--- a/crates/engine/src/cmd/canvas_sketch.rs
+++ b/crates/engine/src/cmd/canvas_sketch.rs
@@ -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;
diff --git a/crates/engine/src/cmd/clearance.rs b/crates/engine/src/cmd/clearance.rs
index 1bb9fe5c01..762eadb55d 100644
--- a/crates/engine/src/cmd/clearance.rs
+++ b/crates/engine/src/cmd/clearance.rs
@@ -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 };
diff --git a/crates/engine/src/cmd/clipboard.rs b/crates/engine/src/cmd/clipboard.rs
index b862984545..5667564185 100644
--- a/crates/engine/src/cmd/clipboard.rs
+++ b/crates/engine/src/cmd/clipboard.rs
@@ -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.)];
diff --git a/crates/engine/src/cmd/clipboard_foreign.rs b/crates/engine/src/cmd/clipboard_foreign.rs
index 50b6c48717..b33960a8c5 100644
--- a/crates/engine/src/cmd/clipboard_foreign.rs
+++ b/crates/engine/src/cmd/clipboard_foreign.rs
@@ -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 {
diff --git a/crates/engine/src/cmd/compare.rs b/crates/engine/src/cmd/compare.rs
index 58727974c4..c241e7408a 100644
--- a/crates/engine/src/cmd/compare.rs
+++ b/crates/engine/src/cmd/compare.rs
@@ -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;
diff --git a/crates/engine/src/cmd/component.rs b/crates/engine/src/cmd/component.rs
index 030d1a96ef..2203e0d4d2 100644
--- a/crates/engine/src/cmd/component.rs
+++ b/crates/engine/src/cmd/component.rs
@@ -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};
diff --git a/crates/engine/src/cmd/component_align.rs b/crates/engine/src/cmd/component_align.rs
index 2499769047..7e8ed09781 100644
--- a/crates/engine/src/cmd/component_align.rs
+++ b/crates/engine/src/cmd/component_align.rs
@@ -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};
diff --git a/crates/engine/src/cmd/component_clone.rs b/crates/engine/src/cmd/component_clone.rs
index 11b80c4b61..0e0ab69285 100644
--- a/crates/engine/src/cmd/component_clone.rs
+++ b/crates/engine/src/cmd/component_clone.rs
@@ -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);
}
diff --git a/crates/engine/src/cmd/component_clone_assembly_tests.rs b/crates/engine/src/cmd/component_clone_assembly_tests.rs
index ff1868d729..02390ecff3 100644
--- a/crates/engine/src/cmd/component_clone_assembly_tests.rs
+++ b/crates/engine/src/cmd/component_clone_assembly_tests.rs
@@ -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 } }
diff --git a/crates/engine/src/cmd/component_clone_tests.rs b/crates/engine/src/cmd/component_clone_tests.rs
index b879f2d3f5..727d21b9d1 100644
--- a/crates/engine/src/cmd/component_clone_tests.rs
+++ b/crates/engine/src/cmd/component_clone_tests.rs
@@ -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"}));
diff --git a/crates/engine/src/cmd/component_extract.rs b/crates/engine/src/cmd/component_extract.rs
index 8cc8d850af..2ac92d4c3d 100644
--- a/crates/engine/src/cmd/component_extract.rs
+++ b/crates/engine/src/cmd/component_extract.rs
@@ -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_};
diff --git a/crates/engine/src/cmd/component_foreign_tests.rs b/crates/engine/src/cmd/component_foreign_tests.rs
index 6043b04968..1e989339e0 100644
--- a/crates/engine/src/cmd/component_foreign_tests.rs
+++ b/crates/engine/src/cmd/component_foreign_tests.rs
@@ -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 {
diff --git a/crates/engine/src/cmd/component_link.rs b/crates/engine/src/cmd/component_link.rs
index d33fdbcffe..b2e0bedb64 100644
--- a/crates/engine/src/cmd/component_link.rs
+++ b/crates/engine/src/cmd/component_link.rs
@@ -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.
diff --git a/crates/engine/src/cmd/component_properties.rs b/crates/engine/src/cmd/component_properties.rs
index 34c7e5ecd1..1cb482d5fa 100644
--- a/crates/engine/src/cmd/component_properties.rs
+++ b/crates/engine/src/cmd/component_properties.rs
@@ -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};
diff --git a/crates/engine/src/cmd/component_properties_tests.rs b/crates/engine/src/cmd/component_properties_tests.rs
index 20fcaee26e..fc42af5d61 100644
--- a/crates/engine/src/cmd/component_properties_tests.rs
+++ b/crates/engine/src/cmd/component_properties_tests.rs
@@ -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}));
diff --git a/crates/engine/src/cmd/component_relink_tests.rs b/crates/engine/src/cmd/component_relink_tests.rs
index f214f20ab3..672279a872 100644
--- a/crates/engine/src/cmd/component_relink_tests.rs
+++ b/crates/engine/src/cmd/component_relink_tests.rs
@@ -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"));
diff --git a/crates/engine/src/cmd/component_sketches_to_parts.rs b/crates/engine/src/cmd/component_sketches_to_parts.rs
index c36c752da4..f2e2dae2dc 100644
--- a/crates/engine/src/cmd/component_sketches_to_parts.rs
+++ b/crates/engine/src/cmd/component_sketches_to_parts.rs
@@ -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};
diff --git a/crates/engine/src/cmd/config_certificate_tests.rs b/crates/engine/src/cmd/config_certificate_tests.rs
index e82e64c676..5c9a450a98 100644
--- a/crates/engine/src/cmd/config_certificate_tests.rs
+++ b/crates/engine/src/cmd/config_certificate_tests.rs
@@ -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}"))
diff --git a/crates/engine/src/cmd/config_style_tests.rs b/crates/engine/src/cmd/config_style_tests.rs
index f353a0d8fe..7c25af895b 100644
--- a/crates/engine/src/cmd/config_style_tests.rs
+++ b/crates/engine/src/cmd/config_style_tests.rs
@@ -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());
diff --git a/crates/engine/src/cmd/construct.rs b/crates/engine/src/cmd/construct.rs
index 26c4b83547..938d138213 100644
--- a/crates/engine/src/cmd/construct.rs
+++ b/crates/engine/src/cmd/construct.rs
@@ -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};
diff --git a/crates/engine/src/cmd/contact_sweep.rs b/crates/engine/src/cmd/contact_sweep.rs
index 3418000d9d..d507ad3d7e 100644
--- a/crates/engine/src/cmd/contact_sweep.rs
+++ b/crates/engine/src/cmd/contact_sweep.rs
@@ -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};
diff --git a/crates/engine/src/cmd/contact_sweep_tests.rs b/crates/engine/src/cmd/contact_sweep_tests.rs
index 62906e2cb5..9828e7557b 100644
--- a/crates/engine/src/cmd/contact_sweep_tests.rs
+++ b/crates/engine/src/cmd/contact_sweep_tests.rs
@@ -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()
diff --git a/crates/engine/src/cmd/delete.rs b/crates/engine/src/cmd/delete.rs
index 36e3a0a268..f000d14a86 100644
--- a/crates/engine/src/cmd/delete.rs
+++ b/crates/engine/src/cmd/delete.rs
@@ -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:?}");
diff --git a/crates/engine/src/cmd/edit.rs b/crates/engine/src/cmd/edit.rs
index e158d3611b..c133e69036 100644
--- a/crates/engine/src/cmd/edit.rs
+++ b/crates/engine/src/cmd/edit.rs
@@ -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()) {
diff --git a/crates/engine/src/cmd/edit_tests.rs b/crates/engine/src/cmd/edit_tests.rs
index f129a957a7..3d750a7659 100644
--- a/crates/engine/src/cmd/edit_tests.rs
+++ b/crates/engine/src/cmd/edit_tests.rs
@@ -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!({}));
diff --git a/crates/engine/src/cmd/face.rs b/crates/engine/src/cmd/face.rs
index 6f8eba21bb..adb56c4bcf 100644
--- a/crates/engine/src/cmd/face.rs
+++ b/crates/engine/src/cmd/face.rs
@@ -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"));
diff --git a/crates/engine/src/cmd/face_join_tests.rs b/crates/engine/src/cmd/face_join_tests.rs
index de35d74f3f..ca8ba1ec47 100644
--- a/crates/engine/src/cmd/face_join_tests.rs
+++ b/crates/engine/src/cmd/face_join_tests.rs
@@ -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}"))
diff --git a/crates/engine/src/cmd/face_tests.rs b/crates/engine/src/cmd/face_tests.rs
index f8721b428c..2c0fdfb3ed 100644
--- a/crates/engine/src/cmd/face_tests.rs
+++ b/crates/engine/src/cmd/face_tests.rs
@@ -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 {
diff --git a/crates/engine/src/cmd/features.rs b/crates/engine/src/cmd/features.rs
index 270ac66426..f86dfd23d5 100644
--- a/crates/engine/src/cmd/features.rs
+++ b/crates/engine/src/cmd/features.rs
@@ -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 { .. })
{
diff --git a/crates/engine/src/cmd/features_more.rs b/crates/engine/src/cmd/features_more.rs
index b17f827ade..3c5c991f22 100644
--- a/crates/engine/src/cmd/features_more.rs
+++ b/crates/engine/src/cmd/features_more.rs
@@ -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)?,
diff --git a/crates/engine/src/cmd/features_more_tests.rs b/crates/engine/src/cmd/features_more_tests.rs
index 38fa94f90e..2a8683aec7 100644
--- a/crates/engine/src/cmd/features_more_tests.rs
+++ b/crates/engine/src/cmd/features_more_tests.rs
@@ -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
diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rs
index 3c2159a686..3ef6d18cd0 100644
--- a/crates/engine/src/cmd/file.rs
+++ b/crates/engine/src/cmd/file.rs
@@ -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");
diff --git a/crates/engine/src/cmd/file_import.rs b/crates/engine/src/cmd/file_import.rs
index 0a3ea1d103..4577435d83 100644
--- a/crates/engine/src/cmd/file_import.rs
+++ b/crates/engine/src/cmd/file_import.rs
@@ -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};
diff --git a/crates/engine/src/cmd/frame.rs b/crates/engine/src/cmd/frame.rs
index d0fec7a264..4eabb3edb0 100644
--- a/crates/engine/src/cmd/frame.rs
+++ b/crates/engine/src/cmd/frame.rs
@@ -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};
diff --git a/crates/engine/src/cmd/inspect.rs b/crates/engine/src/cmd/inspect.rs
index 591fea3699..48fa4f6740 100644
--- a/crates/engine/src/cmd/inspect.rs
+++ b/crates/engine/src/cmd/inspect.rs
@@ -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)
}
diff --git a/crates/engine/src/cmd/interference.rs b/crates/engine/src/cmd/interference.rs
index 16849c0de3..69dec681c5 100644
--- a/crates/engine/src/cmd/interference.rs
+++ b/crates/engine/src/cmd/interference.rs
@@ -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;
diff --git a/crates/engine/src/cmd/join_pieces.rs b/crates/engine/src/cmd/join_pieces.rs
index cae7a7d4da..cbb3ce9aec 100644
--- a/crates/engine/src/cmd/join_pieces.rs
+++ b/crates/engine/src/cmd/join_pieces.rs
@@ -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;
diff --git a/crates/engine/src/cmd/joint_edge_tests.rs b/crates/engine/src/cmd/joint_edge_tests.rs
index e471703825..00721f9119 100644
--- a/crates/engine/src/cmd/joint_edge_tests.rs
+++ b/crates/engine/src/cmd/joint_edge_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/joint_frames_tests.rs b/crates/engine/src/cmd/joint_frames_tests.rs
index c0d2cc06bc..28b8ef70c4 100644
--- a/crates/engine/src/cmd/joint_frames_tests.rs
+++ b/crates/engine/src/cmd/joint_frames_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/joints.rs b/crates/engine/src/cmd/joints.rs
index a1baec8bd9..59515de81c 100644
--- a/crates/engine/src/cmd/joints.rs
+++ b/crates/engine/src/cmd/joints.rs
@@ -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};
diff --git a/crates/engine/src/cmd/joints_as_built_tests.rs b/crates/engine/src/cmd/joints_as_built_tests.rs
index 9acd97e54b..5fa016fa5a 100644
--- a/crates/engine/src/cmd/joints_as_built_tests.rs
+++ b/crates/engine/src/cmd/joints_as_built_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/joints_exprs_tests.rs b/crates/engine/src/cmd/joints_exprs_tests.rs
index d3cdfa05b4..a8d95531c5 100644
--- a/crates/engine/src/cmd/joints_exprs_tests.rs
+++ b/crates/engine/src/cmd/joints_exprs_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/joints_face_tests.rs b/crates/engine/src/cmd/joints_face_tests.rs
index 181e532f63..f461d89aca 100644
--- a/crates/engine/src/cmd/joints_face_tests.rs
+++ b/crates/engine/src/cmd/joints_face_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/joints_point_x_tests.rs b/crates/engine/src/cmd/joints_point_x_tests.rs
index c74b0b8bdb..b6a09b6461 100644
--- a/crates/engine/src/cmd/joints_point_x_tests.rs
+++ b/crates/engine/src/cmd/joints_point_x_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/joints_reach_tests.rs b/crates/engine/src/cmd/joints_reach_tests.rs
index d9003e7560..c1fcb3314c 100644
--- a/crates/engine/src/cmd/joints_reach_tests.rs
+++ b/crates/engine/src/cmd/joints_reach_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/joints_relations_tests.rs b/crates/engine/src/cmd/joints_relations_tests.rs
index 2c09d1eaec..176f024551 100644
--- a/crates/engine/src/cmd/joints_relations_tests.rs
+++ b/crates/engine/src/cmd/joints_relations_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/joints_tests.rs b/crates/engine/src/cmd/joints_tests.rs
index 0ec4ba5e0a..bfe07b643d 100644
--- a/crates/engine/src/cmd/joints_tests.rs
+++ b/crates/engine/src/cmd/joints_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/joints_turn_tests.rs b/crates/engine/src/cmd/joints_turn_tests.rs
index 4e645a8efe..bd5bf78943 100644
--- a/crates/engine/src/cmd/joints_turn_tests.rs
+++ b/crates/engine/src/cmd/joints_turn_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/libraries_tests.rs b/crates/engine/src/cmd/libraries_tests.rs
index 2ba525f60b..b18dfe08ba 100644
--- a/crates/engine/src/cmd/libraries_tests.rs
+++ b/crates/engine/src/cmd/libraries_tests.rs
@@ -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();
diff --git a/crates/engine/src/cmd/lineage_face_tests.rs b/crates/engine/src/cmd/lineage_face_tests.rs
index 0efd8c9a2b..0c3346ba11 100644
--- a/crates/engine/src/cmd/lineage_face_tests.rs
+++ b/crates/engine/src/cmd/lineage_face_tests.rs
@@ -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();
diff --git a/crates/engine/src/cmd/mass_properties.rs b/crates/engine/src/cmd/mass_properties.rs
index 2922ecf339..fc76e680f7 100644
--- a/crates/engine/src/cmd/mass_properties.rs
+++ b/crates/engine/src/cmd/mass_properties.rs
@@ -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;
diff --git a/crates/engine/src/cmd/mass_properties_tests.rs b/crates/engine/src/cmd/mass_properties_tests.rs
index 5dc671ed94..cbab572d22 100644
--- a/crates/engine/src/cmd/mass_properties_tests.rs
+++ b/crates/engine/src/cmd/mass_properties_tests.rs
@@ -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 {
diff --git a/crates/engine/src/cmd/measure_sel.rs b/crates/engine/src/cmd/measure_sel.rs
index b83e9c1993..8a75cbb196 100644
--- a/crates/engine/src/cmd/measure_sel.rs
+++ b/crates/engine/src/cmd/measure_sel.rs
@@ -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()});
diff --git a/crates/engine/src/cmd/measure_shape.rs b/crates/engine/src/cmd/measure_shape.rs
index cbe9b712ea..eb61dddfd5 100644
--- a/crates/engine/src/cmd/measure_shape.rs
+++ b/crates/engine/src/cmd/measure_shape.rs
@@ -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 }
diff --git a/crates/engine/src/cmd/model_axis_tests.rs b/crates/engine/src/cmd/model_axis_tests.rs
index 60858c0e01..d8d376400a 100644
--- a/crates/engine/src/cmd/model_axis_tests.rs
+++ b/crates/engine/src/cmd/model_axis_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/motion.rs b/crates/engine/src/cmd/motion.rs
index 432aed07ee..fdafc4a212 100644
--- a/crates/engine/src/cmd/motion.rs
+++ b/crates/engine/src/cmd/motion.rs
@@ -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;
diff --git a/crates/engine/src/cmd/motion_analysis.rs b/crates/engine/src/cmd/motion_analysis.rs
index 29529f6ee1..8e3092c536 100644
--- a/crates/engine/src/cmd/motion_analysis.rs
+++ b/crates/engine/src/cmd/motion_analysis.rs
@@ -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};
diff --git a/crates/engine/src/cmd/motion_analysis_tests.rs b/crates/engine/src/cmd/motion_analysis_tests.rs
index e27c2c916e..5226860289 100644
--- a/crates/engine/src/cmd/motion_analysis_tests.rs
+++ b/crates/engine/src/cmd/motion_analysis_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/motion_animation.rs b/crates/engine/src/cmd/motion_animation.rs
index a1b58f0ef7..d4b3144c6c 100644
--- a/crates/engine/src/cmd/motion_animation.rs
+++ b/crates/engine/src/cmd/motion_animation.rs
@@ -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};
diff --git a/crates/engine/src/cmd/motion_sweep.rs b/crates/engine/src/cmd/motion_sweep.rs
index 22541ddb54..fb6b35781c 100644
--- a/crates/engine/src/cmd/motion_sweep.rs
+++ b/crates/engine/src/cmd/motion_sweep.rs
@@ -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};
diff --git a/crates/engine/src/cmd/motion_sweep_tests.rs b/crates/engine/src/cmd/motion_sweep_tests.rs
index 88e84882e3..9d85dfe6df 100644
--- a/crates/engine/src/cmd/motion_sweep_tests.rs
+++ b/crates/engine/src/cmd/motion_sweep_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/motion_tests.rs b/crates/engine/src/cmd/motion_tests.rs
index 23e410b6dc..eca7cc1aeb 100644
--- a/crates/engine/src/cmd/motion_tests.rs
+++ b/crates/engine/src/cmd/motion_tests.rs
@@ -1,5 +1,6 @@
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use crate::Session;
diff --git a/crates/engine/src/cmd/motion_trace.rs b/crates/engine/src/cmd/motion_trace.rs
index 531bf56578..dad4603072 100644
--- a/crates/engine/src/cmd/motion_trace.rs
+++ b/crates/engine/src/cmd/motion_trace.rs
@@ -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};
diff --git a/crates/engine/src/cmd/occurrence_tests.rs b/crates/engine/src/cmd/occurrence_tests.rs
index c23ef3005f..0cfc771d14 100644
--- a/crates/engine/src/cmd/occurrence_tests.rs
+++ b/crates/engine/src/cmd/occurrence_tests.rs
@@ -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");
diff --git a/crates/engine/src/cmd/offset_edit_guard_tests.rs b/crates/engine/src/cmd/offset_edit_guard_tests.rs
index dea069997d..bbb7bec535 100644
--- a/crates/engine/src/cmd/offset_edit_guard_tests.rs
+++ b/crates/engine/src/cmd/offset_edit_guard_tests.rs
@@ -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};
diff --git a/crates/engine/src/cmd/offset_ends_tests.rs b/crates/engine/src/cmd/offset_ends_tests.rs
index 9ebb58dcdb..9c8e9eb55b 100644
--- a/crates/engine/src/cmd/offset_ends_tests.rs
+++ b/crates/engine/src/cmd/offset_ends_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/offset_plane_face_tests.rs b/crates/engine/src/cmd/offset_plane_face_tests.rs
index 2047ba1c46..db08ed6ea9 100644
--- a/crates/engine/src/cmd/offset_plane_face_tests.rs
+++ b/crates/engine/src/cmd/offset_plane_face_tests.rs
@@ -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}"))
diff --git a/crates/engine/src/cmd/offset_topology_tests.rs b/crates/engine/src/cmd/offset_topology_tests.rs
index 64caa0039f..6880434de3 100644
--- a/crates/engine/src/cmd/offset_topology_tests.rs
+++ b/crates/engine/src/cmd/offset_topology_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/parameter_sweep.rs b/crates/engine/src/cmd/parameter_sweep.rs
index 174f13a653..35664beb94 100644
--- a/crates/engine/src/cmd/parameter_sweep.rs
+++ b/crates/engine/src/cmd/parameter_sweep.rs
@@ -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_};
diff --git a/crates/engine/src/cmd/parameters_tests.rs b/crates/engine/src/cmd/parameters_tests.rs
index e4f3b16c68..210737840f 100644
--- a/crates/engine/src/cmd/parameters_tests.rs
+++ b/crates/engine/src/cmd/parameters_tests.rs
@@ -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);
diff --git a/crates/engine/src/cmd/parts.rs b/crates/engine/src/cmd/parts.rs
index 4bbf8917c0..a2ac92cf5a 100644
--- a/crates/engine/src/cmd/parts.rs
+++ b/crates/engine/src/cmd/parts.rs
@@ -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);
}
diff --git a/crates/engine/src/cmd/patterns_tests.rs b/crates/engine/src/cmd/patterns_tests.rs
index b4c025806a..5e2609c022 100644
--- a/crates/engine/src/cmd/patterns_tests.rs
+++ b/crates/engine/src/cmd/patterns_tests.rs
@@ -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();
diff --git a/crates/engine/src/cmd/plastic.rs b/crates/engine/src/cmd/plastic.rs
index 687b5508aa..651802584c 100644
--- a/crates/engine/src/cmd/plastic.rs
+++ b/crates/engine/src/cmd/plastic.rs
@@ -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"}));
diff --git a/crates/engine/src/cmd/print_face.rs b/crates/engine/src/cmd/print_face.rs
index 8c64b722d2..db203ba2d6 100644
--- a/crates/engine/src/cmd/print_face.rs
+++ b/crates/engine/src/cmd/print_face.rs
@@ -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_};
diff --git a/crates/engine/src/cmd/render/clear_coat.rs b/crates/engine/src/cmd/render/clear_coat.rs
index f8a47a35c7..4e71dc3255 100644
--- a/crates/engine/src/cmd/render/clear_coat.rs
+++ b/crates/engine/src/cmd/render/clear_coat.rs
@@ -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,
diff --git a/crates/engine/src/cmd/render/job_tests.rs b/crates/engine/src/cmd/render/job_tests.rs
index f15ddeff36..a411318254 100644
--- a/crates/engine/src/cmd/render/job_tests.rs
+++ b/crates/engine/src/cmd/render/job_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/render/settings_tests.rs b/crates/engine/src/cmd/render/settings_tests.rs
index 6c6adf0d9f..de1a59accf 100644
--- a/crates/engine/src/cmd/render/settings_tests.rs
+++ b/crates/engine/src/cmd/render/settings_tests.rs
@@ -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,
diff --git a/crates/engine/src/cmd/render/staging.rs b/crates/engine/src/cmd/render/staging.rs
index 60540f6011..586434e238 100644
--- a/crates/engine/src/cmd/render/staging.rs
+++ b/crates/engine/src/cmd/render/staging.rs
@@ -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;
diff --git a/crates/engine/src/cmd/render/surface_bindings.rs b/crates/engine/src/cmd/render/surface_bindings.rs
index f275478ffc..f71a31dfd4 100644
--- a/crates/engine/src/cmd/render/surface_bindings.rs
+++ b/crates/engine/src/cmd/render/surface_bindings.rs
@@ -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};
diff --git a/crates/engine/src/cmd/render/textures.rs b/crates/engine/src/cmd/render/textures.rs
index a527d9198f..a02f163a9f 100644
--- a/crates/engine/src/cmd/render/textures.rs
+++ b/crates/engine/src/cmd/render/textures.rs
@@ -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![],
}],
};
diff --git a/crates/engine/src/cmd/render/transmission.rs b/crates/engine/src/cmd/render/transmission.rs
index 557003e10b..bec310e97f 100644
--- a/crates/engine/src/cmd/render/transmission.rs
+++ b/crates/engine/src/cmd/render/transmission.rs
@@ -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},
diff --git a/crates/engine/src/cmd/revolve_convention_tests.rs b/crates/engine/src/cmd/revolve_convention_tests.rs
index 301c94c3c4..3a395f6339 100644
--- a/crates/engine/src/cmd/revolve_convention_tests.rs
+++ b/crates/engine/src/cmd/revolve_convention_tests.rs
@@ -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 {
diff --git a/crates/engine/src/cmd/section.rs b/crates/engine/src/cmd/section.rs
index 15fb8d92a2..54dcd97361 100644
--- a/crates/engine/src/cmd/section.rs
+++ b/crates/engine/src/cmd/section.rs
@@ -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};
diff --git a/crates/engine/src/cmd/sheet.rs b/crates/engine/src/cmd/sheet.rs
index 25168a8112..5cdce0e7a7 100644
--- a/crates/engine/src/cmd/sheet.rs
+++ b/crates/engine/src/cmd/sheet.rs
@@ -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) {
diff --git a/crates/engine/src/cmd/sheet_convert_tests.rs b/crates/engine/src/cmd/sheet_convert_tests.rs
index ff075b6e1e..7735324aeb 100644
--- a/crates/engine/src/cmd/sheet_convert_tests.rs
+++ b/crates/engine/src/cmd/sheet_convert_tests.rs
@@ -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:?}");
}
}
diff --git a/crates/engine/src/cmd/sheet_dxf_tests.rs b/crates/engine/src/cmd/sheet_dxf_tests.rs
index 26a7360542..53b9940840 100644
--- a/crates/engine/src/cmd/sheet_dxf_tests.rs
+++ b/crates/engine/src/cmd/sheet_dxf_tests.rs
@@ -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.
diff --git a/crates/engine/src/cmd/sheet_face_names_tests.rs b/crates/engine/src/cmd/sheet_face_names_tests.rs
index 6b6500fed9..ed8d56b082 100644
--- a/crates/engine/src/cmd/sheet_face_names_tests.rs
+++ b/crates/engine/src/cmd/sheet_face_names_tests.rs
@@ -1,5 +1,6 @@
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use crate::Session;
diff --git a/crates/engine/src/cmd/sheet_tests.rs b/crates/engine/src/cmd/sheet_tests.rs
index 2f0897b430..7175474808 100644
--- a/crates/engine/src/cmd/sheet_tests.rs
+++ b/crates/engine/src/cmd/sheet_tests.rs
@@ -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]));
diff --git a/crates/engine/src/cmd/silhouette.rs b/crates/engine/src/cmd/silhouette.rs
index 45c8a3c669..2a0c377f10 100644
--- a/crates/engine/src/cmd/silhouette.rs
+++ b/crates/engine/src/cmd/silhouette.rs
@@ -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;
diff --git a/crates/engine/src/cmd/single_hole_tests.rs b/crates/engine/src/cmd/single_hole_tests.rs
index 2d074f97c6..63876d7526 100644
--- a/crates/engine/src/cmd/single_hole_tests.rs
+++ b/crates/engine/src/cmd/single_hole_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/sketch.rs b/crates/engine/src/cmd/sketch.rs
index 8aeee9c4bf..cd01f46403 100644
--- a/crates/engine/src/cmd/sketch.rs
+++ b/crates/engine/src/cmd/sketch.rs
@@ -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,
}
}
diff --git a/crates/engine/src/cmd/sketch_3d.rs b/crates/engine/src/cmd/sketch_3d.rs
index de10b0603c..3658001592 100644
--- a/crates/engine/src/cmd/sketch_3d.rs
+++ b/crates/engine/src/cmd/sketch_3d.rs
@@ -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;
diff --git a/crates/engine/src/cmd/sketch_3d_frame_tests.rs b/crates/engine/src/cmd/sketch_3d_frame_tests.rs
index e392ab52f3..fdadbb4175 100644
--- a/crates/engine/src/cmd/sketch_3d_frame_tests.rs
+++ b/crates/engine/src/cmd/sketch_3d_frame_tests.rs
@@ -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 {
diff --git a/crates/engine/src/cmd/sketch_axis_ref_tests.rs b/crates/engine/src/cmd/sketch_axis_ref_tests.rs
index 828b44ee08..41329fe10a 100644
--- a/crates/engine/src/cmd/sketch_axis_ref_tests.rs
+++ b/crates/engine/src/cmd/sketch_axis_ref_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/sketch_canvas.rs b/crates/engine/src/cmd/sketch_canvas.rs
index 36e3a4636d..689fb5a76a 100644
--- a/crates/engine/src/cmd/sketch_canvas.rs
+++ b/crates/engine/src/cmd/sketch_canvas.rs
@@ -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};
diff --git a/crates/engine/src/cmd/sketch_centre_align_tests.rs b/crates/engine/src/cmd/sketch_centre_align_tests.rs
index c9a1e53f54..1f39fb37db 100644
--- a/crates/engine/src/cmd/sketch_centre_align_tests.rs
+++ b/crates/engine/src/cmd/sketch_centre_align_tests.rs
@@ -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;
diff --git a/crates/engine/src/cmd/sketch_circle_edge_tests.rs b/crates/engine/src/cmd/sketch_circle_edge_tests.rs
index 5ed440a2f4..c4544b52c0 100644
--- a/crates/engine/src/cmd/sketch_circle_edge_tests.rs
+++ b/crates/engine/src/cmd/sketch_circle_edge_tests.rs
@@ -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"
);
diff --git a/crates/engine/src/cmd/sketch_clipboard.rs b/crates/engine/src/cmd/sketch_clipboard.rs
index fbe6b3c4bb..8497a0d68d 100644
--- a/crates/engine/src/cmd/sketch_clipboard.rs
+++ b/crates/engine/src/cmd/sketch_clipboard.rs
@@ -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;
diff --git a/crates/engine/src/cmd/sketch_clipboard_tests.rs b/crates/engine/src/cmd/sketch_clipboard_tests.rs
index 86b2ee7f1a..8809c6a2c3 100644
--- a/crates/engine/src/cmd/sketch_clipboard_tests.rs
+++ b/crates/engine/src/cmd/sketch_clipboard_tests.rs
@@ -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};
diff --git a/crates/engine/src/cmd/sketch_constraints.rs b/crates/engine/src/cmd/sketch_constraints.rs
index 2fad3462aa..f64e45d51a 100644
--- a/crates/engine/src/cmd/sketch_constraints.rs
+++ b/crates/engine/src/cmd/sketch_constraints.rs
@@ -2,7 +2,8 @@
//! inference for interactive tools.
use serde_json::{Value, json};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::{ConstraintKind, CurveKind, Sketch};
use super::sketch::{add_c, constraint_result, dof_now, edit, listed, redundancy, residual_of};
diff --git a/crates/engine/src/cmd/sketch_constraints_tests.rs b/crates/engine/src/cmd/sketch_constraints_tests.rs
index ca3409bdd2..a60e08d68e 100644
--- a/crates/engine/src/cmd/sketch_constraints_tests.rs
+++ b/crates/engine/src/cmd/sketch_constraints_tests.rs
@@ -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;
use crate::Session;
@@ -182,7 +183,7 @@ fn curvature_polygon_arc_length_linear_diameter() {
let sk = sketch(&s);
let ai = sk.curve_index(&a).unwrap();
let len = match sk.segs(ai)[0] {
- solidcraft_geom::Seg2::Arc { radius, sweep, .. } => radius * sweep,
+ solidcore_record::Seg2::Arc { radius, sweep, .. } => radius * sweep,
_ => 0.0,
};
assert!((len - 20.0).abs() < 1e-6, "{len}");
@@ -1707,7 +1708,7 @@ fn an_arc_and_its_end_point_dimension_the_arc_length() {
let arc_length = |s: &Session, a: &str| {
let sk = sketch(s);
match sk.segs(sk.curve_index(a).unwrap())[0] {
- solidcraft_geom::Seg2::Arc { radius, sweep, .. } => radius * sweep.abs(),
+ solidcore_record::Seg2::Arc { radius, sweep, .. } => radius * sweep.abs(),
_ => f64::NAN,
}
};
diff --git a/crates/engine/src/cmd/sketch_construction.rs b/crates/engine/src/cmd/sketch_construction.rs
index f57e48e129..5f33e0e4a4 100644
--- a/crates/engine/src/cmd/sketch_construction.rs
+++ b/crates/engine/src/cmd/sketch_construction.rs
@@ -2,7 +2,8 @@
//! analytic solutions.
use serde_json::{Value, json};
-use solidcraft_geom::{Seg2, Vec2};
+use solidcore_record::{Seg2, Vec2};
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::{ConstraintKind, CurveKind, Sketch};
use super::sketch::{add_c, curve_ref, edit, ids_of, line_or_axis_ref, line_pts, req_parg, result};
diff --git a/crates/engine/src/cmd/sketch_corner_tests.rs b/crates/engine/src/cmd/sketch_corner_tests.rs
index 09174c30a6..b2e86e8a1c 100644
--- a/crates/engine/src/cmd/sketch_corner_tests.rs
+++ b/crates/engine/src/cmd/sketch_corner_tests.rs
@@ -3,6 +3,7 @@
//! corner (a clear error that leaves the sketch as it was).
use serde_json::{Value, json};
+use solidcraft_geom::prelude::*;
use crate::Session;
@@ -299,9 +300,9 @@ fn a_fillet_keeps_the_dimensions_of_its_corner_on_a_virtual_sharp() {
// The virtual corner sits where the corner was, and the part keeps its size.
let k = sk(&s);
let vc = k.point(k.point_index(&corner).unwrap()).unwrap();
- assert!(vc.dist(solidcraft_geom::Vec2::new(0.0, 100.0)) < 1e-6, "{vc:?}");
+ assert!(vc.dist(solidcore_record::Vec2::new(0.0, 100.0)) < 1e-6, "{vc:?}");
let top_end = k.point(k.resolve_point("top.end").unwrap()).unwrap();
- assert!(top_end.dist(solidcraft_geom::Vec2::new(-80.0, 100.0)) < 1e-6, "{top_end:?}");
+ assert!(top_end.dist(solidcore_record::Vec2::new(-80.0, 100.0)) < 1e-6, "{top_end:?}");
let (lo, hi) = k.bounds().unwrap();
assert!((hi.x - lo.x - 80.0).abs() < 1e-6 && (hi.y - lo.y - 100.0).abs() < 1e-6, "{lo:?} {hi:?}");
// It is drawn with extension lines from both lines' ends to it.
@@ -357,7 +358,7 @@ fn a_fillet_of_a_nearly_straight_or_folded_corner_with_dimensions_does_not_panic
/// by other geometry and a dimensioned length are refused, and change nothing.
#[test]
fn a_fillet_or_chamfer_brings_two_separate_lines_to_where_they_meet() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::CurveKind;
let lines = |s: &mut Session, a: [[f64; 2]; 2], b: [[f64; 2]; 2]| {
let la = curves(&run(s, "sketch.line", json!({"points": a, "connect": false})))[0].clone();
diff --git a/crates/engine/src/cmd/sketch_create.rs b/crates/engine/src/cmd/sketch_create.rs
index 5ac98bcebd..d231b6c12d 100644
--- a/crates/engine/src/cmd/sketch_create.rs
+++ b/crates/engine/src/cmd/sketch_create.rs
@@ -2,7 +2,8 @@
//! arc slots.
use serde_json::{Value, json};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::{ConstraintKind, CurveKind, LinkKind, LinkSource, Shape, Sketch, TextAlign, TextExprs, TextStyle};
/// The style parameters of `sketch.text` and `sketch.edit_text`.
@@ -1153,7 +1154,8 @@ pub(super) fn solve_new_only(sk: &mut Sketch, first_new: usize) {
#[cfg(test)]
mod blend_tests {
use serde_json::{Value, json};
- use solidcraft_geom::{Seg2, Vec2};
+ use solidcore_record::{Seg2, Vec2};
+ use solidcraft_geom::prelude::*;
use solidcraft_sketch::CurveKind;
use crate::Session;
@@ -1185,7 +1187,7 @@ mod blend_tests {
}
/// The derivatives 1…`order` of exact piece `seg` at its end (`at_end`), from the piece's own
- /// geometry: what a blend must match, computed here independently of `Seg2::derivatives`.
+ /// geometry: what a blend must match, computed here independently of `Seg2Geom::derivatives`.
fn piece_derivatives(seg: &Seg2, at_end: bool, order: usize) -> Vec<Vec2> {
let t = if at_end { 1.0 } else { 0.0 };
let p = seg.point_at(t);
diff --git a/crates/engine/src/cmd/sketch_dimensioned.rs b/crates/engine/src/cmd/sketch_dimensioned.rs
index 2de6c63562..1ecd6806cd 100644
--- a/crates/engine/src/cmd/sketch_dimensioned.rs
+++ b/crates/engine/src/cmd/sketch_dimensioned.rs
@@ -11,8 +11,8 @@
//! creator joins [`dimension_roles`] with its roles and entities, and `locate` gets a frame with a
//! Z direction; the UI routes the 3D tools through `tools::draw`, which asks `dimension_roles`.
use serde_json::{Map, Value, json};
+use solidcore_record::Vec3;
use solidcraft_doc::expr::{Kind, definition};
-use solidcraft_geom::Vec3;
use crate::{
Result, Session,
diff --git a/crates/engine/src/cmd/sketch_dimensioned_tests.rs b/crates/engine/src/cmd/sketch_dimensioned_tests.rs
index c5cdca86bd..93a7805e27 100644
--- a/crates/engine/src/cmd/sketch_dimensioned_tests.rs
+++ b/crates/engine/src/cmd/sketch_dimensioned_tests.rs
@@ -1,5 +1,6 @@
use crate::Session;
use serde_json::{Value, json};
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::ConstraintKind;
fn run(s: &mut Session, command: &str, params: Value) -> Value {
diff --git a/crates/engine/src/cmd/sketch_drag.rs b/crates/engine/src/cmd/sketch_drag.rs
index f8920ed8bd..78e8225779 100644
--- a/crates/engine/src/cmd/sketch_drag.rs
+++ b/crates/engine/src/cmd/sketch_drag.rs
@@ -12,9 +12,10 @@
//! geometry cannot reach stop short at the edge of that stretch and go on past it. It steps only
//! when the move is long next to the dragged geometry, so a normal mouse frame is a single solve.
+use solidcraft_geom::prelude::*;
use std::f64::consts::{PI, TAU};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use solidcraft_sketch::{Analysis, Budget, ConstraintKind, CurveKind, Hold, Sketch, conic_rho_from_point};
use super::{Ent, Left, counted_solve};
diff --git a/crates/engine/src/cmd/sketch_drag_live_tests.rs b/crates/engine/src/cmd/sketch_drag_live_tests.rs
index b2fe9cb963..d3df28daab 100644
--- a/crates/engine/src/cmd/sketch_drag_live_tests.rs
+++ b/crates/engine/src/cmd/sketch_drag_live_tests.rs
@@ -2,7 +2,8 @@
//! rank analysis, and evaluates nothing after it; the gesture's end evaluates the model once.
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use super::solve_counts;
use crate::Session;
@@ -96,12 +97,12 @@ fn body_contains(s: &Session, p: Vec3) -> bool {
s.model.state().bodies.first().expect("a body").body.classify_point(p).unwrap() == solidcraft_kernel::PointClass::Inside
}
-fn pt(s: &Session, id: &str) -> solidcraft_geom::Vec2 {
+fn pt(s: &Session, id: &str) -> solidcore_record::Vec2 {
let sk = s.active_sketch.and_then(|i| s.doc.sketch(i).ok()).expect("sketch mode");
sk.resolve_point(id).and_then(|i| sk.point(i)).expect("the point")
}
-fn corner(s: &Session) -> solidcraft_geom::Vec2 {
+fn corner(s: &Session) -> solidcore_record::Vec2 {
let id = s.active_sketch.expect("sketch mode");
let st = s.world_state().unwrap();
let sk = &st.sketch(id).expect("the shown sketch").sketch;
@@ -120,7 +121,7 @@ fn a_live_frame_solves_once_and_leaves_the_features_after_the_sketch_stale() {
assert_eq!(r["sketch"]["solved"], json!(true));
assert_eq!(r["sketch"]["dof"], json!(2), "the degrees of freedom from before the drag");
// The sketch shows its new place; the extrude keeps its last result.
- assert!(corner(&s).dist(solidcraft_geom::Vec2::new(4.0, 5.0)) < 1e-9);
+ assert!(corner(&s).dist(solidcore_record::Vec2::new(4.0, 5.0)) < 1e-9);
let result = s.model.result(extrude).expect("the extrude's result");
assert!(result.stale);
assert!(s.model.state().bodies.first().expect("a body").body.same(&body), "the body is not rebuilt");
@@ -136,7 +137,7 @@ fn a_live_frame_copies_the_design_once_and_its_undo_step_keeps_the_design_before
crate::tests::doc_copies::take();
frames(&mut s, 1, true);
assert_eq!(crate::tests::doc_copies::take(), 0, "the edited design is stored, not copied again");
- assert!(corner(&s).dist(solidcraft_geom::Vec2::new(4.0, 5.0)) < 1e-9);
+ assert!(corner(&s).dist(solidcore_record::Vec2::new(4.0, 5.0)) < 1e-9);
assert_eq!(s.undo.len(), undo + 1);
assert!(s.undo.last().is_some_and(|u| std::sync::Arc::ptr_eq(&u.doc, &before)), "undo goes back to the design before");
run(&mut s, "edit.undo", json!({}));
@@ -164,7 +165,7 @@ fn the_drag_end_evaluates_once_to_the_scripted_drags_result() {
assert!(live.model.result(extrude).is_some_and(|r| !r.stale && r.error.is_none()));
// One undo step for the gesture is the UI's business; each frame is still undoable.
run(&mut live, "edit.undo", json!({}));
- assert!(corner(&live).dist(solidcraft_geom::Vec2::new(3.0, 5.0)) < 1e-9);
+ assert!(corner(&live).dist(solidcore_record::Vec2::new(3.0, 5.0)) < 1e-9);
}
#[test]
@@ -210,8 +211,8 @@ fn a_drag_reports_how_far_the_geometry_followed() {
// The grabbed midpoint follows a 15 mm circle around the fixed start.
let r = run(&mut s, "sketch.drag", json!({"entity": "l1", "from": [25, 10], "to": [25, 20], "live": live}));
let at = crate::params::vec2(&r["at"]).expect("`at`");
- let base = solidcraft_geom::Vec2::new(10.0, 10.0);
- let expected = base + solidcraft_geom::Vec2::new(15.0, 10.0).normalized().unwrap() * 15.0;
+ let base = solidcore_record::Vec2::new(10.0, 10.0);
+ let expected = base + solidcore_record::Vec2::new(15.0, 10.0).normalized().unwrap() * 15.0;
assert!(at.dist(expected) < 1e-4, "{r}");
assert!(at.dist((pt(&s, "l1.start") + pt(&s, "l1.end")) * 0.5) < 1e-6);
assert!((r["reached"].as_f64().unwrap() - (at.y - 10.0) / 10.0).abs() < 1e-6);
@@ -233,7 +234,7 @@ fn a_live_drag_of_a_lone_sketch_shows_it_without_evaluating() {
assert_eq!(s.evaluations, 0);
assert_eq!(solve_counts::take(), (2, 0));
// The free rectangle's corner moves alone; its profile follows.
- assert!(corner(&s).dist(solidcraft_geom::Vec2::new(3.0, 5.0)) < 1e-9);
+ assert!(corner(&s).dist(solidcore_record::Vec2::new(3.0, 5.0)) < 1e-9);
let st = s.model.state();
let profile = st.sketches[0].profiles.first().expect("a profile");
assert!((profile.area - 22.0 * 15.0).abs() < 1e-9, "{}", profile.area);
@@ -261,8 +262,8 @@ fn the_grab_follows_the_points_that_move() {
run(&mut s, "sketch.line", json!({"points": [[10, 10], [30, 10]]}));
run(&mut s, "sketch.constraint.fix", json!({"entities": ["l1.start"]}));
ui_frames(&mut s, "l1", [20.0, 10.0], &[[0.0, 1.0]; 6]);
- assert!(pt(&s, "l1.end").dist(solidcraft_geom::Vec2::new(30.0, 22.0)) < 1e-6, "{:?}", pt(&s, "l1.end"));
- assert!(pt(&s, "l1.start").dist(solidcraft_geom::Vec2::new(10.0, 10.0)) < 1e-12);
+ assert!(pt(&s, "l1.end").dist(solidcore_record::Vec2::new(30.0, 22.0)) < 1e-6, "{:?}", pt(&s, "l1.end"));
+ assert!(pt(&s, "l1.start").dist(solidcore_record::Vec2::new(10.0, 10.0)) < 1e-12);
}
#[test]
@@ -363,7 +364,7 @@ fn a_drag_with_the_rest_of_a_selection_moves_it_as_one() {
run(&mut s, "sketch.circle.center", json!({"center": [40, 10], "radius": 3, "id": "c1"}));
s
};
- let v = solidcraft_geom::Vec2::new;
+ let v = solidcore_record::Vec2::new;
for live in [false, true] {
// Dragged alone, the line leaves the tail's free end where it was as far as it can.
let mut s = start();
@@ -387,7 +388,7 @@ fn a_drag_with_the_rest_of_a_selection_moves_it_as_one() {
/// A 5 x 5 square drawn on the top face of a 30 x 20 x 10 box, the face's edges projected into
/// its sketch; returns the session and a corner of the square (its id and where it is).
-fn on_a_face() -> (Session, String, solidcraft_geom::Vec2) {
+fn on_a_face() -> (Session, String, solidcore_record::Vec2) {
let mut s = Session::default();
run(&mut s, "solid.box", json!({"length": 30, "width": 20, "height": 10}));
run(&mut s, "sketch.create", json!({"plane": {"face": [15, 10, 10]}}));
@@ -403,10 +404,10 @@ fn on_a_face() -> (Session, String, solidcraft_geom::Vec2) {
}
/// One live frame moving `point` from `at` by `dx`; returns where it went.
-fn live_frame(s: &mut Session, point: &str, at: solidcraft_geom::Vec2, dx: f64) -> solidcraft_geom::Vec2 {
+fn live_frame(s: &mut Session, point: &str, at: solidcore_record::Vec2, dx: f64) -> solidcore_record::Vec2 {
let to = [at.x + dx, at.y];
run(s, "sketch.drag", json!({"entity": point, "from": [at.x, at.y], "to": to, "live": true}));
- solidcraft_geom::Vec2::new(to[0], to[1])
+ solidcore_record::Vec2::new(to[0], to[1])
}
#[test]
diff --git a/crates/engine/src/cmd/sketch_equation_tests.rs b/crates/engine/src/cmd/sketch_equation_tests.rs
index f511519eb4..e210d4ad0c 100644
--- a/crates/engine/src/cmd/sketch_equation_tests.rs
+++ b/crates/engine/src/cmd/sketch_equation_tests.rs
@@ -1,7 +1,8 @@
//! Equation curves (#8352): a fit point spline from formulas over the design's parameters.
use serde_json::{Value, json};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::CurveKind;
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_face.rs b/crates/engine/src/cmd/sketch_face.rs
index 76322b8e9d..e628b42aa2 100644
--- a/crates/engine/src/cmd/sketch_face.rs
+++ b/crates/engine/src/cmd/sketch_face.rs
@@ -2,8 +2,9 @@
use crate::params::{bad, vec3};
use crate::{Result, Session};
use serde_json::Value;
+use solidcore_record::Plane;
use solidcraft_doc::{EmbossFace, PlaneRef, apply_point, apply_vector, mat_inverse, mat_mul};
-use solidcraft_geom::Plane;
+use solidcraft_geom::prelude::*;
pub(in crate::cmd) fn is_face(p: &Value) -> bool {
p.get("plane").and_then(|plane| plane.get("face")).is_some()
@@ -22,7 +23,7 @@ pub(in crate::cmd) fn capture_internal(s: &Session, value: &Value, cmd: &str) ->
/// looks at the design.
pub(crate) struct FacePickForm<'a> {
/// The picked point, in world coordinates.
- pub point: solidcraft_geom::Vec3,
+ pub point: solidcore_record::Vec3,
/// Keep the plane as it is now instead of following the face.
pub fixed: bool,
/// The exact pick: the world body and the face's index, given together.
diff --git a/crates/engine/src/cmd/sketch_face_tests.rs b/crates/engine/src/cmd/sketch_face_tests.rs
index 7f3ca4609b..44c60602f5 100644
--- a/crates/engine/src/cmd/sketch_face_tests.rs
+++ b/crates/engine/src/cmd/sketch_face_tests.rs
@@ -1,6 +1,7 @@
use crate::Session;
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::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} {params}: {error}"))
@@ -526,7 +527,7 @@ fn rounded_enclosure_shell_side_and_floor_attach_through_width_wall_and_reopen()
assert!(!mesh.contains(Vec3::new(49., 0., 12.)), "USB must remain open after resize/reopen");
assert!(mesh.contains(Vec3::new(49., 15., 12.)), "adjacent right wall remains solid");
assert!(mesh.contains(Vec3::new(-49., 0., 12.)), "opposite wall must stay solid");
- let seed = state.sketch(floor).unwrap().plane.to_world(solidcraft_geom::Vec2::new(40., 20.)) + Vec3::Z * 6.;
+ let seed = state.sketch(floor).unwrap().plane.to_world(solidcore_record::Vec2::new(40., 20.)) + Vec3::Z * 6.;
assert!(mesh.contains(seed), "seed boss starts on current floor");
for shift in [Vec3::ZERO, Vec3::new(-80., 0., 0.), Vec3::new(0., -40., 0.), Vec3::new(-80., -40., 0.)] {
assert!(mesh.contains(seed + shift), "each patterned boss must survive resize/reopen at {:?}", seed + shift);
diff --git a/crates/engine/src/cmd/sketch_flip_tests.rs b/crates/engine/src/cmd/sketch_flip_tests.rs
index 14222e8445..0c6a075845 100644
--- a/crates/engine/src/cmd/sketch_flip_tests.rs
+++ b/crates/engine/src/cmd/sketch_flip_tests.rs
@@ -2,8 +2,9 @@
//! sketch keeps the plane's own side, and older designs open, rebuild and save as before.
use serde_json::{Value, json};
+use solidcore_record::{Plane, Vec2, Vec3};
use solidcraft_doc::{FeatureKind, PlaneRef};
-use solidcraft_geom::{Plane, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_freeform.rs b/crates/engine/src/cmd/sketch_freeform.rs
index ceda14e56a..03710ddc2f 100644
--- a/crates/engine/src/cmd/sketch_freeform.rs
+++ b/crates/engine/src/cmd/sketch_freeform.rs
@@ -3,7 +3,8 @@
//! stays exact; the pieces replace the original curve.
use serde_json::{Value, json};
-use solidcraft_geom::{Seg2, Vec2};
+use solidcore_record::{Seg2, Vec2};
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::{ConstraintKind, CurveKind, Sketch};
use super::sketch::add_c;
@@ -163,7 +164,7 @@ fn add_pieces(sk: &mut Sketch, segs: &[Seg2], start: Option<usize>, end: Option<
CurveKind::Conic { a: prev, b: to, apex: x, rho: w / (1.0 + w) }
}
Seg2::Bezier { n, p } => {
- let k = (n as usize).clamp(1, solidcraft_geom::MAX_BEZIER_DEGREE);
+ let k = (n as usize).clamp(1, solidcore_record::MAX_BEZIER_DEGREE);
let mut pts = vec![prev];
for q in p.iter().take(k).skip(1) {
pts.push(sk.add_point(*q, None)?);
diff --git a/crates/engine/src/cmd/sketch_import.rs b/crates/engine/src/cmd/sketch_import.rs
index 4f724e4cbf..1ef7b05057 100644
--- a/crates/engine/src/cmd/sketch_import.rs
+++ b/crates/engine/src/cmd/sketch_import.rs
@@ -1,9 +1,10 @@
//! Sketch drawing exchange: Insert DXF, Insert SVG and sketch DXF export.
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
use serde_json::{Value, json};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use solidcraft_io::{Geom2, MAX_DRAWING_BYTES};
use solidcraft_sketch::{CurveKind, LinkKind, LinkSource, Sketch};
@@ -169,7 +170,7 @@ fn bounds_of(geom: &[Geom2]) -> Option<(Vec2, Vec2)> {
// Points along the curve, not its apex, which can lie well outside it (an elliptical
// arc of a DXF comes in as conics, #8155).
Geom2::Conic { a, apex, b, rho } if *rho > 0.0 && *rho < 1.0 => {
- let seg = solidcraft_geom::Seg2::Conic { a: *a, apex: *apex, b: *b, w: rho / (1.0 - rho) };
+ let seg = solidcore_record::Seg2::Conic { a: *a, apex: *apex, b: *b, w: rho / (1.0 - rho) };
pts.extend((0..=64).map(|i| seg.point_at(f64::from(i) / 64.0)));
}
Geom2::Conic { a, apex, b, .. } => pts.extend([*a, *apex, *b]),
diff --git a/crates/engine/src/cmd/sketch_infinite_tests.rs b/crates/engine/src/cmd/sketch_infinite_tests.rs
index 00c5dbf958..b6a5a56ab1 100644
--- a/crates/engine/src/cmd/sketch_infinite_tests.rs
+++ b/crates/engine/src/cmd/sketch_infinite_tests.rs
@@ -3,7 +3,8 @@
//! profile.
use serde_json::{Value, json};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::{CurveKind, Sketch};
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_inspect.rs b/crates/engine/src/cmd/sketch_inspect.rs
index 9e66fe72ac..743b75e968 100644
--- a/crates/engine/src/cmd/sketch_inspect.rs
+++ b/crates/engine/src/cmd/sketch_inspect.rs
@@ -2,7 +2,9 @@
//! centre of mass of bodies.
use serde_json::Value;
-use solidcraft_geom::{Aabb3, Seg2, Vec2, Vec3};
+use solidcore_record::{Seg2, Vec2, Vec3};
+use solidcraft_geom::Aabb3;
+use solidcraft_geom::prelude::*;
use super::CommandSpec;
use crate::params::{bad, bool_, num, string_list, vec3};
@@ -505,6 +507,7 @@ fn center_of_mass(s: &mut Session, p: &Value) -> Result<Value> {
#[cfg(test)]
mod tests {
use serde_json::{Value, json};
+ use solidcraft_geom::prelude::*;
use crate::Session;
@@ -543,7 +546,7 @@ mod tests {
/// options, a sketch curve keeps its own sketch, and `clear` turns the analysis off.
#[test]
fn added_combs_share_one_scale_and_clear_turns_them_off() {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let mut s = Session::default();
s.execute("solid.cylinder", &json!({"radius": 5, "height": 10})).unwrap();
s.execute("solid.cylinder", &json!({"base": [40, 0, 0], "radius": 10, "height": 10})).unwrap();
@@ -839,7 +842,7 @@ mod tests {
let spline = face["face"].as_u64().unwrap() as u32;
for c in curve_points(&r) {
for q in &c {
- let p = solidcraft_geom::Vec3::new(q[0], q[1], q[2]);
+ let p = solidcore_record::Vec3::new(q[0], q[1], q[2]);
// On that face (within the display mesh's sag), within its extent, clear of the hole.
let d = mesh
.triangles
diff --git a/crates/engine/src/cmd/sketch_line_circle_tests.rs b/crates/engine/src/cmd/sketch_line_circle_tests.rs
index df8ac2d247..513ecf2260 100644
--- a/crates/engine/src/cmd/sketch_line_circle_tests.rs
+++ b/crates/engine/src/cmd/sketch_line_circle_tests.rs
@@ -3,7 +3,8 @@
//! line that cuts it), drives it, follows its parameter, and survives undo and reopening.
use serde_json::{Value, json};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_model_plane_tests.rs b/crates/engine/src/cmd/sketch_model_plane_tests.rs
index d702358487..b6c6447385 100644
--- a/crates/engine/src/cmd/sketch_model_plane_tests.rs
+++ b/crates/engine/src/cmd/sketch_model_plane_tests.rs
@@ -4,7 +4,8 @@
//! the links follow when a parameter moves the plane.
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_modify.rs b/crates/engine/src/cmd/sketch_modify.rs
index 80b0031b9b..720dde8530 100644
--- a/crates/engine/src/cmd/sketch_modify.rs
+++ b/crates/engine/src/cmd/sketch_modify.rs
@@ -1,11 +1,12 @@
//! Sketch modify tools: trim, extend, break, fillet, chamfer, offset, mirror, circular and
//! rectangular patterns, move/copy and scale.
+use solidcraft_geom::prelude::*;
use std::f64::consts::{FRAC_PI_2, PI, TAU};
use serde_json::{Value, json};
+use solidcore_record::{Plane, Vec2};
use solidcraft_doc::ProfileSel;
-use solidcraft_geom::{Plane, Vec2};
use solidcraft_sketch::{ConstraintKind, Curve, CurveKind, Shape, Sketch, Wire, WireSpace, intersections, intersections_within};
use super::sketch::{add_c, coincident_points, edit, ids_of, line_or_axis_ref, solve_current};
diff --git a/crates/engine/src/cmd/sketch_modify_tests.rs b/crates/engine/src/cmd/sketch_modify_tests.rs
index 2f9a39ced8..b38f93fcf3 100644
--- a/crates/engine/src/cmd/sketch_modify_tests.rs
+++ b/crates/engine/src/cmd/sketch_modify_tests.rs
@@ -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};
use crate::Session;
@@ -1571,7 +1572,7 @@ fn a_point_added_to_a_spline_keeps_its_constraints_and_undoes() {
let fit: Vec<Vec2> = old.iter().map(|i| before.point(*i).unwrap()).collect();
let curve = before.exact_segs(si).unwrap();
let off =
- |segs: &[solidcraft_geom::Seg2], q: Vec2| segs.iter().map(|seg| seg.point_at(seg.closest_param(q)).dist(q)).fold(f64::INFINITY, f64::min);
+ |segs: &[solidcore_record::Seg2], q: Vec2| segs.iter().map(|seg| seg.point_at(seg.closest_param(q)).dist(q)).fold(f64::INFINITY, f64::min);
let out = run(&mut s, "sketch.spline.insert_point", json!({"curve": sid, "at": [15, 6]}));
let after = sketch(&s);
@@ -1674,7 +1675,7 @@ fn a_point_removed_from_a_spline_goes_with_its_dimension_and_undoes() {
/// of an offset are refused.
#[test]
fn a_reversed_spline_runs_the_other_way_along_the_same_path() {
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
let mut s = new_sketch();
let fit =
ids(&run(&mut s, "sketch.spline.fit_point", json!({"points": [[0, 0], [10, 8], [25, 2], [30, 6]], "connect": false}))["curves"])[0].clone();
@@ -2528,7 +2529,7 @@ fn periodic_offset_extrusion_survives_post_extrude_span_changes_and_cold_reopen(
for (distance, material) in [(1.25, true), (0.5, false), (1.75, false)] {
let point = ellipse + normal * distance;
assert_eq!(
- body.classify_point(solidcraft_geom::Vec3::new(point.x, point.y, 1.5)).unwrap() == solidcraft_kernel::PointClass::Inside,
+ body.classify_point(solidcore_record::Vec3::new(point.x, point.y, 1.5)).unwrap() == solidcraft_kernel::PointClass::Inside,
material
);
}
@@ -2537,7 +2538,7 @@ fn periodic_offset_extrusion_survives_post_extrude_span_changes_and_cold_reopen(
let point = centre + u * (major + distance);
assert_eq!(ring.region.contains(point), material);
assert_eq!(
- body.classify_point(solidcraft_geom::Vec3::new(point.x, point.y, 1.5)).unwrap() == solidcraft_kernel::PointClass::Inside,
+ body.classify_point(solidcore_record::Vec3::new(point.x, point.y, 1.5)).unwrap() == solidcraft_kernel::PointClass::Inside,
material
);
}
@@ -4565,7 +4566,7 @@ fn offset_corners_trim_the_overlap_and_extend_the_gap() {
#[test]
fn move_copy_drawn_arc_keeps_exact_geometry_and_original() {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let mut s = new_sketch();
run(&mut s, "sketch.options", json!({"sketch_3d":true}));
let source = ids(&run(&mut s, "sketch.arc3d", json!({"start":[10,0,3],"through":[0,10,3],"end":[-10,0,3]}))["curves"])[0].clone();
@@ -4601,7 +4602,7 @@ fn move_copy_drawn_arc_keeps_exact_geometry_and_original() {
#[test]
fn move_copy_drawn_arc_turns_in_the_sketch_plane_without_flattening() {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let mut s = Session::default();
run(&mut s, "sketch.create", json!({"plane":"YZ"}));
run(&mut s, "sketch.options", json!({"sketch_3d":true}));
@@ -4620,7 +4621,7 @@ fn move_copy_drawn_arc_turns_in_the_sketch_plane_without_flattening() {
#[test]
fn move_copy_drawn_wires_mix_with_planar_curves_and_deduplicate() {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let mut s = new_sketch();
run(&mut s, "sketch.options", json!({"sketch_3d":true}));
let curve = ids(&run(&mut s, "sketch.line", json!({"points":[[1,2],[4,2]]}))["curves"])[0].clone();
diff --git a/crates/engine/src/cmd/sketch_perf_tests.rs b/crates/engine/src/cmd/sketch_perf_tests.rs
index 220d98f95c..f76d83fa39 100644
--- a/crates/engine/src/cmd/sketch_perf_tests.rs
+++ b/crates/engine/src/cmd/sketch_perf_tests.rs
@@ -19,7 +19,7 @@ fn big(n: usize) -> Session {
let id = s.active_sketch.unwrap();
let mut doc = (*s.doc).clone();
let sk = doc.sketch_mut(id).unwrap();
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::ConstraintKind::*;
let side = (n as f64).sqrt().ceil() as usize;
for k in 0..n {
@@ -86,7 +86,7 @@ fn sketch_perf() {
/// Fill sketch `id` with `n` constrained rectangles, each with a circle inside.
fn fill(doc: &mut solidcraft_doc::Document, id: u64, n: usize, x0: f64) {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_sketch::ConstraintKind::*;
let Ok(sk) = doc.sketch_mut(id) else { return };
for k in 0..n {
diff --git a/crates/engine/src/cmd/sketch_point_expr_tests.rs b/crates/engine/src/cmd/sketch_point_expr_tests.rs
index c8b148ec8f..390ffb2f7a 100644
--- a/crates/engine/src/cmd/sketch_point_expr_tests.rs
+++ b/crates/engine/src/cmd/sketch_point_expr_tests.rs
@@ -2,7 +2,8 @@
//! where it comes to, and the point follows the parameters without a dimension or a solve.
use serde_json::{Value, json};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_project.rs b/crates/engine/src/cmd/sketch_project.rs
index 45e7325da4..915b596bd5 100644
--- a/crates/engine/src/cmd/sketch_project.rs
+++ b/crates/engine/src/cmd/sketch_project.rs
@@ -4,9 +4,10 @@
//! normal geometry.
use serde_json::{Value, json};
+use solidcore_record::{Plane, Vec2, Vec3};
use solidcraft_doc::project::resolve;
use solidcraft_doc::{Document, FeatureKind};
-use solidcraft_geom::{Plane, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::{ConstraintKind, LinkKind, LinkSource, Sketch};
use super::sketch_store;
diff --git a/crates/engine/src/cmd/sketch_project_edge_tests.rs b/crates/engine/src/cmd/sketch_project_edge_tests.rs
index 97472f680a..dee4d18713 100644
--- a/crates/engine/src/cmd/sketch_project_edge_tests.rs
+++ b/crates/engine/src/cmd/sketch_project_edge_tests.rs
@@ -3,7 +3,8 @@
//! is taken for it when it is split or gone: the sketch fails, asking for the edge again.
use serde_json::{Value, json};
-use solidcraft_geom::{Vec2, Vec3};
+use solidcore_record::{Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::{Link, LinkSource, Shape};
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_project_side_tests.rs b/crates/engine/src/cmd/sketch_project_side_tests.rs
index 83295250a5..2a3283432e 100644
--- a/crates/engine/src/cmd/sketch_project_side_tests.rs
+++ b/crates/engine/src/cmd/sketch_project_side_tests.rs
@@ -3,7 +3,8 @@
//! line, also past the place the point is stored at.
use serde_json::{Value, json};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_project_tests.rs b/crates/engine/src/cmd/sketch_project_tests.rs
index 9562649091..d2e5f8cecf 100644
--- a/crates/engine/src/cmd/sketch_project_tests.rs
+++ b/crates/engine/src/cmd/sketch_project_tests.rs
@@ -1,4 +1,5 @@
use serde_json::{Value, json};
+use solidcraft_geom::prelude::*;
use crate::Session;
@@ -48,12 +49,12 @@ fn initial_projection_retains_selected_face_when_closest_point_lands_on_shared_e
run(&mut s, "solid.box", json!({"length":20,"width":20,"height":10,"body_name":"Target"}));
let state = s.model.state();
let body = state.body("Target").unwrap();
- let source = solidcraft_sketch::LinkSource::Face { body: "Target".into(), at: solidcraft_geom::Vec3::new(-0.1, 5., 10.5) };
+ let source = solidcraft_sketch::LinkSource::Face { body: "Target".into(), at: solidcore_record::Vec3::new(-0.1, 5., 10.5) };
let resolved = solidcraft_doc::project::resolve(
&s.doc,
&std::collections::BTreeMap::new(),
&state,
- &solidcraft_geom::Plane::XY,
+ &solidcore_record::Plane::XY,
solidcraft_sketch::LinkKind::Project,
&source,
)
@@ -517,8 +518,8 @@ fn three_d_sketch_curves() {
/// B-rep piece under the pick; a fit-point spline's wall is one face per span joined by hidden seams.
#[test]
fn intersection_curve_of_picked_faces_spans_the_whole_surface() {
+ use solidcore_record::Plane;
use solidcraft_doc::project::resolve;
- use solidcraft_geom::Plane;
use solidcraft_sketch::{LinkKind, LinkSource};
use std::collections::BTreeMap;
@@ -690,7 +691,7 @@ fn sweeps_and_pipes_follow_3d_sketch_curves() {
// A sweep of a square profile drawn square to the curve at its start.
let (a, b) = (pts[0], pts[1]);
let t = (b - a).normalized().unwrap();
- let x = t.cross(solidcraft_geom::Vec3::Z).normalized().unwrap();
+ let x = t.cross(solidcore_record::Vec3::Z).normalized().unwrap();
let y = t.cross(x);
run(&mut s, "sketch.create", json!({"plane": {"origin": [a.x, a.y, a.z], "x_dir": [x.x, x.y, x.z], "y_dir": [y.x, y.y, y.z]}}));
run(&mut s, "sketch.rectangle.two_point", json!({"p0": [-1, -1], "p1": [1, 1]}));
@@ -1048,13 +1049,13 @@ fn intersect_keeps_its_exact_cuts() {
let curves = intersect_curves(&tilted, json!({"plane": "XY", "offset": 10})).unwrap();
let ends = line_ends(&curves);
assert!(ends.len() == curves.len() && ends.len() >= 16, "{curves:?}");
- let axis = solidcraft_geom::Vec3::new(1.0, 0.0, 1.0).normalized().unwrap();
+ let axis = solidcore_record::Vec3::new(1.0, 0.0, 1.0).normalized().unwrap();
// The cylinder's box: its axis 40 along (1, 0, 1)/√2 and its ends' discs of radius 5 span
// (40 + 2·5)/√2 in x and z and 10 in y.
let span = 50.0 * std::f64::consts::FRAC_1_SQRT_2;
let reach = 1e-3 * (2.0 * span * span + 100.0).sqrt();
for e in &ends {
- for p in [solidcraft_geom::Vec3::new(e[0], e[1], 10.0), solidcraft_geom::Vec3::new(e[2], e[3], 10.0)] {
+ for p in [solidcore_record::Vec3::new(e[0], e[1], 10.0), solidcore_record::Vec3::new(e[2], e[3], 10.0)] {
assert!(((p - axis * p.dot(axis)).len() - 5.0).abs() < reach, "{p:?}");
}
}
@@ -1201,7 +1202,7 @@ fn whole_body_project_stays_on_the_body_outline_after_a_late_chamfer() {
}
for i in 0..=16 {
let t = t0 + sweep * f64::from(i) / 16.0;
- let q = solidcraft_geom::Vec2::new(c.x + r * t.cos(), c.y + r * t.sin());
+ let q = solidcore_record::Vec2::new(c.x + r * t.cos(), c.y + r * t.sin());
worst = worst.max((x0 - q.x).max(q.x - x1).max(y0 - q.y).max(q.y - y1));
}
assert!(sweep < std::f64::consts::PI + 0.01, "{plane} {chamfer:?}: arc sweeps {sweep} rad, not a rounded corner");
@@ -1278,7 +1279,7 @@ fn a_rounded_slot_rim_projects_as_an_arc_of_its_circle() {
run(&mut s, "sketch.finish", json!({}));
let state = s.model.state();
- let center = solidcraft_geom::Vec2::new(20., 2.);
+ let center = solidcore_record::Vec2::new(20., 2.);
for id in [edge, face] {
let sk = &state.sketch(id).unwrap().sketch;
let pos = |i: usize| sk.points[i].pos;
@@ -1338,7 +1339,7 @@ fn whole_body_project_of_a_chamfered_hook_keeps_its_arcs() {
match curve.kind {
CurveKind::Line { .. } => {}
CurveKind::Arc { c, a, b } => {
- assert!(pos(c).dist(solidcraft_geom::Vec2::new(-15., 0.)) < 1e-3, "arc centre {:?}", pos(c));
+ assert!(pos(c).dist(solidcore_record::Vec2::new(-15., 0.)) < 1e-3, "arc centre {:?}", pos(c));
assert!((pos(a).dist(pos(c)) - pos(b).dist(pos(c))).abs() < 1e-6);
radii.push(pos(a).dist(pos(c)));
}
@@ -1460,8 +1461,8 @@ fn a_thicker_angle_moves_the_projected_face_of_the_sketch_on_it() {
let st = s.model.state();
let ss = st.sketch(sketch).unwrap();
assert!(ss.sketch.links.iter().all(|l| !l.lost));
- let world = |p: solidcraft_geom::Vec2| ss.plane.to_world(p);
- let at = |x: f64, y: f64| ss.sketch.points.iter().any(|p| world(p.pos).dist(solidcraft_geom::Vec3::new(x, y, 30.)) < 1e-6);
+ let world = |p: solidcore_record::Vec2| ss.plane.to_world(p);
+ let at = |x: f64, y: f64| ss.sketch.points.iter().any(|p| world(p.pos).dist(solidcore_record::Vec3::new(x, y, 30.)) < 1e-6);
// The inner corner is at (30, 30) now, and the hole 10 from the wall that moved.
assert!(at(30., 30.) && !at(20., 20.));
let center = ss.sketch.points.iter().find(|p| p.id == format!("{hole}.center")).unwrap();
diff --git a/crates/engine/src/cmd/sketch_rect_tests.rs b/crates/engine/src/cmd/sketch_rect_tests.rs
index 82bb7b2895..ec26a4fa02 100644
--- a/crates/engine/src/cmd/sketch_rect_tests.rs
+++ b/crates/engine/src/cmd/sketch_rect_tests.rs
@@ -2,6 +2,7 @@
//! over-constrained (dragging, dimensioning, pinning the centre, making them square).
use serde_json::{Value, json};
+use solidcraft_geom::prelude::*;
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_redundant_tests.rs b/crates/engine/src/cmd/sketch_redundant_tests.rs
index 78bcd75650..d14cb58207 100644
--- a/crates/engine/src/cmd/sketch_redundant_tests.rs
+++ b/crates/engine/src/cmd/sketch_redundant_tests.rs
@@ -4,7 +4,8 @@
//! with the sketch are refused.
use serde_json::{Value, json};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_robust_tests.rs b/crates/engine/src/cmd/sketch_robust_tests.rs
index 65559d89bf..00d8cade7f 100644
--- a/crates/engine/src/cmd/sketch_robust_tests.rs
+++ b/crates/engine/src/cmd/sketch_robust_tests.rs
@@ -3,6 +3,7 @@
//! degenerate is left behind).
use serde_json::{Value, json};
+use solidcraft_geom::prelude::*;
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_rounded_rect_tests.rs b/crates/engine/src/cmd/sketch_rounded_rect_tests.rs
index 159230b1d2..9fa88f4ac9 100644
--- a/crates/engine/src/cmd/sketch_rounded_rect_tests.rs
+++ b/crates/engine/src/cmd/sketch_rounded_rect_tests.rs
@@ -1,6 +1,7 @@
//! Rounded Rectangle (#891): a 2-point rectangle whose corners are filleted alike, in one step.
use serde_json::{Value, json};
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::ConstraintKind;
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_support.rs b/crates/engine/src/cmd/sketch_support.rs
index 926f57777d..636ec37067 100644
--- a/crates/engine/src/cmd/sketch_support.rs
+++ b/crates/engine/src/cmd/sketch_support.rs
@@ -1,6 +1,7 @@
//! Bounded roots on exact curve pieces against an infinite line or complete circle.
//! Rational pieces are intersected in homogeneous coordinates, without sampled chords.
-use solidcraft_geom::{Seg2, Vec2};
+use solidcore_record::{Seg2, Vec2};
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::{Shape, intersections};
use crate::{Result, params::bad};
@@ -205,7 +206,7 @@ mod tests {
elevated.push(y[n - 1]);
y = elevated;
}
- let mut points = [Vec2::ZERO; solidcraft_geom::MAX_BEZIER_CTRL];
+ let mut points = [Vec2::ZERO; solidcore_record::MAX_BEZIER_CTRL];
for (i, p) in points.iter_mut().take(8).enumerate() {
*p = Vec2::new(10.0 + i as f64 * 20.0 / 7.0, y[i]);
}
diff --git a/crates/engine/src/cmd/sketch_symmetry_point_tests.rs b/crates/engine/src/cmd/sketch_symmetry_point_tests.rs
index 05077e1135..71c138467a 100644
--- a/crates/engine/src/cmd/sketch_symmetry_point_tests.rs
+++ b/crates/engine/src/cmd/sketch_symmetry_point_tests.rs
@@ -2,7 +2,8 @@
//! or given as `point`. Each pair is joined by a construction line the point is the midpoint of.
use serde_json::{Value, json};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::{ConstraintKind, Sketch};
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_text_expr_tests.rs b/crates/engine/src/cmd/sketch_text_expr_tests.rs
index 779a14a659..9250bc4b14 100644
--- a/crates/engine/src/cmd/sketch_text_expr_tests.rs
+++ b/crates/engine/src/cmd/sketch_text_expr_tests.rs
@@ -2,7 +2,8 @@
//! text keeps the expression, follows the parameters, and a number typed instead replaces it.
use serde_json::{Value, json};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::LinkSource;
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_trim_path_tests.rs b/crates/engine/src/cmd/sketch_trim_path_tests.rs
index 91e8b94bd1..49842c13f0 100644
--- a/crates/engine/src/cmd/sketch_trim_path_tests.rs
+++ b/crates/engine/src/cmd/sketch_trim_path_tests.rs
@@ -2,7 +2,8 @@
//! with `sketch.trim` would, in one undo step.
use serde_json::{Value, json};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::Shape;
use crate::Session;
diff --git a/crates/engine/src/cmd/sketch_ux_tests.rs b/crates/engine/src/cmd/sketch_ux_tests.rs
index 5aca48d2b7..ae40e44774 100644
--- a/crates/engine/src/cmd/sketch_ux_tests.rs
+++ b/crates/engine/src/cmd/sketch_ux_tests.rs
@@ -2,6 +2,7 @@
//! which entity moves when a two-entity constraint is applied.
use serde_json::{Value, json};
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::{DimFrame, Sketch, dim_frame, dim_layout};
use crate::Session;
@@ -53,7 +54,7 @@ fn every_dimension_kind_has_a_drawable_frame() {
let mut kinds = Vec::new();
for c in dims {
let f = dim_frame(&sk, &c.kind).unwrap_or_else(|| panic!("no frame for {c:?}"));
- let l = dim_layout(&f, None, 0.1, solidcraft_geom::Vec2::new(1.0, 0.5));
+ let l = dim_layout(&f, None, 0.1, solidcore_record::Vec2::new(1.0, 0.5));
assert!(!l.lines.is_empty() && !l.arrows.is_empty(), "{c:?}");
assert!(l.text.is_finite());
kinds.push(std::mem::discriminant(&f));
@@ -80,10 +81,10 @@ fn dimension_text_is_stored_relative_to_the_dimension_and_follows_it() {
let f = dim_frame(&sk, &c.kind).expect("frame");
dim_layout(&f, c.text, 0.1, Default::default()).text
};
- assert!(text(&s).dist(solidcraft_geom::Vec2::new(20.0, -8.0)) < 1e-9);
+ assert!(text(&s).dist(solidcore_record::Vec2::new(20.0, -8.0)) < 1e-9);
// Moved by the parameter name; then the line moves and the text goes with it.
run(&mut s, "sketch.dimension_text", json!({"dimension": param, "at": [30, 12]}));
- assert!(text(&s).dist(solidcraft_geom::Vec2::new(30.0, 12.0)) < 1e-9);
+ assert!(text(&s).dist(solidcore_record::Vec2::new(30.0, 12.0)) < 1e-9);
run(&mut s, "sketch.move_point", json!({"point": "l1.start", "to": [0, 10]}));
run(&mut s, "sketch.move_point", json!({"point": "l1.end", "to": [40, 10]}));
// Still 10 along and 12 across from the middle of the (moved) line.
@@ -114,7 +115,7 @@ fn deleting_a_dimension_frees_its_parameter() {
// ---------------------------------------------------------------------------------------------
// Fix / Unfix
-fn pt(s: &Session, id: &str) -> solidcraft_geom::Vec2 {
+fn pt(s: &Session, id: &str) -> solidcore_record::Vec2 {
let sk = sketch(s);
sk.resolve_point(id).and_then(|i| sk.point(i)).unwrap_or_else(|| panic!("no point {id}"))
}
@@ -163,7 +164,7 @@ fn fixing_curves_holds_their_points_and_radius() {
assert!(si["curves"].as_array().is_some_and(|c| c.iter().all(|c| c["fixed"] == true)), "{si}");
// A fixed circle keeps centre and radius; a dimension on it conflicts.
run(&mut s, "sketch.move_point", json!({"point": "c1.center", "to": [0, 0]}));
- assert_eq!(pt(&s, "c1.center"), solidcraft_geom::Vec2::new(10.0, 10.0));
+ assert_eq!(pt(&s, "c1.center"), solidcore_record::Vec2::new(10.0, 10.0));
assert!(s.execute("sketch.dimension", &json!({"entities": ["c1"], "value": 20})).is_err());
let r0 = sketch(&s).radius(0);
assert_eq!(r0, Some(5.0));
@@ -296,7 +297,7 @@ fn projected_geometry_can_become_construction() {
// Two-entity constraints: the first pick stays, the second moves
/// Positions of an entity's points (and its radius).
-fn snap(s: &Session, id: &str) -> (Vec<solidcraft_geom::Vec2>, Option<f64>) {
+fn snap(s: &Session, id: &str) -> (Vec<solidcore_record::Vec2>, Option<f64>) {
let sk = sketch(s);
if let Some(i) = sk.curve_index(id) {
let pts = sk.curves[i].kind.point_ids().into_iter().filter_map(|p| sk.point(p)).collect();
@@ -305,7 +306,7 @@ fn snap(s: &Session, id: &str) -> (Vec<solidcraft_geom::Vec2>, Option<f64>) {
(vec![pt(s, id)], None)
}
-fn same(a: &(Vec<solidcraft_geom::Vec2>, Option<f64>), b: &(Vec<solidcraft_geom::Vec2>, Option<f64>)) -> bool {
+fn same(a: &(Vec<solidcore_record::Vec2>, Option<f64>), b: &(Vec<solidcore_record::Vec2>, Option<f64>)) -> bool {
a.0.len() == b.0.len() && a.0.iter().zip(&b.0).all(|(p, q)| p.dist(*q) < 1e-9) && a.1.zip(b.1).is_none_or(|(x, y)| (x - y).abs() < 1e-9)
}
@@ -437,7 +438,7 @@ fn point_constraints_keep_the_first_pick() {
let (a0, l0) = (snap(&s, "p1"), snap(&s, "l1"));
run(&mut s, "sketch.constraint.symmetry", json!({"a": "p1", "b": "p2", "line": "l1"}));
assert!(same(&snap(&s, "p1"), &a0) && same(&snap(&s, "l1"), &l0));
- assert!(pt(&s, "p2").dist(solidcraft_geom::Vec2::new(3.0, -7.0)) < 1e-6, "{:?}", pt(&s, "p2"));
+ assert!(pt(&s, "p2").dist(solidcore_record::Vec2::new(3.0, -7.0)) < 1e-6, "{:?}", pt(&s, "p2"));
}
#[test]
@@ -570,12 +571,12 @@ fn drag(s: &mut Session, e: &str, from: [f64; 2], to: [f64; 2]) {
run(s, "sketch.drag", json!({"entity": e, "from": from, "to": to}));
}
-fn v(x: f64, y: f64) -> solidcraft_geom::Vec2 {
- solidcraft_geom::Vec2::new(x, y)
+fn v(x: f64, y: f64) -> solidcore_record::Vec2 {
+ solidcore_record::Vec2::new(x, y)
}
/// The corners of the polygon drawn by `out`, in order, and its support circle's centre and radius.
-fn polygon_shape(s: &Session, out: &Value) -> (Vec<solidcraft_geom::Vec2>, solidcraft_geom::Vec2, f64) {
+fn polygon_shape(s: &Session, out: &Value) -> (Vec<solidcore_record::Vec2>, solidcore_record::Vec2, f64) {
use solidcraft_sketch::CurveKind;
let sk = sketch(s);
let corners = out["curves"]
@@ -593,7 +594,7 @@ fn polygon_shape(s: &Session, out: &Value) -> (Vec<solidcraft_geom::Vec2>, solid
}
/// A regular polygon: corners equally far from `c`, sides equally long.
-fn assert_regular(corners: &[solidcraft_geom::Vec2], c: solidcraft_geom::Vec2, what: &str) {
+fn assert_regular(corners: &[solidcore_record::Vec2], c: solidcore_record::Vec2, what: &str) {
let n = corners.len();
let reach: Vec<f64> = corners.iter().map(|q| q.dist(c)).collect();
let sides: Vec<f64> = (0..n).map(|i| corners[i].dist(corners[(i + 1) % n])).collect();
@@ -781,7 +782,7 @@ fn arm_drags(links: Links) -> (usize, usize) {
let v3 = v2 + v(b * (th1 + bend).cos(), b * (th1 + bend).sin());
let (tr, tt) = (lo + rnd() * (hi - lo), rnd() * TAU);
let to = o + v(tr * tt.cos(), tr * tt.sin());
- let clear = |p: solidcraft_geom::Vec2| (lo..=hi).contains(&p.dist(o));
+ let clear = |p: solidcore_record::Vec2| (lo..=hi).contains(&p.dist(o));
if !(0..=100).all(|i| clear(v3 + (to - v3) * (i as f64 / 100.0))) {
continue;
}
@@ -868,13 +869,13 @@ fn hanging_triangle_flips(n: usize) -> usize {
let v3 = v2 + v(b * (th1 + bend).cos(), b * (th1 + bend).sin());
let (tr, tt) = (lo + rnd() * (hi - lo), rnd() * TAU);
let to = o + v(tr * tt.cos(), tr * tt.sin());
- let clear = |p: solidcraft_geom::Vec2| (lo..=hi).contains(&p.dist(o));
+ let clear = |p: solidcore_record::Vec2| (lo..=hi).contains(&p.dist(o));
if !(0..=100).all(|i| clear(v3 + (to - v3) * (i as f64 / 100.0))) {
continue;
}
kept += 1;
let turn = rnd() * TAU;
- let u = solidcraft_geom::Vec2::from_angle(turn);
+ let u = solidcore_record::Vec2::from_angle(turn);
let normal = u.perp() * if rnd() < 0.5 { 1.0 } else { -1.0 };
let (tq, tr) = (v3 + u * 3.9, v3 + u * 1.95 + normal * (4.0f64 - 1.95 * 1.95).sqrt());
{
@@ -1068,7 +1069,7 @@ fn a_dragged_fillet_stays_in_its_corner() {
let arc_id = sk0.curves[arc].id.clone();
let inside = |s: &Session| {
let sk = sketch(s);
- let side = |p: solidcraft_geom::Vec2, a: solidcraft_geom::Vec2, b: solidcraft_geom::Vec2| (b - a).cross(p - a).signum();
+ let side = |p: solidcore_record::Vec2, a: solidcore_record::Vec2, b: solidcore_record::Vec2| (b - a).cross(p - a).signum();
let c = sk.center(arc).expect("centre");
let (p0, k1, k2, p3) = (pt(s, "l1.start"), pt(s, "l1.end"), pt(s, "l2.start"), pt(s, "l2.end"));
let r = sk.radius(arc).unwrap_or(0.0);
@@ -1379,8 +1380,8 @@ fn three_d_curves_need_the_option_and_move_joined() {
let sk = sketch(&s);
let w = &sk.wires[sk.wire_index(&sid).expect("spline")];
assert!(w.pts.len() > 10);
- assert!(w.pts.first().expect("p").dist(solidcraft_geom::Vec3::new(10.0, 0.0, 10.0)) < 1e-12);
- assert!(w.pts.last().expect("p").dist(solidcraft_geom::Vec3::new(20.0, 0.0, 20.0)) < 1e-12);
+ assert!(w.pts.first().expect("p").dist(solidcore_record::Vec3::new(10.0, 0.0, 10.0)) < 1e-12);
+ assert!(w.pts.last().expect("p").dist(solidcore_record::Vec3::new(20.0, 0.0, 20.0)) < 1e-12);
// The shared corner moves for both lines (and the spline that starts there).
let r = run(&mut s, "sketch.move3d", json!({"wire": ids[1], "index": 1, "by": [0, 0, 5]}));
assert_eq!(r["moved"], 2);
@@ -1538,7 +1539,7 @@ fn hung_elbow_side(s: &Session) -> f64 {
}
/// The hand of `hung_arm` swung by `angle` about the shoulder.
-fn hung_hand_target(s: &Session, angle: f64, scale: f64) -> solidcraft_geom::Vec2 {
+fn hung_hand_target(s: &Session, angle: f64, scale: f64) -> solidcore_record::Vec2 {
let (b, h) = (pt(s, "ab.end"), pt(s, "eh.end"));
let r = h - b;
let (c, si) = (angle.cos(), angle.sin());
@@ -1941,7 +1942,7 @@ fn dragging_an_end_of_a_tangent_line_leaves_its_other_end_still() {
drag(&mut s, &format!("{l}.end"), [20.0, 10.0], [5.0, 12.0]);
assert!(at(&s, &format!("{l}.start")).dist(start) < 1e-7, "the far end moved: {:?}", at(&s, &format!("{l}.start")));
assert!(
- at(&s, &format!("{l}.end")).dist(solidcraft_geom::Vec2::new(5.0, 12.0)) < 1e-6,
+ at(&s, &format!("{l}.end")).dist(solidcore_record::Vec2::new(5.0, 12.0)) < 1e-6,
"the end went where dragged: {:?}",
at(&s, &format!("{l}.end"))
);
@@ -2025,12 +2026,12 @@ fn a_changed_length_dimension_keeps_its_first_point() {
let width = run(&mut s, "sketch.dimension", json!({"entities": [bottom]}))["param"].as_str().unwrap().to_string();
let height = run(&mut s, "sketch.dimension", json!({"entities": [right]}))["param"].as_str().unwrap().to_string();
run(&mut s, "parameters.change", json!({"name": width, "expression": "60 mm"}));
- assert!(at(&s, "p1").dist(solidcraft_geom::Vec2::new(10.0, 10.0)) < 1e-6, "the first corner stays: {:?}", at(&s, "p1"));
- assert!(at(&s, "p2").dist(solidcraft_geom::Vec2::new(70.0, 10.0)) < 1e-6, "the far corner moves: {:?}", at(&s, "p2"));
+ assert!(at(&s, "p1").dist(solidcore_record::Vec2::new(10.0, 10.0)) < 1e-6, "the first corner stays: {:?}", at(&s, "p1"));
+ assert!(at(&s, "p2").dist(solidcore_record::Vec2::new(70.0, 10.0)) < 1e-6, "the far corner moves: {:?}", at(&s, "p2"));
// Several at once: the right side grows up from its start, the bottom-right corner.
run(&mut s, "parameters.change", json!({"changes": {height: "25 mm"}}));
- assert!(at(&s, "p2").dist(solidcraft_geom::Vec2::new(70.0, 10.0)) < 1e-6, "{:?}", at(&s, "p2"));
- assert!(at(&s, "p3").dist(solidcraft_geom::Vec2::new(70.0, 35.0)) < 1e-6, "{:?}", at(&s, "p3"));
+ assert!(at(&s, "p2").dist(solidcore_record::Vec2::new(70.0, 10.0)) < 1e-6, "{:?}", at(&s, "p2"));
+ assert!(at(&s, "p3").dist(solidcore_record::Vec2::new(70.0, 35.0)) < 1e-6, "{:?}", at(&s, "p3"));
// Centred on the Y axis: holding a corner can't keep it symmetric, so both ends move.
let mut s = new_sketch();
diff --git a/crates/engine/src/cmd/stacked_face_tests.rs b/crates/engine/src/cmd/stacked_face_tests.rs
index 673d62dad1..79d67db7a5 100644
--- a/crates/engine/src/cmd/stacked_face_tests.rs
+++ b/crates/engine/src/cmd/stacked_face_tests.rs
@@ -5,6 +5,7 @@
use crate::Session;
use serde_json::{Value, json};
use solidcraft_doc::FaceAttachmentStatus;
+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}"))
@@ -40,7 +41,7 @@ fn two_extrudes(circle: bool, full: bool, on_face: bool, operation: &str) -> Ses
s
}
-fn healthy(s: &Session, sketch: &str) -> solidcraft_geom::Plane {
+fn healthy(s: &Session, sketch: &str) -> solidcore_record::Plane {
let id = s.doc.find_feature(sketch).map(|f| f.id).unwrap();
match s.placed_document().sketch_face_attachment(id, &s.model) {
FaceAttachmentStatus::Healthy { plane, .. } => plane,
diff --git a/crates/engine/src/cmd/surface.rs b/crates/engine/src/cmd/surface.rs
index fd866538b3..1e812db8dc 100644
--- a/crates/engine/src/cmd/surface.rs
+++ b/crates/engine/src/cmd/surface.rs
@@ -8,6 +8,7 @@ use solidcraft_doc::{
};
use solidcraft_doc::{BodyName, SketchId};
use solidcraft_doc::{Dir, FacePick, Position};
+use solidcraft_geom::prelude::*;
use solidcraft_kernel::{Construction, Continuity};
use super::CommandSpec;
@@ -91,7 +92,8 @@ fn patch(s: &mut Session, p: &Value) -> Result<Value> {
let crown = crown_param(p, cmd)?;
let continuity = patch_continuity(p, cmd)?;
let points: Vec<Position> = patch_points(p, cmd)?.into_iter().map(Position).collect();
- let edges: Vec<solidcraft_geom::Vec3> = p.get("edges").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
+ let edges: Vec<solidcore_record::Vec3> =
+ p.get("edges").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
let mut v = if !edges.is_empty() {
if edges.len() > 10_000 {
return Err(bad(cmd, "too many edges"));
@@ -177,7 +179,7 @@ fn patch_continuity(p: &Value, cmd: &str) -> Result<PatchContinuity> {
}
/// The points a patch passes through (at most 64, each a finite point).
-fn patch_points(p: &Value, cmd: &str) -> Result<Vec<solidcraft_geom::Vec3>> {
+fn patch_points(p: &Value, cmd: &str) -> Result<Vec<solidcore_record::Vec3>> {
let Some(v) = p.get("points") else { return Ok(Vec::new()) };
let list = v
.as_array()
@@ -202,7 +204,7 @@ fn crown_param(p: &Value, cmd: &str) -> Result<f64> {
fn blend_side(p: &Value, cmd: &str, key: &str) -> Result<BlendSide> {
let side = p.get(key).ok_or_else(|| bad(cmd, format!("`{key}` must be {{body, edges}}")))?;
let body = str_(side, "body").ok_or_else(|| bad(cmd, format!("`{key}.body` must name a body")))?;
- let edges: Vec<solidcraft_geom::Vec3> =
+ let edges: Vec<solidcore_record::Vec3> =
side.get("edges").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
if edges.is_empty() || edges.len() > 10_000 {
return Err(bad(cmd, format!("`{key}.edges` must list 1 to 10000 points on the edges of a chain")));
@@ -261,12 +263,13 @@ fn surface_extrude(s: &mut Session, p: &Value) -> Result<Value> {
}
/// A body by name, and points on some of its faces (none: all of them).
-fn body_faces(s: &Session, p: &Value, cmd: &str) -> Result<(String, Vec<solidcraft_geom::Vec3>)> {
+fn body_faces(s: &Session, p: &Value, cmd: &str) -> Result<(String, Vec<solidcore_record::Vec3>)> {
let body = str_(p, "body").ok_or_else(|| bad(cmd, "`body` is required"))?.to_string();
if s.model.state().body(&body).is_none() {
return Err(bad(cmd, format!("no body `{body}`")));
}
- let faces: Vec<solidcraft_geom::Vec3> = p.get("faces").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
+ let faces: Vec<solidcore_record::Vec3> =
+ p.get("faces").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
if faces.len() > 10_000 {
return Err(bad(cmd, "too many faces"));
}
@@ -298,7 +301,7 @@ fn untrim(s: &mut Session, p: &Value) -> Result<Value> {
if points.len() > 10_000 {
return Err(bad(cmd, "too many holes"));
}
- let points: Option<Vec<solidcraft_geom::Vec3>> = points.iter().map(vec3).collect();
+ let points: Option<Vec<solidcore_record::Vec3>> = points.iter().map(vec3).collect();
Some(points.ok_or_else(|| bad(cmd, "`holes` must list points [x, y, z] on the inner loops"))?)
}
Some(_) => return Err(bad(cmd, "`holes` must be \"all\" or a list of points [x, y, z] on the inner loops")),
@@ -382,7 +385,7 @@ fn surface_loft(s: &mut Session, p: &Value) -> Result<Value> {
// A section is a chain of sketch curves, or an edge chain of a body whose face the end of
// the loft repeats.
if let Some(body) = str_(sec, "body") {
- let edges: Vec<solidcraft_geom::Vec3> =
+ let edges: Vec<solidcore_record::Vec3> =
sec.get("edges").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
if edges.is_empty() || edges.len() > 10_000 {
return Err(bad(cmd, "`sections.edges` must list 1 to 10000 points on the edges of a chain"));
@@ -433,7 +436,8 @@ fn surface_loft(s: &mut Session, p: &Value) -> Result<Value> {
fn offset(s: &mut Session, p: &Value) -> Result<Value> {
let cmd = "surface.offset";
- let faces: Vec<solidcraft_geom::Vec3> = p.get("faces").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
+ let faces: Vec<solidcore_record::Vec3> =
+ p.get("faces").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
if faces.is_empty() || faces.len() > 10_000 {
return Err(bad(cmd, "`faces` must list points on the faces to offset"));
}
@@ -459,7 +463,8 @@ fn ruled(s: &mut Session, p: &Value) -> Result<Value> {
if s.model.state().body(&body).is_none() {
return Err(bad(cmd, format!("no body `{body}`")));
}
- let edges: Vec<solidcraft_geom::Vec3> = p.get("edges").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
+ let edges: Vec<solidcore_record::Vec3> =
+ p.get("edges").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
if edges.is_empty() || edges.len() > 10_000 {
return Err(bad(cmd, "`edges` must list points on a chain of the body's edges"));
}
@@ -573,7 +578,8 @@ fn extend(s: &mut Session, p: &Value) -> Result<Value> {
if s.model.state().body(&body).is_none() {
return Err(bad(cmd, format!("no body `{body}`")));
}
- let edges: Vec<solidcraft_geom::Vec3> = p.get("edges").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
+ let edges: Vec<solidcore_record::Vec3> =
+ p.get("edges").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
if edges.is_empty() || edges.len() > 10_000 {
return Err(bad(cmd, "`edges` must list points on the edges to extend"));
}
@@ -614,7 +620,7 @@ fn extend(s: &mut Session, p: &Value) -> Result<Value> {
}
/// Points to keep: one `[x, y, z]`, or a list of them (at most 10 000).
-fn keep_points(v: Option<&Value>, cmd: &str, key: &str) -> Result<Vec<solidcraft_geom::Vec3>> {
+fn keep_points(v: Option<&Value>, cmd: &str, key: &str) -> Result<Vec<solidcore_record::Vec3>> {
let Some(v) = v.filter(|v| !v.is_null()) else { return Ok(Vec::new()) };
if let Some(p) = vec3(v) {
return Ok(vec![p]);
@@ -1196,7 +1202,7 @@ mod tests {
plate_with_three_holes(&mut s);
let top = [5.0, 5.0, 2.0];
let name =
- solidcraft_doc::naming::face_name_at_body(s.model.state().body("Plate").unwrap(), solidcraft_geom::Vec3::new(5.0, 5.0, 2.0)).unwrap();
+ solidcraft_doc::naming::face_name_at_body(s.model.state().body("Plate").unwrap(), solidcore_record::Vec3::new(5.0, 5.0, 2.0)).unwrap();
run(&mut s, "surface.untrim", json!({"face": {"body": "Plate", "point": top}, "body_name": "Top"}));
let st = s.world_state().unwrap();
let made = &st.body("Top").unwrap().body;
@@ -1973,7 +1979,7 @@ mod tests {
run(&mut s, "surface.patch", json!({"edges": rim, "body": "Saddle", "body_name": "Shell"}));
let st = s.world_state().unwrap();
assert!(st.body("Shell").unwrap().body.is_surface(), "a patch on a rim is a sheet");
- let before: Vec<solidcraft_geom::Vec3> = st.body("Shell").unwrap().body.edges(0.1).unwrap().iter().flat_map(|e| e.points.clone()).collect();
+ let before: Vec<solidcore_record::Vec3> = st.body("Shell").unwrap().body.edges(0.1).unwrap().iter().flat_map(|e| e.points.clone()).collect();
assert!(!before.is_empty());
let area_before = area(&s, "Shell");
// The fairing reports both energies. The fit is not the fairest surface on its own rim, so
@@ -1986,7 +1992,7 @@ mod tests {
// The edges do not move: every boundary point of the faired body is where it was, bit for
// bit, and the sheet is still the one face.
let st = s.world_state().unwrap();
- let after: Vec<solidcraft_geom::Vec3> = st.body("Shell").unwrap().body.edges(0.1).unwrap().iter().flat_map(|e| e.points.clone()).collect();
+ let after: Vec<solidcore_record::Vec3> = st.body("Shell").unwrap().body.edges(0.1).unwrap().iter().flat_map(|e| e.points.clone()).collect();
assert_eq!(after, before, "fairing must not move the face's edges");
assert_eq!(st.body("Shell").unwrap().body.face_count(), 1);
// Undo takes the fairing back, redo puts it back, and a cold reopen rebuilds the same.
diff --git a/crates/engine/src/cmd/surface_analysis.rs b/crates/engine/src/cmd/surface_analysis.rs
index d3055c9b40..2876808f1e 100644
--- a/crates/engine/src/cmd/surface_analysis.rs
+++ b/crates/engine/src/cmd/surface_analysis.rs
@@ -4,7 +4,8 @@
//! `inspect.analysis` says which or turns it off.
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use super::CommandSpec;
use crate::params::{bad, bool_, num, str_, vec3};
@@ -943,7 +944,7 @@ mod tests {
s.execute("inspect.environment_map", &json!({})).unwrap();
assert_eq!(s.analysis, Some(SurfaceAnalysis::Environment));
s.execute("inspect.accessibility", &json!({"direction": [0, 0, -3]})).unwrap();
- assert_eq!(s.analysis, Some(SurfaceAnalysis::Access { dir: solidcraft_geom::Vec3::new(0.0, 0.0, -1.0) }));
+ assert_eq!(s.analysis, Some(SurfaceAnalysis::Access { dir: solidcore_record::Vec3::new(0.0, 0.0, -1.0) }));
s.execute("inspect.curvature_map", &json!({"clear": true})).unwrap();
assert_eq!(s.analysis, None);
assert_eq!(s.undo.len(), undo, "no undo steps");
@@ -1123,7 +1124,7 @@ mod tests {
let seam = s.continuity[0].clone();
let revision = s.revision;
s.execute("view.apply", &json!({"camera":{"target":[1,2,3],"yaw":0,"pitch":0,"distance":40}})).unwrap();
- assert_eq!(s.camera.unwrap().target, solidcraft_geom::Vec3::new(1.0, 2.0, 3.0));
+ assert_eq!(s.camera.unwrap().target, solidcore_record::Vec3::new(1.0, 2.0, 3.0));
// Camera apply is an echo; these real display changes advance Session's view revision.
s.execute("browser.visibility", &json!({"items":[seam.body],"visible":false})).unwrap();
s.execute("browser.visibility", &json!({"items":[seam.body],"visible":true})).unwrap();
diff --git a/crates/engine/src/cmd/surface_boundary.rs b/crates/engine/src/cmd/surface_boundary.rs
index 4c6ab4ee8d..572e3e74bf 100644
--- a/crates/engine/src/cmd/surface_boundary.rs
+++ b/crates/engine/src/cmd/surface_boundary.rs
@@ -6,6 +6,7 @@
use serde_json::Value;
use solidcraft_doc::{BodyName, FeatureKind, NetworkCurve, Operation, Position, SketchId};
+use solidcraft_geom::prelude::*;
use solidcraft_kernel::{Construction, Continuity};
use super::CommandSpec;
@@ -55,7 +56,7 @@ fn loop_patch(s: &mut Session, p: &Value) -> Result<Value> {
// of each is the first of the next, and the last boundary's end is the first one's start.
let state = s.model.state();
let sk = state.sketch(sketch).ok_or_else(|| bad(cmd, "the sketch has not been solved"))?;
- let mut ends: Vec<(solidcraft_geom::Vec2, solidcraft_geom::Vec2)> = Vec::with_capacity(curves.len());
+ let mut ends: Vec<(solidcore_record::Vec2, solidcore_record::Vec2)> = Vec::with_capacity(curves.len());
for id in &curves {
let ci = sk.sketch.curve_index(id).ok_or_else(|| bad(cmd, format!("no sketch curve `{id}`")))?;
let pieces = sk.sketch.exact_pieces(ci);
diff --git a/crates/engine/src/cmd/surface_match.rs b/crates/engine/src/cmd/surface_match.rs
index 30d6d618cd..a16e8edf45 100644
--- a/crates/engine/src/cmd/surface_match.rs
+++ b/crates/engine/src/cmd/surface_match.rs
@@ -33,11 +33,13 @@ fn match_surface(s: &mut Session, p: &Value) -> Result<Value> {
if s.model.state().body(&target).is_none() {
return Err(bad(cmd, format!("no body `{target}`")));
}
- let faces: Vec<solidcraft_geom::Vec3> = p.get("faces").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
+ let faces: Vec<solidcore_record::Vec3> =
+ p.get("faces").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
if faces.len() > 64 {
return Err(bad(cmd, "too many points on the face to rebuild"));
}
- let edges: Vec<solidcraft_geom::Vec3> = p.get("edges").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
+ let edges: Vec<solidcore_record::Vec3> =
+ p.get("edges").and_then(Value::as_array).map(|a| a.iter().filter_map(vec3).collect()).unwrap_or_default();
if edges.is_empty() || edges.len() > 10_000 {
return Err(bad(cmd, "`edges` must list 1 to 10000 points on the target's edge chain"));
}
@@ -63,7 +65,7 @@ mod tests {
use super::*;
use crate::Session;
use serde_json::json;
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
fn run(s: &mut Session, c: &str, p: Value) -> Value {
s.execute(c, &p).unwrap_or_else(|e| panic!("{c}: {e}"))
diff --git a/crates/engine/src/cmd/thin_extrude_tests.rs b/crates/engine/src/cmd/thin_extrude_tests.rs
index 9fd35741fb..208e9a6014 100644
--- a/crates/engine/src/cmd/thin_extrude_tests.rs
+++ b/crates/engine/src/cmd/thin_extrude_tests.rs
@@ -2,6 +2,7 @@
//! area times its height).
use serde_json::{Value, json};
+use solidcraft_geom::prelude::*;
use crate::Session;
@@ -182,15 +183,15 @@ fn attachment(s: &Session, sketch: &str) -> solidcraft_doc::FaceAttachmentStatus
s.placed_document().sketch_face_attachment(id, &s.model)
}
-fn attached(s: &Session, sketch: &str) -> (solidcraft_geom::Plane, Option<solidcraft_doc::config::FaceCertificate>) {
+fn attached(s: &Session, sketch: &str) -> (solidcore_record::Plane, Option<solidcraft_doc::config::FaceCertificate>) {
match attachment(s, sketch) {
solidcraft_doc::FaceAttachmentStatus::Healthy { plane, target, .. } => (plane, target.certificate),
other => panic!("{sketch}: {other:?}"),
}
}
-fn same_plane(a: &solidcraft_geom::Plane, b: &solidcraft_geom::Plane) {
- let near = |p: solidcraft_geom::Vec3, q: solidcraft_geom::Vec3| (p - q).len() < 1e-9;
+fn same_plane(a: &solidcore_record::Plane, b: &solidcore_record::Plane) {
+ let near = |p: solidcore_record::Vec3, q: solidcore_record::Vec3| (p - q).len() < 1e-9;
assert!(near(a.origin, b.origin) && near(a.x, b.x) && near(a.y, b.y), "{a:?} != {b:?}");
}
@@ -284,7 +285,7 @@ fn no_errors(s: &Session, context: &str) {
}
/// How far a face's plane lies from the origin along its own normal.
-fn plane_offset(plane: &solidcraft_geom::Plane) -> f64 {
+fn plane_offset(plane: &solidcore_record::Plane) -> f64 {
plane.normal().dot(plane.origin)
}
@@ -342,7 +343,7 @@ fn flat_side_faces(s: &Session) -> Vec<(String, [f64; 3])> {
let mut out = Vec::new();
let Some(body) = world.bodies.first() else { return out };
let mesh = body.mesh();
- let mut best: std::collections::BTreeMap<usize, (solidcraft_geom::Vec3, f64)> = std::collections::BTreeMap::new();
+ let mut best: std::collections::BTreeMap<usize, (solidcore_record::Vec3, f64)> = std::collections::BTreeMap::new();
for (triangle, face) in mesh.triangles.iter().zip(&mesh.tri_face) {
if let Some([a, b, c]) = mesh.tri(triangle) {
let area = (b - a).cross(c - a).len();
@@ -379,7 +380,7 @@ fn the_round_sides_of_a_thin_ring_are_named_by_the_circle_they_run_beside() {
for (side, radius) in [("left", 9.0), ("right", 11.0)] {
let name = format!("F2:wall:c1:{side}");
assert!(walls.contains(&&name), "{walls:?}");
- let at = solidcraft_geom::Vec3::new(0.0, radius, 2.5);
+ let at = solidcore_record::Vec3::new(0.0, radius, 2.5);
assert_eq!(solidcraft_doc::naming::face_names_at(&s.model.state(), &[at]), vec![name.clone()]);
}
}
diff --git a/crates/engine/src/cmd/urdf_tests.rs b/crates/engine/src/cmd/urdf_tests.rs
index 50ed4c2906..859c748e64 100644
--- a/crates/engine/src/cmd/urdf_tests.rs
+++ b/crates/engine/src/cmd/urdf_tests.rs
@@ -1,6 +1,7 @@
//! URDF export (#719, docs/urdf.md): files, names, limits, mass and forward kinematics against
//! the joint solver.
+use solidcraft_geom::prelude::*;
use std::path::PathBuf;
use serde_json::{Value, json};
@@ -111,7 +112,7 @@ fn stl_volume(bytes: &[u8]) -> Option<f64> {
for (k, p) in t.iter().enumerate() {
let n = mesh.positions.len() as u32;
tri[k] = *index.entry(p.map(f32::to_bits)).or_insert_with(|| {
- mesh.positions.push(solidcraft_geom::Vec3::new(p[0] as f64, p[1] as f64, p[2] as f64));
+ mesh.positions.push(solidcore_record::Vec3::new(p[0] as f64, p[1] as f64, p[2] as f64));
n
});
}
@@ -375,7 +376,7 @@ fn urdf_inertial_is_mass_weighted() {
}
assert!(i.inertia[0][1].abs() < 1e-15);
// The centre of mass is the cube's centre, in the link frame.
- assert!(i.com.dist(solidcraft_doc::apply_point(&l.mesh_origin, solidcraft_geom::Vec3::new(105.0, 5.0, 5.0))) < 1e-9, "{:?}", i.com);
+ assert!(i.com.dist(solidcraft_doc::apply_point(&l.mesh_origin, solidcore_record::Vec3::new(105.0, 5.0, 5.0))) < 1e-9, "{:?}", i.com);
}
#[test]
diff --git a/crates/engine/src/cmd/view_dxf.rs b/crates/engine/src/cmd/view_dxf.rs
index 61663410c3..f48ab9def7 100644
--- a/crates/engine/src/cmd/view_dxf.rs
+++ b/crates/engine/src/cmd/view_dxf.rs
@@ -11,7 +11,7 @@ mod projection;
pub(super) mod sketch;
use serde_json::{Value, json};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use solidcraft_io::{DxfEntity, DxfLayer, DxfLinetype, DxfShape};
use solidcraft_render::Camera;
diff --git a/crates/engine/src/cmd/view_dxf_meshes.rs b/crates/engine/src/cmd/view_dxf_meshes.rs
index d407045869..2341336b8e 100644
--- a/crates/engine/src/cmd/view_dxf_meshes.rs
+++ b/crates/engine/src/cmd/view_dxf_meshes.rs
@@ -1,13 +1,15 @@
//! Export-only mesh instances. Keep one geometry buffer per unambiguous definition, while
//! retaining the current placed body's edge choices (tangent classification can vary after
//! placement). Never modify the document, fuse parts, or share across separate exports.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
use std::mem::size_of;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
+use solidcore_record::Vec3;
use solidcraft_doc::{IDENTITY, Mat, ModelBody, mat_inverse, mat_mul};
-use solidcraft_geom::{Aabb3, Mesh, Vec3};
+use solidcraft_geom::{Aabb3, Mesh};
use solidcraft_kernel::{KernelError, map_with_local_pools};
use super::{CMD, progress::Stage};
diff --git a/crates/engine/src/cmd/view_dxf_projection.rs b/crates/engine/src/cmd/view_dxf_projection.rs
index d4e0b7157e..8ce88ff706 100644
--- a/crates/engine/src/cmd/view_dxf_projection.rs
+++ b/crates/engine/src/cmd/view_dxf_projection.rs
@@ -1,8 +1,10 @@
//! Vector hidden-line removal: intersect each projected edge with triangle half planes and
//! its depth plane, then union occluded parameter intervals. A BVH bounds the candidate work.
+use solidcore_record::{Vec2, Vec3};
+use solidcraft_geom::Aabb3;
#[cfg(test)]
use solidcraft_geom::Mesh;
-use solidcraft_geom::{Aabb3, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use solidcraft_io::{DxfEntity, DxfShape};
use solidcraft_render::Camera;
use std::collections::BTreeMap;
diff --git a/crates/engine/src/cmd/view_dxf_scene.rs b/crates/engine/src/cmd/view_dxf_scene.rs
index 5a6ca4e071..4ca66b75f1 100644
--- a/crates/engine/src/cmd/view_dxf_scene.rs
+++ b/crates/engine/src/cmd/view_dxf_scene.rs
@@ -2,12 +2,14 @@
//! triangle hierarchy per shared mesh. Per-placement node bounds are small; projected
//! triangle coordinates are evaluated only in visited leaves. Covered line intervals prune
//! subsequent nodes and instances, including the entire query once coverage is complete.
+use solidcraft_geom::prelude::*;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
use web_time::Instant;
+use solidcore_record::Vec3;
use solidcraft_doc::apply_point;
-use solidcraft_geom::{Aabb3, Mesh, Vec3};
+use solidcraft_geom::{Aabb3, Mesh};
use solidcraft_render::Camera;
use super::super::meshes::{Placement, Scene, WORKERS, claim, transformed_bounds};
@@ -617,7 +619,7 @@ mod tests {
}
fn canonical(lines: Vec<Line>) -> Vec<([i64; 2], [i64; 2], bool)> {
- let k = |p: solidcraft_geom::Vec2| [(p.x * 1e6).round() as i64, (p.y * 1e6).round() as i64];
+ let k = |p: solidcore_record::Vec2| [(p.x * 1e6).round() as i64, (p.y * 1e6).round() as i64];
let mut result = lines
.into_iter()
.map(|l| {
diff --git a/crates/engine/src/cmd/view_dxf_sketch.rs b/crates/engine/src/cmd/view_dxf_sketch.rs
index 0fe89be924..3445cb5b9d 100644
--- a/crates/engine/src/cmd/view_dxf_sketch.rs
+++ b/crates/engine/src/cmd/view_dxf_sketch.rs
@@ -3,7 +3,8 @@
//! curves, text outlines and drawn 3D-sketch curves. Construction geometry, centerlines,
//! projected references, points, dimensions and constraints are viewport overlays and are left
//! out. The active sketch is drawn on top, as the viewport draws it.
-use solidcraft_geom::{Plane, Vec3};
+use solidcore_record::{Plane, Vec3};
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::Sketch;
use super::progress::Stage;
diff --git a/crates/engine/src/cmd/view_dxf_tests.rs b/crates/engine/src/cmd/view_dxf_tests.rs
index aefc1527cd..d9a9462bef 100644
--- a/crates/engine/src/cmd/view_dxf_tests.rs
+++ b/crates/engine/src/cmd/view_dxf_tests.rs
@@ -1,5 +1,6 @@
use super::*;
-use solidcraft_geom::{Vec2, Vec3};
+use solidcore_record::{Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use solidcraft_render::StandardView;
fn run(s: &mut Session, id: &str, p: Value) -> Value {
diff --git a/crates/engine/src/cmd/view_navigation.rs b/crates/engine/src/cmd/view_navigation.rs
index 5d5356ae0a..71c4558c76 100644
--- a/crates/engine/src/cmd/view_navigation.rs
+++ b/crates/engine/src/cmd/view_navigation.rs
@@ -1,5 +1,6 @@
//! Stateless camera commands shared by the navigation cube and programmatic callers.
use serde_json::{Value, json};
+use solidcraft_geom::prelude::*;
use solidcraft_render::{Camera, StandardView};
use super::CommandSpec;
@@ -206,14 +207,14 @@ fn turn_to(s: &mut Session, p: &Value, cmd: &str) -> Result<Value> {
camera_reply(cmd, cam)
}
-fn normal_target(s: &Session) -> Option<(solidcraft_geom::Vec3, solidcraft_geom::Vec3)> {
+fn normal_target(s: &Session) -> Option<(solidcore_record::Vec3, solidcore_record::Vec3)> {
let state = s.world_state().ok()?;
s.selection.iter().find_map(|selection| match selection {
Sel::Face { body, index, point } if point.is_finite() => {
let plane = state.body(body)?.body.planar_face(*index)?;
Some((*point, plane.normal()))
}
- Sel::Plane { name } => solidcraft_geom::Plane::named(name).map(|plane| (plane.origin, plane.normal())),
+ Sel::Plane { name } => solidcore_record::Plane::named(name).map(|plane| (plane.origin, plane.normal())),
_ => None,
})
}
@@ -490,7 +491,7 @@ fn navigate(_s: &mut Session, p: &Value) -> Result<Value> {
.map(|d| if d == 90.0 { (1.0, 0.0) } else { d.to_radians().sin_cos() })
.ok_or_else(|| bad(cmd, "degrees must be a number above 0 and at most 180"))?,
};
- let turn = |toward: solidcraft_geom::Vec3| cam.looking_from(b * cos + toward * sin);
+ let turn = |toward: solidcore_record::Vec3| cam.looking_from(b * cos + toward * sin);
match p.get("action").and_then(Value::as_str) {
Some("left") => cam = turn(-r),
Some("right") => cam = turn(r),
@@ -531,7 +532,7 @@ fn continuous(mut cam: Camera, p: &Value) -> Result<Value> {
}
let orbit = |cam: &mut Camera| {
if free_orbit {
- cam.rotate_in_view(solidcraft_geom::Vec3::new(-delta.y * 0.008, -delta.x * 0.008, 0.0));
+ cam.rotate_in_view(solidcore_record::Vec3::new(-delta.y * 0.008, -delta.x * 0.008, 0.0));
} else {
cam.orbit(delta.x, delta.y);
}
@@ -582,7 +583,7 @@ pub(crate) fn square_heading(yaw: f64) -> f64 {
#[cfg(test)]
mod tests {
use super::*;
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
use solidcraft_render::UpAxis;
#[test]
diff --git a/crates/engine/src/construct_tests.rs b/crates/engine/src/construct_tests.rs
index 8af12922ae..59389c1c49 100644
--- a/crates/engine/src/construct_tests.rs
+++ b/crates/engine/src/construct_tests.rs
@@ -2,7 +2,8 @@
//! 40 × 30 × 20 box at the origin, a cylinder, a sphere and a torus.
use serde_json::{Value, json};
-use solidcraft_geom::{Plane, Vec3};
+use solidcore_record::{Plane, Vec3};
+use solidcraft_geom::prelude::*;
use crate::Session;
use crate::view::{construction_axes, construction_planes, construction_points};
diff --git a/crates/engine/src/cosmetic_threads.rs b/crates/engine/src/cosmetic_threads.rs
index 6dd5920698..869bfaff19 100644
--- a/crates/engine/src/cosmetic_threads.rs
+++ b/crates/engine/src/cosmetic_threads.rs
@@ -1,9 +1,11 @@
//! Original schematic cylindrical hatching for evaluated cosmetic threads. The segments lie
//! on the displayed triangles, so neither a separate cylinder nor a helical B-rep is needed.
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
+use solidcore_record::Vec3;
use solidcraft_doc::{ModelBody, ThreadInfo};
-use solidcraft_geom::{Mesh, Vec3};
+use solidcraft_geom::Mesh;
/// Shared upper bound for cosmetic strokes in one viewport/snapshot scene.
pub const MAX_SCENE_SEGMENTS: usize = 65_536;
diff --git a/crates/engine/src/display_mesh_tests.rs b/crates/engine/src/display_mesh_tests.rs
index 003cb79a5c..0c4199a361 100644
--- a/crates/engine/src/display_mesh_tests.rs
+++ b/crates/engine/src/display_mesh_tests.rs
@@ -1,10 +1,12 @@
//! What the application draws of a large sheet with small bends and holes, and that what
//! reads the same mesh (bounds, picks, inside tests) answers as before.
+use solidcraft_geom::prelude::*;
use std::f64::consts::{FRAC_PI_2, TAU};
use serde_json::{Value, json};
-use solidcraft_geom::{Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Mesh;
use solidcraft_kernel::{DISPLAY_ANGLE, FaceSurface, face_surface};
use crate::Session;
diff --git a/crates/engine/src/exact_tool_tests.rs b/crates/engine/src/exact_tool_tests.rs
index 564f81a066..87cf2a4d1e 100644
--- a/crates/engine/src/exact_tool_tests.rs
+++ b/crates/engine/src/exact_tool_tests.rs
@@ -4,7 +4,7 @@
//! (a cut) or material (a join) on the bodies' faces, not just at a few sample points.
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::Session;
diff --git a/crates/engine/src/face_name_tests.rs b/crates/engine/src/face_name_tests.rs
index dfa1354809..f7e1a18ee6 100644
--- a/crates/engine/src/face_name_tests.rs
+++ b/crates/engine/src/face_name_tests.rs
@@ -4,7 +4,7 @@
use std::f64::consts::PI;
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::Session;
diff --git a/crates/engine/src/frames.rs b/crates/engine/src/frames.rs
index 7645800bea..5591dedecd 100644
--- a/crates/engine/src/frames.rs
+++ b/crates/engine/src/frames.rs
@@ -10,8 +10,9 @@
//! without moved components).
use serde_json::{Map, Value};
+use solidcore_record::Vec3;
use solidcraft_doc::{Mat, apply_point, apply_vector, is_identity, map_point_expr, map_vector_expr, mat_inverse};
-use solidcraft_geom::Vec3;
+use solidcraft_geom::prelude::*;
use crate::Session;
diff --git a/crates/engine/src/frames_tests.rs b/crates/engine/src/frames_tests.rs
index 3038286803..fd82140309 100644
--- a/crates/engine/src/frames_tests.rs
+++ b/crates/engine/src/frames_tests.rs
@@ -2,7 +2,8 @@
//! world land in the component's own frame (user bug #4).
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use crate::Session;
diff --git a/crates/engine/src/fuzz.rs b/crates/engine/src/fuzz.rs
index 97f76137a9..36313f57e1 100644
--- a/crates/engine/src/fuzz.rs
+++ b/crates/engine/src/fuzz.rs
@@ -8,7 +8,7 @@
use serde::Serialize;
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_kernel::fuzz::Rng;
pub use solidcraft_kernel::fuzz::{BoolCase, boolean_case, boolean_shapes};
diff --git a/crates/engine/src/hole_face_tests.rs b/crates/engine/src/hole_face_tests.rs
index 1a88882cf5..115bc8ca2b 100644
--- a/crates/engine/src/hole_face_tests.rs
+++ b/crates/engine/src/hole_face_tests.rs
@@ -3,7 +3,7 @@
//! where it was put and says so instead of sliding to the face's nearest point.
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::Session;
diff --git a/crates/engine/src/hole_matrix_tests.rs b/crates/engine/src/hole_matrix_tests.rs
index 6aa601d529..123b2be852 100644
--- a/crates/engine/src/hole_matrix_tests.rs
+++ b/crates/engine/src/hole_matrix_tests.rs
@@ -13,10 +13,11 @@
//! case that passes fails the test (take it off the list), and so does an unlisted one that fails.
//! `HOLE_MATRIX_BLESS=1 cargo test -p solidcraft-engine hole_matrix` rewrites the list.
+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;
diff --git a/crates/engine/src/hole_reference_tests.rs b/crates/engine/src/hole_reference_tests.rs
index 493a024c7d..f504488ec9 100644
--- a/crates/engine/src/hole_reference_tests.rs
+++ b/crates/engine/src/hole_reference_tests.rs
@@ -3,11 +3,12 @@
//! when the part changes (also after the design is saved and reopened), and a bad reference is
//! refused with an error. A cylinder takes the same references for its base (#6380).
+use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
use serde_json::{Value, json};
+use solidcore_record::Vec3;
use solidcraft_doc::FeatureKind;
-use solidcraft_geom::Vec3;
use crate::{EngineError, Session};
diff --git a/crates/engine/src/large_assembly_tests.rs b/crates/engine/src/large_assembly_tests.rs
index e9130ca6be..ade58e30b1 100644
--- a/crates/engine/src/large_assembly_tests.rs
+++ b/crates/engine/src/large_assembly_tests.rs
@@ -7,9 +7,9 @@
//! `SOLIDCRAFT_BENCH_PARTS=400 cargo test --release -p solidcraft-engine bench_generated_assembly -- --ignored --nocapture`
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_doc::BodyName;
use solidcraft_doc::{Document, FeatureKind, Operation, mat_inverse, point_expr, rigid};
-use solidcraft_geom::Vec3;
use crate::Session;
diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs
index 3141aac26d..152c65f962 100644
--- a/crates/engine/src/lib.rs
+++ b/crates/engine/src/lib.rs
@@ -38,12 +38,13 @@ pub mod status_items;
pub mod timing;
pub mod view;
+use solidcraft_geom::prelude::*;
use std::sync::Arc;
use serde::{Deserialize, Serialize};
use serde_json::Value;
+use solidcore_record::Vec3;
use solidcraft_doc::{Document, Model, ModelState};
-use solidcraft_geom::Vec3;
pub use cmd::settings::{MAX_PROFILE_NAME, profile_name};
pub use cmd::{
@@ -1174,7 +1175,7 @@ impl Session {
for sketch in w.sketches.iter_mut().filter(|sk| self.doc.feature(sk.feature).is_some_and(|f| f.component == self.active_component)) {
let sketch = Arc::make_mut(sketch);
let plane = sketch.plane;
- sketch.plane = solidcraft_geom::Plane::new(
+ sketch.plane = solidcore_record::Plane::new(
solidcraft_doc::apply_point(&delta, plane.origin),
solidcraft_doc::apply_vector(&delta, plane.x),
solidcraft_doc::apply_vector(&delta, plane.y),
diff --git a/crates/engine/src/measure_centre_tests.rs b/crates/engine/src/measure_centre_tests.rs
index f0bff39b11..47cca287ac 100644
--- a/crates/engine/src/measure_centre_tests.rs
+++ b/crates/engine/src/measure_centre_tests.rs
@@ -2,10 +2,11 @@
//! distances with the closest and farthest listed too, diameters and radii, slot sizes. Every
//! expected value is worked out by hand from the part's dimensions.
+use solidcraft_geom::prelude::*;
use std::f64::consts::{PI, TAU};
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::Session;
diff --git a/crates/engine/src/naming_history_tests.rs b/crates/engine/src/naming_history_tests.rs
index 18165a21a9..616668746a 100644
--- a/crates/engine/src/naming_history_tests.rs
+++ b/crates/engine/src/naming_history_tests.rs
@@ -4,7 +4,7 @@
//! names again by sampling geometry could do.
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::Session;
diff --git a/crates/engine/src/params.rs b/crates/engine/src/params.rs
index 0e25fd1912..8de8f269f1 100644
--- a/crates/engine/src/params.rs
+++ b/crates/engine/src/params.rs
@@ -1,8 +1,8 @@
//! Helpers to read hostile JSON parameters.
use serde_json::Value;
+use solidcore_record::{Vec2, Vec3};
use solidcraft_doc::Expr;
-use solidcraft_geom::{Vec2, Vec3};
use crate::{EngineError, Result, kernel};
diff --git a/crates/engine/src/pattern_suppress_tests.rs b/crates/engine/src/pattern_suppress_tests.rs
index fee44fcd30..d2bd7382d3 100644
--- a/crates/engine/src/pattern_suppress_tests.rs
+++ b/crates/engine/src/pattern_suppress_tests.rs
@@ -2,6 +2,7 @@
//! pattern says so.
use serde_json::{Value, json};
+use solidcraft_geom::prelude::*;
use crate::Session;
@@ -55,12 +56,12 @@ fn enclosure_datums_follow_wall_height_and_board_depth_with_material_proofs() {
let state = session.world_state().unwrap();
let case = state.body("Case").unwrap().mesh();
let lid = state.body("Lid").unwrap().mesh();
- assert!(case.contains(solidcraft_geom::Vec3::new(-24.5, -21.5, 7.)));
- assert!(!case.contains(solidcraft_geom::Vec3::new(-26.5, -21.5, 7.)));
- assert!(!case.contains(solidcraft_geom::Vec3::new(-10., -35.25, 11.35)));
- assert!(case.contains(solidcraft_geom::Vec3::new(-10., -35.25, 15.)));
+ assert!(case.contains(solidcore_record::Vec3::new(-24.5, -21.5, 7.)));
+ assert!(!case.contains(solidcore_record::Vec3::new(-26.5, -21.5, 7.)));
+ assert!(!case.contains(solidcore_record::Vec3::new(-10., -35.25, 11.35)));
+ assert!(case.contains(solidcore_record::Vec3::new(-10., -35.25, 15.)));
assert!(
- lid.contains(solidcraft_geom::Vec3::new(0., 32.2, 29.)),
+ lid.contains(solidcore_record::Vec3::new(0., 32.2, 29.)),
"lid bounds {:?}; lip {:?}; probes {:?}",
lid.bounds(),
session
@@ -78,11 +79,11 @@ fn enclosure_datums_follow_wall_height_and_board_depth_with_material_proofs() {
.unwrap()
.sketch
.links,
- (20..35).map(|y| (y, lid.contains(solidcraft_geom::Vec3::new(0., f64::from(y) + 0.2, 29.)))).collect::<Vec<_>>()
+ (20..35).map(|y| (y, lid.contains(solidcore_record::Vec3::new(0., f64::from(y) + 0.2, 29.)))).collect::<Vec<_>>()
);
- assert!(!lid.contains(solidcraft_geom::Vec3::new(0., 32.9, 29.)));
- assert!(!lid.contains(solidcraft_geom::Vec3::new(-33.5, -28.5, 32.)));
- assert!(lid.contains(solidcraft_geom::Vec3::new(-31.5, -28.5, 32.)));
+ assert!(!lid.contains(solidcore_record::Vec3::new(0., 32.9, 29.)));
+ assert!(!lid.contains(solidcore_record::Vec3::new(-33.5, -28.5, 32.)));
+ assert!(lid.contains(solidcore_record::Vec3::new(-31.5, -28.5, 32.)));
};
assert_material(&s);
let reopened = Session::new(solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap());
@@ -92,8 +93,8 @@ fn enclosure_datums_follow_wall_height_and_board_depth_with_material_proofs() {
#[test]
fn enclosure_arc_extinction_keeps_a_real_sharp_inner_lip_after_resize_and_reopen() {
+ use solidcore_record::{Vec2, Vec3};
use solidcraft_doc::FeatureKind;
- use solidcraft_geom::{Vec2, Vec3};
use solidcraft_sketch::CurveKind;
let mut s = Session::default();
@@ -160,14 +161,14 @@ fn enclosure_arc_extinction_keeps_a_real_sharp_inner_lip_after_resize_and_reopen
.segs
.iter()
.map(|segment| match segment {
- solidcraft_geom::Seg2::Arc { radius, sweep, .. } => radius.abs() * sweep.abs(),
- solidcraft_geom::Seg2::Line { .. } => 0.,
+ solidcore_record::Seg2::Arc { radius, sweep, .. } => radius.abs() * sweep.abs(),
+ solidcore_record::Seg2::Line { .. } => 0.,
other => panic!("unexpected ring boundary {other:?}"),
})
.sum::<f64>();
assert!((arc_perimeter - std::f64::consts::TAU * 0.8).abs() < 1e-8);
assert_eq!(regions[0].holes.len(), 1);
- assert!(regions[0].holes[0].segs.iter().all(|segment| matches!(segment, solidcraft_geom::Seg2::Line { .. })));
+ assert!(regions[0].holes[0].segs.iter().all(|segment| matches!(segment, solidcore_record::Seg2::Line { .. })));
// Body::tessellate floors the requested sag tolerance at size * 1e-6.
// Only the outer arcs incur chord error: their tolerance-wide boundary
// strip bounds the volume error without changing CAD or export tolerances.
diff --git a/crates/engine/src/product_scene.rs b/crates/engine/src/product_scene.rs
index 6441de40de..3e794e8b33 100644
--- a/crates/engine/src/product_scene.rs
+++ b/crates/engine/src/product_scene.rs
@@ -55,9 +55,9 @@ pub fn extract(s: &Session) -> Result<ProductScene> {
mod tests {
use super::*;
use crate::Sel;
- use crate::geom::Vec3;
use crate::render::*;
use serde_json::json;
+ use solidcore_record::Vec3;
use std::sync::Arc;
#[test]
diff --git a/crates/engine/src/profile_curves_tests.rs b/crates/engine/src/profile_curves_tests.rs
index 77aa1e3eb0..bb8a99bf2f 100644
--- a/crates/engine/src/profile_curves_tests.rs
+++ b/crates/engine/src/profile_curves_tests.rs
@@ -68,7 +68,7 @@ fn a_profile_picked_by_curves_follows_a_parameter_change() {
if let Some(f) = s.doc_mut().feature_mut(id)
&& let FeatureKind::Extrude { profiles, .. } = &mut f.kind
{
- *profiles = ProfileSel::Points { points: vec![solidcraft_geom::Vec2::new(25.0, 10.0)] };
+ *profiles = ProfileSel::Points { points: vec![solidcore_record::Vec2::new(25.0, 10.0)] };
}
s.refresh();
assert!((volumes(&s)[0] - 6000.0).abs() < 1.0);
diff --git a/crates/engine/src/profile_refs_tests.rs b/crates/engine/src/profile_refs_tests.rs
index 72e06f4a91..8cbff001b5 100644
--- a/crates/engine/src/profile_refs_tests.rs
+++ b/crates/engine/src/profile_refs_tests.rs
@@ -68,14 +68,14 @@ fn a_port_picked_by_index_stays_a_cut_after_a_width_change() {
assert!((s.model.state().sketch(port).unwrap().plane.origin.x - 50.).abs() < 1e-6);
let world = s.world_state().unwrap();
let mesh = world.body("Enclosure").unwrap().mesh();
- assert!(!mesh.contains(solidcraft_geom::Vec3::new(49., 0., 12.)));
- assert!(mesh.contains(solidcraft_geom::Vec3::new(49., 0., 20.)));
+ assert!(!mesh.contains(solidcore_record::Vec3::new(49., 0., 12.)));
+ assert!(mesh.contains(solidcore_record::Vec3::new(49., 0., 20.)));
let reopened = Session::new(solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap());
assert!(reopened.model.result(id).unwrap().error.is_none());
let world = reopened.world_state().unwrap();
let mesh = world.body("Enclosure").unwrap().mesh();
- assert!(!mesh.contains(solidcraft_geom::Vec3::new(49., 0., 12.)));
- assert!(mesh.contains(solidcraft_geom::Vec3::new(49., 0., 20.)));
+ assert!(!mesh.contains(solidcore_record::Vec3::new(49., 0., 12.)));
+ assert!(mesh.contains(solidcore_record::Vec3::new(49., 0., 20.)));
}
/// A pick the sketch no longer has is an error on the feature, never a different profile.
diff --git a/crates/engine/src/render_lights.rs b/crates/engine/src/render_lights.rs
index 2014637c54..fa48f4135d 100644
--- a/crates/engine/src/render_lights.rs
+++ b/crates/engine/src/render_lights.rs
@@ -1,7 +1,8 @@
//! Shared light inspection and numerical adapters; no document or view-state mutation.
use crate::schema::render_lights::{Geometry, Light};
+use solidcore_record::Vec3;
use solidcraft_doc::render_settings::{RenderJob, RenderSetup};
-use solidcraft_geom::Vec3;
+use solidcraft_geom::prelude::*;
use solidcraft_render::job::LightingPreset;
use solidcraft_render::job::{AreaLight, AreaLights, DirectionalLightOptions, PunctualLightOptions, RectangleLightOptions, SpotConeOptions, Sun};
diff --git a/crates/engine/src/sample.rs b/crates/engine/src/sample.rs
index 0ca0e60cbe..877beb056a 100644
--- a/crates/engine/src/sample.rs
+++ b/crates/engine/src/sample.rs
@@ -164,17 +164,17 @@ mod tests {
let world = session.world_state().unwrap();
let plate = world.body("Plate").unwrap().mesh();
assert!((plate.bounds().max.z - 26.).abs() < 1e-6);
- assert!(plate.contains(solidcraft_geom::Vec3::new(5., 25., 10.)));
- assert!(plate.contains(solidcraft_geom::Vec3::new(40., 35., 24.)));
- assert!(!plate.contains(solidcraft_geom::Vec3::new(40., 25., 24.)));
- assert!(!plate.contains(solidcraft_geom::Vec3::new(40., 25., 2.)));
- assert!(plate.contains(solidcraft_geom::Vec3::new(40., 35., 2.)));
+ assert!(plate.contains(solidcore_record::Vec3::new(5., 25., 10.)));
+ assert!(plate.contains(solidcore_record::Vec3::new(40., 35., 24.)));
+ assert!(!plate.contains(solidcore_record::Vec3::new(40., 25., 24.)));
+ assert!(!plate.contains(solidcore_record::Vec3::new(40., 25., 2.)));
+ assert!(plate.contains(solidcore_record::Vec3::new(40., 35., 2.)));
let reopened = crate::Session::new(solidcraft_doc::Document::from_json(&session.doc.to_json()).unwrap());
assert!((reopened.model.state().sketch(bore).unwrap().plane.origin.z - 26.).abs() < 1e-6);
let reopened_world = reopened.world_state().unwrap();
let reopened_plate = reopened_world.body("Plate").unwrap().mesh();
- assert!(!reopened_plate.contains(solidcraft_geom::Vec3::new(40., 25., 2.)));
- assert!(reopened_plate.contains(solidcraft_geom::Vec3::new(40., 35., 2.)));
+ assert!(!reopened_plate.contains(solidcore_record::Vec3::new(40., 25., 2.)));
+ assert!(reopened_plate.contains(solidcore_record::Vec3::new(40., 35., 2.)));
}
/// Every built-in sample builds without a failing feature or joint, and without a panic on
diff --git a/crates/engine/src/schema/component_tests.rs b/crates/engine/src/schema/component_tests.rs
index 2be7b22dbd..983c8705bc 100644
--- a/crates/engine/src/schema/component_tests.rs
+++ b/crates/engine/src/schema/component_tests.rs
@@ -1,3 +1,4 @@
+use solidcraft_geom::prelude::*;
use std::sync::Arc;
use serde_json::{Value, json};
diff --git a/crates/engine/src/schema/inspect.rs b/crates/engine/src/schema/inspect.rs
index 45d2afe26b..cc674dcf03 100644
--- a/crates/engine/src/schema/inspect.rs
+++ b/crates/engine/src/schema/inspect.rs
@@ -233,7 +233,7 @@ impl From<&solidcraft_doc::ThreadInfo> for ModelThread {
},
starts: t.starts,
axis_point: t.axis_point.into(),
- axis: solidcraft_geom::Vec3::from(t.axis).into(),
+ axis: solidcore_record::Vec3::from(t.axis).into(),
start: t.start,
end: t.end,
}
diff --git a/crates/engine/src/schema/sheet.rs b/crates/engine/src/schema/sheet.rs
index 28022daf68..652ceccf7c 100644
--- a/crates/engine/src/schema/sheet.rs
+++ b/crates/engine/src/schema/sheet.rs
@@ -17,8 +17,8 @@ use schemars::{JsonSchema, Schema, SchemaGenerator, json_schema};
use serde::de::Error as _;
use serde::{Deserialize, Deserializer};
use serde_json::Value;
+use solidcore_record::Vec3;
use solidcraft_doc::FlangeEdge;
-use solidcraft_geom::Vec3;
use super::check::whole;
use super::types::{AngleExpr, FaceRef, FeatureCommon, IdOrName, LengthExpr, Point3, ProfilesParam, SketchRef, StringList, feature_common, present};
diff --git a/crates/engine/src/schema/sketch_inspect.rs b/crates/engine/src/schema/sketch_inspect.rs
index 8075b8ea64..3baded8493 100644
--- a/crates/engine/src/schema/sketch_inspect.rs
+++ b/crates/engine/src/schema/sketch_inspect.rs
@@ -8,7 +8,7 @@ use schemars::{JsonSchema, Schema, SchemaGenerator, json_schema};
use serde::de::Error as _;
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::Value;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use super::check::whole;
use super::types::{Point3, SketchRef, StringList, present};
diff --git a/crates/engine/src/schema/tests.rs b/crates/engine/src/schema/tests.rs
index bc9bce2d07..3a5cdeccd3 100644
--- a/crates/engine/src/schema/tests.rs
+++ b/crates/engine/src/schema/tests.rs
@@ -774,7 +774,7 @@ fn face_and_edge_refs_match_the_pick_readers() {
assert!(parse::<EdgeRef>(json!({"body": "A", "index": 1.0})).is_none());
assert_eq!(edge_schema["anyOf"][2]["properties"]["index"]["type"], "integer");
assert_eq!(parse::<EdgeRef>(json!({"body": "A", "index": 4})), Some(EdgeRef::Index { body: "A".into(), index: 4 }));
- assert_eq!(parse::<FaceRef>(json!({"point": [1, 2, 3]})), Some(FaceRef::Point(solidcraft_geom::Vec3::new(1.0, 2.0, 3.0))));
+ assert_eq!(parse::<FaceRef>(json!({"point": [1, 2, 3]})), Some(FaceRef::Point(solidcore_record::Vec3::new(1.0, 2.0, 3.0))));
}
/// The pick lists take 1 to 1000 picks, as `face_points` and `edge_points` do, and so do their
diff --git a/crates/engine/src/schema/types.rs b/crates/engine/src/schema/types.rs
index 1fcb5ef177..72adae3a23 100644
--- a/crates/engine/src/schema/types.rs
+++ b/crates/engine/src/schema/types.rs
@@ -8,8 +8,8 @@ use schemars::{JsonSchema, Schema, SchemaGenerator, json_schema};
use serde::de::Error as _;
use serde::{Deserialize, Deserializer};
use serde_json::{Value, json};
+use solidcore_record::{Vec2, Vec3};
use solidcraft_doc::{Expr, Operation, ThinSide, Touching};
-use solidcraft_geom::{Vec2, Vec3};
use super::check::{keyed, whole};
use crate::params;
diff --git a/crates/engine/src/sketch_edit_removed_tests.rs b/crates/engine/src/sketch_edit_removed_tests.rs
index 44b92c07ef..23293bb54a 100644
--- a/crates/engine/src/sketch_edit_removed_tests.rs
+++ b/crates/engine/src/sketch_edit_removed_tests.rs
@@ -3,7 +3,8 @@
//! (#1167): the history is rolled back, the view of it is not. A body the sketch is built on stays.
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::LinkSource;
use crate::Session;
diff --git a/crates/engine/src/snap.rs b/crates/engine/src/snap.rs
index 3f86ec1cef..b553d13e0d 100644
--- a/crates/engine/src/snap.rs
+++ b/crates/engine/src/snap.rs
@@ -7,7 +7,9 @@
//! as the viewport shows the model.
use serde::Serialize;
-use solidcraft_geom::{UnitVec3, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::UnitVec3;
+use solidcraft_geom::prelude::*;
use crate::cmd::Shape;
use crate::{Sel, Session};
diff --git a/crates/engine/src/snap_tests.rs b/crates/engine/src/snap_tests.rs
index 50e31a42d0..249e8f5d4a 100644
--- a/crates/engine/src/snap_tests.rs
+++ b/crates/engine/src/snap_tests.rs
@@ -1,10 +1,11 @@
//! Snap points (#5881): the centres, middles and ends edges and faces offer. Every expected
//! point is worked out by hand from the part's dimensions.
+use solidcraft_geom::prelude::*;
use std::f64::consts::{FRAC_1_SQRT_2, PI};
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::snap::{SnapKind, SnapPoint, snap_points};
use crate::{Sel, Session};
diff --git a/crates/engine/src/status_details.rs b/crates/engine/src/status_details.rs
index 349b6c2142..d5d6267ed3 100644
--- a/crates/engine/src/status_details.rs
+++ b/crates/engine/src/status_details.rs
@@ -84,7 +84,7 @@ impl crate::Session {
}
/// Validate again at activation; a button's earlier descriptor is never authority.
- pub fn continuity_target_points(&self, body: &str, edge: usize) -> Option<&[solidcraft_geom::Vec3]> {
+ pub fn continuity_target_points(&self, body: &str, edge: usize) -> Option<&[solidcore_record::Vec3]> {
if !self.continuity_details().iter().any(|row| row.body == body && row.edge == edge && row.current) {
return None;
}
diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs
index 9e5637af72..4eb70dce28 100644
--- a/crates/engine/src/tests.rs
+++ b/crates/engine/src/tests.rs
@@ -121,8 +121,8 @@ fn a_later_round_at_a_mitred_corner_is_blended_with_the_rounds_there() {
let first = run(&mut s, "solid.fillet", json!({"edges": [[20, 10, 20], [10, 0, 20]], "radius": 2}))["feature"].as_u64().unwrap();
// A point halfway along each r2 round, at 45° between its faces.
let k = 2.0 - 2.0_f64.sqrt();
- let rounds = [solidcraft_geom::Vec3::new(20.0 - k, 10.0, 20.0 - k), solidcraft_geom::Vec3::new(10.0, k, 20.0 - k)];
- let named = |s: &mut Session, at: solidcraft_geom::Vec3| {
+ let rounds = [solidcore_record::Vec3::new(20.0 - k, 10.0, 20.0 - k), solidcore_record::Vec3::new(10.0, k, 20.0 - k)];
+ let named = |s: &mut Session, at: solidcore_record::Vec3| {
let st = s.model.state();
let (d, index) = solidcraft_doc::appearance::nearest_face(st.body("Box").unwrap(), at).unwrap();
// Found on the display mesh, whose facets lie within its chord of the faces.
@@ -142,7 +142,7 @@ fn a_later_round_at_a_mitred_corner_is_blended_with_the_rounds_there() {
assert_eq!(after, before);
// The r3 round (halfway up, at 45°) and the corner's patches: the faces the second fillet made.
let k3 = 3.0 - 4.5_f64.sqrt();
- assert!(named(&mut s, solidcraft_geom::Vec3::new(20.0 - k3, k3, 10.0)).starts_with(&format!("F{second}:blend:")));
+ assert!(named(&mut s, solidcore_record::Vec3::new(20.0 - k3, k3, 10.0)).starts_with(&format!("F{second}:blend:")));
let made = faces.iter().filter(|f| f["name"].as_str().is_some_and(|n| n.starts_with(&format!("F{second}:")))).count();
// the r3 round and the corner's patch
assert_eq!(made, 2, "{faces:?}");
@@ -192,14 +192,14 @@ fn join_extrude_from_a_chamfered_top_face() {
assert!((solved.plane.origin.z - height).abs() < 1e-8);
assert!(solved.sketch.links.iter().all(|link| link.auto_face && !link.lost));
let body = &state.bodies[0];
- assert_eq!(body.body.classify_point(solidcraft_geom::Vec3::new(0., 0., height + 4.)).unwrap(), solidcraft_kernel::PointClass::Inside);
- assert_eq!(body.body.classify_point(solidcraft_geom::Vec3::new(0., 0., height + 6.)).unwrap(), solidcraft_kernel::PointClass::Outside);
+ assert_eq!(body.body.classify_point(solidcore_record::Vec3::new(0., 0., height + 4.)).unwrap(), solidcraft_kernel::PointClass::Inside);
+ assert_eq!(body.body.classify_point(solidcore_record::Vec3::new(0., 0., height + 6.)).unwrap(), solidcraft_kernel::PointClass::Outside);
assert_eq!(
- body.body.classify_point(solidcraft_geom::Vec3::new(10. - bevel - 0.5, 0., height + 4.)).unwrap(),
+ body.body.classify_point(solidcore_record::Vec3::new(10. - bevel - 0.5, 0., height + 4.)).unwrap(),
solidcraft_kernel::PointClass::Inside
);
assert_eq!(
- body.body.classify_point(solidcraft_geom::Vec3::new(10. - bevel + 0.5, 0., height + 4.)).unwrap(),
+ body.body.classify_point(solidcore_record::Vec3::new(10. - bevel + 0.5, 0., height + 4.)).unwrap(),
solidcraft_kernel::PointClass::Outside
);
}
@@ -562,8 +562,8 @@ fn rounds_on_a_bar_running_tangent_into_a_cylinder() {
// through (32, 8, 15) is a cylinder of radius 8.
let state = s.model.state();
let rec = state.bodies[0].body.record();
- let p0 = solidcraft_geom::Vec3::new(32.0, 8.0, 15.0);
- let on: Vec<&solidcraft_geom::brep::Surface> = rec
+ let p0 = solidcore_record::Vec3::new(32.0, 8.0, 15.0);
+ let on: Vec<&solidcore_record::brep::Surface> = rec
.faces
.iter()
.map(|f| &f.surface)
@@ -574,7 +574,7 @@ fn rounds_on_a_bar_running_tangent_into_a_cylinder() {
.collect();
let kinds: Vec<String> = on.iter().map(|s| format!("{s:?}").chars().take(48).collect()).collect();
assert!(
- !on.is_empty() && on.iter().all(|s| matches!(s, solidcraft_geom::brep::Surface::Cylinder { radius, .. } if (radius - 8.0).abs() < 1e-9)),
+ !on.is_empty() && on.iter().all(|s| matches!(s, solidcore_record::brep::Surface::Cylinder { radius, .. } if (radius - 8.0).abs() < 1e-9)),
"{kinds:?}"
);
}
@@ -1307,7 +1307,7 @@ fn sample_edges_chain_and_faces() {
let chain = m.tangent_chain(e, 2f64.to_radians());
// The plate's top outline: 4 lines and 4 corner arcs (a boolean may leave an edge twice,
// once per face; count distinct ones).
- let mut mids: Vec<solidcraft_geom::Vec3> = Vec::new();
+ let mut mids: Vec<solidcore_record::Vec3> = Vec::new();
for i in &chain {
let p = &m.edges[*i];
let mid = p[p.len() / 2];
@@ -1806,7 +1806,7 @@ fn auto_extrude_joins_side_contact_elbow_and_keeps_new_body_explicit() {
assert!(body.validity().is_empty());
assert_eq!(body.lumps().unwrap().len(), 1);
assert_eq!(body.face_count(), 8, "the two flat elbow sides must be single faces");
- assert_eq!(body.classify_point(geom::Vec3::new(5.0, 10.0, 25.0)).unwrap(), solidcraft_kernel::PointClass::Inside);
+ assert_eq!(body.classify_point(solidcore_record::Vec3::new(5.0, 10.0, 25.0)).unwrap(), solidcraft_kernel::PointClass::Inside);
}
}
}
@@ -1828,7 +1828,11 @@ fn auto_extrude_joins_corner_screw_boss() {
let body = &st.bodies.first().unwrap().body;
assert_eq!(body.lumps().unwrap().len(), 1);
assert!(body.validity().is_empty());
- assert_eq!(body.classify_point(geom::Vec3::new(10.0, 10.0, 32.0)).unwrap(), solidcraft_kernel::PointClass::Outside, "the screw hole stays open");
+ assert_eq!(
+ body.classify_point(solidcore_record::Vec3::new(10.0, 10.0, 32.0)).unwrap(),
+ solidcraft_kernel::PointClass::Outside,
+ "the screw hole stays open"
+ );
}
#[test]
@@ -4006,7 +4010,7 @@ fn side_face_pick(s: &Session, body: &str) -> Value {
.faces(0.01)
.unwrap()
.into_iter()
- .filter(|f| f.plane_normal.is_some_and(|n| n.dot(solidcraft_geom::Vec3::X) > 0.999))
+ .filter(|f| f.plane_normal.is_some_and(|n| n.dot(solidcore_record::Vec3::X) > 0.999))
.max_by(|a, b| a.centroid.x.total_cmp(&b.centroid.x))
.unwrap();
json!({"body": b.name, "index": face.index, "face": [face.centroid.x, face.centroid.y, face.centroid.z]})
@@ -4078,7 +4082,7 @@ fn an_exact_pick_of_a_region_cut_by_the_face_outline_takes_only_that_region() {
let state = s.model.state();
let ss = state.sketch(id).unwrap();
assert_eq!(ss.profiles.len(), 3, "the lens, the crescent past the face and the rest of the face");
- let at = |x: f64| ss.profiles.iter().position(|p| p.region.contains(solidcraft_geom::Vec2::new(x, 0.0))).unwrap();
+ let at = |x: f64| ss.profiles.iter().position(|p| p.region.contains(solidcore_record::Vec2::new(x, 0.0))).unwrap();
let (on_face, past_face) = (at(7.0), at(14.0));
// The volume of the new body, and how many profiles its extrude is built from.
let extrude = |extra: Value| -> (f64, usize) {
@@ -4761,7 +4765,7 @@ fn a_side_drawn_in_two_collinear_pieces_extrudes_into_one_face() {
let st = s.model.state();
let body = st.body("Body1").unwrap();
let edge = format!("F2:side:{}|F2:top", pieces[1]);
- let at = solidcraft_doc::naming::find_edge(body, &edge, geom::Vec3::new(15.0, 0.0, 5.0)).unwrap();
+ let at = solidcraft_doc::naming::find_edge(body, &edge, solidcore_record::Vec3::new(15.0, 0.0, 5.0)).unwrap();
assert!(at.y.abs() < 1e-9 && (at.z - 5.0).abs() < 1e-9, "{edge} at {at:?}");
// A sketch attaches to the joined side as to any side.
assert_eq!(run(&mut s, "sketch.create", json!({"plane": {"face": [15, 0, 2.5]}}))["attachment"], "exact_face");
diff --git a/crates/engine/src/tests/curved_seam_round.rs b/crates/engine/src/tests/curved_seam_round.rs
index 971ea89af3..107b5881f5 100644
--- a/crates/engine/src/tests/curved_seam_round.rs
+++ b/crates/engine/src/tests/curved_seam_round.rs
@@ -8,7 +8,7 @@
use std::f64::consts::PI;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use super::*;
diff --git a/crates/engine/src/tests/import_component.rs b/crates/engine/src/tests/import_component.rs
index de5d141674..d35f6f61c8 100644
--- a/crates/engine/src/tests/import_component.rs
+++ b/crates/engine/src/tests/import_component.rs
@@ -5,7 +5,8 @@
//! imports sit loose in a component open and rebuild as they did.
use serde_json::{Value, json};
-use solidcraft_geom::{Aabb3, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Aabb3;
use solidcraft_kernel::{ExportBody, ExportProduct, StepHeader, box_solid, step_export_products};
use super::run;
diff --git a/crates/engine/src/tests/large_step_import.rs b/crates/engine/src/tests/large_step_import.rs
index ce4b74bfca..3a9fb3d5f2 100644
--- a/crates/engine/src/tests/large_step_import.rs
+++ b/crates/engine/src/tests/large_step_import.rs
@@ -11,8 +11,8 @@ use crate::*;
fn step_file(name: &str, count: usize) -> String {
let bodies: Vec<_> = (0..count)
.map(|i| {
- let at = solidcraft_geom::Vec3::new((i % 32) as f64 * 12.0, (i / 32) as f64 * 12.0, 0.0);
- solidcraft_kernel::box_solid(at, at + solidcraft_geom::Vec3::new(10.0, 10.0, 10.0)).unwrap()
+ let at = solidcore_record::Vec3::new((i % 32) as f64 * 12.0, (i / 32) as f64 * 12.0, 0.0);
+ solidcraft_kernel::box_solid(at, at + solidcore_record::Vec3::new(10.0, 10.0, 10.0)).unwrap()
})
.collect();
let text = solidcraft_kernel::step_export(&bodies.iter().collect::<Vec<_>>(), name).unwrap();
diff --git a/crates/engine/src/tests/loft_ring.rs b/crates/engine/src/tests/loft_ring.rs
index 7263ffae27..9c2e2eac18 100644
--- a/crates/engine/src/tests/loft_ring.rs
+++ b/crates/engine/src/tests/loft_ring.rs
@@ -37,7 +37,7 @@ fn a_ring_section_keeps_its_hole_and_rejects_a_disc() {
for face in 0..body.body.face_count() {
assert!(solidcraft_doc::naming::face_name_exact(body, face), "face {face} lost its sketch-curve provenance");
}
- assert!(!body.body.mesh(&solidcraft_kernel::MeshTolerance::chord(0.001)).unwrap().contains(solidcraft_geom::Vec3::new(0.0, 0.0, 10.0)));
+ assert!(!body.body.mesh(&solidcraft_kernel::MeshTolerance::chord(0.001)).unwrap().contains(solidcore_record::Vec3::new(0.0, 0.0, 10.0)));
run(&mut s, "edit.undo", json!({}));
assert!(s.model.state().bodies.is_empty());
run(&mut s, "edit.redo", json!({}));
diff --git a/crates/engine/src/tests/mesh_convert.rs b/crates/engine/src/tests/mesh_convert.rs
index 3977155712..d2ed9a884e 100644
--- a/crates/engine/src/tests/mesh_convert.rs
+++ b/crates/engine/src/tests/mesh_convert.rs
@@ -1,6 +1,6 @@
use super::*;
+use solidcore_record::Vec3;
use solidcraft_doc::{Document, FeatureKind, MeshData};
-use solidcraft_geom::Vec3;
fn imported_box() -> Session {
let body = solidcraft_kernel::box_solid(Vec3::ZERO, Vec3::new(10., 20., 30.)).unwrap();
diff --git a/crates/engine/src/tests/mirror_placed.rs b/crates/engine/src/tests/mirror_placed.rs
index 396d8abee2..9b6f2ac41c 100644
--- a/crates/engine/src/tests/mirror_placed.rs
+++ b/crates/engine/src/tests/mirror_placed.rs
@@ -3,7 +3,7 @@
//! geometry and put the copy in the active component, so the copy lost the placement.
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use super::run;
use crate::*;
diff --git a/crates/engine/src/tests/rounded_loft_face.rs b/crates/engine/src/tests/rounded_loft_face.rs
index 8384540d89..6e2f688e16 100644
--- a/crates/engine/src/tests/rounded_loft_face.rs
+++ b/crates/engine/src/tests/rounded_loft_face.rs
@@ -2,7 +2,7 @@
//! end a few 1e-5 mm short of the face's other edges, and where a round dies away at a corner the
//! mesh keeps an edge from a point to itself; the face's outline still closes into one profile.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use super::*;
diff --git a/crates/engine/src/tests/step_import_options.rs b/crates/engine/src/tests/step_import_options.rs
index 397d17bbcf..52fbbc05fb 100644
--- a/crates/engine/src/tests/step_import_options.rs
+++ b/crates/engine/src/tests/step_import_options.rs
@@ -2,7 +2,7 @@
//! on `file.insert_step` and `doc.open`.
use serde_json::{Value, json};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_kernel::{ExportBody, ExportProduct, StepHeader, box_solid, step_export_products};
use super::run;
diff --git a/crates/engine/src/thread_tests.rs b/crates/engine/src/thread_tests.rs
index b1a8cc0729..7ffd7eaaf8 100644
--- a/crates/engine/src/thread_tests.rs
+++ b/crates/engine/src/thread_tests.rs
@@ -1,10 +1,11 @@
//! Modelled threads: the ISO metric profile cut along a helix, inside and outside,
//! including fine pitches on large shafts and the sample flange.
+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;
@@ -154,8 +155,8 @@ fn tapped_thread_depth_rejects_invalid_or_excessive_values_atomically() {
/// threads now use more stations. The same cut polygons must rebuild as a closed solid.
#[test]
fn faceted_flange_thread_preserves_thin_crest_boundaries() {
- use crate::geom::{Plane, Vec2, Vec3};
use crate::kernel;
+ use solidcore_record::{Plane, Vec2, Vec3};
let mut s = Session::default();
let sample = crate::sample::samples().into_iter().find(|s| s.name == "Bolted Flange").unwrap();
@@ -1031,7 +1032,7 @@ fn a_runout_fades_the_groove_out_before_the_shoulder() {
/// independently (`seam_diagnostics`, projecting stations onto both surfaces).
#[test]
fn a_modelled_threads_flank_joins_are_not_drawn() {
- use solidcraft_geom::brep::Surface;
+ use solidcore_record::brep::Surface;
let mut s = Session::default();
run(&mut s, "solid.cylinder", json!({"radius": 5.0, "height": 12, "body_name": "Shaft"}));
run(&mut s, "solid.thread", json!({"face": [5.0, 0, 6.0], "designation": "M10x1.5", "modeled": true}));
diff --git a/crates/engine/src/view.rs b/crates/engine/src/view.rs
index 94d3d2b520..5712ae1a39 100644
--- a/crates/engine/src/view.rs
+++ b/crates/engine/src/view.rs
@@ -2,9 +2,11 @@
//! grid and the origin. Used by the headless snapshot renderer; the GPU viewport draws the same
//! content.
+use solidcraft_geom::prelude::*;
use std::sync::Arc;
-use solidcraft_geom::{Aabb3, Plane, Vec3};
+use solidcore_record::{Plane, Vec3};
+use solidcraft_geom::Aabb3;
use solidcraft_render::{AnalysisColors, Camera, Rgb, Scene, SceneAnalysis, SceneLine, SceneMesh};
use solidcraft_sketch::Sketch;
@@ -144,7 +146,7 @@ fn bounds_by(s: &Session, of: impl Fn(&solidcraft_doc::ModelBody) -> Aabb3) -> R
for ss in st.sketches.iter().filter(|x| sketch_shown(s, x.feature)) {
// All four corners: on a tilted plane two opposite ones don't span the rectangle.
if let Some((lo, hi)) = ss.sketch.bounds() {
- for p in [lo, hi, solidcraft_geom::Vec2::new(lo.x, hi.y), solidcraft_geom::Vec2::new(hi.x, lo.y)] {
+ for p in [lo, hi, solidcore_record::Vec2::new(lo.x, hi.y), solidcore_record::Vec2::new(hi.x, lo.y)] {
b.add(ss.plane.to_world(p));
}
}
diff --git a/crates/engine/src/view_bounds_tests.rs b/crates/engine/src/view_bounds_tests.rs
index f8eced1b78..4d69169f0d 100644
--- a/crates/engine/src/view_bounds_tests.rs
+++ b/crates/engine/src/view_bounds_tests.rs
@@ -1,7 +1,9 @@
// Home and Fit frame what is visible now: bodies where they are placed (occurrence moves,
// joints, motion), sketches only while they are drawn, nothing hidden or consumed.
use serde_json::{Value, json};
-use solidcraft_geom::{Aabb3, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Aabb3;
+use solidcraft_geom::prelude::*;
use crate::Session;
diff --git a/crates/engine/src/view_display_tests.rs b/crates/engine/src/view_display_tests.rs
index 7a507c50a1..229dc905ec 100644
--- a/crates/engine/src/view_display_tests.rs
+++ b/crates/engine/src/view_display_tests.rs
@@ -1,6 +1,6 @@
use super::*;
use serde_json::json;
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use solidcraft_sketch::{LinkGeom, LinkKind, LinkSource};
fn line(sk: &mut Sketch, y: f64) -> usize {
diff --git a/crates/engine/src/view_palette_tests.rs b/crates/engine/src/view_palette_tests.rs
index 9976073b58..970faec536 100644
--- a/crates/engine/src/view_palette_tests.rs
+++ b/crates/engine/src/view_palette_tests.rs
@@ -3,7 +3,7 @@
use super::*;
use serde_json::json;
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use solidcraft_sketch::{LinkGeom, LinkKind, LinkSource};
/// #4214: the grid's fade is at full strength in the middle of the view, and gone before the
diff --git a/crates/engine/src/world_placement_cache_tests.rs b/crates/engine/src/world_placement_cache_tests.rs
index d720351c42..03124d8bec 100644
--- a/crates/engine/src/world_placement_cache_tests.rs
+++ b/crates/engine/src/world_placement_cache_tests.rs
@@ -1,6 +1,8 @@
//! Placement-cache changes must retain physical picking, pending positions and named joints.
-use crate::{Session, geom::Vec3};
+use crate::Session;
use serde_json::{Value, json};
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use std::sync::Arc;
fn run(session: &mut Session, command: &str, params: Value) -> Value {
diff --git a/crates/engine/tests/sketch_analysis.rs b/crates/engine/tests/sketch_analysis.rs
index 337062c64c..694e75e422 100644
--- a/crates/engine/tests/sketch_analysis.rs
+++ b/crates/engine/tests/sketch_analysis.rs
@@ -1,10 +1,11 @@
//! Command-level diagnostic work, including the report ultimately published to the model.
+use solidcraft_geom::prelude::*;
use std::sync::Arc;
use serde_json::json;
+use solidcore_record::Vec2;
use solidcraft_engine::Session;
-use solidcraft_geom::Vec2;
use solidcraft_sketch::{Analysis, ConstraintKind, Sketch, profiling::capture};
fn session(horizontal: bool) -> (Session, u64, String) {
diff --git a/crates/engine/tests/sketch_drag_target.rs b/crates/engine/tests/sketch_drag_target.rs
index 1d72ac72a0..dc132f635c 100644
--- a/crates/engine/tests/sketch_drag_target.rs
+++ b/crates/engine/tests/sketch_drag_target.rs
@@ -3,7 +3,8 @@
mod four_bar;
use serde_json::json;
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
#[test]
fn angular_drag_keeps_the_horizontal_construction_line() {
diff --git a/crates/engine/tests/support/four_bar.rs b/crates/engine/tests/support/four_bar.rs
index 8ec6366f28..270883dac9 100644
--- a/crates/engine/tests/support/four_bar.rs
+++ b/crates/engine/tests/support/four_bar.rs
@@ -1,7 +1,8 @@
//! Public-safe 10/40/20/42 mm linkage, matching the reported one-degree-of-freedom sketch.
use serde_json::json;
+use solidcore_record::Vec2;
use solidcraft_engine::Session;
-use solidcraft_geom::Vec2;
+use solidcraft_geom::prelude::*;
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
diff --git a/crates/geom/Cargo.toml b/crates/geom/Cargo.toml
index 538cd41db3..cd95c204b5 100644
--- a/crates/geom/Cargo.toml
+++ b/crates/geom/Cargo.toml
@@ -10,6 +10,7 @@ workspace = true
[dependencies]
serde = { workspace = true }
+solidcore-record = { workspace = true }
thiserror = { workspace = true }
[dev-dependencies]
diff --git a/crates/geom/src/aabb2.rs b/crates/geom/src/aabb2.rs
index 2cf9a8749b..8b28bea5d8 100644
--- a/crates/geom/src/aabb2.rs
+++ b/crates/geom/src/aabb2.rs
@@ -1,6 +1,7 @@
//! A box in the plane, the 2D [`crate::Aabb3`].
-use crate::Vec2;
+use crate::prelude::*;
+use solidcore_record::Vec2;
/// Axis-aligned box in the plane; [`Aabb2::EMPTY`] (low +∞, high −∞) holds nothing.
#[derive(Clone, Copy, Debug, PartialEq)]
diff --git a/crates/geom/src/arcfit.rs b/crates/geom/src/arcfit.rs
index 332cee3338..ea664fa80f 100644
--- a/crates/geom/src/arcfit.rs
+++ b/crates/geom/src/arcfit.rs
@@ -5,9 +5,10 @@
//! keeps smooth curves this way with far fewer pieces than a chord polyline of the same
//! tolerance: a biarc's error falls with the cube of its length, a chord's with the square.
+use crate::prelude::*;
use std::f64::consts::{PI, TAU};
-use crate::{Loop2, Region2, Seg2, Vec2};
+use solidcore_record::{Loop2, Region2, Seg2, Vec2};
/// Most pieces one segment is fitted with.
pub const MAX_FIT_PIECES: usize = 2048;
@@ -16,17 +17,122 @@ const MAX_DEPTH: u32 = 30;
/// Samples inside each candidate span that must lie within the tolerance.
const SAMPLES: usize = 12;
-impl Seg2 {
- /// A straight line or a circular arc (what [`Seg2::fit_arcs`] produces).
- pub fn is_line_or_arc(&self) -> bool {
- matches!(self, Seg2::Line { .. } | Seg2::Arc { .. })
+/// Distance from `p` to a line or arc segment (other segments: to their closest point).
+fn dist_to(s: &Seg2, p: Vec2) -> f64 {
+ match *s {
+ Seg2::Line { a, b } => {
+ let d = b - a;
+ let l2 = d.len2();
+ let t = if l2 > 1e-300 { ((p - a).dot(d) / l2).clamp(0.0, 1.0) } else { 0.0 };
+ (a + d * t).dist(p)
+ }
+ Seg2::Arc { center, radius, start, sweep } => {
+ let ang = (p - center).angle();
+ let delta = if sweep >= 0.0 { (ang - start).rem_euclid(TAU) } else { (start - ang).rem_euclid(TAU) };
+ if delta <= sweep.abs() { (p.dist(center) - radius).abs() } else { p.dist(s.start()).min(p.dist(s.end())) }
+ }
+ _ => s.point_at(s.closest_param(p)).dist(p),
}
+}
+/// The two arcs (or lines) from `p0` leaving along unit `d0` to `p1` arriving along unit `d1`,
+/// meeting tangentially: the tangent lines from both ends are cut at one length `d`, and the
+/// arcs join at the middle of the line between the two cut points (which is `2 d` long).
+fn biarc(p0: Vec2, d0: Vec2, p1: Vec2, d1: Vec2) -> Option<Vec<Seg2>> {
+ let v = p1 - p0;
+ let vv = v.dot(v);
+ if vv < 1e-24 {
+ return None;
+ }
+ let len = vv.sqrt();
+ let chord = v / len;
+ if d0.cross(chord).abs() < 1e-12 && d1.cross(chord).abs() < 1e-12 && d0.dot(chord) > 0.0 && d1.dot(chord) > 0.0 {
+ return Some(vec![Seg2::Line { a: p0, b: p1 }]);
+ }
+ // |v − d (d0 + d1)| = 2 d, the positive root.
+ let t = d0 + d1;
+ let vt = v.dot(t);
+ let a = 2.0 * (1.0 - d0.dot(d1));
+ let d = if a < 1e-12 {
+ if vt <= 1e-12 * len {
+ return None;
+ }
+ vv / (2.0 * vt)
+ } else {
+ (-vt + (vt * vt + a * vv).max(0.0).sqrt()) / a
+ };
+ if !(d.is_finite() && d > 0.0) {
+ return None;
+ }
+ let j = ((p0 + d0 * d) + (p1 - d1 * d)) * 0.5;
+ let mut out = Vec::with_capacity(2);
+ if j.dist(p0) > 1e-12 {
+ out.push(arc_from(p0, d0, j)?);
+ }
+ if j.dist(p1) > 1e-12 {
+ out.push(arc_from(p1, -d1, j)?.reversed());
+ }
+ (!out.is_empty()).then_some(out)
+}
+
+/// The arc leaving `p` along unit `d` that ends at `q` (a line when `q` lies straight ahead).
+fn arc_from(p: Vec2, d: Vec2, q: Vec2) -> Option<Seg2> {
+ let c = q - p;
+ let cc = c.dot(c);
+ let n = d.perp();
+ let h = n.dot(c);
+ // Sagitta of the arc over the chord: a line when the bulge is negligible.
+ if h.abs() * cc.sqrt() < 1e-12 * cc || (cc / (2.0 * h)).abs() > 1e7 {
+ return (d.dot(c) > 0.0).then_some(Seg2::Line { a: p, b: q });
+ }
+ let r = cc / (2.0 * h);
+ let center = p + n * r;
+ let start = (p - center).angle();
+ let mut sweep = (q - center).angle() - start;
+ if r > 0.0 {
+ while sweep <= 0.0 {
+ sweep += TAU;
+ }
+ } else {
+ while sweep >= 0.0 {
+ sweep -= TAU;
+ }
+ }
+ (sweep.is_finite() && sweep.abs() <= TAU).then_some(Seg2::Arc { center, radius: r.abs(), start, sweep })
+}
+
+/// `s` moved to start exactly at `p` (an arc keeps its centre; `p` is within a rounding error).
+fn with_start(s: Seg2, p: Vec2) -> Seg2 {
+ match s {
+ Seg2::Line { b, .. } => Seg2::Line { a: p, b },
+ other => other,
+ }
+}
+
+/// `s` moved to end exactly at `p`.
+fn with_end(s: Seg2, p: Vec2) -> Seg2 {
+ match s {
+ Seg2::Line { a, .. } => Seg2::Line { a, b: p },
+ other => other,
+ }
+}
+
+/// Arcs and lines fitted to a profile segment ([`Seg2`]).
+pub trait Seg2ArcFit {
+ /// A straight line or a circular arc (what [`Seg2::fit_arcs`] produces).
+ fn is_line_or_arc(&self) -> bool;
/// Lines and circular arcs that follow the segment within `tol` (mm), in order, the first
/// starting at the segment's start and the last ending at its end; consecutive pieces share
/// their end points and tangents. Lines and arcs come back unchanged. `None` when the
/// segment is not finite or would need more than [`MAX_FIT_PIECES`] pieces.
- pub fn fit_arcs(&self, tol: f64) -> Option<Vec<Seg2>> {
+ fn fit_arcs(&self, tol: f64) -> Option<Vec<Seg2>>;
+}
+
+impl Seg2ArcFit for Seg2 {
+ fn is_line_or_arc(&self) -> bool {
+ matches!(self, Seg2::Line { .. } | Seg2::Arc { .. })
+ }
+ fn fit_arcs(&self, tol: f64) -> Option<Vec<Seg2>> {
if self.is_line_or_arc() {
return Some(vec![*self]);
}
@@ -87,24 +193,33 @@ impl Seg2 {
}
Some(out)
}
+}
+/// What fitting a segment reads of a span of it.
+trait Span {
/// Unit direction of travel leaving `t` towards `t1`.
+ fn tangent_out(&self, t: f64, t1: f64) -> Option<Vec2>;
+ /// Unit direction of travel arriving at `t1` from `t0`.
+ fn tangent_in(&self, t0: f64, t1: f64) -> Option<Vec2>;
+ /// Largest distance of the span's sample points from its start (a loop's size).
+ fn span_extent(&self, t0: f64, t1: f64) -> f64;
+ /// Do `pieces` follow the span `t0..t1` within `tol` both ways?
+ fn within(&self, pieces: &[Seg2], t0: f64, t1: f64, tol: f64) -> bool;
+ /// Distance from `q` to the span `t0..t1` (closest sample, then Newton steps).
+ fn dist_on_span(&self, q: Vec2, t0: f64, t1: f64, samples: &[Vec2]) -> f64;
+}
+
+impl Span for Seg2 {
fn tangent_out(&self, t: f64, t1: f64) -> Option<Vec2> {
self.derivative(t).normalized().or_else(|| (self.point_at(t + (t1 - t) * 1e-4) - self.point_at(t)).normalized())
}
-
- /// Unit direction of travel arriving at `t1` from `t0`.
fn tangent_in(&self, t0: f64, t1: f64) -> Option<Vec2> {
self.derivative(t1).normalized().or_else(|| (self.point_at(t1) - self.point_at(t1 - (t1 - t0) * 1e-4)).normalized())
}
-
- /// Largest distance of the span's sample points from its start (a loop's size).
fn span_extent(&self, t0: f64, t1: f64) -> f64 {
let p0 = self.point_at(t0);
(1..=SAMPLES).map(|i| self.point_at(t0 + (t1 - t0) * i as f64 / (SAMPLES + 1) as f64).dist(p0)).fold(0.0, f64::max)
}
-
- /// Do `pieces` follow the span `t0..t1` within `tol` both ways?
fn within(&self, pieces: &[Seg2], t0: f64, t1: f64, tol: f64) -> bool {
if pieces.iter().any(|p| matches!(p, Seg2::Arc { sweep, .. } if sweep.abs() > PI)) {
return false;
@@ -123,8 +238,6 @@ impl Seg2 {
})
})
}
-
- /// Distance from `q` to the span `t0..t1` (closest sample, then Newton steps).
fn dist_on_span(&self, q: Vec2, t0: f64, t1: f64, samples: &[Vec2]) -> f64 {
let n = samples.len().saturating_sub(1).max(1);
let (k, mut best) = samples.iter().enumerate().map(|(i, p)| (i, p.dist(q))).fold((0, f64::INFINITY), |a, b| if b.1 < a.1 { b } else { a });
@@ -146,10 +259,17 @@ impl Seg2 {
}
}
-impl Loop2 {
+/// Arcs and lines fitted to a profile loop ([`Loop2`]).
+pub trait Loop2ArcFit {
/// The loop with every free-form segment fitted by lines and arcs (see
/// [`Seg2::fit_arcs`]). `None` when a segment cannot be fitted.
- pub fn fit_arcs(&self, tol: f64) -> Option<Loop2> {
+ fn fit_arcs(&self, tol: f64) -> Option<Loop2>;
+ /// Only lines and arcs?
+ fn is_line_arc(&self) -> bool;
+}
+
+impl Loop2ArcFit for Loop2 {
+ fn fit_arcs(&self, tol: f64) -> Option<Loop2> {
let mut segs = Vec::with_capacity(self.segs.len());
for s in &self.segs {
segs.extend(s.fit_arcs(tol)?);
@@ -159,117 +279,20 @@ impl Loop2 {
}
Some(Loop2 { segs })
}
-
- /// Only lines and arcs?
- pub fn is_line_arc(&self) -> bool {
+ fn is_line_arc(&self) -> bool {
self.segs.iter().all(Seg2::is_line_or_arc)
}
}
-impl Region2 {
+/// Whether a profile region ([`Region2`]) is lines and arcs only.
+pub trait Region2ArcFit {
/// Only lines and arcs?
- pub fn is_line_arc(&self) -> bool {
- self.outer.is_line_arc() && self.holes.iter().all(Loop2::is_line_arc)
- }
-}
-
-/// Distance from `p` to a line or arc segment (other segments: to their closest point).
-fn dist_to(s: &Seg2, p: Vec2) -> f64 {
- match *s {
- Seg2::Line { a, b } => {
- let d = b - a;
- let l2 = d.len2();
- let t = if l2 > 1e-300 { ((p - a).dot(d) / l2).clamp(0.0, 1.0) } else { 0.0 };
- (a + d * t).dist(p)
- }
- Seg2::Arc { center, radius, start, sweep } => {
- let ang = (p - center).angle();
- let delta = if sweep >= 0.0 { (ang - start).rem_euclid(TAU) } else { (start - ang).rem_euclid(TAU) };
- if delta <= sweep.abs() { (p.dist(center) - radius).abs() } else { p.dist(s.start()).min(p.dist(s.end())) }
- }
- _ => s.point_at(s.closest_param(p)).dist(p),
- }
-}
-
-/// The two arcs (or lines) from `p0` leaving along unit `d0` to `p1` arriving along unit `d1`,
-/// meeting tangentially: the tangent lines from both ends are cut at one length `d`, and the
-/// arcs join at the middle of the line between the two cut points (which is `2 d` long).
-fn biarc(p0: Vec2, d0: Vec2, p1: Vec2, d1: Vec2) -> Option<Vec<Seg2>> {
- let v = p1 - p0;
- let vv = v.dot(v);
- if vv < 1e-24 {
- return None;
- }
- let len = vv.sqrt();
- let chord = v / len;
- if d0.cross(chord).abs() < 1e-12 && d1.cross(chord).abs() < 1e-12 && d0.dot(chord) > 0.0 && d1.dot(chord) > 0.0 {
- return Some(vec![Seg2::Line { a: p0, b: p1 }]);
- }
- // |v − d (d0 + d1)| = 2 d, the positive root.
- let t = d0 + d1;
- let vt = v.dot(t);
- let a = 2.0 * (1.0 - d0.dot(d1));
- let d = if a < 1e-12 {
- if vt <= 1e-12 * len {
- return None;
- }
- vv / (2.0 * vt)
- } else {
- (-vt + (vt * vt + a * vv).max(0.0).sqrt()) / a
- };
- if !(d.is_finite() && d > 0.0) {
- return None;
- }
- let j = ((p0 + d0 * d) + (p1 - d1 * d)) * 0.5;
- let mut out = Vec::with_capacity(2);
- if j.dist(p0) > 1e-12 {
- out.push(arc_from(p0, d0, j)?);
- }
- if j.dist(p1) > 1e-12 {
- out.push(arc_from(p1, -d1, j)?.reversed());
- }
- (!out.is_empty()).then_some(out)
-}
-
-/// The arc leaving `p` along unit `d` that ends at `q` (a line when `q` lies straight ahead).
-fn arc_from(p: Vec2, d: Vec2, q: Vec2) -> Option<Seg2> {
- let c = q - p;
- let cc = c.dot(c);
- let n = d.perp();
- let h = n.dot(c);
- // Sagitta of the arc over the chord: a line when the bulge is negligible.
- if h.abs() * cc.sqrt() < 1e-12 * cc || (cc / (2.0 * h)).abs() > 1e7 {
- return (d.dot(c) > 0.0).then_some(Seg2::Line { a: p, b: q });
- }
- let r = cc / (2.0 * h);
- let center = p + n * r;
- let start = (p - center).angle();
- let mut sweep = (q - center).angle() - start;
- if r > 0.0 {
- while sweep <= 0.0 {
- sweep += TAU;
- }
- } else {
- while sweep >= 0.0 {
- sweep -= TAU;
- }
- }
- (sweep.is_finite() && sweep.abs() <= TAU).then_some(Seg2::Arc { center, radius: r.abs(), start, sweep })
+ fn is_line_arc(&self) -> bool;
}
-/// `s` moved to start exactly at `p` (an arc keeps its centre; `p` is within a rounding error).
-fn with_start(s: Seg2, p: Vec2) -> Seg2 {
- match s {
- Seg2::Line { b, .. } => Seg2::Line { a: p, b },
- other => other,
- }
-}
-
-/// `s` moved to end exactly at `p`.
-fn with_end(s: Seg2, p: Vec2) -> Seg2 {
- match s {
- Seg2::Line { a, .. } => Seg2::Line { a, b: p },
- other => other,
+impl Region2ArcFit for Region2 {
+ fn is_line_arc(&self) -> bool {
+ self.outer.is_line_arc() && self.holes.iter().all(Loop2::is_line_arc)
}
}
diff --git a/crates/geom/src/ball.rs b/crates/geom/src/ball.rs
index 46db2293b9..ac8848a9af 100644
--- a/crates/geom/src/ball.rs
+++ b/crates/geom/src/ball.rs
@@ -1,7 +1,8 @@
//! The smallest ball holding a set of points (Welzl's algorithm): a measure of a point set's size
//! that does not move with the points, whatever rigid motion carries them.
-use crate::Vec3;
+use crate::prelude::*;
+use solidcore_record::Vec3;
/// A ball: every point within `radius` of `center`.
#[derive(Clone, Copy, Debug, PartialEq)]
diff --git a/crates/geom/src/blend.rs b/crates/geom/src/blend.rs
index 6466ff9875..15636d3fb6 100644
--- a/crates/geom/src/blend.rs
+++ b/crates/geom/src/blend.rs
@@ -2,7 +2,8 @@
//! interpolation of each reference curve's position and derivatives at the joints. This is the
//! geometry `sketch.blend_curve` builds; it knows nothing about sketches or the document.
-use crate::{MAX_DERIVATIVE_ORDER, Vec2, profile::binom};
+use crate::{MAX_DERIVATIVE_ORDER, profile::binom};
+use solidcore_record::Vec2;
/// Control points of the Bézier of degree `2k + 1`, `k = d0.len()`, that starts at `p0` with
/// derivatives `d0` and ends at `p1` with derivatives `d1`, all with respect to its own parameter
diff --git a/crates/geom/src/brep.rs b/crates/geom/src/brep.rs
index d8b48dc503..225fbe0cac 100644
--- a/crates/geom/src/brep.rs
+++ b/crates/geom/src/brep.rs
@@ -1,705 +1,23 @@
-//! SolidCraft-owned portable B-rep data, independent of a modelling backend.
-//! Millimetres, radians, right-handed Z-up. See docs/native-brep.md for semantics.
-//! Validation checks structure and resource budgets; `check_geometry` spot-checks that the
-//! geometry agrees with the topology. Neither certifies geometric validity or trust.
-//!
-//! The records follow SMLib's flat form (`SmBrepData`): one record per logical use, the mated
-//! halves a kernel keeps at run time left for it to rebuild. Names are STEP's B-rep names; each
-//! type says its SMLib counterpart and STEP entity. Curves and surfaces are unbounded: an edge's
-//! bounds are its `interval`, a face's its `domain` and loops.
-use serde::{Deserialize, Serialize};
+//! The kernel's side of the portable B-rep record ([`solidcore_record::brep`]): what computes
+//! from its coordinates. Evaluation ([`eval`]), exact NURBS forms of analytic geometry
+//! ([`form`]), pcurves ([`pcurve`]), the record's geometric checks ([`check`]: frames, planes,
+//! placements; [`geometry`]: that the geometry agrees with the topology), what its labels mean
+//! in their own parameters ([`label`]), rigid motions ([`placement`]) and splitting edges
+//! ([`split_edges`]). The record itself is data: see SolidCraft's docs/native-brep.md.
-mod curve2;
-pub mod envelope;
+// `eval` and `form` name the record's geometry through their parent (`super::Curve`).
+use solidcore_record::brep::{Curve, Curve2, Frame, Surface};
+
+pub mod check;
pub mod eval;
pub mod form;
pub mod geometry;
-pub mod history;
+pub mod label;
pub mod normal_section;
-pub mod part;
pub mod pcurve;
pub mod placement;
mod split;
-mod topology;
-pub use curve2::Curve2;
-
-pub const VERSION: u32 = 4;
-/// The most items (records, points, knots, uses) [`Brep::validate`] takes in a record that comes
-/// from outside the kernel: a file, the control channel, pasted data. A record the kernel built
-/// ([`Brep::validate_built`]) has no such cap.
-pub const MAX_ITEMS: usize = 4_000_000;
-pub const MAX_SHELLS: usize = 1024;
-const MAX_DEPTH: usize = 16;
-const TAU: f64 = std::f64::consts::TAU;
-
-/// A body (SMLib `SmBrep`, STEP `MANIFOLD_SOLID_BREP`/`BREP_WITH_VOIDS`/`SHELL_BASED_SURFACE_MODEL`).
-/// Every list is in canonical order (docs/native-brep.md, "Canonical order"): a face's index
-/// here is its face index everywhere, and so for edges and vertices.
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct Brep {
- pub version: u32,
- /// Intersection tolerance, mm (SMLib's per-brep `XSectTol3d`).
- pub tolerance: f64,
- /// `regions[0]` is the infinite region, then the bounded regions.
- pub regions: Vec<Region>,
- pub shells: Vec<Shell>,
- pub faces: Vec<Face>,
- pub edges: Vec<Edge>,
- pub vertices: Vec<Vertex>,
-}
-
-/// A connected volume of space (SMLib `SmRegionData`). The infinite region has no outer shell
-/// and is never a void. A bounded region's `shells[0]` is its outer shell, a closed face shell;
-/// the rest are inner shells. A closed shell separates two regions and is listed by both: as
-/// the outer shell of the one it encloses and as an inner shell of the one around it. An open
-/// shell, a wire shell or a vertex shell lies in one region and is listed by that one only.
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct Region {
- pub shells: Vec<u32>,
- /// A bounded region that is empty space (a void), not material. False for the infinite region.
- pub void: bool,
-}
-
-/// A connected boundary component (SMLib `SmShellData`; STEP `CLOSED_SHELL`/`OPEN_SHELL`,
-/// `WIRE_SHELL`, `VERTEX_SHELL`). One record stands for both runtime sides of a shell.
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
-pub enum Shell {
- /// Connected faces, with wire edges embedded in them (`wires`, edges no face uses).
- Faces { faces: Vec<OrientedFace>, wires: Vec<u32> },
- /// A connected graph of wire edges and no faces.
- Wire { edges: Vec<u32> },
- /// One isolated point.
- Vertex { vertex: u32 },
-}
-
-/// A face as one shell uses it (SMLib `SmFaceuseData`, STEP `ORIENTED_FACE`).
-#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct OrientedFace {
- pub face: u32,
- /// The face's normal in this shell is the natural normal (∂S/∂u × ∂S/∂v) of the surface its
- /// (u, v) are on, [`Face::parameters`]: its NURBS form when it has one. In a closed shell the
- /// normals point out of the material.
- pub forward: bool,
-}
-
-/// A bounded piece of a surface (SMLib `SmFaceData`, STEP `ADVANCED_FACE`).
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct Face {
- /// What the face is: its surface as the producer names it (a cylinder, a NURBS…).
- pub surface: Surface,
- /// The NURBS form the face is parameterised on, when it differs from `surface`'s own
- /// parameters: a cylinder, cone, sphere, torus or placed revolution as SMLib holds it (every
- /// SMLib analytic surface is a B-spline surface, its trims in that NURBS's parameters), and a
- /// ball patch's own net. When given, `domain` and every pcurve are in this surface's (u, v),
- /// and `surface` only says what it is; it is a `Spline` or `RationalSpline` and `surface` is a
- /// cylinder, cone, sphere, ball patch, torus or placed revolution
- /// (docs/native-brep.md, "Surfaces").
- #[serde(default, skip_serializing_if = "Option::is_none")]
- pub nurbs: Option<Surface>,
- /// The modelled rectangle in surface parameters, `[[u0, u1], [v0, v1]]`, inside the
- /// surface's natural domain and around every loop.
- pub domain: [[f64; 2]; 2],
- /// One outer loop and any inner ones, in the producer's order (truck lists some holes
- /// first; SMLib's import puts the outer loop first, as SMLib requires). Loops are stored
- /// relative to the surface's natural normal, whatever side a shell uses: seen from that
- /// normal, the outer loop runs counter-clockwise and inner loops clockwise, which is what
- /// tells them apart. The first loop is an edge loop.
- pub loops: Vec<Loop>,
-}
-
-/// A face boundary (SMLib `SmLoopData`; STEP `FACE_BOUND` of an `EDGE_LOOP` or `VERTEX_LOOP`).
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
-pub enum Loop {
- /// A closed chain of oriented edges, in traversal order (STEP `EDGE_LOOP`).
- Edges { edges: Vec<OrientedEdge> },
- /// A one-vertex loop: a pole or a collapsed boundary (STEP `VERTEX_LOOP`). Inner only.
- Vertex { vertex: u32 },
-}
-
-/// One occurrence of an edge in a face's loop (SMLib `SmEUData`, one mated pair of runtime
-/// edgeuses; STEP `ORIENTED_EDGE` with its `PCURVE`).
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct OrientedEdge {
- pub edge: u32,
- /// The loop runs along the edge from interval min (start vertex) to max (end vertex).
- pub forward: bool,
- /// The edge in this face's (u, v), on the edge's own interval and running min → max
- /// whatever `forward` says. A seam edge has two uses on one face, each with its pcurve.
- pub pcurve: Curve2,
-}
-
-/// A bounded piece of a curve (SMLib `SmEdgeData`, STEP `EDGE_CURVE`).
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct Edge {
- /// What the edge is: its curve as the producer names it (a line, a circle…).
- pub curve: Curve,
- /// The NURBS form the edge is parameterised on, when it differs from `curve`'s own
- /// parameter: a circle or ellipse as SMLib holds it (every SMLib conic is a B-spline curve,
- /// the trims on it in that NURBS's parameter). When given, `interval` and the pcurves' parameter
- /// are this curve's, and `curve` only says what it is; it is a `Spline` or `RationalSpline` and
- /// `curve` is a line, circle or ellipse (docs/native-brep.md, "Curves").
- #[serde(default, skip_serializing_if = "Option::is_none")]
- pub nurbs: Option<Curve>,
- /// The modelled interval in the edge's parameter ([`Edge::parameters`]), min < max.
- pub interval: [f64; 2],
- /// `[start, end]`, at interval min and max; equal for a closed edge.
- pub vertices: [u32; 2],
- /// mm.
- pub tolerance: f64,
- /// Every oriented edge on this edge, each once, the primary use (the first in canonical
- /// order) first and the rest in radial order: right-hand rule about the edge's direction.
- /// Empty for a wire edge.
- pub uses: Vec<EdgeUseRef>,
-}
-
-/// Where one use of an edge sits (SMLib `SmEUData`'s radial fields): `faces[face]`,
-/// `loops[loop]`, `edges[position]`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct EdgeUseRef {
- pub face: u32,
- pub r#loop: u32,
- pub position: u32,
- /// Going round the edge, the radial cycle enters this use at the side on the surface's
- /// natural normal (SMLib's selected member of the mated pair). It follows from the loop
- /// convention: always `!forward` of the use it names.
- pub upper: bool,
-}
-
-/// A point (SMLib `SmVertexData`, STEP `VERTEX_POINT`).
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct Vertex {
- pub point: [f64; 3],
- /// mm.
- pub tolerance: f64,
-}
-
-/// Right-handed orthonormal frame; z = x_axis cross y_axis (STEP `AXIS2_PLACEMENT_3D`).
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct Frame {
- pub origin: [f64; 3],
- pub x_axis: [f64; 3],
- pub y_axis: [f64; 3],
-}
-
-/// Unbounded 3D curves, each with its parameter `t` (docs/native-brep.md, "Curves").
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
-pub enum Curve {
- /// The line through both points: `start + t * (end - start)`, t = 0 at `start` and 1 at
- /// `end` (STEP `LINE`; truck's `Line`).
- Line { start: [f64; 3], end: [f64; 3] },
- /// `origin + radius * (cos t * x + sin t * y)`, t the angle from x (STEP `CIRCLE`).
- Circle { frame: Frame, radius: f64 },
- /// `origin + radii[0] cos t * x + radii[1] sin t * y` (STEP `ELLIPSE`).
- Ellipse { frame: Frame, radii: [f64; 2] },
- /// Straight segments; segment i spans t in [i, i + 1] (STEP `POLYLINE`).
- Polyline { points: Vec<[f64; 3]> },
- /// A B-spline on its knots (STEP `B_SPLINE_CURVE_WITH_KNOTS`).
- Spline { knots: Vec<f64>, points: Vec<[f64; 3]> },
- /// A NURBS curve: homogeneous `[x*w, y*w, z*w, w]` coefficients (STEP `RATIONAL_B_SPLINE_CURVE`).
- RationalSpline { knots: Vec<f64>, homogeneous: Vec<[f64; 4]> },
- /// The intersection of two surfaces, traced from `leader` (a polyline or spline near it)
- /// to within `tolerance`: the procedural curve itself, exactly as its producer holds it
- /// (STEP `INTERSECTION_CURVE`). t is the leader's parameter.
- SurfaceIntersection { surfaces: [Box<Surface>; 2], leader: Box<Curve>, tolerance: f64 },
-}
-
-/// Unbounded surfaces, each with its (u, v) (docs/native-brep.md, "Surfaces"). Natural
-/// normals are ∂S/∂u × ∂S/∂v.
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
-pub enum Surface {
- /// `origin + u * u_axis + v * v_axis` (STEP `PLANE`).
- Plane { origin: [f64; 3], u_axis: [f64; 3], v_axis: [f64; 3] },
- /// `origin + u * (u_point - origin) + v * (v_point - origin)`: the plane through three points,
- /// as its producer holds them (axes worked out from them would round; truck's `Plane`).
- PlaneThrough { origin: [f64; 3], u_point: [f64; 3], v_point: [f64; 3] },
- /// `origin + v z + radius (cos u x + sin u y)`: u the angle, v the height (STEP
- /// `CYLINDRICAL_SURFACE`).
- Cylinder { frame: Frame, radius: f64 },
- /// `origin + v z + r(v) (cos u x + sin u y)`, `r(v) = radius_at_origin + v tan(half_angle)`,
- /// on the side of the apex where r(v) ≥ 0: above it for a positive half angle, below it for
- /// a negative one (a cone narrowing along z, as SMLib makes them) (STEP `CONICAL_SURFACE`).
- Cone { frame: Frame, radius_at_origin: f64, half_angle: f64 },
- /// `origin + radius (cos v (cos u x + sin u y) + sin v z)`: u the longitude, v the latitude
- /// in [-π/2, π/2] (STEP `SPHERICAL_SURFACE`).
- Sphere { frame: Frame, radius: f64 },
- /// `origin + (R + r cos w)(cos u x + sin u y) + r sin w z`, `w = v + tube_start`: u the
- /// longitude, v the meridian angle measured from `tube_start` (radians; 0, the outer equator,
- /// in STEP `TOROIDAL_SURFACE` and older records). The tube start is the tube's own reference,
- /// as the frame's x axis is the longitude's: a face's form starts its tube on a quarter line
- /// from there (`form`).
- Torus {
- frame: Frame,
- major_radius: f64,
- minor_radius: f64,
- #[serde(default, skip_serializing_if = "is_zero")]
- tube_start: f64,
- },
- /// A rational patch on the sphere of `center` and `radius`: the corner of three equal rounds as
- /// SMLib holds it (`SmBallPatch`). It has no (u, v) of its own: the face's `nurbs` is the patch,
- /// and this says it lies on that sphere, whose offsets are exact and collapse at its centre.
- BallPatch { center: [f64; 3], radius: f64 },
- /// A tensor-product B-spline: `points[i][j]`, i along u (STEP `B_SPLINE_SURFACE_WITH_KNOTS`).
- Spline { u_knots: Vec<f64>, v_knots: Vec<f64>, points: Vec<Vec<[f64; 3]>> },
- /// A NURBS surface: homogeneous `[x*w, y*w, z*w, w]` coefficients.
- RationalSpline { u_knots: Vec<f64>, v_knots: Vec<f64>, homogeneous: Vec<Vec<[f64; 4]>> },
- /// `profile` revolved about `origin` and unit `axis` (right-hand rule), then mapped by the
- /// column-major affine `matrix`: the revolution exactly as its producer holds it, nothing
- /// baked into the profile (truck's `RevolutedCurve` under a `Processor`). When `forward`,
- /// u is the profile's parameter and v the angle in [0, 2π); otherwise u and v swap (u the
- /// angle, v the profile's), which reverses the natural normal.
- PlacedRevolution { profile: Box<Curve>, origin: [f64; 3], axis: [f64; 3], matrix: [[f64; 4]; 4], forward: bool },
-}
-
-#[derive(Clone, Debug, thiserror::Error)]
-#[error("portable B-rep: {0}")]
-pub struct Invalid(pub &'static str);
-
-type Result<T> = std::result::Result<T, Invalid>;
-
-fn require(condition: bool, message: &'static str) -> Result<()> {
- if condition { Ok(()) } else { Err(Invalid(message)) }
-}
-
-/// The items counted so far and the most allowed.
-struct Budget {
- used: usize,
- limit: usize,
-}
-impl Budget {
- /// The budget of a record from outside the kernel.
- fn input() -> Budget {
- Budget { used: 0, limit: MAX_ITEMS }
- }
- fn add(&mut self, n: usize) -> Result<()> {
- self.used = self.used.checked_add(n).ok_or(Invalid("item budget"))?;
- require(self.used <= self.limit, "item budget")
- }
-}
-fn numbers(values: impl IntoIterator<Item = f64>) -> Result<()> {
- require(values.into_iter().all(|v| v.is_finite() && v.abs() <= 1e12), "non-finite or excessive coordinate")
-}
-fn points<const N: usize>(values: &[[f64; N]], budget: &mut Budget) -> Result<()> {
- budget.add(values.len())?;
- numbers(values.iter().flatten().copied())
-}
-fn knots(values: &[f64], count: usize, budget: &mut Budget) -> Result<()> {
- budget.add(values.len())?;
- numbers(values.iter().copied())?;
- let degree = values.len().checked_sub(count.saturating_add(1)).ok_or(Invalid("spline degree"))?;
- require((2..=4096).contains(&count) && (1..=crate::bspline::MAX_SPLINE_DEGREE).contains(&degree) && degree < count, "spline degree or size")?;
- require(values.windows(2).all(|w| w.first() <= w.get(1)), "unordered knots")?;
- require(values.get(degree) < values.get(count), "empty spline domain")?;
- // No knot may have multiplicity greater than degree + 1.
- let mut run = 1;
- for pair in values.windows(2) {
- run = if pair.first() == pair.get(1) { run + 1 } else { 1 };
- require(run <= degree + 1, "knot multiplicity")?;
- }
- Ok(())
-}
-fn weights(values: &[[f64; 4]]) -> Result<()> {
- require(values.iter().all(|p| p.get(3).is_some_and(|w| *w >= 1e-12)), "non-positive rational weight")
-}
-fn grid<const N: usize>(u: &[f64], v: &[f64], rows: &[Vec<[f64; N]>], budget: &mut Budget) -> Result<()> {
- let columns = rows.first().map_or(0, Vec::len);
- knots(u, rows.len(), budget)?;
- knots(v, columns, budget)?;
- for row in rows {
- require(row.len() == columns, "ragged surface")?;
- points(row, budget)?;
- }
- Ok(())
-}
-fn vector(p: [f64; 3]) -> crate::Vec3 {
- crate::Vec3::new(p[0], p[1], p[2])
-}
-fn frame(f: &Frame, budget: &mut Budget) -> Result<()> {
- points(&[f.origin, f.x_axis, f.y_axis], budget)?;
- let (x, y) = (vector(f.x_axis), vector(f.y_axis));
- require((x.len() - 1.).abs() <= 1e-8 && (y.len() - 1.).abs() <= 1e-8 && x.dot(y).abs() <= 1e-8, "nonorthonormal frame")
-}
-/// A field left out of a record where it is zero (its default).
-fn is_zero(x: &f64) -> bool {
- *x == 0.0
-}
-fn radius(r: f64) -> Result<()> {
- require(r.is_finite() && (1e-12..=1e12).contains(&r), "radius")
-}
-/// A tolerance in mm.
-fn tolerance(t: f64) -> Result<()> {
- require(t.is_finite() && t > 0. && t <= 1e3, "tolerance")
-}
-
-/// A parameter's natural range: periodic with period 2π, or between two bounds (infinite for
-/// an unbounded direction).
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum Natural {
- Periodic,
- Range(f64, f64),
-}
-const UNBOUNDED: Natural = Natural::Range(f64::NEG_INFINITY, f64::INFINITY);
-
-/// The active interval of a spline's knots (already validated).
-fn knot_domain(k: &[f64], count: usize) -> Natural {
- let degree = k.len().saturating_sub(count + 1);
- match (k.get(degree), k.get(count)) {
- (Some(a), Some(b)) => Natural::Range(*a, *b),
- _ => Natural::Range(0., 0.),
- }
-}
-fn curve_natural(c: &Curve) -> Natural {
- match c {
- Curve::Line { .. } => UNBOUNDED,
- Curve::Circle { .. } | Curve::Ellipse { .. } => Natural::Periodic,
- Curve::Polyline { points } => Natural::Range(0., points.len().saturating_sub(1) as f64),
- Curve::Spline { knots, points } => knot_domain(knots, points.len()),
- Curve::RationalSpline { knots, homogeneous } => knot_domain(knots, homogeneous.len()),
- Curve::SurfaceIntersection { leader, .. } => curve_natural(leader),
- }
-}
-fn surface_natural(s: &Surface) -> [Natural; 2] {
- use std::f64::consts::FRAC_PI_2;
- match s {
- Surface::Plane { .. } | Surface::PlaneThrough { .. } => [UNBOUNDED; 2],
- Surface::Cylinder { .. } => [Natural::Periodic, UNBOUNDED],
- Surface::Cone { radius_at_origin, half_angle, .. } => {
- let apex = -radius_at_origin / half_angle.tan();
- let v = if *half_angle > 0. { Natural::Range(apex, f64::INFINITY) } else { Natural::Range(f64::NEG_INFINITY, apex) };
- [Natural::Periodic, v]
- }
- Surface::Sphere { .. } => [Natural::Periodic, Natural::Range(-FRAC_PI_2, FRAC_PI_2)],
- Surface::Torus { .. } => [Natural::Periodic; 2],
- // A label: the face's (u, v) are its NURBS form's.
- Surface::BallPatch { .. } => [UNBOUNDED; 2],
- Surface::Spline { u_knots, v_knots, points } => {
- [knot_domain(u_knots, points.len()), knot_domain(v_knots, points.first().map_or(0, Vec::len))]
- }
- Surface::RationalSpline { u_knots, v_knots, homogeneous } => {
- [knot_domain(u_knots, homogeneous.len()), knot_domain(v_knots, homogeneous.first().map_or(0, Vec::len))]
- }
- Surface::PlacedRevolution { profile, forward: true, .. } => [curve_natural(profile), Natural::Periodic],
- Surface::PlacedRevolution { profile, forward: false, .. } => [Natural::Periodic, curve_natural(profile)],
- }
-}
-impl Curve {
- /// The range of `t`. Call on a validated record.
- pub fn natural(&self) -> Natural {
- curve_natural(self)
- }
-}
-impl Surface {
- /// The ranges of u and v. Call on a validated record.
- pub fn natural(&self) -> [Natural; 2] {
- surface_natural(self)
- }
-}
-
-/// `[min, max]`: finite, min < max, inside `natural` (at most one turn long where periodic).
-fn interval(r: &[f64; 2], natural: Natural) -> Result<()> {
- numbers(*r)?;
- require(r[0] < r[1], "empty parameter interval")?;
- match natural {
- Natural::Periodic => {
- let slack = 1e-12 * (1. + r[0].abs().max(r[1].abs()));
- require(r[1] - r[0] <= TAU + slack, "parameter interval exceeds one turn")
- }
- Natural::Range(a, b) => require(a <= r[0] && r[1] <= b, "parameter interval outside the natural domain"),
- }
-}
-
-fn curve(c: &Curve, depth: usize, budget: &mut Budget) -> Result<()> {
- require(depth <= MAX_DEPTH, "geometry depth")?;
- budget.add(1)?;
- match c {
- Curve::Line { start, end } => {
- points(&[*start, *end], budget)?;
- require(start != end, "collapsed line")
- }
- Curve::Circle { frame: f, radius: r } => {
- frame(f, budget)?;
- radius(*r)
- }
- Curve::Ellipse { frame: f, radii } => {
- frame(f, budget)?;
- radii.iter().try_for_each(|r| radius(*r))
- }
- Curve::Polyline { points: p } => {
- require(p.len() >= 2, "empty polyline")?;
- points(p, budget)?;
- require(p.windows(2).all(|p| p.first() != p.get(1)), "collapsed polyline segment")
- }
- Curve::Spline { knots: k, points: p } => {
- knots(k, p.len(), budget)?;
- points(p, budget)
- }
- Curve::RationalSpline { knots: k, homogeneous: p } => {
- knots(k, p.len(), budget)?;
- points(p, budget)?;
- weights(p)
- }
- Curve::SurfaceIntersection { surfaces, leader, tolerance } => {
- require(tolerance.is_finite() && (0.0..=1e3).contains(tolerance), "intersection tolerance")?;
- for s in surfaces {
- surface(s, depth + 1, budget)?;
- }
- // The leader is only a starting guess for the trace: its knots are the producer's,
- // and a traced polyline may repeat a point.
- require(depth < MAX_DEPTH, "geometry depth")?;
- budget.add(1)?;
- match &**leader {
- Curve::Polyline { points: p } => {
- require(p.len() >= 2, "empty intersection leader")?;
- points(p, budget)
- }
- Curve::Spline { knots: k, points: p } => {
- knots(k, p.len(), budget)?;
- points(p, budget)
- }
- _ => Err(Invalid("intersection leader")),
- }
- }
- }
-}
-fn surface(s: &Surface, depth: usize, budget: &mut Budget) -> Result<()> {
- require(depth <= MAX_DEPTH, "geometry depth")?;
- budget.add(1)?;
- match s {
- Surface::Plane { origin, u_axis, v_axis } => {
- points(&[*origin, *u_axis, *v_axis], budget)?;
- require(vector(*u_axis).cross(vector(*v_axis)).len() > 1e-12, "degenerate plane")
- }
- Surface::PlaneThrough { origin, u_point, v_point } => {
- points(&[*origin, *u_point, *v_point], budget)?;
- let o = vector(*origin);
- require((vector(*u_point) - o).cross(vector(*v_point) - o).len() > 1e-12, "degenerate plane")
- }
- Surface::Cylinder { frame: f, radius: r } | Surface::Sphere { frame: f, radius: r } => {
- frame(f, budget)?;
- radius(*r)
- }
- Surface::Cone { frame: f, radius_at_origin, half_angle } => {
- frame(f, budget)?;
- numbers([*radius_at_origin, *half_angle])?;
- require(*radius_at_origin >= 0. && half_angle.abs() >= 1e-12 && half_angle.abs() < std::f64::consts::FRAC_PI_2, "cone dimensions")
- }
- Surface::Torus { frame: f, major_radius, minor_radius, tube_start } => {
- frame(f, budget)?;
- radius(*major_radius)?;
- radius(*minor_radius)?;
- require(tube_start.is_finite() && tube_start.abs() <= std::f64::consts::TAU, "torus tube start")?;
- require(major_radius > minor_radius, "ring torus radii")
- }
- Surface::BallPatch { center, radius: r } => {
- points(&[*center], budget)?;
- radius(*r)
- }
- Surface::Spline { u_knots, v_knots, points: p } => grid(u_knots, v_knots, p, budget),
- Surface::RationalSpline { u_knots, v_knots, homogeneous: p } => {
- grid(u_knots, v_knots, p, budget)?;
- for row in p {
- weights(row)?;
- }
- Ok(())
- }
- Surface::PlacedRevolution { profile, origin, axis, matrix, .. } => {
- points(&[*origin, *axis], budget)?;
- require((vector(*axis).len() - 1.0).abs() <= 1e-8, "revolution axis is not unit length")?;
- points(matrix, budget)?;
- let [x, y, z, _] = matrix.map(|c| vector([c[0], c[1], c[2]]));
- require(x.cross(y).dot(z).abs() > 1e-12, "singular revolution placement")?;
- curve(profile, depth + 1, budget)
- }
- }
-}
-
-impl Edge {
- /// The curve the edge's parameter is on: its NURBS form when it has one, else its curve.
- /// Everything that evaluates the edge at a parameter goes through this, with `interval`.
- pub fn parameters(&self) -> &Curve {
- self.nurbs.as_ref().unwrap_or(&self.curve)
- }
-
- /// The edge's interval on `curve` itself, for code that reads what the edge is (a circle's
- /// angles): `interval` when the edge has no NURBS form; otherwise the angles of its ends on the
- /// NURBS, unwrapped forward along the edge (a whole turn for a closed edge). A form's
- /// circle or ellipse has its frame turned so its angle grows along the NURBS (the SMLib
- /// conversion makes it so). `None` where the NURBS can't be evaluated.
- pub fn curve_interval(&self) -> Option<[f64; 2]> {
- curve_interval(&self.curve, self.nurbs.as_ref(), self.interval)
- }
-}
-
-/// [`Edge::curve_interval`] of an edge given by its parts: its `curve`, its NURBS form and its
-/// interval on that form.
-pub fn curve_interval(curve: &Curve, nurbs: Option<&Curve>, interval: [f64; 2]) -> Option<[f64; 2]> {
- use std::f64::consts::TAU;
- let Some(n) = nurbs else { return Some(interval) };
- let (frame, radii) = match curve {
- Curve::Circle { frame, radius } => (frame, [*radius, *radius]),
- Curve::Ellipse { frame, radii } => (frame, *radii),
- _ => return Some(interval),
- };
- let eval = eval::CurveEval::new(n).ok()?;
- let [t0, t1] = interval;
- let o = crate::Vec3::new(frame.origin[0], frame.origin[1], frame.origin[2]);
- let (x, y) = (crate::Vec3::from(frame.x_axis), crate::Vec3::from(frame.y_axis));
- let angle = |t: f64| eval.point(t).map(|p| ((p - o).dot(y) / radii[1]).atan2((p - o).dot(x) / radii[0]).rem_euclid(TAU));
- let (a0, a1) = (angle(t0)?, angle(t1)?);
- let sweep = (a1 - a0).rem_euclid(TAU);
- Some([a0, a0 + if sweep <= 1e-12 { TAU } else { sweep }])
-}
-
-impl Face {
- /// The surface the face's (u, v) are on: its NURBS form when it has one, else its surface.
- /// Everything that evaluates the face's domain or pcurves goes through this.
- pub fn parameters(&self) -> &Surface {
- self.nurbs.as_ref().unwrap_or(&self.surface)
- }
-
- /// Whether the face's NURBS form turns its natural normal against `surface`'s (away from
- /// the axis of a cylinder or cone, the centre of a sphere, the tube's centre circle of a
- /// torus), at the middle of `domain`. A shell's `forward` is about [`Face::parameters`], so
- /// the side `surface` is used on is `forward != form_turns()`. `Some(false)` without a form;
- /// `None` where the form does not evaluate there.
- pub fn form_turns(&self) -> Option<bool> {
- let Some(form) = &self.nurbs else { return Some(false) };
- let eval = eval::SurfaceEval::new(form).ok()?;
- let [[u0, u1], [v0, v1]] = self.domain;
- let (p, su, sv) = eval.derivs(0.5 * (u0 + u1), 0.5 * (v0 + v1))?;
- let v3 = |a: [f64; 3]| crate::Vec3::new(a[0], a[1], a[2]);
- let radial = |f: &Frame| {
- let (o, z) = (v3(f.origin), v3(f.x_axis).cross(v3(f.y_axis)));
- let d = p - o;
- (o, d - z * (d.dot(z) / z.dot(z)))
- };
- let outward = match &self.surface {
- Surface::Cylinder { frame, .. } | Surface::Cone { frame, .. } => radial(frame).1,
- Surface::Sphere { frame, .. } => p - v3(frame.origin),
- Surface::BallPatch { center, .. } => p - v3(*center),
- Surface::Torus { frame, major_radius, .. } => {
- let (o, r) = radial(frame);
- p - (o + r.normalized()? * *major_radius)
- }
- _ => return None,
- };
- let along = su.cross(sv).dot(outward);
- (along.abs() > 0.0).then_some(along < 0.0)
- }
-}
-
-impl Brep {
- /// Validate portable structure without calling a kernel or evaluating geometry: resource
- /// budgets, geometry records, parameter ranges, references, loops, regions, every edge's
- /// list of uses and the canonical order. Does not certify watertightness, that edges lie on
- /// their surfaces or that pcurves lift onto their edges ([`Brep::check_geometry`] spot-checks
- /// those).
- ///
- /// For a record from outside the kernel (a file, the control channel, pasted data): it is
- /// refused past [`MAX_ITEMS`] items, so hostile input is bounded before anything walks it.
- pub fn validate(&self) -> Result<()> {
- self.validate_within(Budget::input())
- }
-
- /// [`Brep::validate`] for a record the kernel built in memory (an operation's result, a
- /// body's own record, a part of a validated record): every check but the item budget. The
- /// record already sits in memory, its size set by inputs that were bounded where they came
- /// in, and the checks are linear in it; a cap here would only refuse a real result.
- pub fn validate_built(&self) -> Result<()> {
- self.validate_within(Budget { used: 0, limit: usize::MAX })
- }
-
- fn validate_within(&self, mut budget: Budget) -> Result<()> {
- require(self.version == VERSION, "unsupported version")?;
- tolerance(self.tolerance)?;
- require(!self.shells.is_empty() && self.shells.len() <= MAX_SHELLS, "shell count")?;
- require(!self.regions.is_empty() && self.regions.len() <= 2 * MAX_SHELLS + 1, "region count")?;
- budget.add(self.regions.len() + self.faces.len() + self.edges.len())?;
- for v in &self.vertices {
- points(&[v.point], &mut budget)?;
- tolerance(v.tolerance)?;
- }
- for e in &self.edges {
- curve(&e.curve, 0, &mut budget)?;
- if let Some(n) = &e.nurbs {
- curve(n, 0, &mut budget)?;
- require(matches!(n, Curve::Spline { .. } | Curve::RationalSpline { .. }), "NURBS form is not a NURBS")?;
- require(
- matches!(e.curve, Curve::Line { .. } | Curve::Circle { .. } | Curve::Ellipse { .. }),
- "NURBS form on a curve that is not a line, circle or ellipse",
- )?;
- }
- // A circle or ellipse is a label: its geometry is its NURBS form.
- require(
- e.nurbs.is_some() || !matches!(e.curve, Curve::Circle { .. } | Curve::Ellipse { .. }),
- "a circle or ellipse without its NURBS form",
- )?;
- interval(&e.interval, curve_natural(e.parameters()))?;
- require(e.vertices.iter().all(|&v| (v as usize) < self.vertices.len()), "edge vertices")?;
- tolerance(e.tolerance)?;
- budget.add(e.uses.len())?;
- }
- for f in &self.faces {
- surface(&f.surface, 0, &mut budget)?;
- if let Some(n) = &f.nurbs {
- surface(n, 0, &mut budget)?;
- require(matches!(n, Surface::Spline { .. } | Surface::RationalSpline { .. }), "NURBS form is not a NURBS")?;
- require(
- matches!(
- f.surface,
- Surface::Cylinder { .. }
- | Surface::Cone { .. }
- | Surface::Sphere { .. }
- | Surface::BallPatch { .. }
- | Surface::Torus { .. }
- | Surface::PlacedRevolution { .. }
- ),
- "NURBS form on a surface that is not a cylinder, cone, sphere, ball patch, torus or revolution",
- )?;
- }
- // A cylinder, cone, sphere, ball patch, torus or revolution is a label: its geometry is
- // its form.
- require(
- f.nurbs.is_some()
- || !matches!(
- f.surface,
- Surface::Cylinder { .. }
- | Surface::Cone { .. }
- | Surface::Sphere { .. }
- | Surface::BallPatch { .. }
- | Surface::Torus { .. }
- | Surface::PlacedRevolution { .. }
- ),
- "a cylinder, cone, sphere, ball patch, torus or revolution without its NURBS form",
- )?;
- let [u, v] = surface_natural(f.parameters());
- interval(&f.domain[0], u)?;
- interval(&f.domain[1], v)?;
- budget.add(f.loops.len())?;
- for l in &f.loops {
- if let Loop::Edges { edges } = l {
- budget.add(edges.len())?;
- for e in edges {
- curve2::curve2(&e.pcurve, &mut budget)?;
- }
- }
- }
- }
- topology::check(self)
- }
-}
+pub use split::split_edges;
#[cfg(test)]
mod tests;
diff --git a/crates/geom/src/brep/check.rs b/crates/geom/src/brep/check.rs
new file mode 100644
index 0000000000..46687c5923
--- /dev/null
+++ b/crates/geom/src/brep/check.rs
@@ -0,0 +1,81 @@
+//! The kernel's checks of a record's geometric records, which the record's own structural
+//! validation ([`Brep::validate`]) leaves to the kernel because they compute: every frame is
+//! orthonormal, every plane spans two directions, and every placed revolution turns about a unit
+//! axis under a non-singular placement. [`validate`] and [`validate_built`] are the record's
+//! validation and these together: what a record must pass before the kernel takes it.
+use crate::prelude::*;
+use solidcore_record::brep::{Brep, Curve, Frame, Result, Surface, require};
+
+use solidcore_record::Vec3;
+
+/// [`Brep::validate`] (a record from outside the kernel), then [`geometry`].
+pub fn validate(b: &Brep) -> Result<()> {
+ b.validate()?;
+ geometry(b)
+}
+
+/// [`Brep::validate_built`] (a record the kernel built), then [`geometry`].
+pub fn validate_built(b: &Brep) -> Result<()> {
+ b.validate_built()?;
+ geometry(b)
+}
+
+/// Every edge's and face's geometric records: their frames, planes and placements ([`curve`],
+/// [`surface`]). Call on a record its structural validation accepted.
+pub fn geometry(b: &Brep) -> Result<()> {
+ for e in &b.edges {
+ curve(&e.curve)?;
+ if let Some(n) = &e.nurbs {
+ curve(n)?;
+ }
+ }
+ for f in &b.faces {
+ surface(&f.surface)?;
+ if let Some(n) = &f.nurbs {
+ surface(n)?;
+ }
+ }
+ Ok(())
+}
+
+fn vector(p: [f64; 3]) -> Vec3 {
+ Vec3::new(p[0], p[1], p[2])
+}
+
+/// A frame's axes are unit and perpendicular, to 1e-8.
+pub fn frame(f: &Frame) -> Result<()> {
+ let (x, y) = (vector(f.x_axis), vector(f.y_axis));
+ require((x.len() - 1.).abs() <= 1e-8 && (y.len() - 1.).abs() <= 1e-8 && x.dot(y).abs() <= 1e-8, "nonorthonormal frame")
+}
+
+/// A curve's geometric records, and those of the surfaces of an intersection curve. Call on a
+/// curve its structural validation accepted.
+pub fn curve(c: &Curve) -> Result<()> {
+ match c {
+ Curve::Circle { frame: f, .. } | Curve::Ellipse { frame: f, .. } => frame(f),
+ Curve::SurfaceIntersection { surfaces, .. } => surfaces.iter().try_for_each(|s| surface(s)),
+ Curve::Line { .. } | Curve::Polyline { .. } | Curve::Spline { .. } | Curve::RationalSpline { .. } => Ok(()),
+ }
+}
+
+/// A surface's geometric records, and its profile's for a placed revolution. Call on a surface
+/// its structural validation accepted.
+pub fn surface(s: &Surface) -> Result<()> {
+ match s {
+ Surface::Plane { u_axis, v_axis, .. } => require(vector(*u_axis).cross(vector(*v_axis)).len() > 1e-12, "degenerate plane"),
+ Surface::PlaneThrough { origin, u_point, v_point } => {
+ let o = vector(*origin);
+ require((vector(*u_point) - o).cross(vector(*v_point) - o).len() > 1e-12, "degenerate plane")
+ }
+ Surface::Cylinder { frame: f, .. } | Surface::Sphere { frame: f, .. } | Surface::Cone { frame: f, .. } | Surface::Torus { frame: f, .. } => {
+ frame(f)
+ }
+ Surface::PlacedRevolution { profile, axis, matrix, .. } => {
+ require((vector(*axis).len() - 1.0).abs() <= 1e-8, "revolution axis is not unit length")?;
+ let [x, y, z, _] = matrix.map(|c| vector([c[0], c[1], c[2]]));
+ require(x.cross(y).dot(z).abs() > 1e-12, "singular revolution placement")?;
+ curve(profile)
+ }
+ Surface::BallPatch { .. } | Surface::Spline { .. } | Surface::RationalSpline { .. } => Ok(()),
+ }
+}
diff --git a/crates/geom/src/brep/curve2.rs b/crates/geom/src/brep/curve2.rs
deleted file mode 100644
index 9d286d9e1e..0000000000
--- a/crates/geom/src/brep/curve2.rs
+++ /dev/null
@@ -1,111 +0,0 @@
-//! Pcurves: an edge in its face's surface parameters, (u, v). 2D B-splines only, as SMLib keeps
-//! its UV trim curves (`SmBSplineCurve`); 2D lines and arcs are exact as degree-1 and rational
-//! quadratic splines.
-use serde::{Deserialize, Serialize};
-
-use super::{Budget, Result, knots, numbers, require};
-
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
-pub enum Curve2 {
- Spline {
- knots: Vec<f64>,
- points: Vec<[f64; 2]>,
- },
- /// Homogeneous `[u*w, v*w, w]` coefficients.
- RationalSpline {
- knots: Vec<f64>,
- homogeneous: Vec<[f64; 3]>,
- },
-}
-
-impl Curve2 {
- /// The active parameter interval `[knots[degree], knots[count]]`.
- pub fn interval(&self) -> Option<[f64; 2]> {
- let (k, count) = match self {
- Curve2::Spline { knots, points } => (knots, points.len()),
- Curve2::RationalSpline { knots, homogeneous } => (knots, homogeneous.len()),
- };
- let degree = k.len().checked_sub(count.checked_add(1)?)?;
- Some([*k.get(degree)?, *k.get(count)?])
- }
-
- /// The point at `t` (`None` outside the interval or for a malformed record).
- pub fn eval(&self, t: f64) -> Option<[f64; 2]> {
- let (knots, h): (&[f64], Vec<[f64; 3]>) = match self {
- Curve2::Spline { knots, points } => (knots, points.iter().map(|&[u, v]| [u, v, 1.0]).collect()),
- Curve2::RationalSpline { knots, homogeneous } => (knots, homogeneous.clone()),
- };
- let p = knots.len().checked_sub(h.len() + 1)?;
- let span = crate::bspline::find_span(knots, p, h.len(), t)?;
- let n = basis(knots, p, span, t)?;
- let mut s = [0.0; 3];
- for (j, nj) in n.iter().enumerate() {
- let q = h.get(span + j - p)?;
- for (a, x) in s.iter_mut().zip(q) {
- *a += nj * x;
- }
- }
- (s[2].abs() > 0.0).then(|| [s[0] / s[2], s[1] / s[2]])
- }
-}
-
-/// The `p + 1` basis functions non-zero on knot span `span` at `t`, of any degree (NURBS Book
-/// A2.2).
-fn basis(knots: &[f64], p: usize, span: usize, t: f64) -> Option<Vec<f64>> {
- if span < p || span + p >= knots.len() {
- return None;
- }
- let k = |i: usize| knots.get(i).copied().unwrap_or(0.0);
- let mut n = vec![0.0; p + 1];
- let (mut left, mut right) = (vec![0.0; p + 1], vec![0.0; p + 1]);
- *n.first_mut()? = 1.0;
- for j in 1..=p {
- *left.get_mut(j)? = t - k(span + 1 - j);
- *right.get_mut(j)? = k(span + j) - t;
- let mut saved = 0.0;
- for r in 0..j {
- let (rr, lj) = (*right.get(r + 1)?, *left.get(j - r)?);
- let den = rr + lj;
- let tmp = if den != 0.0 { n.get(r)? / den } else { 0.0 };
- *n.get_mut(r)? = saved + rr * tmp;
- saved = lj * tmp;
- }
- *n.get_mut(j)? = saved;
- }
- Some(n)
-}
-
-pub(super) fn curve2(c: &Curve2, budget: &mut Budget) -> Result<()> {
- budget.add(1)?;
- match c {
- Curve2::Spline { knots: k, points } => {
- knots(k, points.len(), budget)?;
- budget.add(points.len())?;
- numbers(points.iter().flatten().copied())
- }
- Curve2::RationalSpline { knots: k, homogeneous } => {
- knots(k, homogeneous.len(), budget)?;
- budget.add(homogeneous.len())?;
- numbers(homogeneous.iter().flatten().copied())?;
- require(homogeneous.iter().all(|p| p[2] >= 1e-12), "non-positive rational weight")
- }
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn pcurves_validate_and_round_trip() {
- let line = Curve2::Spline { knots: vec![0., 0., 1., 1.], points: vec![[0., 0.], [1., 2.]] };
- curve2(&line, &mut Budget::input()).unwrap();
- assert_eq!(line.interval(), Some([0., 1.]));
- assert_eq!(serde_json::from_str::<Curve2>(&serde_json::to_string(&line).unwrap()).unwrap(), line);
- let bad = Curve2::RationalSpline { knots: vec![0., 0., 1., 1.], homogeneous: vec![[0., 0., 1.], [1., 2., 0.]] };
- assert!(curve2(&bad, &mut Budget::input()).is_err());
- let nan = Curve2::Spline { knots: vec![0., 0., 1., 1.], points: vec![[0., f64::NAN], [1., 2.]] };
- assert!(curve2(&nan, &mut Budget::input()).is_err());
- }
-}
diff --git a/crates/geom/src/brep/envelope.rs b/crates/geom/src/brep/envelope.rs
deleted file mode 100644
index 2483992ce6..0000000000
--- a/crates/geom/src/brep/envelope.rs
+++ /dev/null
@@ -1,118 +0,0 @@
-//! Stable version-one body metadata records. Runtime model types never define this wire contract.
-use serde::{Deserialize, Serialize};
-
-pub const VERSION: u32 = 1;
-
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct Metadata {
- pub version: u32,
- pub color: Option<[f32; 3]>,
- pub paint: Option<Paint>,
- pub boundaries: Option<Vec<Vec<[f64; 3]>>>,
- pub face_sources: Option<Vec<Option<FaceSource>>>,
- pub history: Option<History>,
- pub preserve_boundaries: bool,
-}
-
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct Plane {
- pub origin: [f64; 3],
- pub x_axis: [f64; 3],
- pub y_axis: [f64; 3],
-}
-
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
-pub enum Segment {
- Line { start: [f64; 2], end: [f64; 2] },
- Arc { center: [f64; 2], radius: f64, start: f64, sweep: f64 },
- Cubic { points: [[f64; 2]; 4] },
- Conic { points: [[f64; 2]; 3], middle_weight: f64 },
- Bezier { points: Vec<[f64; 2]> },
-}
-
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct Region {
- pub outer: Vec<Segment>,
- pub holes: Vec<Vec<Segment>>,
-}
-
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
-pub enum FaceSource {
- ExtrusionSide { segment: Segment, plane: Option<Plane>, coalesced: bool },
- CertifiedExtrusionSide { producer: u64, sketch: u64, curve: String, plane: Option<Plane> },
- ExtrusionCap { high: bool, region: Region, plane: Plane },
- CertifiedExtrusionCap { producer: u64, sketch: u64, high: bool, outer: Vec<String>, holes: Vec<Vec<String>>, plane: Plane },
- CylinderCap { producer: u64, high: bool, plane: Plane },
- BoxFace { producer: Option<u64>, axis: u8, high: bool, plane: Plane },
- PlanarShell { producer: Option<u64>, source: Box<FaceSource>, inner: bool, plane: Plane },
- Imported { item: u64, face: u64, payload_sha256: Option<String>, producer: Option<u64> },
-}
-
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct Paint {
- pub opacity: f32,
- pub faces: Vec<FacePaint>,
-}
-
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct FacePaint {
- pub face: u32,
- pub color: [f32; 3],
- pub opacity: f32,
-}
-
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct History {
- pub operands: u32,
- pub faces: Vec<FaceHistory>,
- pub edges: Vec<EdgeHistory>,
-}
-
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct FaceHistory {
- pub origins: Vec<FaceOrigin>,
- pub change: Change,
-}
-
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-pub struct EdgeHistory {
- pub faces: Vec<u32>,
- pub origins: Vec<EdgeOrigin>,
-}
-
-#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
-#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
-pub enum FaceOrigin {
- Face { operand: u32, face: u32 },
- Profile { segment: u32 },
- Cap { end: bool },
- Edge { operand: u32, edge: u32 },
- Offset { operand: u32, face: u32 },
-}
-
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
-pub enum EdgeOrigin {
- Edge { operand: u32, edge: u32 },
- Meeting { sides: [Vec<FaceOrigin>; 2] },
-}
-
-#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(rename_all = "snake_case")]
-pub enum Change {
- Kept,
- Modified,
- Split,
- Merged,
- Generated,
-}
diff --git a/crates/geom/src/brep/eval.rs b/crates/geom/src/brep/eval.rs
index 20a5270ea1..d2f8a712f8 100644
--- a/crates/geom/src/brep/eval.rs
+++ b/crates/geom/src/brep/eval.rs
@@ -11,11 +11,12 @@
use super::normal_section::normal_section;
use super::pcurve::Error;
use super::{Curve, Curve2, Frame, Surface};
-use crate::Vec3;
use crate::bspline::MAX_SPLINE_DEGREE;
+use crate::prelude::*;
use crate::tess::partials::{Partials, tabulate, trig_derivative};
use crate::tess::uv::{self, Domain};
use crate::tess::{EvalCurve, EvalSurface, MAX_EVAL_KNOTS, MAX_EVAL_POINTS};
+use solidcore_record::Vec3;
use std::f64::consts::{FRAC_PI_2, TAU};
/// Newton steps of one intersection point.
@@ -613,7 +614,7 @@ pub fn face_flux(s: &SurfaceEval, v0: f64, loops: &[Vec<(&Curve2, bool)>], field
let at = |k: f64| {
let f = k / FLUX_PIECES as f64;
// Exactly the ends at f = 0 and 1, whatever the interval's rounding.
- c.eval(if *forward { t0 * (1.0 - f) + t1 * f } else { t1 * (1.0 - f) + t0 * f })
+ super::pcurve::eval(c, if *forward { t0 * (1.0 - f) + t1 * f } else { t1 * (1.0 - f) + t0 * f })
};
for k in 0..FLUX_PIECES {
let (a, m, z) = (at(k as f64)?, at(k as f64 + 0.5)?, at(k as f64 + 1.0)?);
diff --git a/crates/geom/src/brep/form.rs b/crates/geom/src/brep/form.rs
index 619f8a4ec6..c1008f4d61 100644
--- a/crates/geom/src/brep/form.rs
+++ b/crates/geom/src/brep/form.rs
@@ -19,7 +19,8 @@
//! the arcs of its tube. A line is the degree-1 B-spline on its own parameter.
use super::{Curve, Frame, Surface};
-use crate::Vec3;
+use crate::prelude::*;
+use solidcore_record::Vec3;
use std::f64::consts::{FRAC_1_SQRT_2, FRAC_PI_2, FRAC_PI_8, TAU};
/// Rounding room on an angle at a quarter's end.
diff --git a/crates/geom/src/brep/geometry.rs b/crates/geom/src/brep/geometry.rs
index ef398420d0..da2cb58bcd 100644
--- a/crates/geom/src/brep/geometry.rs
+++ b/crates/geom/src/brep/geometry.rs
@@ -12,8 +12,9 @@
//! an edge's for its pcurves, an edge's and its vertex's together where they meet, a vertex's on
//! its surface. A point that cannot be evaluated is an error, never a panic.
use super::eval::{CurveEval, SurfaceEval};
-use super::{Brep, Curve2, Loop};
-use crate::Vec3;
+use crate::prelude::*;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Brep, Curve2, Loop};
/// Where a record disagrees with itself.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -89,7 +90,7 @@ fn unevaluable(record: Record, what: impl std::fmt::Display) -> Mismatch {
/// the pcurve's end.
fn on_pcurve(pc: &Curve2, t: f64) -> Option<[f64; 2]> {
let [a, b] = pc.interval()?;
- pc.eval(t.clamp(a.min(b), a.max(b)))
+ super::pcurve::eval(pc, t.clamp(a.min(b), a.max(b)))
}
/// `gap` within `tolerance` (a non-finite gap never is).
@@ -105,129 +106,127 @@ const EMPTY_AREA: f64 = 1e-9;
const PCURVE_POINTS: [&str; 3] =
["pcurve start lifts off its edge's curve", "pcurve middle lifts off its edge's curve", "pcurve end lifts off its edge's curve"];
-impl Brep {
- /// Check that the record's geometry agrees with its topology, within its tolerances (module
- /// docs). Call on a record [`Brep::validate`] accepted: this checks geometry, not structure,
- /// though a malformed record is refused, never a panic.
- pub fn check_geometry(&self) -> Result<()> {
- // Each edge's curve at its interval's start, middle and end, shared by all its uses.
- let mut points = Vec::with_capacity(self.edges.len());
- for (i, e) in self.edges.iter().enumerate() {
- let at = Record::Edge(index(i));
- let curve = CurveEval::new(e.parameters()).map_err(|err| unevaluable(at, err))?;
- let [t0, t1] = e.interval;
- let p = [t0, 0.5 * (t0 + t1), t1].map(|t| curve.point(t).ok_or(t));
- let p = match p {
- [Ok(a), Ok(m), Ok(z)] => [a, m, z],
- [Err(t), ..] | [_, Err(t), _] | [.., Err(t)] => return Err(unevaluable(at, format!("the curve has no point at {t}"))),
- };
- for (end, what) in [(0, "curve start misses its start vertex"), (1, "curve end misses its end vertex")] {
- let v = e.vertices.get(end).and_then(|&v| self.vertices.get(v as usize)).ok_or_else(|| unevaluable(at, "edge vertices"))?;
- let q = if end == 0 { p[0] } else { p[2] };
- within(at, what, q.dist(v3(v.point)), v.tolerance + e.tolerance)?;
- }
- points.push(p);
+/// Check that the record's geometry agrees with its topology, within its tolerances (module
+/// docs). Call on a record [`Brep::validate`] accepted: this checks geometry, not structure,
+/// though a malformed record is refused, never a panic.
+pub fn check(brep: &Brep) -> Result<()> {
+ // Each edge's curve at its interval's start, middle and end, shared by all its uses.
+ let mut points = Vec::with_capacity(brep.edges.len());
+ for (i, e) in brep.edges.iter().enumerate() {
+ let at = Record::Edge(index(i));
+ let curve = CurveEval::new(e.parameters()).map_err(|err| unevaluable(at, err))?;
+ let [t0, t1] = e.interval;
+ let p = [t0, 0.5 * (t0 + t1), t1].map(|t| curve.point(t).ok_or(t));
+ let p = match p {
+ [Ok(a), Ok(m), Ok(z)] => [a, m, z],
+ [Err(t), ..] | [_, Err(t), _] | [.., Err(t)] => return Err(unevaluable(at, format!("the curve has no point at {t}"))),
+ };
+ for (end, what) in [(0, "curve start misses its start vertex"), (1, "curve end misses its end vertex")] {
+ let v = e.vertices.get(end).and_then(|&v| brep.vertices.get(v as usize)).ok_or_else(|| unevaluable(at, "edge vertices"))?;
+ let q = if end == 0 { p[0] } else { p[2] };
+ within(at, what, q.dist(v3(v.point)), v.tolerance + e.tolerance)?;
}
- for (fi, f) in self.faces.iter().enumerate() {
- let face = index(fi);
- let surface = SurfaceEval::new(f.parameters()).map_err(|err| unevaluable(Record::Face(face), err))?;
- let period = surface.domain().period;
- // Each edge loop's signed (u, v) area.
- let mut areas: Vec<(u32, f64)> = Vec::with_capacity(f.loops.len());
- for (li, l) in f.loops.iter().enumerate() {
- let r#loop = index(li);
- match l {
- Loop::Vertex { vertex } => {
- let at = Record::VertexLoop { face, r#loop };
- let v = self.vertices.get(*vertex as usize).ok_or_else(|| unevaluable(at, "vertex reference"))?;
- let p = v3(v.point);
- let on = surface.project(p, None, f64::INFINITY).and_then(|q| surface.point(q));
- let gap = on.map_or(f64::INFINITY, |s| s.dist(p));
- within(at, "vertex lies off its face's surface", gap, v.tolerance)?;
- }
- Loop::Edges { edges } => {
- // Where each use starts and ends in (u, v), in the loop's direction.
- let mut ends: Vec<[[f64; 2]; 2]> = Vec::with_capacity(edges.len());
- for (position, u) in edges.iter().enumerate() {
- let at = Record::Use { face, r#loop, position: index(position) };
- let i = u.edge as usize;
- let (e, p) = self.edges.get(i).zip(points.get(i)).ok_or_else(|| unevaluable(at, "edge reference"))?;
- let [t0, t1] = e.interval;
- let mut uv = [[0.0; 2]; 3];
- for (k, t) in [t0, 0.5 * (t0 + t1), t1].into_iter().enumerate() {
- let q = on_pcurve(&u.pcurve, t).ok_or_else(|| unevaluable(at, format!("the pcurve has no point at {t}")))?;
- let s = surface.point(q).ok_or_else(|| unevaluable(at, format!("the surface has no point at {q:?}")))?;
- let (Some(c), Some(what), Some(slot)) = (p.get(k), PCURVE_POINTS.get(k), uv.get_mut(k)) else {
- return Err(unevaluable(at, "pcurve sample"));
- };
- within(at, what, s.dist(*c), e.tolerance)?;
- *slot = q;
- }
- ends.push(if u.forward { [uv[0], uv[2]] } else { [uv[2], uv[0]] });
- }
- // Each use continues the one before it (the last closes the loop), except
- // along a direction that collapses there (a pole): at the vertex where
- // they meet, to within the vertex's tolerance.
- for (position, pair) in ends.iter().enumerate() {
- let before = ends.get(position.checked_sub(1).unwrap_or(ends.len().saturating_sub(1)));
- let (Some([_, end]), [start, _]) = (before, pair) else { continue };
- let reach = edges
- .get(position)
- .and_then(|u| self.edges.get(u.edge as usize).map(|e| e.vertices[if u.forward { 0 } else { 1 }]))
- .and_then(|v| self.vertices.get(v as usize))
- .map_or(0.0, |v| v.tolerance);
- let pole = surface.pole_within(*start, reach);
- for d in 0..2 {
- let (Some(Some(p)), Some(false)) = (period.get(d), pole.get(d)) else { continue };
- let gap = (start[d] - end[d]).abs();
- if !(gap < 0.5 * p) {
- let record = Record::Use { face, r#loop, position: index(position) };
- return Err(Mismatch { record, problem: Problem::Period { gap, period: *p } });
- }
- }
+ points.push(p);
+ }
+ for (fi, f) in brep.faces.iter().enumerate() {
+ let face = index(fi);
+ let surface = SurfaceEval::new(f.parameters()).map_err(|err| unevaluable(Record::Face(face), err))?;
+ let period = surface.domain().period;
+ // Each edge loop's signed (u, v) area.
+ let mut areas: Vec<(u32, f64)> = Vec::with_capacity(f.loops.len());
+ for (li, l) in f.loops.iter().enumerate() {
+ let r#loop = index(li);
+ match l {
+ Loop::Vertex { vertex } => {
+ let at = Record::VertexLoop { face, r#loop };
+ let v = brep.vertices.get(*vertex as usize).ok_or_else(|| unevaluable(at, "vertex reference"))?;
+ let p = v3(v.point);
+ let on = surface.project(p, None, f64::INFINITY).and_then(|q| surface.point(q));
+ let gap = on.map_or(f64::INFINITY, |s| s.dist(p));
+ within(at, "vertex lies off its face's surface", gap, v.tolerance)?;
+ }
+ Loop::Edges { edges } => {
+ // Where each use starts and ends in (u, v), in the loop's direction.
+ let mut ends: Vec<[[f64; 2]; 2]> = Vec::with_capacity(edges.len());
+ for (position, u) in edges.iter().enumerate() {
+ let at = Record::Use { face, r#loop, position: index(position) };
+ let i = u.edge as usize;
+ let (e, p) = brep.edges.get(i).zip(points.get(i)).ok_or_else(|| unevaluable(at, "edge reference"))?;
+ let [t0, t1] = e.interval;
+ let mut uv = [[0.0; 2]; 3];
+ for (k, t) in [t0, 0.5 * (t0 + t1), t1].into_iter().enumerate() {
+ let q = on_pcurve(&u.pcurve, t).ok_or_else(|| unevaluable(at, format!("the pcurve has no point at {t}")))?;
+ let s = surface.point(q).ok_or_else(|| unevaluable(at, format!("the surface has no point at {q:?}")))?;
+ let (Some(c), Some(what), Some(slot)) = (p.get(k), PCURVE_POINTS.get(k), uv.get_mut(k)) else {
+ return Err(unevaluable(at, "pcurve sample"));
+ };
+ within(at, what, s.dist(*c), e.tolerance)?;
+ *slot = q;
}
- // The signed area the loop encloses (positive for the outer loop). Where
- // uses meet at a pole the ring runs straight along the pole's line.
- let at = Record::Loop { face, r#loop };
- let mut ring: Vec<[f64; 2]> = Vec::with_capacity(edges.len().saturating_mul(AREA_SAMPLES));
- for u in edges {
- let [t0, t1] = self.edges.get(u.edge as usize).ok_or_else(|| unevaluable(at, "edge reference"))?.interval;
- for k in 0..AREA_SAMPLES {
- let f = k as f64 / AREA_SAMPLES as f64;
- let t = if u.forward { t0 + (t1 - t0) * f } else { t1 - (t1 - t0) * f };
- ring.push(on_pcurve(&u.pcurve, t).ok_or_else(|| unevaluable(at, format!("the pcurve has no point at {t}")))?);
+ ends.push(if u.forward { [uv[0], uv[2]] } else { [uv[2], uv[0]] });
+ }
+ // Each use continues the one before it (the last closes the loop), except
+ // along a direction that collapses there (a pole): at the vertex where
+ // they meet, to within the vertex's tolerance.
+ for (position, pair) in ends.iter().enumerate() {
+ let before = ends.get(position.checked_sub(1).unwrap_or(ends.len().saturating_sub(1)));
+ let (Some([_, end]), [start, _]) = (before, pair) else { continue };
+ let reach = edges
+ .get(position)
+ .and_then(|u| brep.edges.get(u.edge as usize).map(|e| e.vertices[if u.forward { 0 } else { 1 }]))
+ .and_then(|v| brep.vertices.get(v as usize))
+ .map_or(0.0, |v| v.tolerance);
+ let pole = surface.pole_within(*start, reach);
+ for d in 0..2 {
+ let (Some(Some(p)), Some(false)) = (period.get(d), pole.get(d)) else { continue };
+ let gap = (start[d] - end[d]).abs();
+ if !(gap < 0.5 * p) {
+ let record = Record::Use { face, r#loop, position: index(position) };
+ return Err(Mismatch { record, problem: Problem::Period { gap, period: *p } });
}
}
- let area = signed_area(&ring);
- let extent = (0..2)
- .map(|d| {
- let (lo, hi) = ring.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(a, b), q| (a.min(q[d]), b.max(q[d])));
- hi - lo
- })
- .fold(0.0, f64::max);
- if !(area.abs() > EMPTY_AREA * extent * extent) {
- return Err(Mismatch { record: at, problem: Problem::Empty { area } });
+ }
+ // The signed area the loop encloses (positive for the outer loop). Where
+ // uses meet at a pole the ring runs straight along the pole's line.
+ let at = Record::Loop { face, r#loop };
+ let mut ring: Vec<[f64; 2]> = Vec::with_capacity(edges.len().saturating_mul(AREA_SAMPLES));
+ for u in edges {
+ let [t0, t1] = brep.edges.get(u.edge as usize).ok_or_else(|| unevaluable(at, "edge reference"))?.interval;
+ for k in 0..AREA_SAMPLES {
+ let f = k as f64 / AREA_SAMPLES as f64;
+ let t = if u.forward { t0 + (t1 - t0) * f } else { t1 - (t1 - t0) * f };
+ ring.push(on_pcurve(&u.pcurve, t).ok_or_else(|| unevaluable(at, format!("the pcurve has no point at {t}")))?);
}
- areas.push((r#loop, area));
}
+ let area = signed_area(&ring);
+ let extent = (0..2)
+ .map(|d| {
+ let (lo, hi) = ring.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(a, b), q| (a.min(q[d]), b.max(q[d])));
+ hi - lo
+ })
+ .fold(0.0, f64::max);
+ if !(area.abs() > EMPTY_AREA * extent * extent) {
+ return Err(Mismatch { record: at, problem: Problem::Empty { area } });
+ }
+ areas.push((r#loop, area));
}
}
- // One loop runs counter-clockwise, the outer; every other one clockwise. Which is
- // which comes from the areas, not the loops' order: the truck adapter writes a face's
- // wires in truck's order, which need not put the outer one first.
- let by_size = |a: &(u32, f64), b: &(u32, f64)| a.1.abs().total_cmp(&b.1.abs());
- let ccw: Vec<(u32, f64)> = areas.iter().copied().filter(|a| a.1 > 0.0).collect();
- let wrong = match ccw.len() {
- 0 => areas.into_iter().max_by(by_size).map(|(l, area)| (l, true, area)),
- 1 => None,
- _ => ccw.into_iter().min_by(by_size).map(|(l, area)| (l, false, area)),
- };
- if let Some((r#loop, outer, area)) = wrong {
- return Err(Mismatch { record: Record::Loop { face, r#loop }, problem: Problem::Turn { outer, area } });
- }
}
- Ok(())
+ // One loop runs counter-clockwise, the outer; every other one clockwise. Which is
+ // which comes from the areas, not the loops' order: the truck adapter writes a face's
+ // wires in truck's order, which need not put the outer one first.
+ let by_size = |a: &(u32, f64), b: &(u32, f64)| a.1.abs().total_cmp(&b.1.abs());
+ let ccw: Vec<(u32, f64)> = areas.iter().copied().filter(|a| a.1 > 0.0).collect();
+ let wrong = match ccw.len() {
+ 0 => areas.into_iter().max_by(by_size).map(|(l, area)| (l, true, area)),
+ 1 => None,
+ _ => ccw.into_iter().min_by(by_size).map(|(l, area)| (l, false, area)),
+ };
+ if let Some((r#loop, outer, area)) = wrong {
+ return Err(Mismatch { record: Record::Loop { face, r#loop }, problem: Problem::Turn { outer, area } });
+ }
}
+ Ok(())
}
/// Signed area of a closed polygon in (u, v): positive counter-clockwise.
diff --git a/crates/geom/src/brep/history.rs b/crates/geom/src/brep/history.rs
deleted file mode 100644
index 95533c276f..0000000000
--- a/crates/geom/src/brep/history.rs
+++ /dev/null
@@ -1,381 +0,0 @@
-//! Exact face and edge history: for each face and edge of an operation's result, what it came
-//! from among the operation's operands, recorded by the code that built it (never sampled).
-//!
-//! Indices are canonical face and edge indices (docs/native-brep.md, "Canonical order"), the
-//! positions in a body's face order and edge order. Operand numbers are positions in the
-//! operation's own operand list, which each operation documents. An operation returns its
-//! history beside the B-rep; a backend that cannot report it returns none and never guesses.
-//! These are the runtime types; the saved form is [`super::envelope`], kept separate so that a
-//! change here cannot redefine saved fields. `solidcraft_kernel::history` re-exports them and
-//! adds what needs a kernel body.
-
-use std::collections::{BTreeSet, HashMap};
-
-/// Why a history could not be composed or checked.
-#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)]
-#[error("history: {0}")]
-pub struct Failed(pub &'static str);
-
-type Result<T> = std::result::Result<T, Failed>;
-
-fn failed(detail: &'static str) -> Failed {
- Failed(detail)
-}
-
-/// Where a result face came from.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize, serde::Deserialize)]
-pub enum FaceOrigin {
- /// A face of input `operand` (its index in the operand's face order).
- Face { operand: usize, face: usize },
- /// Swept from segment `segment` of the profile's loops (in order: outer, then holes).
- Profile { segment: usize },
- /// The start or end cap of a sweep (the profile itself, or where it ends up).
- Cap { end: bool },
- /// Made in place of edge `edge` of input `operand` (a fillet or chamfer).
- Edge { operand: usize, edge: usize },
- /// An offset of face `face` of input `operand` (a shell's inner wall).
- Offset { operand: usize, face: usize },
-}
-
-/// How a result face relates to its origins.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
-pub enum Change {
- /// The same face as its origin (same region).
- Kept,
- /// Its origin's surface, trimmed differently.
- Modified,
- /// One of several result faces made from one input face.
- Split,
- /// Made from several input faces (coplanar or cosurface faces joined).
- Merged,
- /// New to the operation (no input face under it).
- Generated,
-}
-
-#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
-pub struct FaceProv {
- pub origins: Vec<FaceOrigin>,
- pub change: Change,
-}
-
-/// One side of a meeting: the origins of the face on that side of the edge. One origin, or
-/// several where that face was made from several (a merged face) and the edge lies along it
-/// as a whole. Never empty; sorted, without repeats, so equal sides compare equal.
-#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize, serde::Deserialize)]
-pub struct Side(Vec<FaceOrigin>);
-
-impl Side {
- /// The side made of `origins` (in any order, repeats allowed); `None` when there are none.
- pub fn new(origins: impl IntoIterator<Item = FaceOrigin>) -> Option<Side> {
- let side = Side::canonical(origins.into_iter().collect());
- (!side.0.is_empty()).then_some(side)
- }
-
- /// Its origins, sorted.
- pub fn origins(&self) -> &[FaceOrigin] {
- &self.0
- }
-
- /// The side's one origin, when it has exactly one.
- pub fn single(&self) -> Option<FaceOrigin> {
- match self.0.as_slice() {
- [o] => Some(*o),
- _ => None,
- }
- }
-
- /// The same side with each origin mapped by `f` (failing where `f` does).
- pub fn try_map<E>(&self, f: impl Fn(FaceOrigin) -> std::result::Result<FaceOrigin, E>) -> std::result::Result<Side, E> {
- Ok(Side::canonical(self.0.iter().map(|o| f(*o)).collect::<std::result::Result<_, E>>()?))
- }
-
- /// The same side with each origin's operand renumbered by `f`.
- pub fn map_operand(&self, f: impl Fn(usize) -> usize) -> Side {
- Side::canonical(self.0.iter().map(|o| o.map_operand(&f)).collect())
- }
-
- /// `origins` sorted, without repeats.
- fn canonical(mut origins: Vec<FaceOrigin>) -> Side {
- origins.sort_unstable();
- origins.dedup();
- Side(origins)
- }
-}
-
-impl From<FaceOrigin> for Side {
- fn from(origin: FaceOrigin) -> Side {
- Side(vec![origin])
- }
-}
-
-/// Where a result edge came from.
-#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize, serde::Deserialize)]
-pub enum EdgeOrigin {
- /// (Part of) edge `edge` of input `operand`.
- Edge { operand: usize, edge: usize },
- /// Where two faces meet that met nowhere before (a boolean's intersection curve): the
- /// origins of the face on each side, `a <= b` (made with [`EdgeOrigin::meet`]).
- Meet { a: Side, b: Side },
-}
-
-/// A result edge: the result faces it separates and what it came from (empty when it is new
-/// and lies between faces new to the operation, or between two pieces of one face: a split
-/// line).
-#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
-pub struct EdgeProv {
- pub faces: Vec<usize>,
- pub origins: Vec<EdgeOrigin>,
-}
-
-/// History of an operation's result: one entry per face and per edge, in the result's orders.
-#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize)]
-pub struct History {
- /// How many operands the operation had.
- pub operands: usize,
- pub faces: Vec<FaceProv>,
- pub edges: Vec<EdgeProv>,
-}
-
-impl FaceOrigin {
- /// The same origin with its operand (if it has one) renumbered by `f`.
- pub fn map_operand(self, f: impl Fn(usize) -> usize) -> FaceOrigin {
- match self {
- FaceOrigin::Face { operand, face } => FaceOrigin::Face { operand: f(operand), face },
- FaceOrigin::Edge { operand, edge } => FaceOrigin::Edge { operand: f(operand), edge },
- FaceOrigin::Offset { operand, face } => FaceOrigin::Offset { operand: f(operand), face },
- other => other,
- }
- }
-}
-
-impl EdgeOrigin {
- /// Where the faces with origins `a` and `b` (sides, or single origins) meet, in canonical
- /// order (the lesser side first).
- pub fn meet(a: impl Into<Side>, b: impl Into<Side>) -> EdgeOrigin {
- let (a, b) = (a.into(), b.into());
- if a <= b { EdgeOrigin::Meet { a, b } } else { EdgeOrigin::Meet { a: b, b: a } }
- }
-
- /// The same origin with its operands renumbered by `f`.
- pub fn map_operand(&self, f: impl Fn(usize) -> usize) -> EdgeOrigin {
- match self {
- EdgeOrigin::Edge { operand, edge } => EdgeOrigin::Edge { operand: f(*operand), edge: *edge },
- EdgeOrigin::Meet { a, b } => EdgeOrigin::meet(a.map_operand(&f), b.map_operand(&f)),
- }
- }
-}
-
-impl History {
- /// Check that this history describes a result with `result` (faces, edges) made from operands
- /// with `counts`: one entry per face and edge, and every origin within its operand's faces
- /// and edges.
- pub fn check_counts(&self, result: (usize, usize), counts: &[(usize, usize)]) -> Result<()> {
- if self.operands != counts.len() {
- return Err(failed("operand count does not match"));
- }
- if self.faces.len() != result.0 || self.edges.len() != result.1 {
- return Err(failed("entries do not match the result's faces and edges"));
- }
- let face_ok = |o: &FaceOrigin| match *o {
- FaceOrigin::Face { operand, face } | FaceOrigin::Offset { operand, face } => counts.get(operand).is_some_and(|c| face < c.0),
- FaceOrigin::Edge { operand, edge } => counts.get(operand).is_some_and(|c| edge < c.1),
- FaceOrigin::Profile { .. } | FaceOrigin::Cap { .. } => true,
- };
- if !self.faces.iter().all(|f| f.origins.iter().all(face_ok)) {
- return Err(failed("a face origin lies outside its operand"));
- }
- for e in &self.edges {
- if e.faces.iter().any(|f| *f >= self.faces.len()) {
- return Err(failed("an edge lies on a face outside the result"));
- }
- let ok = e.origins.iter().all(|o| match o {
- EdgeOrigin::Edge { operand, edge } => counts.get(*operand).is_some_and(|c| *edge < c.1),
- EdgeOrigin::Meet { a, b } => a.origins().iter().chain(b.origins()).all(face_ok),
- });
- if !ok {
- return Err(failed("an edge origin lies outside its operand"));
- }
- if e.origins.iter().any(|o| matches!(o, EdgeOrigin::Meet { a, b } if a > b)) {
- return Err(failed("a meeting's sides are out of order"));
- }
- }
- Ok(())
- }
-
- /// Compose with the history of the operation that made operand `k`: origins on operand `k`
- /// become that operation's origins, its operands (none, for a body made from a sketch)
- /// taking `k`'s place in the operand list; a meeting's side becomes the origins of the faces
- /// it names (several where that operation merged faces). Fails, without changing `self`,
- /// where a lineage cannot be expressed (an offset of a face that operation generated or
- /// merged, a blend of an edge it generated, a meeting with a face it made from nothing).
- pub fn substitute(&mut self, k: usize, inner: &History) -> Result<()> {
- if k >= self.operands {
- return Err(failed("no such operand"));
- }
- let n = inner.operands;
- // Operands before k stay, k's come in at k, those after k move by n - 1.
- let outer = |op: usize| if op < k { op } else { op + n - 1 };
- let lifted = |op: usize| op + k;
- let inner_face = |face: usize| inner.faces.get(face).ok_or_else(|| failed("a face origin lies outside the inner result"));
- let inner_edge = |edge: usize| inner.edges.get(edge).ok_or_else(|| failed("an edge origin lies outside the inner result"));
- // A face origin as origins of the composed operation, with the inner face's change.
- let map_face = |o: FaceOrigin| -> Result<(Vec<FaceOrigin>, Option<Change>)> {
- match o {
- FaceOrigin::Face { operand, face } if operand == k => {
- let p = inner_face(face)?;
- Ok((p.origins.iter().map(|x| x.map_operand(lifted)).collect(), Some(p.change)))
- }
- FaceOrigin::Offset { operand, face } if operand == k => match inner_face(face)?.origins.as_slice() {
- [FaceOrigin::Face { operand, face }] => Ok((vec![FaceOrigin::Offset { operand: lifted(*operand), face: *face }], None)),
- _ => Err(failed("an offset of a face the inner operation generated or merged")),
- },
- FaceOrigin::Edge { operand, edge } if operand == k => match inner_edge(edge)?.origins.as_slice() {
- [EdgeOrigin::Edge { operand, edge }] => Ok((vec![FaceOrigin::Edge { operand: lifted(*operand), edge: *edge }], None)),
- _ => Err(failed("a blend of an edge the inner operation generated")),
- },
- other => Ok((vec![other.map_operand(outer)], None)),
- }
- };
- let mut faces = Vec::with_capacity(self.faces.len());
- for f in &self.faces {
- let mut origins = BTreeSet::new();
- let mut kept = f.change == Change::Kept;
- for o in &f.origins {
- let (os, change) = map_face(*o)?;
- origins.extend(os);
- kept &= change.is_none_or(|c| c == Change::Kept);
- }
- let origins: Vec<FaceOrigin> = origins.into_iter().collect();
- let change = if f.change == Change::Generated || !origins.iter().any(|o| matches!(o, FaceOrigin::Face { .. })) {
- Change::Generated
- } else if origins.len() > 1 {
- Change::Merged
- } else if kept {
- Change::Kept
- } else {
- Change::Modified
- };
- faces.push(FaceProv { origins, change });
- }
- // Split where an origin lies under several composed faces (pieces the inner operation
- // split and this one joined back, or dropped all but one of, are not).
- mark_shared_split(&mut faces);
- // One side of a meeting: the origins of what its faces were made from.
- let side = |s: &Side| -> Result<Side> {
- let mut origins = Vec::new();
- for o in s.origins() {
- origins.extend(map_face(*o)?.0);
- }
- Side::new(origins).ok_or_else(|| failed("an edge meets a face the inner operation made from nothing"))
- };
- let mut edges = Vec::with_capacity(self.edges.len());
- for e in &self.edges {
- let mut origins = BTreeSet::new();
- for o in &e.origins {
- match o {
- EdgeOrigin::Edge { operand, edge } if *operand == k => {
- origins.extend(inner_edge(*edge)?.origins.iter().map(|x| x.map_operand(lifted)))
- }
- EdgeOrigin::Edge { .. } => {
- origins.insert(o.map_operand(outer));
- }
- EdgeOrigin::Meet { a, b } => {
- origins.insert(EdgeOrigin::meet(side(a)?, side(b)?));
- }
- }
- }
- edges.push(EdgeProv { faces: e.faces.clone(), origins: origins.into_iter().collect() });
- }
- self.operands = self.operands + n - 1;
- self.faces = faces;
- self.edges = edges;
- Ok(())
- }
-
- /// Renumber the operands: operand `i` becomes `map[i]` of `operands` (several may become
- /// one, which joins their origins), or is dropped (`None`), which fails, without changing
- /// `self`, where an origin lies on it.
- pub fn renumber(&mut self, map: &[Option<usize>], operands: usize) -> Result<()> {
- if map.len() != self.operands || map.iter().flatten().any(|op| *op >= operands) {
- return Err(failed("operand map does not match"));
- }
- let to = |op: usize| map.get(op).copied().flatten().ok_or_else(|| failed("an origin lies on a dropped operand"));
- let face = |o: FaceOrigin| -> Result<FaceOrigin> {
- Ok(match o {
- FaceOrigin::Face { operand, face } => FaceOrigin::Face { operand: to(operand)?, face },
- FaceOrigin::Edge { operand, edge } => FaceOrigin::Edge { operand: to(operand)?, edge },
- FaceOrigin::Offset { operand, face } => FaceOrigin::Offset { operand: to(operand)?, face },
- other => other,
- })
- };
- let mut faces = Vec::with_capacity(self.faces.len());
- for f in &self.faces {
- let origins: BTreeSet<FaceOrigin> = f.origins.iter().map(|o| face(*o)).collect::<Result<_>>()?;
- // Origins that became one are one face: no longer a merge.
- let change = if f.change == Change::Merged && origins.len() == 1 { Change::Modified } else { f.change };
- faces.push(FaceProv { origins: origins.into_iter().collect(), change });
- }
- let mut edges = Vec::with_capacity(self.edges.len());
- for e in &self.edges {
- let origins: BTreeSet<EdgeOrigin> = e
- .origins
- .iter()
- .map(|o| match o {
- EdgeOrigin::Edge { operand, edge } => Ok(EdgeOrigin::Edge { operand: to(*operand)?, edge: *edge }),
- EdgeOrigin::Meet { a, b } => Ok(EdgeOrigin::meet(a.try_map(face)?, b.try_map(face)?)),
- })
- .collect::<Result<_>>()?;
- edges.push(EdgeProv { faces: e.faces.clone(), origins: origins.into_iter().collect() });
- }
- self.operands = operands;
- self.faces = faces;
- self.edges = edges;
- Ok(())
- }
-
- /// [`History::renumber`], consuming.
- pub fn renumbered(mut self, map: &[Option<usize>], operands: usize) -> Result<History> {
- self.renumber(map, operands)?;
- Ok(self)
- }
-
- /// [`History::substitute`], consuming.
- pub fn substituted(mut self, k: usize, inner: &History) -> Result<History> {
- self.substitute(k, inner)?;
- Ok(self)
- }
-
- /// This history, whose operand `i` was made by the operation `parts[i]` describes (all of
- /// them over the same operands), as a history over those operands.
- pub fn over(mut self, parts: &[&History]) -> Result<History> {
- let n = parts.first().map_or(0, |p| p.operands);
- if parts.len() != self.operands || parts.iter().any(|p| p.operands != n) {
- return Err(failed("operand histories do not match"));
- }
- // Each part's operands come in at its place: then part i's operand j is i * n + j.
- for (k, part) in parts.iter().enumerate().rev() {
- self.substitute(k, part)?;
- }
- let map: Vec<Option<usize>> = (0..self.operands).map(|op| op.checked_rem(n)).collect();
- self.renumber(&map, n)?;
- Ok(self)
- }
-}
-
-/// Faces of one origin that is under other faces too, and that still say Kept or Modified,
-/// are Split (also where histories are put side by side: pieces of one body can share a
-/// source).
-pub fn mark_shared_split(faces: &mut [FaceProv]) {
- let mut uses: HashMap<FaceOrigin, usize> = HashMap::new();
- for o in faces.iter().flat_map(|f| &f.origins) {
- *uses.entry(*o).or_default() += 1;
- }
- for f in faces.iter_mut() {
- if matches!(f.change, Change::Kept | Change::Modified)
- && let [o] = f.origins.as_slice()
- && uses.get(o).copied().unwrap_or(0) > 1
- {
- f.change = Change::Split;
- }
- }
-}
diff --git a/crates/geom/src/brep/label.rs b/crates/geom/src/brep/label.rs
new file mode 100644
index 0000000000..5031ab8d47
--- /dev/null
+++ b/crates/geom/src/brep/label.rs
@@ -0,0 +1,94 @@
+//! What a record's labels mean in their own parameters, computed: the natural (u, v) ranges of
+//! a surface as it is named (a cone's apex), an edge's interval on its circle or ellipse, and
+//! whether a face's NURBS form turns its natural normal against its surface's. The record holds
+//! these as data; working them out is the kernel's.
+use crate::prelude::*;
+use solidcore_record::brep::{Curve, Edge, Face, Frame, Natural, Surface, UNBOUNDED, knot_domain};
+
+use super::eval;
+
+/// The ranges of u and v of `s` as it is named (its own (u, v), not its NURBS form's). Call on a
+/// validated record.
+pub fn surface_natural(s: &Surface) -> [Natural; 2] {
+ use std::f64::consts::FRAC_PI_2;
+ match s {
+ Surface::Plane { .. } | Surface::PlaneThrough { .. } => [UNBOUNDED; 2],
+ Surface::Cylinder { .. } => [Natural::Periodic, UNBOUNDED],
+ Surface::Cone { radius_at_origin, half_angle, .. } => {
+ let apex = -radius_at_origin / half_angle.tan();
+ let v = if *half_angle > 0. { Natural::Range(apex, f64::INFINITY) } else { Natural::Range(f64::NEG_INFINITY, apex) };
+ [Natural::Periodic, v]
+ }
+ Surface::Sphere { .. } => [Natural::Periodic, Natural::Range(-FRAC_PI_2, FRAC_PI_2)],
+ Surface::Torus { .. } => [Natural::Periodic; 2],
+ // A label: the face's (u, v) are its NURBS form's.
+ Surface::BallPatch { .. } => [UNBOUNDED; 2],
+ Surface::Spline { u_knots, v_knots, points } => {
+ [knot_domain(u_knots, points.len()), knot_domain(v_knots, points.first().map_or(0, Vec::len))]
+ }
+ Surface::RationalSpline { u_knots, v_knots, homogeneous } => {
+ [knot_domain(u_knots, homogeneous.len()), knot_domain(v_knots, homogeneous.first().map_or(0, Vec::len))]
+ }
+ Surface::PlacedRevolution { profile, forward: true, .. } => [profile.natural(), Natural::Periodic],
+ Surface::PlacedRevolution { profile, forward: false, .. } => [Natural::Periodic, profile.natural()],
+ }
+}
+
+/// The edge's interval on its `curve` itself, for code that reads what the edge is (a circle's
+/// angles): its `interval` when it has no NURBS form; otherwise the angles of its ends on the
+/// NURBS, unwrapped forward along the edge (a whole turn for a closed edge). A form's circle or
+/// ellipse has its frame turned so its angle grows along the NURBS (the SMLib conversion makes
+/// it so). `None` where the NURBS can't be evaluated.
+pub fn edge_curve_interval(edge: &Edge) -> Option<[f64; 2]> {
+ curve_interval(&edge.curve, edge.nurbs.as_ref(), edge.interval)
+}
+
+/// [`edge_curve_interval`] of an edge given by its parts: its `curve`, its NURBS form and its
+/// interval on that form.
+pub fn curve_interval(curve: &Curve, nurbs: Option<&Curve>, interval: [f64; 2]) -> Option<[f64; 2]> {
+ use std::f64::consts::TAU;
+ let Some(n) = nurbs else { return Some(interval) };
+ let (frame, radii) = match curve {
+ Curve::Circle { frame, radius } => (frame, [*radius, *radius]),
+ Curve::Ellipse { frame, radii } => (frame, *radii),
+ _ => return Some(interval),
+ };
+ let eval = eval::CurveEval::new(n).ok()?;
+ let [t0, t1] = interval;
+ let o = solidcore_record::Vec3::new(frame.origin[0], frame.origin[1], frame.origin[2]);
+ let (x, y) = (solidcore_record::Vec3::from(frame.x_axis), solidcore_record::Vec3::from(frame.y_axis));
+ let angle = |t: f64| eval.point(t).map(|p| ((p - o).dot(y) / radii[1]).atan2((p - o).dot(x) / radii[0]).rem_euclid(TAU));
+ let (a0, a1) = (angle(t0)?, angle(t1)?);
+ let sweep = (a1 - a0).rem_euclid(TAU);
+ Some([a0, a0 + if sweep <= 1e-12 { TAU } else { sweep }])
+}
+
+/// Whether the face's NURBS form turns its natural normal against `surface`'s (away from the
+/// axis of a cylinder or cone, the centre of a sphere, the tube's centre circle of a torus), at
+/// the middle of `domain`. A shell's `forward` is about [`Face::parameters`], so the side
+/// `surface` is used on is `forward != form_turns(face)`. `Some(false)` without a form; `None`
+/// where the form does not evaluate there.
+pub fn form_turns(face: &Face) -> Option<bool> {
+ let Some(form) = &face.nurbs else { return Some(false) };
+ let eval = eval::SurfaceEval::new(form).ok()?;
+ let [[u0, u1], [v0, v1]] = face.domain;
+ let (p, su, sv) = eval.derivs(0.5 * (u0 + u1), 0.5 * (v0 + v1))?;
+ let v3 = |a: [f64; 3]| solidcore_record::Vec3::new(a[0], a[1], a[2]);
+ let radial = |f: &Frame| {
+ let (o, z) = (v3(f.origin), v3(f.x_axis).cross(v3(f.y_axis)));
+ let d = p - o;
+ (o, d - z * (d.dot(z) / z.dot(z)))
+ };
+ let outward = match &face.surface {
+ Surface::Cylinder { frame, .. } | Surface::Cone { frame, .. } => radial(frame).1,
+ Surface::Sphere { frame, .. } => p - v3(frame.origin),
+ Surface::BallPatch { center, .. } => p - v3(*center),
+ Surface::Torus { frame, major_radius, .. } => {
+ let (o, r) = radial(frame);
+ p - (o + r.normalized()? * *major_radius)
+ }
+ _ => return None,
+ };
+ let along = su.cross(sv).dot(outward);
+ (along.abs() > 0.0).then_some(along < 0.0)
+}
diff --git a/crates/geom/src/brep/normal_section.rs b/crates/geom/src/brep/normal_section.rs
index e41035fe84..d318b842e9 100644
--- a/crates/geom/src/brep/normal_section.rs
+++ b/crates/geom/src/brep/normal_section.rs
@@ -17,8 +17,9 @@
//! (the lower orders' terms on the right), and the height's coefficient is the normal part of the
//! same expansion. Nothing is sampled: the answer is exact up to rounding.
-use crate::Vec3;
+use crate::prelude::*;
use crate::tess::partials::{MAX_PARTIAL_ORDER, Partials, orders};
+use solidcore_record::Vec3;
/// Taylor coefficients in `x` up to the fourth power (index = power).
type Series<T> = [T; MAX_PARTIAL_ORDER + 1];
@@ -118,7 +119,7 @@ fn factorial(n: usize) -> f64 {
mod tests {
use super::*;
use crate::brep::eval::SurfaceEval;
- use crate::brep::{Frame, Surface};
+ use solidcore_record::brep::{Frame, Surface};
fn frame() -> Frame {
Frame { origin: [1., 2., 3.], x_axis: [0., 1., 0.], y_axis: [0., 0., 1.] }
diff --git a/crates/geom/src/brep/part.rs b/crates/geom/src/brep/part.rs
deleted file mode 100644
index 89e3f44621..0000000000
--- a/crates/geom/src/brep/part.rs
+++ /dev/null
@@ -1,445 +0,0 @@
-//! Part of a record: the bounded material regions asked for, each with the voids inside it, as a
-//! record of its own in canonical order (docs/native-brep.md, "Canonical order"), and where each
-//! of its faces, edges and vertices was in the whole. A lump of a body is the part of one of its
-//! material regions; material inside one of its voids (an island) is a lump of its own. Records
-//! of bodies apart from each other join into one by [`Brep::compound`].
-use serde::{Deserialize, Serialize};
-
-use super::{Brep, Edge, EdgeUseRef, Invalid, Loop, OrientedFace, Region, Result, Shell, require};
-
-/// A record cut from a larger one, and the source index of each of its items.
-#[derive(Clone, Debug, PartialEq)]
-pub struct Part {
- pub brep: Brep,
- pub faces: Vec<u32>,
- pub edges: Vec<u32>,
- pub vertices: Vec<u32>,
-}
-
-/// The most two material regions of a record share, least first: a point, a curve, an area.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
-#[serde(rename_all = "snake_case")]
-pub enum Contact {
- /// A vertex and no edge or face: they touch at a point.
- Vertex,
- /// An edge and no face: they touch along a curve.
- Edge,
- /// A face: they meet over an area.
- Face,
-}
-
-/// Two material regions that meet (positions in [`Brep::material_regions`], the lower first),
-/// and the most they share.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
-pub struct RegionContact {
- pub regions: [usize; 2],
- pub contact: Contact,
-}
-
-/// First-appearance numbering of a subset of `n` source items.
-struct Renumber {
- new: Vec<Option<u32>>,
- old: Vec<u32>,
-}
-impl Renumber {
- fn new(n: usize) -> Renumber {
- Renumber { new: vec![None; n], old: Vec::new() }
- }
- /// The new index of source item `i`, numbering it now if it is new.
- fn visit(&mut self, i: u32) -> Result<u32> {
- let slot = self.new.get_mut(i as usize).ok_or(Invalid("part reference"))?;
- if let Some(k) = slot {
- return Ok(*k);
- }
- let k = u32::try_from(self.old.len()).map_err(|_| Invalid("part index"))?;
- *slot = Some(k);
- self.old.push(i);
- Ok(k)
- }
- fn get(&self, i: u32) -> Option<u32> {
- self.new.get(i as usize).copied().flatten()
- }
-}
-
-impl Brep {
- /// Indices of the bounded material regions (not voids), in region order.
- pub fn material_regions(&self) -> Vec<usize> {
- self.regions.iter().enumerate().skip(1).filter(|(_, r)| !r.void).map(|(i, _)| i).collect()
- }
-
- /// How the material regions meet, read from the record: each pair of regions that shares a
- /// face, an edge or a vertex, with the most they share. `regions` index
- /// [`Brep::material_regions`] (so a body's lumps); pairs not listed are apart. Regions share
- /// an edge where it is used by faces of both (more than two faces) or each has a copy of it
- /// (an edge of the same curve and interval between vertices at the same points), a vertex
- /// where edges or vertex loops of both end at it or at a copy of it (a vertex at the same
- /// point). Sorted by pair.
- pub fn region_contacts(&self) -> Result<Vec<RegionContact>> {
- let material = self.material_regions();
- // The material regions (positions in `material`) each face, edge and vertex belongs to.
- let mut on_face: Vec<Vec<usize>> = vec![Vec::new(); self.faces.len()];
- let mut on_edge: Vec<Vec<usize>> = vec![Vec::new(); self.edges.len()];
- let mut on_vertex: Vec<Vec<usize>> = vec![Vec::new(); self.vertices.len()];
- let mark = |list: &mut Vec<Vec<usize>>, i: u32, k: usize| -> Result<()> {
- let owners = list.get_mut(i as usize).ok_or(Invalid("contact reference"))?;
- if owners.last() != Some(&k) {
- owners.push(k);
- }
- Ok(())
- };
- for (k, &r) in material.iter().enumerate() {
- let region = self.regions.get(r).ok_or(Invalid("region reference"))?;
- for &s in &region.shells {
- match self.shells.get(s as usize).ok_or(Invalid("shell reference"))? {
- Shell::Faces { faces, wires } => {
- for f in faces {
- mark(&mut on_face, f.face, k)?;
- for l in &self.faces.get(f.face as usize).ok_or(Invalid("face reference"))?.loops {
- match l {
- Loop::Edges { edges } => {
- for u in edges {
- mark(&mut on_edge, u.edge, k)?;
- }
- }
- Loop::Vertex { vertex } => mark(&mut on_vertex, *vertex, k)?,
- }
- }
- }
- for &e in wires {
- mark(&mut on_edge, e, k)?;
- }
- }
- Shell::Wire { edges } => {
- for &e in edges {
- mark(&mut on_edge, e, k)?;
- }
- }
- Shell::Vertex { vertex } => mark(&mut on_vertex, *vertex, k)?,
- }
- }
- }
- for (e, owners) in on_edge.iter().enumerate() {
- for &v in &self.edges.get(e).ok_or(Invalid("edge reference"))?.vertices {
- for &k in owners {
- let list = on_vertex.get_mut(v as usize).ok_or(Invalid("contact reference"))?;
- if !list.contains(&k) {
- list.push(k);
- }
- }
- }
- }
- // A producer that keeps each solid's boundary closed on its own gives solids that touch a
- // copy each of the edge or vertex they share (SMLib's export splits them so): the same
- // curve over the same interval between vertices at the same points, a vertex at the same
- // point. Copies are one edge or vertex here; their owners are listed together.
- let point = |v: u32| self.vertices.get(v as usize).map(|x| x.point.map(f64::to_bits)).ok_or(Invalid("vertex reference"));
- let mut at_point = std::collections::BTreeMap::<[u64; 3], Vec<usize>>::new();
- for (v, owners) in on_vertex.iter().enumerate().filter(|(_, o)| !o.is_empty()) {
- at_point.entry(point(u32::try_from(v).map_err(|_| Invalid("vertex index"))?)?).or_default().extend(owners);
- }
- let mut edge_copies = std::collections::BTreeMap::<([[u64; 3]; 2], [u64; 2]), Vec<(&Edge, Vec<usize>)>>::new();
- for (e, owners) in on_edge.iter().enumerate().filter(|(_, o)| !o.is_empty()) {
- let edge = self.edges.get(e).ok_or(Invalid("edge reference"))?;
- let key = ([point(edge.vertices[0])?, point(edge.vertices[1])?], edge.interval.map(f64::to_bits));
- let same = edge_copies.entry(key).or_default();
- match same.iter_mut().find(|(other, _)| other.curve == edge.curve && other.nurbs == edge.nurbs) {
- Some((_, all)) => all.extend(owners),
- None => same.push((edge, owners.clone())),
- }
- }
- let copied = |lists: Vec<Vec<usize>>| -> Vec<Vec<usize>> {
- lists
- .into_iter()
- .map(|mut l| {
- l.sort_unstable();
- l.dedup();
- l
- })
- .collect()
- };
- let edge_copies = copied(edge_copies.into_values().flatten().map(|(_, owners)| owners).collect());
- let vertex_copies = copied(at_point.into_values().collect());
- let mut pairs = std::collections::BTreeMap::<[usize; 2], Contact>::new();
- for (owners, contact) in [
- (&on_face, Contact::Face),
- (&on_edge, Contact::Edge),
- (&edge_copies, Contact::Edge),
- (&on_vertex, Contact::Vertex),
- (&vertex_copies, Contact::Vertex),
- ] {
- for list in owners.iter().filter(|l| l.len() > 1) {
- for (i, &a) in list.iter().enumerate() {
- for &b in list.iter().skip(i + 1) {
- let most = pairs.entry([a.min(b), a.max(b)]).or_insert(contact);
- *most = (*most).max(contact);
- }
- }
- }
- }
- Ok(pairs.into_iter().map(|(regions, contact)| RegionContact { regions, contact }).collect())
- }
-
- /// The part made of the material regions `regions` (indices into `self.regions`, bounded,
- /// not voids): each with its outer shell, its open and wire shells, and a void for each
- /// closed inner shell. An island inside one of those voids is in the part, inside it, when
- /// its own region is among `regions`, and left out otherwise.
- pub fn part(&self, regions: &[usize]) -> Result<Part> {
- // Which region each closed shell encloses (the region listing it first), and which
- // region lies around it (the one listing it after its own outer shell; 0 for the open).
- let mut encloses: Vec<Option<usize>> = vec![None; self.shells.len()];
- let mut around: Vec<usize> = vec![0; self.shells.len()];
- for (r, region) in self.regions.iter().enumerate() {
- for (k, &s) in region.shells.iter().enumerate() {
- let i = s as usize;
- if r > 0 && k == 0 {
- *encloses.get_mut(i).ok_or(Invalid("region shell reference"))? = Some(r);
- } else {
- *around.get_mut(i).ok_or(Invalid("region shell reference"))? = r;
- }
- }
- }
- // The part's regions over source shells: each material region as it is, each void
- // inside one by its outer shell, and the infinite region around every outer shell whose
- // surrounding void is not in the part. A material region inside a void that is in the
- // part (an island in a hollow both are taken from) stays inside it.
- let mut voids: Vec<(usize, Vec<u32>)> = Vec::new();
- let mut kept: Vec<(Vec<u32>, bool)> = Vec::new();
- for &r in regions {
- let region = self.regions.get(r).ok_or(Invalid("part region"))?;
- require(r > 0 && !region.void, "a part's region is bounded material")?;
- require(!region.shells.is_empty(), "bounded region without an outer shell")?;
- kept.push((region.shells.clone(), false));
- for &s in region.shells.iter().skip(1) {
- if let Some(v) = encloses.get(s as usize).copied().flatten() {
- require(self.regions.get(v).is_some_and(|v| v.void), "a closed inner shell of material encloses a void")?;
- voids.push((v, vec![s]));
- }
- }
- }
- let mut outer = Vec::new();
- for &r in regions {
- let Some(&s) = self.regions.get(r).and_then(|region| region.shells.first()) else { continue };
- let container = around.get(s as usize).copied().unwrap_or(0);
- match voids.iter_mut().find(|(v, _)| *v == container) {
- Some((_, list)) => list.push(s),
- None => outer.push(s),
- }
- }
- let source_regions: Vec<(Vec<u32>, bool)> =
- std::iter::once((outer, false)).chain(kept).chain(voids.into_iter().map(|(_, list)| (list, true))).collect();
- self.renumbered(&source_regions)
- }
-
- /// The record in canonical order (docs/native-brep.md, "Canonical order"), every region and
- /// shell kept, open, wire and vertex shells included, and where each item was in it. For a
- /// record whose parts a builder put together in its own order: each edge's uses are worked
- /// out from the walk (a list that already names exactly those uses keeps its radial order).
- /// A face no shell uses is left out.
- pub fn canonical(&self) -> Result<Part> {
- let regions: Vec<(Vec<u32>, bool)> = self.regions.iter().map(|r| (r.shells.clone(), r.void)).collect();
- self.renumbered(&regions)
- }
-
- /// The record of `source_regions` (each the source shells it lists and whether it is a void,
- /// the infinite region first), renumbered in canonical order.
- fn renumbered(&self, source_regions: &[(Vec<u32>, bool)]) -> Result<Part> {
- // Canonical order: shells and faces walking regions → shells → oriented faces.
- let mut shells = Renumber::new(self.shells.len());
- let mut faces = Renumber::new(self.faces.len());
- let mut direction = vec![true; self.faces.len()];
- let mut new_regions = Vec::with_capacity(source_regions.len());
- for (list, void) in source_regions {
- let mut mapped = Vec::with_capacity(list.len());
- for &s in list {
- mapped.push(shells.visit(s)?);
- if let Some(Shell::Faces { faces: uses, .. }) = self.shells.get(s as usize) {
- for f in uses {
- if faces.get(f.face).is_none()
- && let Some(d) = direction.get_mut(f.face as usize)
- {
- *d = f.forward;
- }
- faces.visit(f.face)?;
- }
- }
- }
- new_regions.push(Region { shells: mapped, void: *void });
- }
- // Edges walking faces → loops → oriented edges (backwards where the face's first side is
- // reversed), then wire edges walking shells.
- // Each edge's first use in that walk is its primary use: (new face, loop, position).
- let mut edges = Renumber::new(self.edges.len());
- let mut walked: Vec<Vec<EdgeUseRef>> = vec![Vec::new(); self.edges.len()];
- for (k, &f) in faces.old.iter().enumerate() {
- let face = self.faces.get(f as usize).ok_or(Invalid("face reference"))?;
- let forward = direction.get(f as usize).copied().unwrap_or(true);
- let k = index(k)?;
- for (li, l) in face.loops.iter().enumerate() {
- let Loop::Edges { edges: uses } = l else { continue };
- let n = uses.len();
- for step in 0..n {
- let p = if forward { step } else { n - 1 - step };
- let u = uses.get(p).ok_or(Invalid("edge reference"))?;
- edges.visit(u.edge)?;
- let at = EdgeUseRef { face: k, r#loop: index(li)?, position: index(p)?, upper: !u.forward };
- walked.get_mut(u.edge as usize).ok_or(Invalid("edge reference"))?.push(at);
- }
- }
- }
- for &s in &shells.old {
- let wires = match self.shells.get(s as usize).ok_or(Invalid("shell reference"))? {
- Shell::Faces { wires, .. } => wires.as_slice(),
- Shell::Wire { edges } => edges.as_slice(),
- Shell::Vertex { .. } => &[],
- };
- for &e in wires {
- edges.visit(e)?;
- }
- }
- // Vertices walking edges (start, end), then vertex loops, then vertex shells.
- let mut vertices = Renumber::new(self.vertices.len());
- for &e in &edges.old {
- for &v in &self.edges.get(e as usize).ok_or(Invalid("edge reference"))?.vertices {
- vertices.visit(v)?;
- }
- }
- for &f in &faces.old {
- for l in &self.faces.get(f as usize).ok_or(Invalid("face reference"))?.loops {
- if let Loop::Vertex { vertex } = l {
- vertices.visit(*vertex)?;
- }
- }
- }
- for &s in &shells.old {
- if let Some(Shell::Vertex { vertex }) = self.shells.get(s as usize) {
- vertices.visit(*vertex)?;
- }
- }
-
- let map = |r: &Renumber, i: u32| r.get(i).ok_or(Invalid("part reference outside the part"));
- let new_shells = shells
- .old
- .iter()
- .map(|&s| {
- Ok(match self.shells.get(s as usize).ok_or(Invalid("shell reference"))? {
- Shell::Faces { faces: uses, wires } => Shell::Faces {
- faces: uses.iter().map(|f| Ok(OrientedFace { face: map(&faces, f.face)?, forward: f.forward })).collect::<Result<_>>()?,
- wires: wires.iter().map(|&e| map(&edges, e)).collect::<Result<_>>()?,
- },
- Shell::Wire { edges: wire } => Shell::Wire { edges: wire.iter().map(|&e| map(&edges, e)).collect::<Result<_>>()? },
- Shell::Vertex { vertex } => Shell::Vertex { vertex: map(&vertices, *vertex)? },
- })
- })
- .collect::<Result<Vec<_>>>()?;
- let new_faces = faces
- .old
- .iter()
- .map(|&f| {
- let mut face = self.faces.get(f as usize).ok_or(Invalid("face reference"))?.clone();
- for l in &mut face.loops {
- match l {
- Loop::Edges { edges: uses } => {
- for u in uses {
- u.edge = map(&edges, u.edge)?;
- }
- }
- Loop::Vertex { vertex } => *vertex = map(&vertices, *vertex)?,
- }
- }
- Ok(face)
- })
- .collect::<Result<Vec<_>>>()?;
- let new_edges = edges
- .old
- .iter()
- .map(|&e| {
- let mut edge = self.edges.get(e as usize).ok_or(Invalid("edge reference"))?.clone();
- edge.vertices = [map(&vertices, edge.vertices[0])?, map(&vertices, edge.vertices[1])?];
- edge.uses = part_uses(&edge.uses, &faces, walked.get(e as usize).map_or(&[][..], Vec::as_slice));
- Ok(edge)
- })
- .collect::<Result<Vec<_>>>()?;
- let new_vertices =
- vertices.old.iter().map(|&v| self.vertices.get(v as usize).cloned().ok_or(Invalid("vertex reference"))).collect::<Result<_>>()?;
- let brep = Brep {
- version: self.version,
- tolerance: self.tolerance,
- regions: new_regions,
- shells: new_shells,
- faces: new_faces,
- edges: new_edges,
- vertices: new_vertices,
- };
- brep.validate_built()?;
- Ok(Part { brep, faces: faces.old, edges: edges.old, vertices: vertices.old })
- }
-}
-
-/// An edge's uses on the part's faces (`walked`: in the canonical walk's order, the first its
-/// primary use): the source's radial cycle with the other faces' uses left out (a sub-cycle keeps
-/// its order), turned to start at the primary use, where the source names exactly the walked
-/// uses; the walk's own order otherwise (a record whose builder left them to be worked out).
-fn part_uses(uses: &[EdgeUseRef], faces: &Renumber, walked: &[EdgeUseRef]) -> Vec<EdgeUseRef> {
- let mut kept: Vec<EdgeUseRef> = uses.iter().filter_map(|u| faces.get(u.face).map(|face| EdgeUseRef { face, ..*u })).collect();
- if kept.len() != walked.len() || !walked.iter().all(|w| kept.contains(w)) {
- return walked.to_vec();
- }
- if let Some(first) = walked.first().and_then(|p| kept.iter().position(|u| u == p)) {
- kept.rotate_left(first);
- }
- kept
-}
-
-fn index(i: usize) -> Result<u32> {
- u32::try_from(i).map_err(|_| Invalid("part index"))
-}
-
-/// Bodies' records joined into one record of all their material, side by side, in canonical
-/// order: what bodies apart from each other are together. The part's `faces`, `edges` and
-/// `vertices` number the inputs one after another (input 0's items first).
-pub fn compound(records: &[&Brep]) -> Result<Part> {
- let mut all = Brep {
- version: super::VERSION,
- tolerance: records.iter().map(|r| r.tolerance).fold(0.0, f64::max),
- regions: vec![Region { shells: Vec::new(), void: false }],
- shells: Vec::new(),
- faces: Vec::new(),
- edges: Vec::new(),
- vertices: Vec::new(),
- };
- for r in records {
- let offset = |n: usize| u32::try_from(n).map_err(|_| Invalid("compound size"));
- let (s0, f0, e0, v0) = (offset(all.shells.len())?, offset(all.faces.len())?, offset(all.edges.len())?, offset(all.vertices.len())?);
- let (infinite, bounded) = r.regions.split_first().ok_or(Invalid("region count"))?;
- if let Some(open) = all.regions.first_mut() {
- open.shells.extend(infinite.shells.iter().map(|s| s + s0));
- }
- all.regions.extend(bounded.iter().map(|region| Region { shells: region.shells.iter().map(|s| s + s0).collect(), void: region.void }));
- all.shells.extend(r.shells.iter().map(|shell| match shell {
- Shell::Faces { faces, wires } => Shell::Faces {
- faces: faces.iter().map(|f| OrientedFace { face: f.face + f0, forward: f.forward }).collect(),
- wires: wires.iter().map(|e| e + e0).collect(),
- },
- Shell::Wire { edges } => Shell::Wire { edges: edges.iter().map(|e| e + e0).collect() },
- Shell::Vertex { vertex } => Shell::Vertex { vertex: vertex + v0 },
- }));
- all.faces.extend(r.faces.iter().map(|f| {
- let mut f = f.clone();
- for l in &mut f.loops {
- match l {
- Loop::Edges { edges } => edges.iter_mut().for_each(|u| u.edge += e0),
- Loop::Vertex { vertex } => *vertex += v0,
- }
- }
- f
- }));
- all.edges.extend(r.edges.iter().map(|e| {
- let mut e = e.clone();
- e.vertices = e.vertices.map(|v| v + v0);
- e.uses.iter_mut().for_each(|u| u.face += f0);
- e
- }));
- all.vertices.extend(r.vertices.iter().cloned());
- }
- all.part(&all.material_regions())
-}
diff --git a/crates/geom/src/brep/pcurve.rs b/crates/geom/src/brep/pcurve.rs
index 1fa54b7aca..1b01c70d30 100644
--- a/crates/geom/src/brep/pcurve.rs
+++ b/crates/geom/src/brep/pcurve.rs
@@ -18,10 +18,11 @@
//! undefined; there it is taken from the nearest sample where it is defined, so a pcurve runs
//! straight into the pole, and where two uses meet at a pole the loop runs along the pole's line.
use super::eval::{CurveEval, SurfaceEval};
-use super::{Budget, Curve, Curve2, Surface, curve, curve_natural, interval, surface};
-use crate::Vec3;
use crate::bspline::{HPoint, segment};
+use crate::prelude::*;
use crate::tess::uv::{self, Domain};
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Budget, Curve, Curve2, Surface, check_curve, check_curve2, check_interval, check_surface};
/// Why no pcurves: the records are malformed or out of bounds (`Invalid`), no pcurve within
/// the tolerance was found or the geometry is not supported (`Failed`), or the fit would exceed
@@ -44,7 +45,7 @@ type Result<T> = std::result::Result<T, Error>;
/// the use's exact pcurve where the producer holds one (`given`, on the use's interval in its
/// curve's direction: a kernel's own UV trim mapped exactly into the record's parameters). A
/// given pcurve is taken as it is, only moved by whole periods with its loop; it is never
-/// checked against the edge or replaced here (`Brep::check_geometry` checks it).
+/// checked against the edge or replaced here (`brep::geometry::check` checks it).
#[derive(Clone, Copy, Debug)]
pub struct EdgeUse<'a> {
pub edge: u32,
@@ -132,7 +133,7 @@ fn check_size(loops: &[Vec<EdgeUse<'_>>], tolerance: f64) -> Result<()> {
/// error, any other error fails the face.
fn each_pcurve(surface_record: &Surface, on: &On, loops: &[Vec<EdgeUse<'_>>], tolerance: f64) -> Result<Vec<Vec<Result<Curve2>>>> {
let mut budget = Budget::input();
- surface(surface_record, 0, &mut budget).map_err(|e| Error::Invalid(e.to_string()))?;
+ check_surface(surface_record, &mut budget).and_then(|()| super::check::surface(surface_record)).map_err(|e| Error::Invalid(e.to_string()))?;
// A seam edge used twice is worked out once.
let mut done: Vec<(u32, Result<Curve2>)> = Vec::new();
let mut out = Vec::with_capacity(loops.len());
@@ -147,8 +148,10 @@ fn each_pcurve(surface_record: &Surface, on: &On, loops: &[Vec<EdgeUse<'_>>], to
pcs.push(pc.clone());
continue;
}
- curve(u.curve, 0, &mut budget).map_err(|e| Error::Invalid(format!("loop {w} use {i}: {e}")))?;
- interval(&u.interval, curve_natural(u.curve)).map_err(|e| Error::Invalid(format!("loop {w} use {i}: {e}")))?;
+ check_curve(u.curve, &mut budget)
+ .and_then(|()| super::check::curve(u.curve))
+ .map_err(|e| Error::Invalid(format!("loop {w} use {i}: {e}")))?;
+ check_interval(&u.interval, u.curve.natural()).map_err(|e| Error::Invalid(format!("loop {w} use {i}: {e}")))?;
let c = CurveEval::new(u.curve)?;
// An edge record that holds a looser tolerance than the face's (another kernel's
// approximated edge) is checked against its own, up to the same cap.
@@ -218,7 +221,7 @@ pub trait Trims {
/// A producer's own pcurve, checked as a record: a valid 2D B-spline on the use's interval
/// (within 10⁻⁹ of its magnitude, the schema's slack for a linear remap's rounding).
fn own_pcurve(c: &Curve2, [t0, t1]: [f64; 2], budget: &mut Budget) -> Result<Curve2> {
- super::curve2::curve2(c, budget).map_err(|e| Error::Invalid(format!("given pcurve: {e}")))?;
+ check_curve2(c, budget).map_err(|e| Error::Invalid(format!("given pcurve: {e}")))?;
let [a, b] = c.interval().ok_or_else(|| Error::Invalid("given pcurve: no interval".into()))?;
let slack = 1e-9 * t0.abs().max(t1.abs()).max(1.0);
if (a - t0).abs() > slack || (b - t1).abs() > slack {
@@ -501,7 +504,7 @@ impl On {
let even = (0..=CHECKS).map(|k| if k == CHECKS { t1 } else { t0 + (t1 - t0) * k as f64 / CHECKS as f64 });
let spans = knots.windows(2).filter_map(|k| Some((*k.first()?, *k.get(1)?))).filter(|(a, b)| a < b).take(1 << 12).map(|(a, b)| 0.5 * (a + b));
even.chain(spans).all(|t| {
- let lifted = pc.eval(t).and_then(|q| self.surface.point(q));
+ let lifted = eval(pc, t).and_then(|q| self.surface.point(q));
matches!((lifted, curve.point(t)), (Some(a), Some(b)) if a.dist(b) <= target)
})
}
@@ -546,7 +549,7 @@ impl On {
let mut ends = Vec::with_capacity(n);
for (c, fwd) in uses.iter() {
let [a, b] = c.interval().ok_or_else(|| Error::Failed("pcurve interval".into()))?;
- let (Some(s), Some(e)) = (c.eval(a), c.eval(b)) else { return Err(Error::Failed("pcurve ends".into())) };
+ let (Some(s), Some(e)) = (eval(c, a), eval(c, b)) else { return Err(Error::Failed("pcurve ends".into())) };
ends.push(if *fwd { (s, e) } else { (e, s) });
}
for d in 0..2 {
@@ -640,7 +643,7 @@ fn area(uses: &[(Curve2, bool)], shift: &[f64], d: usize) -> f64 {
for k in 0..16 {
let f = k as f64 / 16.0;
let t = if *fwd { a + (b - a) * f } else { b - (b - a) * f };
- if let Some(mut q) = c.eval(t) {
+ if let Some(mut q) = eval(c, t) {
if let Some(x) = q.get_mut(d) {
*x += s;
}
@@ -675,6 +678,51 @@ fn move_by(c: &mut Curve2, d: usize, by: f64) {
}
}
+/// The point of pcurve `c` at `t` (`None` outside its interval or for a malformed record).
+pub fn eval(c: &Curve2, t: f64) -> Option<[f64; 2]> {
+ let (knots, h): (&[f64], Vec<[f64; 3]>) = match c {
+ Curve2::Spline { knots, points } => (knots, points.iter().map(|&[u, v]| [u, v, 1.0]).collect()),
+ Curve2::RationalSpline { knots, homogeneous } => (knots, homogeneous.clone()),
+ };
+ let p = knots.len().checked_sub(h.len() + 1)?;
+ let span = crate::bspline::find_span(knots, p, h.len(), t)?;
+ let n = basis(knots, p, span, t)?;
+ let mut s = [0.0; 3];
+ for (j, nj) in n.iter().enumerate() {
+ let q = h.get(span + j - p)?;
+ for (a, x) in s.iter_mut().zip(q) {
+ *a += nj * x;
+ }
+ }
+ (s[2].abs() > 0.0).then(|| [s[0] / s[2], s[1] / s[2]])
+}
+
+/// The `p + 1` basis functions non-zero on knot span `span` at `t`, of any degree (NURBS Book
+/// A2.2).
+fn basis(knots: &[f64], p: usize, span: usize, t: f64) -> Option<Vec<f64>> {
+ if span < p || span + p >= knots.len() {
+ return None;
+ }
+ let k = |i: usize| knots.get(i).copied().unwrap_or(0.0);
+ let mut n = vec![0.0; p + 1];
+ let (mut left, mut right) = (vec![0.0; p + 1], vec![0.0; p + 1]);
+ *n.first_mut()? = 1.0;
+ for j in 1..=p {
+ *left.get_mut(j)? = t - k(span + 1 - j);
+ *right.get_mut(j)? = k(span + j) - t;
+ let mut saved = 0.0;
+ for r in 0..j {
+ let (rr, lj) = (*right.get(r + 1)?, *left.get(j - r)?);
+ let den = rr + lj;
+ let tmp = if den != 0.0 { n.get(r)? / den } else { 0.0 };
+ *n.get_mut(r)? = saved + rr * tmp;
+ saved = lj * tmp;
+ }
+ *n.get_mut(j)? = saved;
+ }
+ Some(n)
+}
+
#[cfg(test)]
#[path = "pcurve_tests.rs"]
pub(super) mod tests;
diff --git a/crates/geom/src/brep/pcurve_tests.rs b/crates/geom/src/brep/pcurve_tests.rs
index f1234eb3f2..07dab842d1 100644
--- a/crates/geom/src/brep/pcurve_tests.rs
+++ b/crates/geom/src/brep/pcurve_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use crate::brep::Frame;
use crate::brep::eval::{CurveEval, SurfaceEval};
+use solidcore_record::brep::Frame;
use std::f64::consts::{FRAC_PI_2, PI, TAU};
fn frame(origin: [f64; 3], x_axis: [f64; 3], y_axis: [f64; 3]) -> Frame {
@@ -24,7 +24,7 @@ fn lift_error(surface: &Surface, curve: &Curve, interval: [f64; 2], pc: &Curve2)
};
let mut ts: Vec<f64> = (0..=64).map(|k| if k == 64 { t1 } else { t0 + (t1 - t0) * k as f64 / 64. }).collect();
ts.extend(knots.windows(2).filter(|k| k[0] < k[1]).map(|k| 0.5 * (k[0] + k[1])));
- ts.iter().map(|&t| s.point(pc.eval(t).unwrap()).unwrap().dist(c.point(t).unwrap())).fold(0., f64::max)
+ ts.iter().map(|&t| s.point(eval(pc, t).unwrap()).unwrap().dist(c.point(t).unwrap())).fold(0., f64::max)
}
fn segment_points(pc: &Curve2) -> [[f64; 2]; 2] {
match pc {
@@ -211,7 +211,7 @@ fn walk(l: &[EdgeUse<'_>], pcs: &[Curve2]) -> (Vec<([f64; 2], [f64; 2])>, f64) {
for (u, pc) in l.iter().zip(pcs) {
let [a, b] = u.interval;
let ts: Vec<f64> = (0..=16).map(|k| if u.forward { a + (b - a) * k as f64 / 16. } else { b - (b - a) * k as f64 / 16. }).collect();
- let pts: Vec<[f64; 2]> = ts.iter().map(|t| pc.eval(*t).unwrap()).collect();
+ let pts: Vec<[f64; 2]> = ts.iter().map(|t| eval(pc, *t).unwrap()).collect();
ends.push((pts[0], pts[16]));
ring.extend_from_slice(&pts[..16]);
}
@@ -267,12 +267,12 @@ fn meridians_run_straight_into_the_poles() {
for pc in pcs {
assert!(lift_error(&sphere, &meridian, half, pc) <= tol);
for k in 0..=16 {
- let q = pc.eval(-FRAC_PI_2 + PI * k as f64 / 16.).unwrap();
- let u = pcs[0].eval(0.).unwrap()[0];
+ let q = eval(pc, -FRAC_PI_2 + PI * k as f64 / 16.).unwrap();
+ let u = eval(&pcs[0], 0.).unwrap()[0];
assert!((q[0] - u).abs() < 1e-9 || ((q[0] - u).abs() - TAU).abs() < 1e-9, "straight: {q:?}");
}
}
- let (a, b) = (pcs[0].eval(0.).unwrap(), pcs[1].eval(0.).unwrap());
+ let (a, b) = (eval(&pcs[0], 0.).unwrap(), eval(&pcs[1], 0.).unwrap());
assert!(((a[0] - b[0]).abs() - TAU).abs() < 1e-9 && (a[1] - b[1]).abs() < 1e-12, "{a:?} {b:?}");
let (_, area) = walk(&l, pcs);
assert!(area > 0., "counter-clockwise: {area}");
@@ -295,7 +295,7 @@ fn meridians_at_a_pole_span_the_face_box() {
EdgeUse { edge: 1, curve: &last, interval: half, forward: flip, tolerance: 0.0, given: None },
];
let pcs = &pcurves_within(&sphere, std::slice::from_ref(&l), 1e-7, Some([box_u, [-FRAC_PI_2, FRAC_PI_2]])).unwrap()[0];
- let (a, b) = (pcs[0].eval(0.).unwrap()[0], pcs[1].eval(0.).unwrap()[0]);
+ let (a, b) = (eval(&pcs[0], 0.).unwrap()[0], eval(&pcs[1], 0.).unwrap()[0]);
assert!(((a - b).abs() - span).abs() < 1e-9, "box {box_u:?}, flip {flip}: u {a} and {b}");
}
}
@@ -348,7 +348,7 @@ fn a_seam_from_pole_to_pole_encloses_the_whole_sphere() {
assert!(lift_error(on, seam, iv, pc) <= tol, "{what}");
}
let mid = 0.5 * (iv[0] + iv[1]);
- let (a, b) = (pcs[0].eval(mid).unwrap(), pcs[1].eval(mid).unwrap());
+ let (a, b) = (eval(&pcs[0], mid).unwrap(), eval(&pcs[1], mid).unwrap());
assert!(((a[0] - b[0]).abs() - period).abs() < 1e-6 && (a[1] - b[1]).abs() < 1e-12, "a period apart: {a:?} {b:?} {what}");
let (ends, area) = walk(&l, pcs);
for k in 0..2 {
@@ -405,7 +405,7 @@ fn closes_around_the_box(surface: &Surface, l: &[EdgeUse<'_>], seam: [usize; 2],
}
let iv = l[seam[0]].interval;
let mid = 0.5 * (iv[0] + iv[1]);
- let (a, b) = (pcs[seam[0]].eval(mid).unwrap(), pcs[seam[1]].eval(mid).unwrap());
+ let (a, b) = (eval(&pcs[seam[0]], mid).unwrap(), eval(&pcs[seam[1]], mid).unwrap());
let dom = SurfaceEval::new(surface).unwrap().domain();
let period = dom.period[0].unwrap();
assert!(((a[0] - b[0]).abs() - period).abs() < 1e-9 && (a[1] - b[1]).abs() < 1e-9, "{what}: seam uses a period apart: {a:?} {b:?}");
@@ -426,7 +426,7 @@ fn closes_around_the_box(surface: &Surface, l: &[EdgeUse<'_>], seam: [usize; 2],
let (Curve2::Spline { knots, .. } | Curve2::RationalSpline { knots, .. }) = pc;
for k in 0..=32 {
let t = knots[0] + (knots[knots.len() - 1] - knots[0]) * k as f64 / 32.;
- let q = pc.eval(t).unwrap();
+ let q = eval(pc, t).unwrap();
assert!((u.0 - 1e-9..=u.1 + 1e-9).contains(&q[0]), "{what}: base period: {q:?}");
}
}
diff --git a/crates/geom/src/brep/placement.rs b/crates/geom/src/brep/placement.rs
index 52fb39c27e..52f4befe0d 100644
--- a/crates/geom/src/brep/placement.rs
+++ b/crates/geom/src/brep/placement.rs
@@ -3,7 +3,7 @@
//! they are, because a rigid motion keeps distances, angles and handedness. The moved record is
//! the same B-rep in other coordinates, exactly. Reflections and scalings change parameters or
//! geometry kinds; they are a kernel operation, not this.
-use super::{Brep, Curve, Frame, Surface};
+use solidcore_record::brep::{Brep, Curve, Frame, Surface};
/// A rotation (rows of an orthonormal matrix with determinant +1) and a translation:
/// `p ↦ rotation · p + translation`.
@@ -134,21 +134,19 @@ fn compose(a: &[[f64; 4]; 4], b: &[[f64; 4]; 4]) -> [[f64; 4]; 4] {
out
}
-impl Brep {
- /// This record moved by `motion` (module docs): topology, parameters and pcurves unchanged.
- pub fn moved(&self, motion: &Rigid) -> Brep {
- let mut out = self.clone();
- for f in &mut out.faces {
- f.surface = motion.surface(&f.surface);
- f.nurbs = f.nurbs.as_ref().map(|n| motion.surface(n));
- }
- for e in &mut out.edges {
- e.curve = motion.curve(&e.curve);
- e.nurbs = e.nurbs.as_ref().map(|n| motion.curve(n));
- }
- for v in &mut out.vertices {
- v.point = motion.point(v.point);
- }
- out
+/// This record moved by `motion` (module docs): topology, parameters and pcurves unchanged.
+pub fn moved(brep: &Brep, motion: &Rigid) -> Brep {
+ let mut out = brep.clone();
+ for f in &mut out.faces {
+ f.surface = motion.surface(&f.surface);
+ f.nurbs = f.nurbs.as_ref().map(|n| motion.surface(n));
}
+ for e in &mut out.edges {
+ e.curve = motion.curve(&e.curve);
+ e.nurbs = e.nurbs.as_ref().map(|n| motion.curve(n));
+ }
+ for v in &mut out.vertices {
+ v.point = motion.point(v.point);
+ }
+ out
}
diff --git a/crates/geom/src/brep/split.rs b/crates/geom/src/brep/split.rs
index 66cc3d5c37..6cab60ad3c 100644
--- a/crates/geom/src/brep/split.rs
+++ b/crates/geom/src/brep/split.rs
@@ -4,99 +4,97 @@
//! ([`crate::bspline::segment`]: the same points at the same parameters). What a sheet needs so
//! that another sheet's vertex on one of its edges is a vertex of both (no T-junction).
use super::eval::CurveEval;
-use super::part::Part;
-use super::{Brep, Curve2, Edge, Invalid, Loop, OrientedEdge, Result, Shell, Vertex};
use crate::bspline::{HPoint, segment};
+use solidcore_record::brep::part::Part;
+use solidcore_record::brep::{Brep, Curve2, Edge, Invalid, Loop, OrientedEdge, Result, Shell, Vertex};
-impl Brep {
- /// The record with edge `e` split at each `t` of `at` (`(e, t)`, `t` strictly inside the edge's
- /// interval), in canonical order. The part's `edges` name, for each edge, the source edge it is
- /// (a piece of); its `vertices` the source vertex, or for a vertex made at a split
- /// `self.vertices.len()` plus its number among the splits (sorted by edge, then parameter).
- pub fn split_edges(&self, at: &[(u32, f64)]) -> Result<Part> {
- let mut cuts: Vec<Vec<f64>> = vec![Vec::new(); self.edges.len()];
- for &(e, t) in at {
- let edge = self.edges.get(e as usize).ok_or(Invalid("split edge reference"))?;
- let [a, b] = edge.interval;
- if !(t > a && t < b) {
- return Err(Invalid("a split parameter is not inside its edge"));
- }
- cuts.get_mut(e as usize).ok_or(Invalid("split edge reference"))?.push(t);
+/// The record with edge `e` split at each `t` of `at` (`(e, t)`, `t` strictly inside the edge's
+/// interval), in canonical order. The part's `edges` name, for each edge, the source edge it is
+/// (a piece of); its `vertices` the source vertex, or for a vertex made at a split
+/// `brep.vertices.len()` plus its number among the splits (sorted by edge, then parameter).
+pub fn split_edges(brep: &Brep, at: &[(u32, f64)]) -> Result<Part> {
+ let mut cuts: Vec<Vec<f64>> = vec![Vec::new(); brep.edges.len()];
+ for &(e, t) in at {
+ let edge = brep.edges.get(e as usize).ok_or(Invalid("split edge reference"))?;
+ let [a, b] = edge.interval;
+ if !(t > a && t < b) {
+ return Err(Invalid("a split parameter is not inside its edge"));
}
- // Each source edge's pieces: (new edge index, interval), and the new vertices.
- let mut vertices: Vec<Vertex> = self.vertices.clone();
- let mut edges: Vec<Edge> = Vec::with_capacity(self.edges.len() + at.len());
- let mut source: Vec<u32> = Vec::with_capacity(self.edges.len() + at.len());
- let mut pieces: Vec<Vec<(u32, [f64; 2])>> = Vec::with_capacity(self.edges.len());
- for (e, (edge, ts)) in self.edges.iter().zip(cuts.iter_mut()).enumerate() {
- ts.sort_by(f64::total_cmp);
- ts.dedup();
- let curve = if ts.is_empty() { None } else { Some(CurveEval::new(edge.parameters()).map_err(|_| Invalid("a split edge's curve"))?) };
- let [a, b] = edge.interval;
- let mut ends = vec![edge.vertices[0]];
- for &t in ts.iter() {
- let p = curve.as_ref().and_then(|c| c.point(t)).ok_or(Invalid("a split edge has no point there"))?;
- ends.push(index(vertices.len())?);
- vertices.push(Vertex { point: [p.x, p.y, p.z], tolerance: edge.tolerance });
- }
- ends.push(edge.vertices[1]);
- let bounds: Vec<f64> = std::iter::once(a).chain(ts.iter().copied()).chain(std::iter::once(b)).collect();
- let mut list = Vec::with_capacity(bounds.len() - 1);
- for (k, w) in bounds.windows(2).enumerate() {
- let interval = [w[0], w[1]];
- let (Some(&from), Some(&to)) = (ends.get(k), ends.get(k + 1)) else { return Err(Invalid("split ends")) };
- list.push((index(edges.len())?, interval));
- edges.push(Edge { interval, vertices: [from, to], uses: Vec::new(), ..edge.clone() });
- source.push(index(e)?);
- }
- pieces.push(list);
+ cuts.get_mut(e as usize).ok_or(Invalid("split edge reference"))?.push(t);
+ }
+ // Each source edge's pieces: (new edge index, interval), and the new vertices.
+ let mut vertices: Vec<Vertex> = brep.vertices.clone();
+ let mut edges: Vec<Edge> = Vec::with_capacity(brep.edges.len() + at.len());
+ let mut source: Vec<u32> = Vec::with_capacity(brep.edges.len() + at.len());
+ let mut pieces: Vec<Vec<(u32, [f64; 2])>> = Vec::with_capacity(brep.edges.len());
+ for (e, (edge, ts)) in brep.edges.iter().zip(cuts.iter_mut()).enumerate() {
+ ts.sort_by(f64::total_cmp);
+ ts.dedup();
+ let curve = if ts.is_empty() { None } else { Some(CurveEval::new(edge.parameters()).map_err(|_| Invalid("a split edge's curve"))?) };
+ let [a, b] = edge.interval;
+ let mut ends = vec![edge.vertices[0]];
+ for &t in ts.iter() {
+ let p = curve.as_ref().and_then(|c| c.point(t)).ok_or(Invalid("a split edge has no point there"))?;
+ ends.push(index(vertices.len())?);
+ vertices.push(Vertex { point: [p.x, p.y, p.z], tolerance: edge.tolerance });
+ }
+ ends.push(edge.vertices[1]);
+ let bounds: Vec<f64> = std::iter::once(a).chain(ts.iter().copied()).chain(std::iter::once(b)).collect();
+ let mut list = Vec::with_capacity(bounds.len() - 1);
+ for (k, w) in bounds.windows(2).enumerate() {
+ let interval = [w[0], w[1]];
+ let (Some(&from), Some(&to)) = (ends.get(k), ends.get(k + 1)) else { return Err(Invalid("split ends")) };
+ list.push((index(edges.len())?, interval));
+ edges.push(Edge { interval, vertices: [from, to], uses: Vec::new(), ..edge.clone() });
+ source.push(index(e)?);
}
- let piece_list = |e: u32| pieces.get(e as usize).ok_or(Invalid("split edge reference"));
- let mut faces = self.faces.clone();
- for face in &mut faces {
- for l in &mut face.loops {
- let Loop::Edges { edges: uses } = l else { continue };
- let mut out = Vec::with_capacity(uses.len());
- for u in uses.iter() {
- let list = piece_list(u.edge)?;
- let cut = |&(edge, [t0, t1]): &(u32, [f64; 2])| -> Result<OrientedEdge> {
- let pcurve = if list.len() == 1 { u.pcurve.clone() } else { cut_pcurve(&u.pcurve, t0, t1)? };
- Ok(OrientedEdge { edge, forward: u.forward, pcurve })
- };
- if u.forward {
- for p in list {
- out.push(cut(p)?);
- }
- } else {
- for p in list.iter().rev() {
- out.push(cut(p)?);
- }
+ pieces.push(list);
+ }
+ let piece_list = |e: u32| pieces.get(e as usize).ok_or(Invalid("split edge reference"));
+ let mut faces = brep.faces.clone();
+ for face in &mut faces {
+ for l in &mut face.loops {
+ let Loop::Edges { edges: uses } = l else { continue };
+ let mut out = Vec::with_capacity(uses.len());
+ for u in uses.iter() {
+ let list = piece_list(u.edge)?;
+ let cut = |&(edge, [t0, t1]): &(u32, [f64; 2])| -> Result<OrientedEdge> {
+ let pcurve = if list.len() == 1 { u.pcurve.clone() } else { cut_pcurve(&u.pcurve, t0, t1)? };
+ Ok(OrientedEdge { edge, forward: u.forward, pcurve })
+ };
+ if u.forward {
+ for p in list {
+ out.push(cut(p)?);
+ }
+ } else {
+ for p in list.iter().rev() {
+ out.push(cut(p)?);
}
}
- *uses = out;
}
+ *uses = out;
}
- let pieces_of = |wires: &[u32]| -> Result<Vec<u32>> {
- Ok(wires.iter().map(|e| piece_list(*e)).collect::<Result<Vec<_>>>()?.into_iter().flatten().map(|p| p.0).collect())
- };
- let shells = self
- .shells
- .iter()
- .map(|s| {
- Ok(match s {
- Shell::Faces { faces, wires } => Shell::Faces { faces: faces.clone(), wires: pieces_of(wires)? },
- Shell::Wire { edges } => Shell::Wire { edges: pieces_of(edges)? },
- Shell::Vertex { vertex } => Shell::Vertex { vertex: *vertex },
- })
+ }
+ let pieces_of = |wires: &[u32]| -> Result<Vec<u32>> {
+ Ok(wires.iter().map(|e| piece_list(*e)).collect::<Result<Vec<_>>>()?.into_iter().flatten().map(|p| p.0).collect())
+ };
+ let shells = brep
+ .shells
+ .iter()
+ .map(|s| {
+ Ok(match s {
+ Shell::Faces { faces, wires } => Shell::Faces { faces: faces.clone(), wires: pieces_of(wires)? },
+ Shell::Wire { edges } => Shell::Wire { edges: pieces_of(edges)? },
+ Shell::Vertex { vertex } => Shell::Vertex { vertex: *vertex },
})
- .collect::<Result<Vec<_>>>()?;
- let loose = Brep { version: self.version, tolerance: self.tolerance, regions: self.regions.clone(), shells, faces, edges, vertices };
- let mut part = loose.canonical()?;
- for e in &mut part.edges {
- *e = source.get(*e as usize).copied().ok_or(Invalid("split edge reference"))?;
- }
- Ok(part)
+ })
+ .collect::<Result<Vec<_>>>()?;
+ let loose = Brep { version: brep.version, tolerance: brep.tolerance, regions: brep.regions.clone(), shells, faces, edges, vertices };
+ let mut part = loose.canonical()?;
+ for e in &mut part.edges {
+ *e = source.get(*e as usize).copied().ok_or(Invalid("split edge reference"))?;
}
+ Ok(part)
}
/// A pcurve's piece on `[t0, t1]`, a sub-interval of its own.
diff --git a/crates/geom/src/brep/tests.rs b/crates/geom/src/brep/tests.rs
index 5cc90dbff8..1cbbdb0650 100644
--- a/crates/geom/src/brep/tests.rs
+++ b/crates/geom/src/brep/tests.rs
@@ -1,4 +1,6 @@
use super::*;
+use crate::prelude::*;
+use solidcore_record::brep::*;
use std::f64::consts::{FRAC_PI_2, TAU};
fn segment(a: f64, b: f64) -> Curve2 {
@@ -285,8 +287,8 @@ fn every_form_validates_and_round_trips_without_a_kernel() {
("seam from pole to pole", ball()),
("lower forms", sheet_with_lower_forms()),
] {
- body.validate().unwrap_or_else(|e| panic!("{name}: {e}"));
- body.check_geometry().unwrap_or_else(|e| panic!("{name}: {e}"));
+ check::validate(&body).unwrap_or_else(|e| panic!("{name}: {e}"));
+ geometry::check(&body).unwrap_or_else(|e| panic!("{name}: {e}"));
let bytes = serde_json::to_vec(&body).unwrap();
let restored: Brep = serde_json::from_slice(&bytes).unwrap();
assert_eq!(body, restored, "{name}");
@@ -294,90 +296,11 @@ fn every_form_validates_and_round_trips_without_a_kernel() {
}
}
-/// One defect each; every one is refused.
+/// One defect each on a record with NURBS forms; every one is refused (the rest are the
+/// record's own tests).
#[test]
-fn one_defect_fixtures_are_refused() {
+fn one_defect_fixtures_on_forms_are_refused() {
let cases: Vec<(&str, &str, Brep)> = vec![
- ("version", "unsupported version", {
- let mut b = sheet();
- b.version = 3;
- b
- }),
- ("tolerance", "tolerance", {
- let mut b = sheet();
- b.tolerance = f64::NAN;
- b
- }),
- ("vertex tolerance", "tolerance", {
- let mut b = sheet();
- b.vertices[0].tolerance = 0.;
- b
- }),
- ("coordinate", "non-finite or excessive coordinate", {
- let mut b = sheet();
- b.vertices[0].point[0] = f64::INFINITY;
- b
- }),
- ("edge reference", "edge reference", {
- let mut b = sheet();
- if let Loop::Edges { edges } = &mut b.faces[0].loops[0] {
- edges[0].edge = u32::MAX;
- }
- b
- }),
- ("edge vertices", "edge vertices", {
- let mut b = sheet();
- b.edges[0].vertices[0] = u32::MAX;
- b
- }),
- ("disconnected loop", "disconnected loop", {
- let mut b = sheet();
- if let Loop::Edges { edges } = &mut b.faces[0].loops[0] {
- edges.swap(1, 2);
- }
- list_uses(&mut b);
- b
- }),
- ("reversed use", "disconnected loop", {
- let mut b = sheet();
- if let Loop::Edges { edges } = &mut b.faces[0].loops[0] {
- edges[1].forward = false;
- }
- list_uses(&mut b);
- b
- }),
- ("outer vertex loop", "outer loop is not an edge loop", {
- let mut b = sheet_with_lower_forms();
- b.faces[0].loops.swap(0, 1);
- b
- }),
- ("missing use", "edge uses do not list the edge's uses", {
- let mut b = tetra();
- b.edges[0].uses.pop();
- b
- }),
- ("repeated use", "edge use listed twice or not a use of the edge", {
- let mut b = tetra();
- let first = b.edges[0].uses[0];
- b.edges[0].uses[1] = first;
- b
- }),
- ("primary not first", "edge's primary use is not its first", {
- let mut b = tetra();
- b.edges[0].uses.reverse();
- b
- }),
- ("upper", "edge use listed twice or not a use of the edge", {
- let mut b = tetra();
- b.edges[0].uses[1].upper = !b.edges[0].uses[1].upper;
- b
- }),
- ("wire edge with uses", "wire edge with face uses", {
- let mut b = sheet_with_lower_forms();
- let u = b.edges[0].uses[0];
- b.edges[4].uses.push(u);
- b
- }),
("pcurve interval", "pcurve interval differs from its edge's", {
let mut b = tube();
if let Loop::Edges { edges } = &mut b.faces[0].loops[0] {
@@ -390,17 +313,6 @@ fn one_defect_fixtures_are_refused() {
b.edges[0].interval = [0., 4.1];
b
}),
- ("edge interval outside a spline", "parameter interval outside the natural domain", {
- let mut b = sheet();
- b.edges[0].curve = Curve::Spline { knots: vec![0., 0., 1., 1.], points: vec![SQUARE[0], SQUARE[1]] };
- b.edges[0].interval = [0., 1.5];
- b
- }),
- ("empty edge interval", "empty parameter interval", {
- let mut b = sheet();
- b.edges[0].interval = [1., 1.];
- b
- }),
("face domain outside the sphere", "parameter interval outside the natural domain", {
let mut b = sheet();
formed(&mut b, Surface::Sphere { frame: a_frame(), radius: 2. }, [[0., TAU], [-FRAC_PI_2, FRAC_PI_2]]);
@@ -412,98 +324,6 @@ fn one_defect_fixtures_are_refused() {
b.faces[0].domain[0] = [0., 4.1];
b
}),
- ("face domain outside a spline surface", "parameter interval outside the natural domain", {
- let mut b = sheet();
- b.faces[0].surface = Surface::Spline {
- u_knots: vec![0., 0., 1., 1.],
- v_knots: vec![0., 0., 1., 1.],
- points: vec![vec![[0.; 3], [0., 1., 0.]], vec![[1., 0., 0.], [1., 1., 0.]]],
- };
- b
- }),
- ("edges out of order", "edges out of canonical order", {
- let mut b = sheet();
- b.edges.swap(0, 1);
- for f in &mut b.faces {
- for l in &mut f.loops {
- if let Loop::Edges { edges } = l {
- for u in edges {
- u.edge = [1, 0, 2, 3][u.edge as usize];
- }
- }
- }
- }
- list_uses(&mut b);
- b
- }),
- ("vertices out of order", "vertices out of canonical order", {
- let mut b = sheet();
- b.vertices.swap(0, 1);
- for e in &mut b.edges {
- e.vertices = e.vertices.map(|v| [1, 0, 2, 3][v as usize]);
- }
- b
- }),
- ("faces out of order", "faces out of canonical order", {
- let mut b = tetra();
- if let Shell::Faces { faces, .. } = &mut b.shells[0] {
- faces.swap(0, 1);
- }
- b
- }),
- ("orphan vertex", "vertices out of canonical order", {
- let mut b = sheet();
- b.vertices.push(Vertex { point: [9.; 3], tolerance: 1e-7 });
- b
- }),
- ("shell twice in a region", "shell listed twice in a region", {
- // The void lists its one shell twice: still within the shell count.
- let mut b = hollow();
- let void = b.regions.last_mut().unwrap();
- void.shells.push(void.shells[0]);
- b
- }),
- ("void infinite region", "the infinite region is a void", {
- let mut b = sheet();
- b.regions[0].void = true;
- b
- }),
- ("open outer shell", "an open, wire or vertex shell lies in one region", {
- let mut b = sheet();
- b.regions.push(Region { shells: vec![0], void: false });
- b
- }),
- ("closed shell in one region", "a closed shell bounds two regions and encloses one", {
- let mut b = tetra();
- b.regions.pop();
- b
- }),
- ("bounded region without shells", "bounded region without an outer shell", {
- let mut b = tetra();
- b.regions.push(Region { shells: vec![], void: true });
- b
- }),
- ("unlisted shell", "a closed shell bounds two regions and encloses one", {
- let mut b = hollow();
- b.regions[1].shells.pop();
- b.regions.pop();
- b
- }),
- ("face used three times", "face used by neither one nor two oriented faces", {
- let mut b = tetra();
- if let Shell::Faces { faces, .. } = &mut b.shells[0] {
- faces.push(OrientedFace { face: 0, forward: false });
- faces.push(OrientedFace { face: 0, forward: true });
- }
- b
- }),
- ("face twice in one shell", "a face's two sides", {
- let mut b = tetra();
- if let Shell::Faces { faces, .. } = &mut b.shells[0] {
- faces.push(OrientedFace { face: 0, forward: false });
- }
- b
- }),
("cone domain past its apex", "parameter interval outside the natural domain", {
let mut b = sheet();
formed(&mut b, Surface::Cone { frame: a_frame(), radius_at_origin: 1., half_angle: 0.25 * std::f64::consts::PI }, [[0., 1.], [-1., 1.]]);
@@ -512,7 +332,7 @@ fn one_defect_fixtures_are_refused() {
}),
];
for (name, expected, body) in cases {
- let error = body.validate().err().unwrap_or_else(|| panic!("{name} was accepted"));
+ let error = check::validate(&body).err().unwrap_or_else(|| panic!("{name} was accepted"));
assert_eq!(error.0, expected, "{name}");
}
}
@@ -545,8 +365,8 @@ fn a_pcurve_a_rounding_short_of_its_edge_is_read_at_its_end() {
for k in knots.iter_mut().filter(|k| **k == end) {
*k = short;
}
- b.validate().unwrap();
- b.check_geometry().unwrap();
+ check::validate(&b).unwrap();
+ geometry::check(&b).unwrap();
}
/// One geometric defect each, structurally valid: every one is refused, naming the record.
@@ -573,7 +393,7 @@ fn geometric_defects_are_refused_by_record() {
("pcurve bowed off its edge", Record::Use { face: 0, r#loop: 0, position: 0 }, Box::new(off("pcurve middle lifts off its edge's curve")), {
let mut b = sheet();
let pc = pcurve_of(&mut b, 0, 0);
- let (a, z) = (pc.eval(0.).unwrap(), pc.eval(1.).unwrap());
+ let (a, z) = (pcurve::eval(pc, 0.).unwrap(), pcurve::eval(pc, 1.).unwrap());
let middle = [0.5 * (a[0] + z[0]), 0.5 * (a[1] + z[1]) + 0.1];
*pc = Curve2::Spline { knots: vec![0., 0., 0., 1., 1., 1.], points: vec![a, middle, z] };
b
@@ -613,7 +433,7 @@ fn geometric_defects_are_refused_by_record() {
}),
{
let mut b = ball();
- let mid = |b: &mut Brep, k: usize| pcurve_of(b, 0, k).eval(0.).unwrap()[0];
+ let mid = |b: &mut Brep, k: usize| pcurve::eval(pcurve_of(b, 0, k), 0.).unwrap()[0];
let by = mid(&mut b, 0) - mid(&mut b, 1);
// On the sphere's NURBS form one turn is four quarters.
assert!((by.abs() - 4.).abs() < 1e-9, "a period apart: {by}");
@@ -641,8 +461,8 @@ fn geometric_defects_are_refused_by_record() {
),
];
for (name, record, problem, body) in cases {
- body.validate().unwrap_or_else(|e| panic!("{name}: structurally valid: {e}"));
- let error = body.check_geometry().err().unwrap_or_else(|| panic!("{name} was accepted"));
+ check::validate(&body).unwrap_or_else(|e| panic!("{name}: structurally valid: {e}"));
+ let error = geometry::check(&body).err().unwrap_or_else(|| panic!("{name} was accepted"));
assert_eq!(error.record, record, "{name}: {error}");
assert!(problem(&error.problem), "{name}: {error}");
}
@@ -689,160 +509,41 @@ fn hostile_records_never_panic_the_geometry_check() {
b.faces[0].surface = Surface::PlacedRevolution { profile: circle, origin: [0.; 3], axis: [0., 0., 1.], matrix: identity, forward: true };
cases.push(b);
for (i, b) in cases.iter().enumerate() {
- let checked = std::panic::catch_unwind(|| b.check_geometry());
+ let checked = std::panic::catch_unwind(|| geometry::check(b));
assert!(matches!(checked, Ok(Err(_))), "case {i}: {checked:?}");
}
}
+/// The record's geometric records the kernel checks, which the record's structural validation
+/// leaves alone: frames, planes, placements and a cone's apex.
#[test]
-fn a_reversed_face_is_walked_backwards() {
- // The sheet seen from below: its first (only) side is reversed, so the canonical walk
- // meets its loop's edges last to first.
- let mut b = sheet();
- if let Shell::Faces { faces, .. } = &mut b.shells[0] {
- faces[0].forward = false;
- }
- assert!(b.validate().is_err());
- // Renumber the edges (and vertices) in the backward walk's order.
- let Loop::Edges { edges } = &mut b.faces[0].loops[0] else { panic!("an edge loop") };
- let order: Vec<u32> = edges.iter().rev().map(|u| u.edge).collect();
- let mut new = vec![0; order.len()];
- for (i, e) in order.iter().enumerate() {
- new[*e as usize] = i as u32;
- }
- for u in edges.iter_mut() {
- u.edge = new[u.edge as usize];
- }
- let mut edges_ = b.edges.clone();
- for (old, e) in b.edges.iter().enumerate() {
- edges_[new[old] as usize] = e.clone();
- }
- b.edges = edges_;
- let mut seen = Vec::new();
- for e in &b.edges {
- for v in e.vertices {
- if !seen.contains(&v) {
- seen.push(v);
- }
- }
- }
- let vertices = seen.iter().map(|&v| b.vertices[v as usize].clone()).collect();
- b.vertices = vertices;
- for e in &mut b.edges {
- e.vertices = e.vertices.map(|v| seen.iter().position(|&s| s == v).unwrap() as u32);
- }
- for e in &mut b.edges {
- e.uses.clear();
- }
- let Loop::Edges { edges } = &b.faces[0].loops[0] else { panic!("an edge loop") };
- for (p, u) in edges.iter().enumerate().rev() {
- b.edges[u.edge as usize].uses.push(EdgeUseRef { face: 0, r#loop: 0, position: p as u32, upper: !u.forward });
- }
- b.validate().unwrap();
-}
-
-/// A valid record of more than [`MAX_ITEMS`] items: the sheet with its first edge a polyline of
-/// that many points (#3992).
-fn over_the_item_budget() -> Brep {
- let mut b = sheet();
- b.edges[0].curve = Curve::Polyline { points: (0..MAX_ITEMS).map(|i| [i as f64 * 1e-6, 0., 0.]).collect() };
- b
-}
-
-#[test]
-fn the_item_budget_bounds_input_records_and_not_the_kernels_own() {
- // A record from a file or the control channel is refused past the budget; the same record
- // built by the kernel in memory (a boolean's result) is its own size and is taken (#3992).
- let big = over_the_item_budget();
- assert_eq!(big.validate().map_err(|e| e.0), Err("item budget"));
- big.validate_built().unwrap();
- // Every other check still holds for a built record.
- let mut collapsed = big;
- if let Curve::Polyline { points } = &mut collapsed.edges[0].curve {
- points[1] = points[0];
- }
- assert_eq!(collapsed.validate_built().map_err(|e| e.0), Err("collapsed polyline segment"));
-}
-
-#[test]
-fn spline_domains_weights_and_nesting_are_bounded() {
- let mut budget = Budget::input();
- assert!(knots(&[0., 0., 1., 1.], 2, &mut budget).is_ok());
- for bad in [vec![0., 0., 0., 0.], vec![0., 1., 0., 1.], vec![0., 0., f64::INFINITY, 1.]] {
- assert!(knots(&bad, 2, &mut Budget::input()).is_err());
- }
- let c = Curve::RationalSpline { knots: vec![0., 0., 1., 1.], homogeneous: vec![[0., 0., 0., 0.], [1., 0., 0., 1.]] };
- assert!(curve(&c, 0, &mut Budget::input()).is_err());
+fn frames_planes_placements_and_apexes_are_the_kernels() {
+ let f = a_frame();
+ let mut skewed = f.clone();
+ skewed.y_axis = skewed.x_axis;
+ assert!(check::frame(&f).is_ok());
+ assert_eq!(check::frame(&skewed).map_err(|e| e.0), Err("nonorthonormal frame"));
let p = Surface::Plane { origin: [0.; 3], u_axis: [1., 0., 0.], v_axis: [2., 0., 0.] };
- assert!(surface(&p, 0, &mut Budget::input()).is_err());
- assert!(curve(&Curve::Line { start: [0.; 3], end: [1.; 3] }, MAX_DEPTH + 1, &mut Budget::input()).is_err());
- assert!(Budget { used: MAX_ITEMS, limit: MAX_ITEMS }.add(1).is_err());
- assert_eq!(curve_natural(&Curve::Spline { knots: vec![0., 0., 0., 1., 2., 2., 2.], points: vec![[0.; 3]; 4] }), Natural::Range(0., 2.));
-}
-
-#[test]
-fn exact_procedural_records_are_validated_and_round_trip() {
- let plane = |z: f64| Box::new(Surface::Plane { origin: [0., 0., z], u_axis: [1., 0., 0.], v_axis: [0., 1., 0.] });
- let leader = Box::new(Curve::Polyline { points: vec![[0.; 3], [0.; 3], [1., 0., 0.]] });
- let c = Curve::SurfaceIntersection { surfaces: [plane(0.), plane(1.)], leader: leader.clone(), tolerance: 1e-6 };
- curve(&c, 0, &mut Budget::input()).unwrap();
- assert_eq!(curve_natural(&c), Natural::Range(0., 2.));
- assert_eq!(serde_json::from_str::<Curve>(&serde_json::to_string(&c).unwrap()).unwrap(), c);
+ assert_eq!(check::surface(&p).map_err(|e| e.0), Err("degenerate plane"));
let line = Box::new(Curve::Line { start: [0.; 3], end: [1.; 3] });
- for bad in [
- Curve::SurfaceIntersection { surfaces: [plane(0.), plane(1.)], leader: line.clone(), tolerance: 1e-6 },
- Curve::SurfaceIntersection { surfaces: [plane(0.), plane(1.)], leader: leader.clone(), tolerance: f64::NAN },
- Curve::SurfaceIntersection { surfaces: [plane(f64::INFINITY), plane(1.)], leader, tolerance: 1e-6 },
- ] {
- assert!(curve(&bad, 0, &mut Budget::input()).is_err());
- }
let identity = [[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]];
let s = Surface::PlacedRevolution { profile: line.clone(), origin: [0.; 3], axis: [0., 0., 1.], matrix: identity, forward: false };
- surface(&s, 0, &mut Budget::input()).unwrap();
- assert_eq!(surface_natural(&s), [Natural::Periodic, UNBOUNDED]);
- assert_eq!(serde_json::from_str::<Surface>(&serde_json::to_string(&s).unwrap()).unwrap(), s);
+ check::surface(&s).unwrap();
+ assert_eq!(label::surface_natural(&s), [Natural::Periodic, UNBOUNDED]);
let mut flat = identity;
flat[2] = [0.; 4];
let bad = Surface::PlacedRevolution { profile: line, origin: [0.; 3], axis: [0., 0., 1.], matrix: flat, forward: true };
- assert!(surface(&bad, 0, &mut Budget::input()).is_err());
-}
-
-#[test]
-fn analytic_records_are_unbounded_with_independent_frames() {
- let f = a_frame();
- let surfaces = [
- Surface::Cylinder { frame: f.clone(), radius: 2. },
- Surface::Cone { frame: f.clone(), radius_at_origin: 2., half_angle: 0.2 },
- Surface::Cone { frame: f.clone(), radius_at_origin: 2., half_angle: -0.2 },
- Surface::Sphere { frame: f.clone(), radius: 2. },
- Surface::Torus { frame: f.clone(), major_radius: 4., minor_radius: 1., tube_start: 0.0 },
- ];
+ assert_eq!(check::surface(&bad).map_err(|e| e.0), Err("singular revolution placement"));
// A cone narrowing along z (a negative half angle, as SMLib makes them) lies below its apex.
let apex = 2. / 0.2f64.tan();
- let narrowing = Surface::Cone { frame: f.clone(), radius_at_origin: 2., half_angle: -0.2 };
- assert_eq!(surface_natural(&narrowing)[1], Natural::Range(f64::NEG_INFINITY, apex));
- for flat in [0., 1e-13, -1e-13, std::f64::consts::FRAC_PI_2, -std::f64::consts::FRAC_PI_2] {
- assert!(surface(&Surface::Cone { frame: f.clone(), radius_at_origin: 2., half_angle: flat }, 0, &mut Budget::input()).is_err());
- }
- for s in surfaces {
- surface(&s, 0, &mut Budget::input()).unwrap();
- let encoded = serde_json::to_string(&s).unwrap();
- assert_eq!(serde_json::from_str::<Surface>(&encoded).unwrap(), s);
- assert!(!encoded.contains("\"angle\"") && !encoded.contains("height") && !encoded.contains("longitude"));
- }
- for c in [Curve::Circle { frame: f.clone(), radius: 2. }, Curve::Ellipse { frame: f.clone(), radii: [2., 3.] }] {
- curve(&c, 0, &mut Budget::input()).unwrap();
- assert_eq!(serde_json::from_str::<Curve>(&serde_json::to_string(&c).unwrap()).unwrap(), c);
- assert_eq!(curve_natural(&c), Natural::Periodic);
- // A periodic edge may start anywhere and run up to one turn.
- interval(&[-1., TAU - 1.], Natural::Periodic).unwrap();
- }
- let mut bad = f;
- bad.y_axis = bad.x_axis;
- assert!(frame(&bad, &mut Budget::input()).is_err());
- assert!(interval(&[2., 1.], UNBOUNDED).is_err());
- assert!(radius(f64::NAN).is_err());
- assert!(surface(&Surface::Torus { frame: a_frame(), major_radius: 1., minor_radius: 2., tube_start: 0.0 }, 0, &mut Budget::input()).is_err());
+ let narrowing = Surface::Cone { frame: f, radius_at_origin: 2., half_angle: -0.2 };
+ assert_eq!(label::surface_natural(&narrowing)[1], Natural::Range(f64::NEG_INFINITY, apex));
+ // A record with a skewed frame is structurally valid, and refused by the kernel's check.
+ let mut b = tube();
+ let Surface::Cylinder { frame, .. } = &mut b.faces[0].surface else { panic!("a cylinder") };
+ frame.y_axis = frame.x_axis;
+ b.validate().unwrap();
+ assert_eq!(check::validate(&b).map_err(|e| e.0), Err("nonorthonormal frame"));
}
/// A cylinder face round its axis with a hole beside its seam: the seam at 350 degrees (so its
@@ -934,7 +635,7 @@ fn analytic_partials_are_the_derivatives_of_the_order_below() {
Surface::Torus { frame: f.clone(), major_radius: 5., minor_radius: 1.5, tube_start: 0.0 },
];
let (u, v, h) = (0.8, 0.4, 1e-4);
- let close = |a: crate::Vec3, b: crate::Vec3, tol: f64| a.dist(b) <= tol * (1.0 + a.len().max(b.len()));
+ let close = |a: solidcore_record::Vec3, b: solidcore_record::Vec3, tol: f64| a.dist(b) <= tol * (1.0 + a.len().max(b.len()));
for s in &surfaces {
let e = eval::SurfaceEval::new(s).unwrap();
let d = e.partials(u, v).unwrap();
@@ -960,7 +661,7 @@ fn analytic_partials_are_the_derivatives_of_the_order_below() {
/// sphere of radius 5 about the origin, traced from a rough leader, has radius 4.
#[test]
fn curve_jets_are_exact_on_every_record() {
- use crate::Vec3;
+ use solidcore_record::Vec3;
let near = |a: Vec3, b: Vec3| a.dist(b) <= 1e-9 * (1.0 + b.len());
let jet = |c: &Curve, t: f64| eval::CurveEval::new(c).unwrap().jet(t).unwrap();
let flat = Frame { origin: [1., 2., 3.], x_axis: [0.6, 0.8, 0.], y_axis: [-0.8, 0.6, 0.] };
@@ -1027,7 +728,7 @@ fn a_form_on_arcs_of_its_own_is_the_surface_and_does_not_close_around_an_open_fa
for i in 0..=8 {
for j in 0..=12 {
let uv = [domain[0][0] + (domain[0][1] - domain[0][0]) * i as f64 / 8., v0 + (v1 - v0) * j as f64 / 12.];
- let p = own_at.point(uv).unwrap() - crate::Vec3::new(1., 2., 3.);
+ let p = own_at.point(uv).unwrap() - solidcore_record::Vec3::new(1., 2., 3.);
let off = ((p.x.hypot(p.y) - 5.).powi(2) + p.z.powi(2)).sqrt() - 1.5;
assert!(off.abs() < 1e-12, "{uv:?}: {off}");
}
diff --git a/crates/geom/src/brep/topology.rs b/crates/geom/src/brep/topology.rs
deleted file mode 100644
index 609fefdde7..0000000000
--- a/crates/geom/src/brep/topology.rs
+++ /dev/null
@@ -1,254 +0,0 @@
-//! The structural rules of the topology records: references, loops, regions and shells, each
-//! edge's list of uses and the canonical order (docs/native-brep.md). Indices are hostile:
-//! every lookup is checked, and work is linear in the records.
-use std::collections::HashSet;
-
-use super::{Brep, EdgeUseRef, Invalid, Loop, Result, Shell, require};
-
-/// How far a pcurve's interval may differ from its edge's: this fraction of the interval's
-/// magnitude (at least 1), room for a linear remap's rounding and nothing more.
-pub(super) const PCURVE_INTERVAL: f64 = 1e-9;
-
-fn get<'a, T>(items: &'a [T], i: u32, what: &'static str) -> Result<&'a T> {
- items.get(i as usize).ok_or(Invalid(what))
-}
-
-/// The next index in a first-appearance order: `seen[i]` is set the first time `i` turns up,
-/// and that must be in index order (the first new one is `next`).
-struct Order {
- seen: Vec<bool>,
- next: usize,
- what: &'static str,
-}
-impl Order {
- fn new(n: usize, what: &'static str) -> Order {
- Order { seen: vec![false; n], next: 0, what }
- }
- fn visit(&mut self, i: u32) -> Result<bool> {
- let slot = self.seen.get_mut(i as usize).ok_or(Invalid(self.what))?;
- if *slot {
- return Ok(false);
- }
- require(i as usize == self.next, self.what)?;
- *slot = true;
- self.next += 1;
- Ok(true)
- }
- fn complete(&self) -> Result<()> {
- require(self.next == self.seen.len(), self.what)
- }
-}
-
-pub(super) fn check(b: &Brep) -> Result<()> {
- // Regions and shells: which regions list each shell, and as whose outer shell.
- let mut listed = vec![0u32; b.shells.len()];
- let mut outer_of = vec![0u32; b.shells.len()];
- let infinite = b.regions.first().ok_or(Invalid("region count"))?;
- require(!infinite.void, "the infinite region is a void")?;
- // The last region (numbered from 1) that listed each shell: a repeat within one region shows
- // in one lookup, so the check stays linear however many shells and regions there are.
- let mut last_region = vec![0usize; b.shells.len()];
- for (r, region) in b.regions.iter().enumerate() {
- require(region.shells.len() <= b.shells.len(), "region shells")?;
- for (k, &s) in region.shells.iter().enumerate() {
- let last = last_region.get_mut(s as usize).ok_or(Invalid("region shell reference"))?;
- require(*last != r + 1, "shell listed twice in a region")?;
- *last = r + 1;
- let n = listed.get_mut(s as usize).ok_or(Invalid("region shell reference"))?;
- *n += 1;
- if r > 0 && k == 0 {
- require(matches!(get(&b.shells, s, "region shell reference")?, Shell::Faces { .. }), "outer shell is not a face shell")?;
- if let Some(n) = outer_of.get_mut(s as usize) {
- *n += 1;
- }
- }
- }
- require(r == 0 || !region.shells.is_empty(), "bounded region without an outer shell")?;
- }
-
- // Faces: who uses each one. Loops: references, shape and connectivity.
- let mut face_uses: Vec<Vec<(usize, bool)>> = vec![Vec::new(); b.faces.len()];
- for (s, shell) in b.shells.iter().enumerate() {
- match shell {
- Shell::Faces { faces, wires } => {
- require(!faces.is_empty(), "empty shell")?;
- for f in faces {
- face_uses.get_mut(f.face as usize).ok_or(Invalid("oriented face reference"))?.push((s, f.forward));
- }
- for &e in wires {
- require(get(&b.edges, e, "wire edge reference")?.uses.is_empty(), "wire edge with face uses")?;
- }
- }
- Shell::Wire { edges } => {
- require(!edges.is_empty(), "empty wire shell")?;
- for &e in edges {
- require(get(&b.edges, e, "wire edge reference")?.uses.is_empty(), "wire edge with face uses")?;
- }
- }
- Shell::Vertex { vertex } => {
- get(&b.vertices, *vertex, "vertex shell reference")?;
- }
- }
- }
- for uses in &face_uses {
- match uses.as_slice() {
- [_] => {}
- [(a, fa), (b, fb)] => require(a != b && fa != fb, "a face's two sides")?,
- _ => return Err(Invalid("face used by neither one nor two oriented faces")),
- }
- }
- for f in &b.faces {
- require(matches!(f.loops.first(), Some(Loop::Edges { .. })), "outer loop is not an edge loop")?;
- for l in &f.loops {
- match l {
- Loop::Vertex { vertex } => {
- get(&b.vertices, *vertex, "vertex loop reference")?;
- }
- Loop::Edges { edges } => {
- require(!edges.is_empty(), "empty loop")?;
- let (mut first, mut last) = (None, None);
- for u in edges {
- let edge = get(&b.edges, u.edge, "edge reference")?;
- let [a, z] = edge.vertices;
- let (start, end) = if u.forward { (a, z) } else { (z, a) };
- require(last.is_none_or(|v| v == start), "disconnected loop")?;
- first.get_or_insert(start);
- last = Some(end);
- let p = u.pcurve.interval().ok_or(Invalid("pcurve interval"))?;
- let scale = PCURVE_INTERVAL * (1f64).max(edge.interval[0].abs()).max(edge.interval[1].abs());
- require(
- (p[0] - edge.interval[0]).abs() <= scale && (p[1] - edge.interval[1]).abs() <= scale,
- "pcurve interval differs from its edge's",
- )?;
- }
- require(first == last, "open loop")?;
- }
- }
- }
- }
-
- // Shells: a closed face shell (every edge on its faces used at least twice among them)
- // separates two regions and encloses one; any other shell lies in one region.
- let mut count = vec![0u32; b.edges.len()];
- for (s, shell) in b.shells.iter().enumerate() {
- let (listed, outer) = (listed.get(s).copied().unwrap_or(0), outer_of.get(s).copied().unwrap_or(0));
- let closed = match shell {
- Shell::Faces { faces, .. } => {
- let edges = || {
- faces.iter().filter_map(|f| b.faces.get(f.face as usize)).flat_map(|f| &f.loops).flat_map(|l| match l {
- Loop::Edges { edges } => edges.as_slice(),
- Loop::Vertex { .. } => &[],
- })
- };
- for u in edges() {
- if let Some(n) = count.get_mut(u.edge as usize) {
- *n = n.saturating_add(1);
- }
- }
- let closed = edges().all(|u| count.get(u.edge as usize).is_some_and(|n| *n >= 2));
- for u in edges() {
- if let Some(n) = count.get_mut(u.edge as usize) {
- *n = 0;
- }
- }
- closed
- }
- Shell::Wire { .. } | Shell::Vertex { .. } => false,
- };
- if closed {
- require(listed == 2 && outer == 1, "a closed shell bounds two regions and encloses one")?;
- } else {
- require(listed == 1 && outer == 0, "an open, wire or vertex shell lies in one region")?;
- }
- }
-
- // Canonical order. Shells and faces in first appearance walking regions → shells →
- // oriented faces; each face is walked in the direction its first oriented face gives.
- let mut shells = Order::new(b.shells.len(), "shells out of canonical order");
- let mut faces = Order::new(b.faces.len(), "faces out of canonical order");
- let mut direction = vec![true; b.faces.len()];
- for region in &b.regions {
- for &s in &region.shells {
- if !shells.visit(s)? {
- continue;
- }
- if let Some(Shell::Faces { faces: uses, .. }) = b.shells.get(s as usize) {
- for f in uses {
- if faces.visit(f.face)?
- && let Some(d) = direction.get_mut(f.face as usize)
- {
- *d = f.forward;
- }
- }
- }
- }
- }
- shells.complete()?;
- faces.complete()?;
-
- // Edges in first appearance walking faces → loops → oriented edges (backwards in a face
- // whose first side is reversed), then wire edges walking shells; each edge's uses in that
- // walk's order, the first one primary.
- let mut edges = Order::new(b.edges.len(), "edges out of canonical order");
- let mut walked: Vec<Vec<EdgeUseRef>> = vec![Vec::new(); b.edges.len()];
- for (fi, f) in b.faces.iter().enumerate() {
- let forward = direction.get(fi).copied().unwrap_or(true);
- for (li, l) in f.loops.iter().enumerate() {
- let Loop::Edges { edges: uses } = l else { continue };
- let n = uses.len();
- for k in 0..n {
- let p = if forward { k } else { n - 1 - k };
- let u = uses.get(p).ok_or(Invalid("edge reference"))?;
- edges.visit(u.edge)?;
- let at = EdgeUseRef { face: index(fi)?, r#loop: index(li)?, position: index(p)?, upper: !u.forward };
- walked.get_mut(u.edge as usize).ok_or(Invalid("edge reference"))?.push(at);
- }
- }
- }
- for shell in &b.shells {
- let wires = match shell {
- Shell::Faces { wires, .. } => wires.as_slice(),
- Shell::Wire { edges } => edges.as_slice(),
- Shell::Vertex { .. } => &[],
- };
- for &e in wires {
- edges.visit(e)?;
- }
- }
- edges.complete()?;
- for (edge, walked) in b.edges.iter().zip(&walked) {
- require(edge.uses.len() == walked.len(), "edge uses do not list the edge's uses")?;
- require(edge.uses.first() == walked.first(), "edge's primary use is not its first")?;
- // As many entries as uses, and each one a use not listed before: each use once.
- let mut left: HashSet<EdgeUseRef> = walked.iter().copied().collect();
- for u in &edge.uses {
- require(left.remove(u), "edge use listed twice or not a use of the edge")?;
- }
- }
-
- // Vertices in first appearance walking edges (start, end), then vertex loops walking
- // faces → loops, then vertex shells walking shells.
- let mut vertices = Order::new(b.vertices.len(), "vertices out of canonical order");
- for e in &b.edges {
- for &v in &e.vertices {
- vertices.visit(v)?;
- }
- }
- for f in &b.faces {
- for l in &f.loops {
- if let Loop::Vertex { vertex } = l {
- vertices.visit(*vertex)?;
- }
- }
- }
- for shell in &b.shells {
- if let Shell::Vertex { vertex } = shell {
- vertices.visit(*vertex)?;
- }
- }
- vertices.complete()
-}
-
-fn index(i: usize) -> Result<u32> {
- u32::try_from(i).map_err(|_| Invalid("index"))
-}
diff --git a/crates/geom/src/bspline.rs b/crates/geom/src/bspline.rs
index 88d36ed497..8e1dba073b 100644
--- a/crates/geom/src/bspline.rs
+++ b/crates/geom/src/bspline.rs
@@ -13,12 +13,12 @@
use std::ops::{Add, AddAssign, Mul, Sub};
-use crate::Vec3;
+use solidcore_record::Vec3;
/// Highest polynomial degree accepted in either direction: the B-rep record's own bound
/// (`Brep::validate`), so every spline a record may hold can be evaluated. A G4 blend is of
/// degree 9 (five conditions at each end).
-pub const MAX_SPLINE_DEGREE: usize = 16;
+pub const MAX_SPLINE_DEGREE: usize = solidcore_record::brep::MAX_SPLINE_DEGREE;
/// Most knots accepted in one knot vector.
pub const MAX_KNOTS: usize = 1 << 14;
/// Most control points accepted in one tensor surface.
@@ -707,6 +707,7 @@ impl NurbsSurface {
#[cfg(test)]
pub(crate) mod tests {
use super::*;
+ use crate::prelude::*;
/// A small deterministic generator for test data.
pub(crate) struct Lcg(pub(crate) u64);
@@ -795,7 +796,8 @@ pub(crate) mod tests {
#[test]
fn a_segment_is_the_same_curve_on_its_interval() {
- use crate::brep::{Curve, eval::CurveEval};
+ use crate::brep::eval::CurveEval;
+ use solidcore_record::brep::Curve;
let p = 3;
let mut rng = Lcg(11);
let ctrl: Vec<HPoint> = (0..KNOTS.len() - p - 1)
diff --git a/crates/geom/src/bvh.rs b/crates/geom/src/bvh.rs
index 816fa5adf2..46c7b130e4 100644
--- a/crates/geom/src/bvh.rs
+++ b/crates/geom/src/bvh.rs
@@ -3,7 +3,9 @@
//! the box centres, a few items per leaf) and only read afterwards. [`MeshIndex`] holds one over
//! a mesh's triangles and one over its edge segments, for picking.
-use crate::{Aabb3, Mesh, Vec3};
+use crate::prelude::*;
+use crate::{Aabb3, Mesh};
+use solidcore_record::Vec3;
/// Most items in a leaf.
const LEAF: usize = 4;
diff --git a/crates/geom/src/catmull_rom.rs b/crates/geom/src/catmull_rom.rs
index 99ca094fb8..67b6a5f9d5 100644
--- a/crates/geom/src/catmull_rom.rs
+++ b/crates/geom/src/catmull_rom.rs
@@ -21,7 +21,8 @@
//! three points whose last point is its first (within 1e-9) is closed: its neighbours wrap round,
//! so it is as smooth where it closes as anywhere else.
-use crate::Vec3;
+use crate::prelude::*;
+use solidcore_record::Vec3;
/// Samples per span of [`samples`].
pub const SPAN_SAMPLES: usize = 24;
diff --git a/crates/geom/src/cell.rs b/crates/geom/src/cell.rs
index 81219707a5..8814f680ca 100644
--- a/crates/geom/src/cell.rs
+++ b/crates/geom/src/cell.rs
@@ -29,7 +29,8 @@
use serde::{Deserialize, Serialize};
use crate::paper::MAX_COORDINATE_MM;
-use crate::{Aabb2, EPS, Vec2};
+use crate::{Aabb2, EPS};
+use solidcore_record::Vec2;
/// The most parts a cell's content may have.
pub const MAX_PARTS: usize = 64;
diff --git a/crates/geom/src/chain.rs b/crates/geom/src/chain.rs
index 87795a33bb..b6f1023d5e 100644
--- a/crates/geom/src/chain.rs
+++ b/crates/geom/src/chain.rs
@@ -3,10 +3,12 @@
//! a chain is lives in its type, so code that walks its edges never wraps an index by hand, and
//! what only a closed chain has (an area, an inside) is only asked of a ring.
+use crate::prelude::*;
use std::marker::PhantomData;
use std::ops::Deref;
-use crate::{Aabb2, Vec2, Vec3};
+use crate::Aabb2;
+use solidcore_record::{Vec2, Vec3};
/// Whether a chain's last item joins its first.
pub trait Ends: sealed::Sealed {
@@ -142,7 +144,7 @@ impl Ring<Vec3> {
}
/// [`Ring::edges`] of items held elsewhere, for a type that keeps a closed ring in a field of its
-/// own ([`crate::Loop2::joints`]).
+/// own ([`solidcore_record::Loop2::joints`]).
pub(crate) fn around<T>(items: &[T]) -> impl Iterator<Item = (&T, &T)> + Clone {
items.iter().zip(items.iter().cycle().skip(1))
}
diff --git a/crates/geom/src/compare.rs b/crates/geom/src/compare.rs
index 74e4b20fd7..1b8b5dabc8 100644
--- a/crates/geom/src/compare.rs
+++ b/crates/geom/src/compare.rs
@@ -12,10 +12,12 @@
//! intersects the two surfaces, so bodies that share almost every face (two versions of one
//! part) compare as well as any others.
+use crate::prelude::*;
use std::collections::{HashMap, HashSet};
use std::sync::OnceLock;
-use crate::{Aabb3, Mesh, Vec3};
+use crate::{Aabb3, Mesh};
+use solidcore_record::Vec3;
/// Runs a job for every index below `n`: the jobs are independent, so any order and any number
/// of threads will do. [`serial`] runs them one after another; a caller with threads passes one
diff --git a/crates/geom/src/drawing_sheet.rs b/crates/geom/src/drawing_sheet.rs
index 86ec18ba28..f4b58a3d5b 100644
--- a/crates/geom/src/drawing_sheet.rs
+++ b/crates/geom/src/drawing_sheet.rs
@@ -32,10 +32,11 @@
use serde::{Deserialize, Serialize};
+use crate::Aabb2;
use crate::paper::MAX_LINE_MM;
/// The longest side a custom sheet may have, in millimetres: the paper scene's limit.
pub use crate::paper::MAX_SIDE_MM;
-use crate::{Aabb2, Vec2};
+use solidcore_record::Vec2;
/// The most fields an equal division may cut each way.
pub const MAX_EQUAL_FIELDS: u32 = 200;
diff --git a/crates/geom/src/drawing_sheet_tests.rs b/crates/geom/src/drawing_sheet_tests.rs
index 6b6ee2612c..694589321b 100644
--- a/crates/geom/src/drawing_sheet_tests.rs
+++ b/crates/geom/src/drawing_sheet_tests.rs
@@ -1,4 +1,5 @@
use super::*;
+use crate::prelude::*;
const EPS: f64 = 1e-9;
diff --git a/crates/geom/src/drawing_view.rs b/crates/geom/src/drawing_view.rs
index fd824afffd..a75cd9a088 100644
--- a/crates/geom/src/drawing_view.rs
+++ b/crates/geom/src/drawing_view.rs
@@ -11,8 +11,9 @@
//! scales at which a view fits a space.
//! - A **[`ViewFrame`]** places a view on paper: the point of the view's plane at `centre` lands at
//! `position_mm`, everything scaled by the scale. Its [`ViewFrame::paper_map`] moves the view's
-//! curves ([`Seg2::similar`]) and their accuracy ([`CurveAccuracy::scaled`]) onto paper.
+//! curves ([`Seg2Geom::similar`]) and their accuracy ([`CurveAccuracy::scaled`]) onto paper.
+use crate::prelude::*;
use std::fmt;
use std::str::FromStr;
@@ -20,7 +21,8 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use crate::paper::MAX_SIDE_MM;
use crate::section::{CurveAccuracy, MAX_NUMBER, validate_plane};
-use crate::{Aabb2, Plane, Seg2, Similarity2, Vec2, Vec3};
+use crate::{Aabb2, Similarity2};
+use solidcore_record::{Plane, Seg2, Vec2, Vec3};
/// The smallest scale: one paper millimetre for 100 m of model.
pub const MIN_SCALE: f64 = 1e-5;
diff --git a/crates/geom/src/fill.rs b/crates/geom/src/fill.rs
index 94e07a270d..09a21bb37d 100644
--- a/crates/geom/src/fill.rs
+++ b/crates/geom/src/fill.rs
@@ -10,8 +10,9 @@
//! B-spline curve, eq. 3.4: control values at the knot averages reproduce a linear function),
//! A2.1 (span search).
-use crate::Vec3;
use crate::bspline::{Dir, HPoint, NurbsSurface, Side, SplineError, SplineResult, find_span, invalid, local_basis_array};
+use crate::prelude::*;
+use solidcore_record::Vec3;
/// Most loop points a fill takes.
pub const MAX_LOOP_POINTS: usize = 8192;
diff --git a/crates/geom/src/fill_general.rs b/crates/geom/src/fill_general.rs
index a6ccab9766..203cd0e1f5 100644
--- a/crates/geom/src/fill_general.rs
+++ b/crates/geom/src/fill_general.rs
@@ -52,9 +52,10 @@
//! - **A crown** fills the middle out along the surface's own normals, on control points clear of
//! the loop, so it moves neither the loop nor the conditions across it.
-use crate::Vec3;
use crate::bspline::{HPoint, NurbsSurface, SplineError, SplineResult, invalid};
use crate::fill::{Band, Grid, MAX_LOOP_POINTS, SMOOTHNESS, inside_loop, segments_meet};
+use crate::prelude::*;
+use solidcore_record::Vec3;
/// Most spans of the surface along the domain's longer side.
pub const MAX_GENERAL_SPANS: usize = 64;
diff --git a/crates/geom/src/fill_iso.rs b/crates/geom/src/fill_iso.rs
index a324064737..61893de43a 100644
--- a/crates/geom/src/fill_iso.rs
+++ b/crates/geom/src/fill_iso.rs
@@ -110,11 +110,12 @@
//! The fill's boundary is exact, whatever its inside: a station's gap is nought by construction.
//! Input is hostile: sizes are capped and every evaluation checked; nothing here panics.
-use crate::Vec3;
use crate::bspline::{HPoint, MAX_SPLINE_DEGREE, NurbsSurface, SplineError, SplineResult, check_knots, invalid, segment};
use crate::fill_general::Across;
use crate::linkage::MAX_CONTINUITY;
+use crate::prelude::*;
use crate::spline_space::{Cond, Interpolant, Space};
+use solidcore_record::Vec3;
/// Most spans of the fill's space.
pub const MAX_ISO_SPANS: usize = 64;
diff --git a/crates/geom/src/fill_iso_tests.rs b/crates/geom/src/fill_iso_tests.rs
index 8e72be3c76..6770ed0d34 100644
--- a/crates/geom/src/fill_iso_tests.rs
+++ b/crates/geom/src/fill_iso_tests.rs
@@ -1,7 +1,7 @@
use super::*;
use crate::brep::eval::SurfaceEval;
-use crate::brep::{Curve, Frame, Surface};
use crate::linkage::surface_jet;
+use solidcore_record::brep::{Curve, Frame, Surface};
/// A homogeneous point of an edge.
fn eval_edge_h(e: &IsoEdge, t: f64) -> SplineResult<HPoint> {
diff --git a/crates/geom/src/fill_matched.rs b/crates/geom/src/fill_matched.rs
index a8b6e8c745..9857cfb95f 100644
--- a/crates/geom/src/fill_matched.rs
+++ b/crates/geom/src/fill_matched.rs
@@ -46,10 +46,11 @@
//! stands along the plane's normal, is refused, never filled with wrong geometry. Input is
//! hostile: sizes are capped and every evaluation checked; nothing here panics.
-use crate::Vec3;
use crate::bspline::{SplineError, SplineResult, invalid};
use crate::fill::{Band, Grid, LoopFill, LoopFrame, MAX_LOOP_POINTS, SMOOTHNESS, check_projectable, loop_frame};
use crate::fill_general::Station;
+use crate::prelude::*;
+use solidcore_record::Vec3;
/// Most spans of the height field across the box's longer side.
pub const MAX_MATCHED_SPANS: usize = 128;
diff --git a/crates/geom/src/hlr/curve.rs b/crates/geom/src/hlr/curve.rs
index a8f80d1200..1b1b74d51a 100644
--- a/crates/geom/src/hlr/curve.rs
+++ b/crates/geom/src/hlr/curve.rs
@@ -4,10 +4,11 @@
//! `breaks` are the edge's.
use super::HlrError;
-use crate::Vec3;
use crate::brep::eval::{CurveEval, SurfaceEval};
-use crate::brep::{Curve, Edge, Frame};
+use crate::prelude::*;
use crate::section::CurveAccuracy;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Curve, Edge, Frame};
#[derive(Clone, Debug)]
pub(crate) enum C3 {
@@ -46,7 +47,7 @@ pub(crate) fn frame_axes(f: &Frame) -> (Vec3, Vec3, Vec3) {
/// Whether every sample of `c`, a few to each of its breaks, lies within `tolerance` of both
/// `surfaces`.
-fn on_both_surfaces(c: &C3, surfaces: &[Box<crate::brep::Surface>; 2], tolerance: f64) -> bool {
+fn on_both_surfaces(c: &C3, surfaces: &[Box<solidcore_record::brep::Surface>; 2], tolerance: f64) -> bool {
/// Most samples checked; a longer curve's are spread evenly over it.
const MAX_SAMPLES: usize = 512;
let [Ok(a), Ok(b)] = [SurfaceEval::new(&surfaces[0]), SurfaceEval::new(&surfaces[1])] else { return false };
@@ -66,7 +67,7 @@ fn on_both_surfaces(c: &C3, surfaces: &[Box<crate::brep::Surface>; 2], tolerance
impl C3 {
/// The bounded curve of an edge. A line, circle or ellipse with a NURBS form has its bounds
/// on the form ([`Edge::parameters`]): a line's ends are evaluated there, a conic's angles come
- /// from [`Edge::curve_interval`].
+ /// from [`crate::brep::label::edge_curve_interval`].
pub fn of_edge(e: &Edge) -> Result<(C3, CurveAccuracy), HlrError> {
let exact = |c: C3| (c, CurveAccuracy::Analytic);
match (&e.curve, &e.nurbs) {
@@ -92,7 +93,7 @@ impl C3 {
Ok(exact(C3::Line { a: end(e.interval[0])?, b: end(e.interval[1])? }))
}
(Curve::Circle { .. } | Curve::Ellipse { .. }, _) => {
- let angles = e.curve_interval().ok_or(HlrError::Invalid("edge form"))?;
+ let angles = crate::brep::label::edge_curve_interval(e).ok_or(HlrError::Invalid("edge form"))?;
Ok(exact(C3::bounded(&e.curve, angles)?))
}
(curve, _) => Ok(exact(C3::bounded(curve, e.interval)?)),
diff --git a/crates/geom/src/hlr/mod.rs b/crates/geom/src/hlr/mod.rs
index 5917947e01..764fc524b3 100644
--- a/crates/geom/src/hlr/mod.rs
+++ b/crates/geom/src/hlr/mod.rs
@@ -19,12 +19,13 @@ mod silhouette;
pub(crate) mod surface;
mod trim;
+use crate::prelude::*;
use serde::Serialize;
-use crate::brep::Brep;
use crate::section::CurveAccuracy;
-use crate::{Seg2, Vec2, Vec3};
use curve::{C3, as_circle};
+use solidcore_record::brep::Brep;
+use solidcore_record::{Seg2, Vec2, Vec3};
use surface::{Analytic, Hit, S3};
use trim::Trim;
@@ -192,7 +193,7 @@ pub fn prepare_cancellable(b: &Brep, opts: &Options, cancel: &dyn Fn() -> bool)
if !(1..=MAX_TRIM_SAMPLES).contains(&opts.trim_samples) {
return Err(HlrError::Invalid("trim samples"));
}
- b.validate().map_err(|_| HlrError::Invalid("portable B-rep"))?;
+ crate::brep::check::validate(b).map_err(|_| HlrError::Invalid("portable B-rep"))?;
// Work on the body moved to its own centre: rounding in ray and inversion formulas grows
// with the coordinates, and a part may be modelled far from the origin (W05a finding 7).
let offset = anchor(b);
@@ -208,14 +209,14 @@ pub fn prepare_cancellable(b: &Brep, opts: &Options, cancel: &dyn Fn() -> bool)
}
let (c, acc) = C3::of_edge(e)?;
let record = match &e.curve {
- crate::brep::Curve::Line { .. } => "line",
- crate::brep::Curve::Circle { .. } => "circle_arc",
- crate::brep::Curve::Ellipse { .. } => "ellipse_arc",
- crate::brep::Curve::Polyline { .. } => "polyline",
- crate::brep::Curve::Spline { .. } => "spline",
- crate::brep::Curve::RationalSpline { .. } => "rational_spline",
+ solidcore_record::brep::Curve::Line { .. } => "line",
+ solidcore_record::brep::Curve::Circle { .. } => "circle_arc",
+ solidcore_record::brep::Curve::Ellipse { .. } => "ellipse_arc",
+ solidcore_record::brep::Curve::Polyline { .. } => "polyline",
+ solidcore_record::brep::Curve::Spline { .. } => "spline",
+ solidcore_record::brep::Curve::RationalSpline { .. } => "rational_spline",
// Only one with a spline to follow gets here: what was an `intersection` record.
- crate::brep::Curve::SurfaceIntersection { .. } => "intersection",
+ solidcore_record::brep::Curve::SurfaceIntersection { .. } => "intersection",
};
let shape = if matches!(c, C3::Line { .. }) {
"line"
@@ -406,7 +407,10 @@ fn anchor(b: &Brep) -> Vec3 {
/// The body's records with every position moved by `-d`: points, control points and NURBS forms,
/// a placed revolution through its matrix; regions, parameters and pcurves as they are.
fn shifted(b: &Brep, d: Vec3) -> Brep {
- b.moved(&crate::brep::placement::Rigid { rotation: [[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]], translation: [-d.x, -d.y, -d.z] })
+ crate::brep::placement::moved(
+ b,
+ &crate::brep::placement::Rigid { rotation: [[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]], translation: [-d.x, -d.y, -d.z] },
+ )
}
#[derive(Clone, Copy, Debug)]
diff --git a/crates/geom/src/hlr/silhouette.rs b/crates/geom/src/hlr/silhouette.rs
index af14e13323..9b60866b7e 100644
--- a/crates/geom/src/hlr/silhouette.rs
+++ b/crates/geom/src/hlr/silhouette.rs
@@ -6,8 +6,9 @@
use super::curve::C3;
use super::surface::{Analytic, S3};
use super::trim::Trim;
-use crate::Vec3;
+use crate::prelude::*;
use crate::section::CurveAccuracy;
+use solidcore_record::Vec3;
const TAU: f64 = std::f64::consts::TAU;
diff --git a/crates/geom/src/hlr/surface.rs b/crates/geom/src/hlr/surface.rs
index a4d1f536d4..574952e1b8 100644
--- a/crates/geom/src/hlr/surface.rs
+++ b/crates/geom/src/hlr/surface.rs
@@ -5,10 +5,12 @@
use super::HlrError;
use super::curve::{C3, as_circle, frame_axes, v3};
-use crate::Vec3;
use crate::brep::eval::SurfaceEval;
-use crate::brep::{Curve, Face, Frame, Surface, form, placement::Rigid};
+use crate::brep::{form, placement::Rigid};
use crate::bspline::{HPoint, NurbsSurface};
+use crate::prelude::*;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Curve, Face, Frame, Surface};
const TAU: f64 = std::f64::consts::TAU;
diff --git a/crates/geom/src/hlr/trim.rs b/crates/geom/src/hlr/trim.rs
index 5c0e357982..a67667d76f 100644
--- a/crates/geom/src/hlr/trim.rs
+++ b/crates/geom/src/hlr/trim.rs
@@ -5,9 +5,10 @@
use super::curve::C3;
use super::surface::S3;
-use crate::Vec3;
use crate::brep::eval::SurfaceEval;
-use crate::brep::{Face, Loop, OrientedEdge};
+use crate::prelude::*;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Face, Loop, OrientedEdge};
#[derive(Clone, Debug)]
pub(crate) struct Trim {
diff --git a/crates/geom/src/hlr_tests.rs b/crates/geom/src/hlr_tests.rs
index fea1c4fc09..e04ab6631c 100644
--- a/crates/geom/src/hlr_tests.rs
+++ b/crates/geom/src/hlr_tests.rs
@@ -1,5 +1,6 @@
use super::*;
use crate::brep;
+use solidcore_record::brep as rec;
// The fixtures below write a body as data: shells each with their own vertices, edges and faces,
// curves and surfaces carrying their bounds, edges numbered as the fixture likes. `Brep::record`
@@ -40,7 +41,7 @@ struct EdgeUse {
#[derive(Clone)]
enum Curve {
Line { start: [f64; 3], end: [f64; 3] },
- CircleArc { frame: brep::Frame, radius: f64, angle: [f64; 2] },
+ CircleArc { frame: rec::Frame, radius: f64, angle: [f64; 2] },
Polyline { points: Vec<[f64; 3]> },
Spline { knots: Vec<f64>, points: Vec<[f64; 3]> },
RationalSpline { knots: Vec<f64>, homogeneous: Vec<[f64; 4]> },
@@ -60,26 +61,26 @@ enum Surface {
v_point: [f64; 3],
},
Cylinder {
- frame: brep::Frame,
+ frame: rec::Frame,
radius: f64,
angle: [f64; 2],
height: [f64; 2],
},
Cone {
- frame: brep::Frame,
+ frame: rec::Frame,
radius_at_origin: f64,
half_angle: f64,
angle: [f64; 2],
height: [f64; 2],
},
Sphere {
- frame: brep::Frame,
+ frame: rec::Frame,
radius: f64,
longitude: [f64; 2],
latitude: [f64; 2],
},
Torus {
- frame: brep::Frame,
+ frame: rec::Frame,
major_radius: f64,
minor_radius: f64,
longitude: [f64; 2],
@@ -114,23 +115,23 @@ enum Surface {
const IDENTITY: [[f64; 4]; 4] = [[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]];
-fn range(natural: brep::Natural) -> [f64; 2] {
+fn range(natural: rec::Natural) -> [f64; 2] {
match natural {
- brep::Natural::Range(a, b) => [a, b],
- brep::Natural::Periodic => [0., std::f64::consts::TAU],
+ rec::Natural::Range(a, b) => [a, b],
+ rec::Natural::Periodic => [0., std::f64::consts::TAU],
}
}
impl Curve {
/// What the curve is, unbounded.
- fn label(&self) -> brep::Curve {
+ fn label(&self) -> rec::Curve {
match self {
- Curve::Line { start, end } => brep::Curve::Line { start: *start, end: *end },
- Curve::CircleArc { frame, radius, .. } => brep::Curve::Circle { frame: frame.clone(), radius: *radius },
- Curve::Polyline { points } => brep::Curve::Polyline { points: points.clone() },
- Curve::Spline { knots, points } => brep::Curve::Spline { knots: knots.clone(), points: points.clone() },
- Curve::RationalSpline { knots, homogeneous } => brep::Curve::RationalSpline { knots: knots.clone(), homogeneous: homogeneous.clone() },
- Curve::SurfaceIntersection { surfaces, leader, tolerance } => brep::Curve::SurfaceIntersection {
+ Curve::Line { start, end } => rec::Curve::Line { start: *start, end: *end },
+ Curve::CircleArc { frame, radius, .. } => rec::Curve::Circle { frame: frame.clone(), radius: *radius },
+ Curve::Polyline { points } => rec::Curve::Polyline { points: points.clone() },
+ Curve::Spline { knots, points } => rec::Curve::Spline { knots: knots.clone(), points: points.clone() },
+ Curve::RationalSpline { knots, homogeneous } => rec::Curve::RationalSpline { knots: knots.clone(), homogeneous: homogeneous.clone() },
+ Curve::SurfaceIntersection { surfaces, leader, tolerance } => rec::Curve::SurfaceIntersection {
surfaces: [Box::new(surfaces[0].label()), Box::new(surfaces[1].label())],
leader: Box::new(leader.label()),
tolerance: *tolerance,
@@ -148,7 +149,7 @@ impl Curve {
}
/// The label, its NURBS form and the interval the edge's parameter runs over.
- fn parts(&self) -> (brep::Curve, Option<brep::Curve>, [f64; 2]) {
+ fn parts(&self) -> (rec::Curve, Option<rec::Curve>, [f64; 2]) {
let label = self.label();
match self {
Curve::CircleArc { angle, .. } => {
@@ -162,31 +163,31 @@ impl Curve {
impl Surface {
/// What the surface is, unbounded.
- fn label(&self) -> brep::Surface {
+ fn label(&self) -> rec::Surface {
match self {
- Surface::Plane { origin, u_axis, v_axis } => brep::Surface::Plane { origin: *origin, u_axis: *u_axis, v_axis: *v_axis },
+ Surface::Plane { origin, u_axis, v_axis } => rec::Surface::Plane { origin: *origin, u_axis: *u_axis, v_axis: *v_axis },
Surface::PlaneThrough { origin, u_point, v_point } => {
- brep::Surface::PlaneThrough { origin: *origin, u_point: *u_point, v_point: *v_point }
+ rec::Surface::PlaneThrough { origin: *origin, u_point: *u_point, v_point: *v_point }
}
- Surface::Cylinder { frame, radius, .. } => brep::Surface::Cylinder { frame: frame.clone(), radius: *radius },
+ Surface::Cylinder { frame, radius, .. } => rec::Surface::Cylinder { frame: frame.clone(), radius: *radius },
Surface::Cone { frame, radius_at_origin, half_angle, .. } => {
- brep::Surface::Cone { frame: frame.clone(), radius_at_origin: *radius_at_origin, half_angle: *half_angle }
+ rec::Surface::Cone { frame: frame.clone(), radius_at_origin: *radius_at_origin, half_angle: *half_angle }
}
- Surface::Sphere { frame, radius, .. } => brep::Surface::Sphere { frame: frame.clone(), radius: *radius },
+ Surface::Sphere { frame, radius, .. } => rec::Surface::Sphere { frame: frame.clone(), radius: *radius },
Surface::Torus { frame, major_radius, minor_radius, .. } => {
- brep::Surface::Torus { frame: frame.clone(), major_radius: *major_radius, minor_radius: *minor_radius, tube_start: 0. }
+ rec::Surface::Torus { frame: frame.clone(), major_radius: *major_radius, minor_radius: *minor_radius, tube_start: 0. }
}
Surface::Spline { u_knots, v_knots, points } => {
- brep::Surface::Spline { u_knots: u_knots.clone(), v_knots: v_knots.clone(), points: points.clone() }
+ rec::Surface::Spline { u_knots: u_knots.clone(), v_knots: v_knots.clone(), points: points.clone() }
}
Surface::RationalSpline { u_knots, v_knots, homogeneous } => {
- brep::Surface::RationalSpline { u_knots: u_knots.clone(), v_knots: v_knots.clone(), homogeneous: homogeneous.clone() }
+ rec::Surface::RationalSpline { u_knots: u_knots.clone(), v_knots: v_knots.clone(), homogeneous: homogeneous.clone() }
}
// A revolution from its profile, u the angle and v along the profile.
Surface::Revolution { profile, origin, axis, .. } => {
- brep::Surface::PlacedRevolution { profile: Box::new(profile.label()), origin: *origin, axis: *axis, matrix: IDENTITY, forward: false }
+ rec::Surface::PlacedRevolution { profile: Box::new(profile.label()), origin: *origin, axis: *axis, matrix: IDENTITY, forward: false }
}
- Surface::PlacedRevolution { profile, origin, axis, matrix, forward } => brep::Surface::PlacedRevolution {
+ Surface::PlacedRevolution { profile, origin, axis, matrix, forward } => rec::Surface::PlacedRevolution {
profile: Box::new(profile.label()),
origin: *origin,
axis: *axis,
@@ -206,14 +207,14 @@ impl Surface {
Surface::Revolution { profile, angle, .. } => [*angle, profile.extent()],
Surface::PlacedRevolution { profile, forward: true, .. } => [profile.extent(), turn],
Surface::PlacedRevolution { profile, forward: false, .. } => [turn, profile.extent()],
- Surface::Spline { .. } | Surface::RationalSpline { .. } => self.label().natural().map(range),
+ Surface::Spline { .. } | Surface::RationalSpline { .. } => brep::label::surface_natural(&self.label()).map(range),
// Nothing reads a plane's domain; this is around anything a fixture draws on one.
Surface::Plane { .. } | Surface::PlaneThrough { .. } => [[-1e12, 1e12]; 2],
}
}
/// The label, its NURBS form and the face's domain.
- fn parts(&self) -> (brep::Surface, Option<brep::Surface>, [[f64; 2]; 2]) {
+ fn parts(&self) -> (rec::Surface, Option<rec::Surface>, [[f64; 2]; 2]) {
let (label, bounds) = (self.label(), self.bounds());
match self {
Surface::Plane { .. } | Surface::PlaneThrough { .. } | Surface::Spline { .. } | Surface::RationalSpline { .. } => (label, None, bounds),
@@ -231,7 +232,7 @@ impl Brep {
/// in canonical order, first appearance walking faces, loops and uses. Pcurves carry the edge's
/// interval, which `Brep::validate` checks; neither it nor hidden lines read their points, as
/// hidden lines trace trims from the edges in 3D, so these are not on the surface.
- fn record(&self) -> (brep::Brep, Vec<usize>) {
+ fn record(&self) -> (rec::Brep, Vec<usize>) {
let (mut points, mut edges, mut faces, mut spans) = (Vec::new(), Vec::new(), Vec::new(), Vec::new());
for s in &self.shells {
let (base_edge, base_vertex) = (edges.len() as u32, points.len() as u32);
@@ -245,7 +246,7 @@ impl Brep {
}
let mut order: Vec<Option<u32>> = vec![None; edges.len()];
let mut numbers: Vec<usize> = Vec::new();
- let mut walked: Vec<Vec<brep::EdgeUseRef>> = vec![Vec::new(); edges.len()];
+ let mut walked: Vec<Vec<rec::EdgeUseRef>> = vec![Vec::new(); edges.len()];
let mut visit = |e: usize, order: &mut Vec<Option<u32>>| {
if order[e].is_none() {
order[e] = Some(numbers.len() as u32);
@@ -258,7 +259,7 @@ impl Brep {
let position = if f.forward { k } else { l.len() - 1 - k };
let u = l[position];
visit(u.edge as usize, &mut order);
- let at = brep::EdgeUseRef { face: fi as u32, r#loop: li as u32, position: position as u32, upper: !u.forward };
+ let at = rec::EdgeUseRef { face: fi as u32, r#loop: li as u32, position: position as u32, upper: !u.forward };
walked[u.edge as usize].push(at);
}
}
@@ -285,15 +286,15 @@ impl Brep {
let (label, nurbs, interval) = edges[e].curve.parts();
let ends = edges[e].vertices.map(|v| {
*vertex_order[v as usize].get_or_insert_with(|| {
- vertices.push(brep::Vertex { point: points[v as usize], tolerance: 1e-6 });
+ vertices.push(rec::Vertex { point: points[v as usize], tolerance: 1e-6 });
vertices.len() as u32 - 1
})
});
- edge_records.push(brep::Edge { curve: label, nurbs, interval, vertices: ends, tolerance: 1e-6, uses: walked[e].clone() });
+ edge_records.push(rec::Edge { curve: label, nurbs, interval, vertices: ends, tolerance: 1e-6, uses: walked[e].clone() });
}
let pcurve = |edge: u32| {
let [t0, t1] = edge_records[number(edge) as usize].interval;
- brep::Curve2::Spline { knots: vec![t0, t0, t1, t1], points: vec![[0., 0.], [1., 0.]] }
+ rec::Curve2::Spline { knots: vec![t0, t0, t1, t1], points: vec![[0., 0.], [1., 0.]] }
};
let face_records = faces
.iter()
@@ -302,32 +303,32 @@ impl Brep {
let loops = f
.loops
.iter()
- .map(|l| brep::Loop::Edges {
- edges: l.iter().map(|u| brep::OrientedEdge { edge: number(u.edge), forward: u.forward, pcurve: pcurve(u.edge) }).collect(),
+ .map(|l| rec::Loop::Edges {
+ edges: l.iter().map(|u| rec::OrientedEdge { edge: number(u.edge), forward: u.forward, pcurve: pcurve(u.edge) }).collect(),
})
.collect();
- brep::Face { surface, nurbs, domain, loops }
+ rec::Face { surface, nurbs, domain, loops }
})
.collect();
- let mut regions = vec![brep::Region { shells: (0..self.shells.len() as u32).collect(), void: false }];
+ let mut regions = vec![rec::Region { shells: (0..self.shells.len() as u32).collect(), void: false }];
let mut shells = Vec::new();
for (s, (shell_faces, _)) in spans.iter().enumerate() {
// A closed shell (each edge on its faces used twice among them) also bounds a region.
let used = |e: u32| faces[shell_faces.clone()].iter().flat_map(|f| f.loops.iter().flatten()).filter(|u| u.edge == e).count();
if faces[shell_faces.clone()].iter().flat_map(|f| f.loops.iter().flatten()).all(|u| used(u.edge) >= 2) {
- regions.push(brep::Region { shells: vec![s as u32], void: false });
+ regions.push(rec::Region { shells: vec![s as u32], void: false });
}
- let oriented = shell_faces.clone().map(|f| brep::OrientedFace { face: f as u32, forward: faces[f].forward }).collect();
- shells.push(brep::Shell::Faces { faces: oriented, wires: wires[s].clone() });
+ let oriented = shell_faces.clone().map(|f| rec::OrientedFace { face: f as u32, forward: faces[f].forward }).collect();
+ shells.push(rec::Shell::Faces { faces: oriented, wires: wires[s].clone() });
}
- let record = brep::Brep { version: self.version, tolerance: 1e-6, regions, shells, faces: face_records, edges: edge_records, vertices };
+ let record = rec::Brep { version: self.version, tolerance: 1e-6, regions, shells, faces: face_records, edges: edge_records, vertices };
(record, numbers)
}
}
/// The real `prepare_cancellable` on the fixture's record, its edges then back in the fixture's
/// numbering and its arcs on the angles the fixture counted them from (the record's are within a
-/// turn of zero: `Edge::curve_interval`), which is what the assertions below speak of.
+/// turn of zero: `label::edge_curve_interval`), which is what the assertions below speak of.
fn prepare_cancellable(b: &Brep, opts: &Options, cancel: &dyn Fn() -> bool) -> Result<Prepared, HlrError> {
let (record, numbers) = b.record();
let mut def = super::prepare_cancellable(&record, opts, cancel)?;
@@ -385,7 +386,7 @@ fn cuboid(lo: [f64; 3], hi: [f64; 3]) -> Brep {
Face { loops: vec![cycle([0, 4, 6, 2])], surface: plane(0, 4, 2), forward: true },
Face { loops: vec![cycle([1, 3, 7, 5])], surface: plane(1, 3, 5), forward: true },
];
- Brep { version: crate::brep::VERSION, shells: vec![Shell { vertices, edges, faces }] }
+ Brep { version: solidcore_record::brep::VERSION, shells: vec![Shell { vertices, edges, faces }] }
}
fn identity(body: usize, t: [f64; 3]) -> Placement {
@@ -445,7 +446,7 @@ fn quadratic_roots_with_no_linear_term() {
#[test]
fn a_torus_seen_along_its_axis_has_both_equator_silhouettes() {
// A whole-meridian torus record: the outer equator sits where the closed profile's ends meet.
- let frame = crate::brep::Frame { origin: [0.; 3], x_axis: [1., 0., 0.], y_axis: [0., 1., 0.] };
+ let frame = solidcore_record::brep::Frame { origin: [0.; 3], x_axis: [1., 0., 0.], y_axis: [0., 1., 0.] };
let tau = std::f64::consts::TAU;
let s = chart(&Surface::Torus { frame, major_radius: 20., minor_radius: 5., longitude: [0., tau], meridian: [0., tau] });
let mut radii: Vec<f64> = s
@@ -516,7 +517,7 @@ fn a_ray_from_the_hole_crosses_a_thin_large_torus() {
fn a_torus_seen_nearly_along_its_axis_keeps_its_silhouettes() {
// Meridian starting off the equator and a view 1e-4 rad from the axis: the silhouette lives
// in narrow profile intervals around the equators, which must not fall between samples.
- let frame = crate::brep::Frame { origin: [0.; 3], x_axis: [1., 0., 0.], y_axis: [0., 1., 0.] };
+ let frame = solidcore_record::brep::Frame { origin: [0.; 3], x_axis: [1., 0., 0.], y_axis: [0., 1., 0.] };
let tau = std::f64::consts::TAU;
let shift = std::f64::consts::PI / 720.;
let s = chart(&Surface::Torus { frame, major_radius: 1000., minor_radius: 500., longitude: [0., tau], meridian: [shift, shift + tau] });
@@ -544,8 +545,8 @@ fn a_shallow_cut_through_a_torus_tube_is_found() {
}
/// A frame at `o` with x along +X and y along +Y (z along +Z).
-fn frame_at(o: [f64; 3]) -> crate::brep::Frame {
- crate::brep::Frame { origin: o, x_axis: [1., 0., 0.], y_axis: [0., 1., 0.] }
+fn frame_at(o: [f64; 3]) -> solidcore_record::brep::Frame {
+ solidcore_record::brep::Frame { origin: o, x_axis: [1., 0., 0.], y_axis: [0., 1., 0.] }
}
/// A full circle about Z through vertex `v`.
@@ -586,7 +587,7 @@ fn turned(r0: f64, r1: f64, h: f64) -> Brep {
forward: true,
},
];
- Brep { version: crate::brep::VERSION, shells: vec![Shell { vertices: vec![[r0, 0., 0.], [r1, 0., h]], edges, faces }] }
+ Brep { version: solidcore_record::brep::VERSION, shells: vec![Shell { vertices: vec![[r0, 0., 0.], [r1, 0., h]], edges, faces }] }
}
/// A sphere of radius `r` at the origin: two hemispheres meeting at the equator.
@@ -598,7 +599,7 @@ fn sphere(r: f64) -> Brep {
forward: true,
};
let faces = vec![hemisphere([0., half], true), hemisphere([-half, 0.], false)];
- Brep { version: crate::brep::VERSION, shells: vec![Shell { vertices: vec![[r, 0., 0.]], edges: vec![circle([0.; 3], r, 0)], faces }] }
+ Brep { version: solidcore_record::brep::VERSION, shells: vec![Shell { vertices: vec![[r, 0., 0.]], edges: vec![circle([0.; 3], r, 0)], faces }] }
}
/// A torus about Z (major radius `big`, minor `small`): top and bottom halves meeting at the
@@ -612,7 +613,10 @@ fn torus(big: f64, small: f64) -> Brep {
};
let edges = vec![circle([0.; 3], big + small, 0), circle([0.; 3], big - small, 1)];
let faces = vec![half([0., pi], true), half([pi, tau], false)];
- Brep { version: crate::brep::VERSION, shells: vec![Shell { vertices: vec![[big + small, 0., 0.], [big - small, 0., 0.]], edges, faces }] }
+ Brep {
+ version: solidcore_record::brep::VERSION,
+ shells: vec![Shell { vertices: vec![[big + small, 0., 0.], [big - small, 0., 0.]], edges, faces }],
+ }
}
/// A bilinear (twisted) spline patch over x, y in [-5, 5] with z between 0 and 1.
@@ -625,7 +629,7 @@ fn twisted_patch() -> Brep {
surface: Surface::Spline { u_knots: vec![0., 0., 1., 1.], v_knots: vec![0., 0., 1., 1.], points: vec![vec![p[0], p[3]], vec![p[1], p[2]]] },
forward: true,
};
- Brep { version: crate::brep::VERSION, shells: vec![Shell { vertices: p.to_vec(), edges, faces: vec![face] }] }
+ Brep { version: solidcore_record::brep::VERSION, shells: vec![Shell { vertices: p.to_vec(), edges, faces: vec![face] }] }
}
fn pieces(d: &Drawing) -> impl Iterator<Item = &Piece> {
@@ -827,9 +831,11 @@ fn a_flat_spline_patch_is_a_plane_that_hides_for_certain() {
surface: Surface::Spline { u_knots: vec![0., 0., 1., 1.], v_knots: vec![0., 0., 1., 1.], points: vec![vec![p[0], p[3]], vec![p[1], p[2]]] },
forward: true,
};
- let patch =
- prepare(&Brep { version: crate::brep::VERSION, shells: vec![Shell { vertices: p.to_vec(), edges, faces: vec![face] }] }, &Options::default())
- .unwrap();
+ let patch = prepare(
+ &Brep { version: solidcore_record::brep::VERSION, shells: vec![Shell { vertices: p.to_vec(), edges, faces: vec![face] }] },
+ &Options::default(),
+ )
+ .unwrap();
assert!(patch.report.freeform_faces.is_empty());
let bar = prepare(&cuboid([-2., -1., -3.], [2., 1., -1.]), &Options::default()).unwrap();
let view = View::new(Vec3::new(0.1, 0.05, -1.), Vec3::new(0., 1., 0.)).unwrap();
@@ -870,7 +876,7 @@ fn a_circle_racing_through_its_first_turn_is_drawn_whole_edge_on() {
let homogeneous: Vec<[f64; 4]> = num.iter().zip(&w).map(|((re, im), w)| [10. * re, 10. * im, 0., *w]).collect();
let start = [10., 0., 0.];
let disc = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![start],
edges: vec![Edge { vertices: [0, 0], curve: Curve::RationalSpline { knots: [[0.; 7], [1.; 7]].concat(), homogeneous } }],
@@ -909,7 +915,7 @@ fn an_arc_racing_through_almost_a_full_turn_is_drawn_whole() {
let sweep_want = 4. * phi;
let end = [10. * sweep_want.cos(), 10. * sweep_want.sin(), 0.];
let shape = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[10., 0., 0.], end],
edges: vec![
@@ -956,7 +962,7 @@ fn a_short_piece_of_a_fast_arc_turns_its_own_way() {
let homogeneous: Vec<[f64; 4]> = first.iter().chain(second.iter().skip(1)).copied().collect();
let end = [10. * 5.8f64.cos(), 10. * 5.8f64.sin(), 0.];
let shape = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[10., 0., 0.], end],
edges: vec![
@@ -1006,7 +1012,7 @@ fn an_arc_whose_whole_domain_is_8_roundings_wide_is_not_guessed() {
let k = 0.25 + 2f64.powi(-51);
let end = [10. * 3.75f64.cos(), 10. * 3.75f64.sin(), 0.];
let shape = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[10., 0., 0.], end],
edges: vec![
@@ -1049,7 +1055,7 @@ fn a_piece_in_a_knot_span_of_1e_11_turns_its_own_way() {
let k = 0.25 + 1e-11;
let end = [10. * 4.5f64.cos(), 10. * 4.5f64.sin(), 0.];
let shape = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[10., 0., 0.], end],
edges: vec![
@@ -1101,7 +1107,7 @@ fn a_curve_that_swerves_where_its_weight_is_near_zero_is_not_taken_for_a_circle(
})
.collect();
let shape = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[0., -10., 0.], [0., 10., 0.]],
edges: vec![
@@ -1135,9 +1141,11 @@ fn an_edge_leaving_a_left_out_faces_box_in_front_stays_visible() {
surface: Surface::Plane { origin: c[0], u_axis: [10., 0., 6.], v_axis: [0., 0.2, 0.] },
forward: true,
};
- let strip =
- prepare(&Brep { version: crate::brep::VERSION, shells: vec![Shell { vertices: c.to_vec(), edges, faces: vec![face] }] }, &Options::default())
- .unwrap();
+ let strip = prepare(
+ &Brep { version: solidcore_record::brep::VERSION, shells: vec![Shell { vertices: c.to_vec(), edges, faces: vec![face] }] },
+ &Options::default(),
+ )
+ .unwrap();
let view = View::new(Vec3::new(0., 0., -1.), Vec3::new(0., 1., 0.)).unwrap();
let d = hidden_lines(&[patch, strip], &[identity(0, [0.; 3]), identity(1, [0.; 3])], &view, &Options::default(), &never).unwrap();
let states: Vec<([f64; 2], Visibility)> = edge_line(&d, 1, 0).pieces.iter().map(|p| (p.t, p.visibility)).collect();
@@ -1150,7 +1158,7 @@ fn a_nearly_straight_cubic_is_not_taken_for_a_huge_circle() {
// about 1e7, which is 2e-10 of that radius but 2e-6 of the curve. Drawn as chords.
let pts = [[0., 0., 0.], [1000. / 3., 0.071 / 3., 0.], [2000. / 3., 0.071 * 2. / 3. - 0.113 / 3., 0.], [1000., 0., 0.]];
let shape = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[0.; 3], [1000., 0., 0.]],
edges: vec![
@@ -1185,15 +1193,17 @@ fn an_edge_dipping_behind_a_left_out_face_between_samples_is_uncertain() {
surface: Surface::Spline { u_knots: vec![0., 0., 1., 1.], v_knots: vec![0., 0., 1., 1.], points: vec![vec![p[0], p[3]], vec![p[1], p[2]]] },
forward: true,
};
- let patch =
- prepare(&Brep { version: crate::brep::VERSION, shells: vec![Shell { vertices: p.to_vec(), edges, faces: vec![face] }] }, &Options::default())
- .unwrap();
+ let patch = prepare(
+ &Brep { version: solidcore_record::brep::VERSION, shells: vec![Shell { vertices: p.to_vec(), edges, faces: vec![face] }] },
+ &Options::default(),
+ )
+ .unwrap();
assert_eq!(patch.report.freeform_faces, vec![0]);
// z = 20 t^2 - 0.625 t + 0.0035625 as a quadratic Bezier.
let z = [0.0035625, 0.0035625 - 0.3125, 20. - 0.625 + 0.0035625];
let c = [[0., 0.5, z[0]], [5., 0.5, z[1]], [10., 0.5, z[2]]];
let shape = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![c[0], c[2]],
edges: vec![
@@ -1228,7 +1238,7 @@ fn an_arc_that_turns_back_is_drawn_as_chords() {
let th = 2. * u3[3].atan();
let end = [10. * th.cos(), 10. * th.sin(), 0.];
let shape = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[10., 0., 0.], end],
edges: vec![
@@ -1257,7 +1267,7 @@ fn a_cone_tip_trimmed_near_the_apex_is_only_its_tip() {
// tip below it: a box edge at x = 40, z = 50 to 150, seen along +X, is in front of nothing.
let tau = std::f64::consts::TAU;
let tip = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[0.25, 0., 1.]],
edges: vec![circle([0., 0., 1.], 0.25, 0)],
@@ -1294,7 +1304,7 @@ fn an_edge_behind_a_left_out_freeform_face_is_uncertain_there() {
let tau = std::f64::consts::TAU;
let profile = Curve::Spline { knots: vec![0., 0., 0., 1., 1., 1.], points: vec![[12.5, 0., 0.], [13., 0., 5.], [12.5, 0., 10.]] };
let tube = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[12.5, 0., 0.], [12.5, 0., 10.]],
edges: vec![circle([10., 0., 0.], 2.5, 0), circle([10., 0., 10.], 2.5, 1), Edge { vertices: [0, 1], curve: profile.clone() }],
@@ -1336,9 +1346,11 @@ fn a_sloping_edge_that_runs_behind_a_left_out_face_is_uncertain() {
surface: Surface::Plane { origin: c[0], u_axis: [8., 0., -1.6], v_axis: [0., 0.2, 0.] },
forward: true,
};
- let strip =
- prepare(&Brep { version: crate::brep::VERSION, shells: vec![Shell { vertices: c.to_vec(), edges, faces: vec![face] }] }, &Options::default())
- .unwrap();
+ let strip = prepare(
+ &Brep { version: solidcore_record::brep::VERSION, shells: vec![Shell { vertices: c.to_vec(), edges, faces: vec![face] }] },
+ &Options::default(),
+ )
+ .unwrap();
let view = View::new(Vec3::new(0., 0., -1.), Vec3::new(0., 1., 0.)).unwrap();
let d = hidden_lines(&[patch, strip], &[identity(0, [0.; 3]), identity(1, [0.; 3])], &view, &Options::default(), &never).unwrap();
for p in &edge_line(&d, 1, 0).pieces {
@@ -1370,8 +1382,9 @@ fn a_torus_stored_as_a_rational_spline_patch_is_recognised() {
})
.collect();
let at = |t: f64, f: f64| [(big + small * f.cos()) * t.cos(), (big + small * f.cos()) * t.sin(), small * f.sin()];
- let parallel = |f: f64| crate::brep::Frame { origin: [0., 0., small * f.sin()], x_axis: [1., 0., 0.], y_axis: [0., 1., 0.] };
- let meridian = |t: f64| crate::brep::Frame { origin: [big * t.cos(), big * t.sin(), 0.], x_axis: [t.cos(), t.sin(), 0.], y_axis: [0., 0., 1.] };
+ let parallel = |f: f64| solidcore_record::brep::Frame { origin: [0., 0., small * f.sin()], x_axis: [1., 0., 0.], y_axis: [0., 1., 0.] };
+ let meridian =
+ |t: f64| solidcore_record::brep::Frame { origin: [big * t.cos(), big * t.sin(), 0.], x_axis: [t.cos(), t.sin(), 0.], y_axis: [0., 0., 1.] };
let edges = vec![
Edge { vertices: [0, 1], curve: Curve::CircleArc { frame: parallel(-q), radius: big + small * q.cos(), angle: [-q, q] } },
Edge { vertices: [1, 2], curve: Curve::CircleArc { frame: meridian(q), radius: small, angle: [-q, q] } },
@@ -1384,7 +1397,7 @@ fn a_torus_stored_as_a_rational_spline_patch_is_recognised() {
forward: true,
};
let patch = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell { vertices: vec![at(-q, -q), at(q, -q), at(q, q), at(-q, q)], edges, faces: vec![face] }],
};
let def = prepare(&patch, &Options::default()).unwrap();
@@ -1436,8 +1449,9 @@ fn a_torus_patch_with_a_bump_in_a_narrow_knot_span_is_not_taken_for_a_torus() {
})
.collect();
let at = |t: f64, f: f64| [(big + small * f.cos()) * t.cos(), (big + small * f.cos()) * t.sin(), small * f.sin()];
- let parallel = |f: f64| crate::brep::Frame { origin: [0., 0., small * f.sin()], x_axis: [1., 0., 0.], y_axis: [0., 1., 0.] };
- let meridian = |t: f64| crate::brep::Frame { origin: [big * t.cos(), big * t.sin(), 0.], x_axis: [t.cos(), t.sin(), 0.], y_axis: [0., 0., 1.] };
+ let parallel = |f: f64| solidcore_record::brep::Frame { origin: [0., 0., small * f.sin()], x_axis: [1., 0., 0.], y_axis: [0., 1., 0.] };
+ let meridian =
+ |t: f64| solidcore_record::brep::Frame { origin: [big * t.cos(), big * t.sin(), 0.], x_axis: [t.cos(), t.sin(), 0.], y_axis: [0., 0., 1.] };
let edges = vec![
Edge { vertices: [0, 1], curve: Curve::CircleArc { frame: parallel(-q), radius: big + small * q.cos(), angle: [-q, q] } },
Edge { vertices: [1, 2], curve: Curve::CircleArc { frame: meridian(q), radius: small, angle: [-q, q] } },
@@ -1454,7 +1468,7 @@ fn a_torus_patch_with_a_bump_in_a_narrow_knot_span_is_not_taken_for_a_torus() {
forward: true,
};
let patch = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell { vertices: vec![at(-q, -q), at(q, -q), at(q, q), at(-q, q)], edges, faces: vec![face] }],
};
let def = prepare(&patch, &Options::default()).unwrap();
@@ -1470,9 +1484,9 @@ fn a_big_circle_passing_behind_a_thin_left_out_face_is_uncertain_there() {
let tau = std::f64::consts::TAU;
let turn = 8.5 * std::f64::consts::PI / 256.;
let (c, sn) = (turn.cos(), turn.sin());
- let frame = crate::brep::Frame { origin: [0.; 3], x_axis: [-c, -sn, 0.], y_axis: [sn, -c, 0.] };
+ let frame = solidcore_record::brep::Frame { origin: [0.; 3], x_axis: [-c, -sn, 0.], y_axis: [sn, -c, 0.] };
let disc = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[-5000. * c, -5000. * sn, 0.]],
edges: vec![Edge { vertices: [0, 0], curve: Curve::CircleArc { frame, radius: 5000., angle: [0., tau] } }],
@@ -1490,13 +1504,13 @@ fn a_big_circle_passing_behind_a_thin_left_out_face_is_uncertain_there() {
let end = |y: f64, v: u32| Edge {
vertices: [v, v],
curve: Curve::CircleArc {
- frame: crate::brep::Frame { origin: [5000., y, 1.], x_axis: [1., 0., 0.], y_axis: [0., 0., 1.] },
+ frame: solidcore_record::brep::Frame { origin: [5000., y, 1.], x_axis: [1., 0., 0.], y_axis: [0., 0., 1.] },
radius: 0.01,
angle: [0., tau],
},
};
let tube = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[5000.01, -100., 1.], [5000.01, 100., 1.]],
edges: vec![end(-100., 0), end(100., 1), Edge { vertices: [0, 1], curve: profile.clone() }],
@@ -1550,11 +1564,11 @@ fn an_arc_folding_back_under_a_left_out_face_seen_edge_on_is_uncertain_there() {
fn folding_arc_under_a_patch(offset: f64) {
let step = std::f64::consts::PI / 256.;
let ta = -step / 4. + offset;
- let frame = crate::brep::Frame { origin: [0.; 3], x_axis: [1., 0., 0.], y_axis: [0., 0., 1.] };
+ let frame = solidcore_record::brep::Frame { origin: [0.; 3], x_axis: [1., 0., 0.], y_axis: [0., 0., 1.] };
let at = |t: f64| [10000. * t.cos(), 0., 10000. * t.sin()];
let (start, end) = (at(ta), at(ta + std::f64::consts::PI / 8.));
let arc = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![start, end],
edges: vec![
@@ -1577,7 +1591,7 @@ fn folding_arc_under_a_patch(offset: f64) {
surface: Surface::Spline { u_knots: vec![0., 0., 1., 1.], v_knots: vec![0., 0., 1., 1.], points: vec![vec![p[0], p[3]], vec![p[1], p[2]]] },
forward: true,
};
- let patch = Brep { version: crate::brep::VERSION, shells: vec![Shell { vertices: p.to_vec(), edges, faces: vec![face] }] };
+ let patch = Brep { version: solidcore_record::brep::VERSION, shells: vec![Shell { vertices: p.to_vec(), edges, faces: vec![face] }] };
let defs = [prepare(&patch, &Options::default()).unwrap(), prepare(&arc, &Options::default()).unwrap()];
assert_eq!(defs[0].report.freeform_faces, vec![0]);
let view = View::new(Vec3::new(0., 0., -1.), Vec3::new(0., 1., 0.)).unwrap();
@@ -1613,7 +1627,7 @@ fn a_left_out_face_curling_over_its_own_edge_makes_it_uncertain() {
forward: true,
};
let sheet = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell { vertices: vec![at(a, 0.), at(c, 0.), at(c, 8000.), at(a, 8000.)], edges, faces: vec![face] }],
};
let def = prepare(&sheet, &Options::default()).unwrap();
@@ -1684,7 +1698,7 @@ fn a_sphere_with_a_spline_band_between_record_caps_is_one_sphere() {
forward: true,
};
let body = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[rho, 0., -z], [rho, 0., z]],
edges: vec![circle([0., 0., -z], rho, 0), circle([0., 0., z], rho, 1)],
@@ -1719,7 +1733,7 @@ fn chords_of_a_racing_circle_stay_within_their_stated_deviation() {
let w = bernstein_product(&bernstein_product(&q, &q), &q);
let homogeneous: Vec<[f64; 4]> = num.iter().zip(&w).map(|((re, im), w)| [*re, *im, 0., *w]).collect();
let disc = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[1., 0., 0.]],
edges: vec![Edge { vertices: [0, 0], curve: Curve::RationalSpline { knots: [[0.; 7], [1.; 7]].concat(), homogeneous } }],
@@ -1761,7 +1775,7 @@ fn a_big_arc_is_cut_where_it_meets_a_left_out_faces_box() {
let a0 = -std::f64::consts::PI / 8.;
let (start, end) = ([10000. * a0.cos(), 10000. * a0.sin(), 0.], [10000., 0., 0.]);
let arc = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![start, end],
edges: vec![
@@ -1783,13 +1797,13 @@ fn a_big_arc_is_cut_where_it_meets_a_left_out_faces_box() {
let end_circle = |y: f64, v: u32| Edge {
vertices: [v, v],
curve: Curve::CircleArc {
- frame: crate::brep::Frame { origin: [x, y, 1.], x_axis: [1., 0., 0.], y_axis: [0., 0., 1.] },
+ frame: solidcore_record::brep::Frame { origin: [x, y, 1.], x_axis: [1., 0., 0.], y_axis: [0., 0., 1.] },
radius: 2.5,
angle: [0., tau],
},
};
let tube = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[x + 2.5, -4000., 1.], [x + 2.5, 3000., 1.]],
edges: vec![end_circle(-4000., 0), end_circle(3000., 1), Edge { vertices: [0, 1], curve: profile.clone() }],
@@ -1832,7 +1846,7 @@ fn narrow_torus_strips_keep_their_outline() {
};
let phis: [f64; 3] = [0.3002, 0.3005, 0.3008];
let body = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: phis.iter().map(|p| [20. + 10. * p.cos(), 0., 10. * p.sin()]).collect(),
edges: vec![ring(phis[0], 0), ring(phis[1], 1), ring(phis[2], 2)],
@@ -1973,7 +1987,7 @@ fn disc(r: f64, pts: [[f64; 2]; 9], knots: Vec<f64>) -> Brep {
let s = std::f64::consts::FRAC_1_SQRT_2;
let homogeneous = pts.iter().enumerate().map(|(i, p)| if i % 2 == 1 { [p[0] * s, p[1] * s, 0., s] } else { [p[0], p[1], 0., 1.] }).collect();
Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![[r, 0., 0.]],
edges: vec![Edge { vertices: [0, 0], curve: Curve::RationalSpline { knots, homogeneous } }],
@@ -2065,7 +2079,7 @@ fn nearly_coaxial_cones_far_out_keep_their_own_silhouettes() {
// 1e7 mm out, and 1 km ones 0.4 mm apart 1e9 mm out.
for (x, r, gap) in [(1e7, 5., 0.005), (1e9, 1e6, 0.4)] {
let shells = vec![frustum([x, 0., 0.], r, 0.25, [0., 10.]), frustum([x + gap, 0., 0.], r, 0.25, [20., 30.])];
- check_two_cone_outlines(&Brep { version: crate::brep::VERSION, shells });
+ check_two_cone_outlines(&Brep { version: solidcore_record::brep::VERSION, shells });
}
}
@@ -2098,7 +2112,7 @@ fn nearly_coincident_cone_sectors_both_draw_their_outline() {
cone_sector([x, 0., 0.], 1000., 0.25, [0., 1000.], [0., 0.02]),
cone_sector([x + 3e-6, 0., 0.], 1000., 0.25, [2000., 3000.], [0., 0.02]),
];
- let def = prepare(&Brep { version: crate::brep::VERSION, shells }, &Options::default()).unwrap();
+ let def = prepare(&Brep { version: solidcore_record::brep::VERSION, shells }, &Options::default()).unwrap();
let view = View::new(Vec3::new(-(0.01f64.sin()), 0.01f64.cos(), 0.), Vec3::new(0., 0., 1.)).unwrap();
let d = hidden_lines(&[def], &[identity(0, [0.; 3])], &view, &Options::default(), &never).unwrap();
for (z0, z1) in [(0., 1000.), (2000., 3000.)] {
@@ -2141,7 +2155,7 @@ fn spherical_caps_through_one_circle_keep_their_own_outlines() {
cap([0.; 3], r, lat(0.), edge(), [ring, 0., z]),
cap([0., 0., dz], (ring * ring + (z - dz).powi(2)).sqrt(), lat(dz), edge(), [ring, 0., z]),
];
- let def = prepare(&Brep { version: crate::brep::VERSION, shells }, &Options::default()).unwrap();
+ let def = prepare(&Brep { version: solidcore_record::brep::VERSION, shells }, &Options::default()).unwrap();
let view = View::new(Vec3::new(0., 1., 0.), Vec3::new(0., 0., 1.)).unwrap();
let d = hidden_lines(&[def], &[identity(0, [0.; 3])], &view, &Options::default(), &never).unwrap();
// Above the ring the outline is a half circle of about pi * 1000 * 0.41 mm on each side.
@@ -2161,7 +2175,7 @@ fn spherical_caps_through_one_circle_keep_their_own_outlines() {
fn tilted_cone(tilt: f64, h: [f64; 2]) -> Shell {
let (x, y, z) = (Vec3::new(tilt.cos(), 0., -tilt.sin()), Vec3::new(0., 1., 0.), Vec3::new(tilt.sin(), 0., tilt.cos()));
let arr = |v: Vec3| [v.x, v.y, v.z];
- let frame = |o: Vec3| crate::brep::Frame { origin: arr(o), x_axis: arr(x), y_axis: arr(y) };
+ let frame = |o: Vec3| solidcore_record::brep::Frame { origin: arr(o), x_axis: arr(x), y_axis: arr(y) };
let at = |hh: f64| x * (0.25 * hh) + z * hh;
let ring = |hh: f64, v: u32| Edge {
vertices: [v, v],
@@ -2187,7 +2201,7 @@ fn cones_with_slightly_turned_axes_keep_their_own_outlines() {
// One apex, axes 3e-7 rad apart, heights 1000 to 3000 and 6000 to 8000: each frustum draws
// both rulings of its own outline.
let shells = vec![tilted_cone(0., [1000., 3000.]), tilted_cone(3e-7, [6000., 8000.])];
- let def = prepare(&Brep { version: crate::brep::VERSION, shells }, &Options::default()).unwrap();
+ let def = prepare(&Brep { version: solidcore_record::brep::VERSION, shells }, &Options::default()).unwrap();
let view = View::new(Vec3::new(0., 1., 0.), Vec3::new(0., 0., 1.)).unwrap();
let d = hidden_lines(&[def], &[identity(0, [0.; 3])], &view, &Options::default(), &never).unwrap();
for (z0, z1) in [(1000., 3000.), (6000., 8000.)] {
@@ -2239,7 +2253,7 @@ fn a_high_degree_spline_through_points_of_a_circle_is_not_taken_for_one() {
let knots: Vec<f64> = std::iter::repeat_n(0., n + 1).chain(std::iter::repeat_n(1., n + 1)).collect();
let start = points[0];
let disc = Brep {
- version: crate::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
shells: vec![Shell {
vertices: vec![start],
edges: vec![Edge { vertices: [0, 0], curve: Curve::Spline { knots, points } }],
@@ -2613,7 +2627,7 @@ fn a_placement_that_is_not_rigid_is_refused() {
fn a_revolved_circle_is_a_torus_drawn_at_both_equators() {
// The halves of `torus` stored as revolutions of half circles.
let half = |a: [f64; 2]| Curve::CircleArc {
- frame: crate::brep::Frame { origin: [20., 0., 0.], x_axis: [1., 0., 0.], y_axis: [0., 0., 1.] },
+ frame: solidcore_record::brep::Frame { origin: [20., 0., 0.], x_axis: [1., 0., 0.], y_axis: [0., 0., 1.] },
radius: 5.,
angle: a,
};
@@ -2631,15 +2645,15 @@ fn a_revolved_circle_is_a_torus_drawn_at_both_equators() {
}
/// A record's edge on `curve` over `interval`, its form `nurbs`.
-fn bounded_edge(curve: brep::Curve, nurbs: Option<brep::Curve>, interval: [f64; 2]) -> brep::Edge {
- brep::Edge { curve, nurbs, interval, vertices: [0, 1], tolerance: 1e-6, uses: Vec::new() }
+fn bounded_edge(curve: rec::Curve, nurbs: Option<rec::Curve>, interval: [f64; 2]) -> rec::Edge {
+ rec::Edge { curve, nurbs, interval, vertices: [0, 1], tolerance: 1e-6, uses: Vec::new() }
}
#[test]
fn an_edge_is_cut_to_its_interval_on_its_unbounded_curve() {
let close = |a: Vec3, b: [f64; 3]| a.dist(Vec3::new(b[0], b[1], b[2])) < 1e-12;
// A line through two points, from t = 2 to 3, without and with a form.
- let line = brep::Curve::Line { start: [0.; 3], end: [1., 0., 0.] };
+ let line = rec::Curve::Line { start: [0.; 3], end: [1., 0., 0.] };
let (c, acc) = C3::of_edge(&bounded_edge(line.clone(), None, [2., 3.])).unwrap();
assert_eq!(acc, CurveAccuracy::Analytic);
assert!(close(c.at(0.), [2., 0., 0.]) && close(c.at(1.), [3., 0., 0.]), "{c:?}");
@@ -2649,7 +2663,7 @@ fn an_edge_is_cut_to_its_interval_on_its_unbounded_curve() {
assert!(close(c.at(0.), [2., 0., 0.]) && close(c.at(1.), [3., 0., 0.]), "{c:?}");
// An ellipse's angles come back from its form's parameter.
let frame = frame_at([1., 2., 3.]);
- let ellipse = brep::Curve::Ellipse { frame, radii: [4., 2.] };
+ let ellipse = rec::Curve::Ellipse { frame, radii: [4., 2.] };
let (form, interval) = brep::form::curve(&ellipse, [0.5, 2.5]).unwrap();
let (c, _) = C3::of_edge(&bounded_edge(ellipse, Some(form), interval)).unwrap();
let [a0, a1] = c.domain();
@@ -2657,7 +2671,7 @@ fn an_edge_is_cut_to_its_interval_on_its_unbounded_curve() {
assert!(close(c.at(a0), [1. + 4. * 0.5f64.cos(), 2. + 2. * 0.5f64.sin(), 3.]), "{c:?}");
// A polyline between its second and fourth points' middles.
let points = vec![[0., 0., 0.], [1., 0., 0.], [1., 1., 0.], [1., 1., 1.]];
- let (c, _) = C3::of_edge(&bounded_edge(brep::Curve::Polyline { points }, None, [0.5, 2.5])).unwrap();
+ let (c, _) = C3::of_edge(&bounded_edge(rec::Curve::Polyline { points }, None, [0.5, 2.5])).unwrap();
assert_eq!(c.domain(), [0., 3.]);
assert!(
close(c.at(0.), [0.5, 0., 0.]) && close(c.at(1.), [1., 0., 0.]) && close(c.at(2.), [1., 1., 0.]) && close(c.at(3.), [1., 1., 0.5]),
@@ -2666,7 +2680,7 @@ fn an_edge_is_cut_to_its_interval_on_its_unbounded_curve() {
// A cubic spline of two spans, cut across its inner knot: the same points, on its own domain
// and breaks, its hull and Bezier pieces of the part alone.
let (knots, points) = (vec![0., 0., 0., 0., 0.5, 1., 1., 1., 1.], vec![[0., 0., 0.], [1., 3., 0.], [2., -3., 1.], [3., 3., 0.], [4., 0., 2.]]);
- let spline = brep::Curve::Spline { knots, points };
+ let spline = rec::Curve::Spline { knots, points };
let (whole, _) = C3::of_edge(&bounded_edge(spline.clone(), None, [0., 1.])).unwrap();
let (part, _) = C3::of_edge(&bounded_edge(spline.clone(), None, [0.25, 0.75])).unwrap();
assert_eq!(part.domain(), [0.25, 0.75]);
@@ -2684,13 +2698,10 @@ fn an_edge_is_cut_to_its_interval_on_its_unbounded_curve() {
assert!(part.at(0.15).dist(whole.at(0.15)) < 1e-12);
// A traced intersection with a spline leader on its surfaces is that spline, good to its
// tolerance; with a polyline leader there is no curve to follow.
- let plane = Box::new(brep::Surface::Plane { origin: [0.; 3], u_axis: [1., 0., 0.], v_axis: [0., 1., 0.] });
- let traced = |leader: brep::Curve| brep::Curve::SurfaceIntersection {
- surfaces: [plane.clone(), plane.clone()],
- leader: Box::new(leader),
- tolerance: 1e-4,
- };
- let flat = brep::Curve::Spline {
+ let plane = Box::new(rec::Surface::Plane { origin: [0.; 3], u_axis: [1., 0., 0.], v_axis: [0., 1., 0.] });
+ let traced =
+ |leader: rec::Curve| rec::Curve::SurfaceIntersection { surfaces: [plane.clone(), plane.clone()], leader: Box::new(leader), tolerance: 1e-4 };
+ let flat = rec::Curve::Spline {
knots: vec![0., 0., 0., 0., 0.5, 1., 1., 1., 1.],
points: vec![[0., 0., 0.], [1., 3., 0.], [2., -3., 0.], [3., 3., 0.], [4., 0., 0.]],
};
@@ -2700,7 +2711,7 @@ fn an_edge_is_cut_to_its_interval_on_its_unbounded_curve() {
assert!(c.at(0.5).dist(whole.at(0.5)) < 1e-12);
// That spline leaves the plane: it is not their intersection.
assert!(matches!(C3::of_edge(&bounded_edge(traced(spline), None, [0.25, 0.75])), Err(HlrError::Unsupported("surface intersection curve"))));
- let leader = brep::Curve::Polyline { points: vec![[0.; 3], [1., 0., 0.]] };
+ let leader = rec::Curve::Polyline { points: vec![[0.; 3], [1., 0., 0.]] };
assert!(matches!(C3::of_edge(&bounded_edge(traced(leader), None, [0., 1.])), Err(HlrError::Unsupported("surface intersection curve"))));
}
@@ -2709,9 +2720,9 @@ fn a_faces_chart_is_where_its_form_lies_on_its_label() {
// A torus face from a tube start of 0.3: the chart's second coordinate is the tube angle, a
// third of the way up the tube from there, whichever way round the frame's angle counts.
let frame = frame_at([1., 0., 0.]);
- let label = brep::Surface::Torus { frame, major_radius: 20., minor_radius: 5., tube_start: 0.3 };
+ let label = rec::Surface::Torus { frame, major_radius: 20., minor_radius: 5., tube_start: 0.3 };
let (form, domain) = brep::form::surface(&label, [[-0.5, 1.], [0.2, 2.]]).unwrap();
- let face = brep::Face { surface: label, nurbs: Some(form.clone()), domain, loops: Vec::new() };
+ let face = rec::Face { surface: label, nurbs: Some(form.clone()), domain, loops: Vec::new() };
let s = S3::of_face(&face).unwrap();
let [angle, tube] = s.domain();
assert!((angle[0] + 0.5).abs() < 1e-12 && (angle[1] - 1.).abs() < 1e-12, "{angle:?}");
@@ -2721,9 +2732,9 @@ fn a_faces_chart_is_where_its_form_lies_on_its_label() {
let uv = s.inverse(p, None).unwrap();
assert!(s.point(uv).dist(p) < 1e-9, "{uv:?}");
// A whole turn comes to the periodic chart.
- let label = brep::Surface::Cylinder { frame: frame_at([0.; 3]), radius: 2. };
+ let label = rec::Surface::Cylinder { frame: frame_at([0.; 3]), radius: 2. };
let (form, domain) = brep::form::surface(&label, [[1., 1. + std::f64::consts::TAU], [-1., 3.]]).unwrap();
- let s = S3::of_face(&brep::Face { surface: label, nurbs: Some(form), domain, loops: Vec::new() }).unwrap();
+ let s = S3::of_face(&rec::Face { surface: label, nurbs: Some(form), domain, loops: Vec::new() }).unwrap();
assert_eq!(s.periods()[0], Some(std::f64::consts::TAU));
assert!(s.point([0., 0.]).dist(Vec3::new(2., 0., -1.)) < 1e-12);
assert!(s.point([0., 1.]).dist(Vec3::new(2., 0., 3.)) < 1e-12);
@@ -2737,35 +2748,35 @@ fn a_form_turned_against_its_label_keeps_the_face_on_the_loops_side() {
// same loop on the unturned form is the south hemisphere's.
let tau = std::f64::consts::TAU;
let half = std::f64::consts::FRAC_PI_2;
- let label = brep::Surface::Sphere { frame: frame_at([0.; 3]), radius: 10. };
+ let label = rec::Surface::Sphere { frame: frame_at([0.; 3]), radius: 10. };
let chart = S3::bounded(&label, [[0., tau], [-half, half]]).unwrap();
- let circle = brep::Curve::Circle { frame: frame_at([0.; 3]), radius: 10. };
+ let circle = rec::Curve::Circle { frame: frame_at([0.; 3]), radius: 10. };
let (edge_form, interval) = brep::form::curve(&circle, [0., tau]).unwrap();
let edge = bounded_edge(circle, Some(edge_form), interval);
let curves = vec![C3::of_edge(&edge).unwrap().0];
- let backward = brep::Loop::Edges {
- edges: vec![brep::OrientedEdge {
+ let backward = rec::Loop::Edges {
+ edges: vec![rec::OrientedEdge {
edge: 0,
forward: false,
- pcurve: brep::Curve2::Spline { knots: vec![interval[0], interval[0], interval[1], interval[1]], points: vec![[0., 0.], [1., 0.]] },
+ pcurve: rec::Curve2::Spline { knots: vec![interval[0], interval[0], interval[1], interval[1]], points: vec![[0., 0.], [1., 0.]] },
}],
};
let (form, domain) = brep::form::surface(&label, [[0., tau], [0., half]]).unwrap();
- let brep::Surface::RationalSpline { u_knots, v_knots, homogeneous } = form.clone() else { panic!("a sphere's form is rational") };
+ let rec::Surface::RationalSpline { u_knots, v_knots, homogeneous } = form.clone() else { panic!("a sphere's form is rational") };
let columns = homogeneous[0].len();
let swapped = (0..columns).map(|j| homogeneous.iter().map(|row| row[j]).collect()).collect();
- let turned = brep::Face {
+ let turned = rec::Face {
surface: label.clone(),
- nurbs: Some(brep::Surface::RationalSpline { u_knots: v_knots, v_knots: u_knots, homogeneous: swapped }),
+ nurbs: Some(rec::Surface::RationalSpline { u_knots: v_knots, v_knots: u_knots, homogeneous: swapped }),
domain: [domain[1], domain[0]],
loops: vec![backward.clone()],
};
- assert_eq!(turned.form_turns(), Some(true));
+ assert_eq!(brep::label::form_turns(&turned), Some(true));
let north = trim::build(&turned, &curves, &chart, 64);
assert_eq!((north.contains([1., 1.]), north.contains([1., -1.])), (Some(true), Some(false)));
let (form, domain) = brep::form::surface(&label, [[0., tau], [-half, 0.]]).unwrap();
- let plain = brep::Face { surface: label, nurbs: Some(form), domain, loops: vec![backward] };
- assert_eq!(plain.form_turns(), Some(false));
+ let plain = rec::Face { surface: label, nurbs: Some(form), domain, loops: vec![backward] };
+ assert_eq!(brep::label::form_turns(&plain), Some(false));
let south = trim::build(&plain, &curves, &chart, 64);
assert_eq!((south.contains([1., 1.]), south.contains([1., -1.])), (Some(false), Some(true)));
}
diff --git a/crates/geom/src/inertia.rs b/crates/geom/src/inertia.rs
index 3ff6db48d1..8a0ebcb65d 100644
--- a/crates/geom/src/inertia.rs
+++ b/crates/geom/src/inertia.rs
@@ -1,7 +1,9 @@
//! Inertia tensors (#8095): built from how a body's volume spreads about its centre of mass,
//! taken about another point (parallel axes), and their principal moments and axes.
-use crate::{MassProperties, Vec3};
+use crate::MassProperties;
+use crate::prelude::*;
+use solidcore_record::Vec3;
/// A symmetric 3 × 3 tensor, row by row.
pub type Tensor3 = [[f64; 3]; 3];
diff --git a/crates/geom/src/lib.rs b/crates/geom/src/lib.rs
index ab1124aced..1b719d2a25 100644
--- a/crates/geom/src/lib.rs
+++ b/crates/geom/src/lib.rs
@@ -48,17 +48,26 @@ mod unit_vec3;
mod vec;
pub use aabb2::Aabb2;
-pub use arcfit::MAX_FIT_PIECES;
+pub use arcfit::{Loop2ArcFit, MAX_FIT_PIECES, Region2ArcFit, Seg2ArcFit};
pub use ball::Ball;
pub use blend::hermite_bezier;
pub use bvh::{Bvh, MeshIndex};
pub use chain::{Chain, Closed, Ends, Open, Path, Planar, Ring};
pub use grid::Grid;
pub use mesh::{Aabb3, BoxedTriangle, InsideIndex, MassProperties, Mesh, MeshMeasure, find_close_pair};
-pub use plane::Plane;
-pub use profile::{Loop2, MAX_BEZIER_CTRL, MAX_BEZIER_DEGREE, MAX_DERIVATIVE_ORDER, Region2, Seg2, Similarity2, bezier, regions_apart};
+pub use plane::PlaneGeom;
+pub use profile::{Loop2Geom, MAX_DERIVATIVE_ORDER, Region2Geom, Seg2Geom, Similarity2, bezier, regions_apart};
pub use unit_vec3::UnitVec3;
-pub use vec::{Vec2, Vec3};
+pub use vec::{Vec2Geom, Vec3Geom};
+
+/// The geometry traits of the record's plain data ([`solidcore_record::Vec3`],
+/// [`solidcore_record::Plane`], the profile types), in scope with `use solidcraft_geom::prelude::*`.
+pub mod prelude {
+ pub use crate::{
+ Loop2ArcFit as _, Loop2Geom as _, PlaneGeom as _, Region2ArcFit as _, Region2Geom as _, Seg2ArcFit as _, Seg2Geom as _, Vec2Geom as _,
+ Vec3Geom as _,
+ };
+}
/// Geometric tolerance for coincidence tests (mm).
pub const EPS: f64 = 1e-9;
diff --git a/crates/geom/src/linkage.rs b/crates/geom/src/linkage.rs
index daa753ae62..17e3887785 100644
--- a/crates/geom/src/linkage.rs
+++ b/crates/geom/src/linkage.rs
@@ -32,9 +32,10 @@
//!
//! Input is hostile: orders are capped at [`MAX_CONTINUITY`], and every evaluation is checked.
-use crate::Vec3;
use crate::brep::eval::SurfaceEval;
+use crate::prelude::*;
use crate::tess::partials::{MAX_PARTIAL_ORDER, Partials};
+use solidcore_record::Vec3;
/// The highest continuity order handled: G4, the highest order of the surfaces' exact partials.
pub const MAX_CONTINUITY: usize = MAX_PARTIAL_ORDER;
diff --git a/crates/geom/src/linkage_tests.rs b/crates/geom/src/linkage_tests.rs
index d559fbb85b..3bcbfae26d 100644
--- a/crates/geom/src/linkage_tests.rs
+++ b/crates/geom/src/linkage_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::brep::{Frame, Surface};
+use solidcore_record::brep::{Frame, Surface};
fn frame() -> Frame {
Frame { origin: [1.0, -2.0, 0.5], x_axis: [1.0, 0.0, 0.0], y_axis: [0.0, 1.0, 0.0] }
diff --git a/crates/geom/src/mesh.rs b/crates/geom/src/mesh.rs
index 73c2b42ff8..c28294fada 100644
--- a/crates/geom/src/mesh.rs
+++ b/crates/geom/src/mesh.rs
@@ -1,6 +1,7 @@
+use crate::prelude::*;
use serde::{Deserialize, Serialize};
-use crate::Vec3;
+use solidcore_record::Vec3;
/// Axis-aligned bounding box.
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
diff --git a/crates/geom/src/mesh_distance.rs b/crates/geom/src/mesh_distance.rs
index 31653917ae..c125add85d 100644
--- a/crates/geom/src/mesh_distance.rs
+++ b/crates/geom/src/mesh_distance.rs
@@ -4,7 +4,9 @@
//! rather than the product of the triangle counts.
use crate::compare::closest_on_triangle;
-use crate::{Aabb3, Bvh, Mesh, Vec3};
+use crate::prelude::*;
+use crate::{Aabb3, Bvh, Mesh};
+use solidcore_record::Vec3;
/// A mesh's triangles with their B-rep faces, indexed for distance queries.
#[derive(Clone, Debug, Default)]
diff --git a/crates/geom/src/network.rs b/crates/geom/src/network.rs
index 06ecd688f0..d9359479dd 100644
--- a/crates/geom/src/network.rs
+++ b/crates/geom/src/network.rs
@@ -50,9 +50,10 @@
//! Input is hostile: sizes are capped, every evaluation is checked, and failures are
//! [`SplineError`]s naming the curves; nothing here panics.
-use crate::Vec3;
use crate::bspline::{NurbsSurface, SplineError, SplineResult, invalid};
+use crate::prelude::*;
use crate::spline_space::{Cond, Interpolant, Linear, Monotone, Space, embed};
+use solidcore_record::Vec3;
/// Most curves in one direction of a network.
pub const MAX_NETWORK_CURVES: usize = 32;
diff --git a/crates/geom/src/paper.rs b/crates/geom/src/paper.rs
index bcafed7796..be0dbbf59c 100644
--- a/crates/geom/src/paper.rs
+++ b/crates/geom/src/paper.rs
@@ -32,11 +32,13 @@
//! Writers read a [`Prepared`] scene, which only [`Scene::prepare`] makes, so none reads one that
//! wasn't checked. Clipping will happen there too, once, before any writer (A8).
+use crate::prelude::*;
use serde::{Deserialize, Serialize};
use std::f64::consts::FRAC_PI_2;
-use crate::{EPS, Region2, Seg2, Vec2};
+use crate::EPS;
+use solidcore_record::{Region2, Seg2, Vec2};
/// The widest line a scene may draw, in millimetres.
pub const MAX_LINE_MM: f64 = 10.0;
diff --git a/crates/geom/src/paper_tests.rs b/crates/geom/src/paper_tests.rs
index 8cc36a6e55..d33eb4fd85 100644
--- a/crates/geom/src/paper_tests.rs
+++ b/crates/geom/src/paper_tests.rs
@@ -3,7 +3,7 @@ use std::f64::consts::{PI, TAU};
use serde_json::json;
use super::*;
-use crate::{Loop2, MAX_BEZIER_CTRL};
+use solidcore_record::{Loop2, MAX_BEZIER_CTRL};
fn p(x: f64, y: f64) -> Vec2 {
Vec2::new(x, y)
diff --git a/crates/geom/src/plane.rs b/crates/geom/src/plane.rs
index a668e5ae08..af4d1f6a89 100644
--- a/crates/geom/src/plane.rs
+++ b/crates/geom/src/plane.rs
@@ -1,83 +1,68 @@
-use serde::{Deserialize, Serialize};
+use solidcore_record::{Plane, Vec2, Vec3};
-use crate::{Vec2, Vec3};
+use crate::Vec3Geom;
-/// A sketch plane: an origin and two orthonormal in-plane axes. The normal is `x × y`.
-///
-/// World point of sketch point `(u, v)` = `origin + u·x + v·y`.
-#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
-pub struct Plane {
- pub origin: Vec3,
- #[serde(rename = "x_dir")]
- pub x: Vec3,
- #[serde(rename = "y_dir")]
- pub y: Vec3,
+/// The geometry of a sketch plane ([`Plane`]): made from directions, and mapping points to and
+/// from it.
+// `new` makes a plane, or none from degenerate axes.
+#[allow(clippy::new_ret_no_self)]
+pub trait PlaneGeom {
+ /// Plane through `origin` with the given axes, re-orthonormalised. `None` if degenerate.
+ fn new(origin: Vec3, x: Vec3, y: Vec3) -> Option<Plane>;
+ /// Plane through `origin` with normal `n` (in-plane axes chosen deterministically).
+ fn from_normal(origin: Vec3, n: impl Into<Vec3>) -> Option<Plane>;
+ /// The same plane seen from its other side: a half turn about the sketch x axis (y
+ /// reversed), or about the y axis (x reversed) when `about_y`. Still right-handed.
+ fn flipped(&self, about_y: bool) -> Plane;
+ fn normal(&self) -> Vec3;
+ fn to_world(&self, p: Vec2) -> Vec3;
+ fn dir_to_world(&self, d: Vec2) -> Vec3;
+ fn to_local(&self, p: Vec3) -> Vec2;
+ /// Signed distance of `p` above the plane (along the normal).
+ fn height(&self, p: Vec3) -> f64;
+ /// The plane moved along its normal by `d`.
+ fn offset(&self, d: f64) -> Plane;
+ /// Intersection of the ray `o + t·dir` with the plane (t may be negative).
+ fn intersect_ray(&self, o: Vec3, dir: Vec3) -> Option<Vec3>;
}
-impl Plane {
- /// Top: sketch x = +X, y = +Y, normal +Z.
- pub const XY: Plane = Plane { origin: Vec3::ZERO, x: Vec3::X, y: Vec3::Y };
- /// Front: sketch x = +X, y = −Z, normal +Y.
- pub const XZ: Plane = Plane { origin: Vec3::ZERO, x: Vec3::X, y: Vec3::new(0.0, 0.0, -1.0) };
- /// Right: sketch x = +Y, y = +Z, normal +X.
- pub const YZ: Plane = Plane { origin: Vec3::ZERO, x: Vec3::Y, y: Vec3::Z };
-
- /// Plane through `origin` with the given axes, re-orthonormalised. `None` if degenerate.
- pub fn new(origin: Vec3, x: Vec3, y: Vec3) -> Option<Plane> {
+impl PlaneGeom for Plane {
+ fn new(origin: Vec3, x: Vec3, y: Vec3) -> Option<Plane> {
let x = x.normalized()?;
let n = x.cross(y).normalized()?;
let y = n.cross(x).normalized()?;
origin.is_finite().then_some(Plane { origin, x, y })
}
-
- /// Plane through `origin` with normal `n` (in-plane axes chosen deterministically).
- pub fn from_normal(origin: Vec3, n: impl Into<Vec3>) -> Option<Plane> {
+ fn from_normal(origin: Vec3, n: impl Into<Vec3>) -> Option<Plane> {
let n = n.into().normalized()?;
// Horizontal planes keep world X as sketch x; others use the horizontal direction Z × n.
let cand = if n.dot(Vec3::Z).abs() > 0.9 { Vec3::X } else { Vec3::Z.cross(n) };
let x = (cand - n * cand.dot(n)).normalized()?;
Plane::new(origin, x, n.cross(x))
}
-
- /// The same plane seen from its other side: a half turn about the sketch x axis (y
- /// reversed), or about the y axis (x reversed) when `about_y`. Still right-handed.
- pub fn flipped(&self, about_y: bool) -> Plane {
+ fn flipped(&self, about_y: bool) -> Plane {
if about_y { Plane { x: -self.x, ..*self } } else { Plane { y: -self.y, ..*self } }
}
-
- /// Named origin plane: `XY`, `XZ`, `YZ` (case-insensitive).
- pub fn named(name: &str) -> Option<Plane> {
- match name.to_ascii_uppercase().as_str() {
- "XY" | "TOP" => Some(Plane::XY),
- "XZ" | "FRONT" => Some(Plane::XZ),
- "YZ" | "RIGHT" => Some(Plane::YZ),
- _ => None,
- }
- }
-
- pub fn normal(&self) -> Vec3 {
+ fn normal(&self) -> Vec3 {
self.x.cross(self.y)
}
- pub fn to_world(&self, p: Vec2) -> Vec3 {
+ fn to_world(&self, p: Vec2) -> Vec3 {
self.origin + self.x * p.x + self.y * p.y
}
- pub fn dir_to_world(&self, d: Vec2) -> Vec3 {
+ fn dir_to_world(&self, d: Vec2) -> Vec3 {
self.x * d.x + self.y * d.y
}
- pub fn to_local(&self, p: Vec3) -> Vec2 {
+ fn to_local(&self, p: Vec3) -> Vec2 {
let d = p - self.origin;
Vec2::new(d.dot(self.x), d.dot(self.y))
}
- /// Signed distance of `p` above the plane (along the normal).
- pub fn height(&self, p: Vec3) -> f64 {
+ fn height(&self, p: Vec3) -> f64 {
(p - self.origin).dot(self.normal())
}
- /// The plane moved along its normal by `d`.
- pub fn offset(&self, d: f64) -> Plane {
+ fn offset(&self, d: f64) -> Plane {
Plane { origin: self.origin + self.normal() * d, ..*self }
}
- /// Intersection of the ray `o + t·dir` with the plane (t may be negative).
- pub fn intersect_ray(&self, o: Vec3, dir: Vec3) -> Option<Vec3> {
+ fn intersect_ray(&self, o: Vec3, dir: Vec3) -> Option<Vec3> {
let n = self.normal();
let den = dir.dot(n);
if den.abs() < 1e-12 {
diff --git a/crates/geom/src/profile.rs b/crates/geom/src/profile.rs
index 2e376e53a3..36a53555cb 100644
--- a/crates/geom/src/profile.rs
+++ b/crates/geom/src/profile.rs
@@ -1,66 +1,21 @@
-//! Planar profiles: closed loops of lines, circular arcs, cubic Béziers and conics (rational
-//! quadratic Béziers), and regions (an outer loop minus holes). Sketches produce them; the
-//! kernel turns them into faces.
+//! The geometry of planar profiles ([`Seg2`], [`Loop2`], [`Region2`]: plain data in the
+//! record): evaluation, derivatives, lengths, areas, containment, polylines and triangles.
+//! Sketches produce profiles; the kernel turns them into faces.
use std::f64::consts::TAU;
-use serde::{Deserialize, Serialize};
+use solidcore_record::{Loop2, MAX_BEZIER_CTRL, MAX_BEZIER_DEGREE, Region2, Seg2, Vec2};
-use crate::{Aabb2, Ring, Vec2};
+use crate::prelude::*;
+use crate::{Aabb2, Ring};
-/// One boundary segment in sketch coordinates.
-#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(tag = "type", rename_all = "snake_case")]
-pub enum Seg2 {
- Line {
- a: Vec2,
- b: Vec2,
- },
- /// Arc from `start` angle sweeping `sweep` radians (positive = counter-clockwise).
- Arc {
- center: Vec2,
- radius: f64,
- start: f64,
- sweep: f64,
- },
- /// Cubic Bézier.
- Cubic {
- p0: Vec2,
- p1: Vec2,
- p2: Vec2,
- p3: Vec2,
- },
- /// Rational quadratic Bézier from `a` to `b` with control `apex` of weight `w` (end
- /// weights 1): exact conic arcs (ellipses, parabolas, hyperbolas).
- Conic {
- a: Vec2,
- apex: Vec2,
- b: Vec2,
- w: f64,
- },
- /// Bézier of degree `n` (4…[`MAX_BEZIER_DEGREE`]) over `p[0..=n]` (the rest unused): pieces of
- /// higher-degree splines.
- Bezier {
- n: u8,
- p: [Vec2; MAX_BEZIER_CTRL],
- },
-}
-
-/// Highest degree of [`Seg2::Bezier`]: a degree-9 piece is the single Bézier a G4 blend curve
-/// (`sketch.blend_curve` with `continuity: "g4"`) is made of.
-pub const MAX_BEZIER_DEGREE: usize = 9;
-
-/// Control points a [`Seg2::Bezier`] carries: its highest degree plus one (the unused tail is
-/// zero).
-pub const MAX_BEZIER_CTRL: usize = MAX_BEZIER_DEGREE + 1;
-
-/// Highest derivative order [`Seg2::derivatives`] hands out, and therefore the highest
+/// Highest derivative order [`Seg2Geom::derivatives`] hands out, and therefore the highest
/// continuity order a blend curve can be built for (4 = G4).
pub const MAX_DERIVATIVE_ORDER: usize = 4;
/// A similarity of the plane: a point is scaled by `scale` (above 0) about the origin, turned
/// `angle` radians counter-clockwise, then moved by `shift`. It keeps shapes and the direction
-/// curves turn in, so an arc stays an arc ([`Seg2::similar`]).
+/// curves turn in, so an arc stays an arc ([`Seg2Geom::similar`]).
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Similarity2 {
scale: f64,
@@ -112,18 +67,18 @@ pub fn bezier(pts: &[Vec2]) -> Option<Seg2> {
})
}
-/// Smallest radius, conic weight and absolute arc sweep [`Seg2::check`] accepts.
+/// Smallest radius, conic weight and absolute arc sweep [`Seg2Geom::check`] accepts.
const MIN_POSITIVE: f64 = 1e-12;
-/// Largest conic weight [`Seg2::check`] accepts.
+/// Largest conic weight [`Seg2Geom::check`] accepts.
const MAX_WEIGHT: f64 = 1e12;
-/// Largest arc start angle either way, in radians, [`Seg2::check`] accepts.
+/// Largest arc start angle either way, in radians, [`Seg2Geom::check`] accepts.
const MAX_START_ANGLE: f64 = 1e6;
fn require(condition: bool, message: &'static str) -> Result<(), &'static str> {
if condition { Ok(()) } else { Err(message) }
}
-/// Every value finite and at most `max_abs` in size: [`Seg2::check`]'s rule for coordinates, which
+/// Every value finite and at most `max_abs` in size: [`Seg2Geom::check`]'s rule for coordinates, which
/// `section` applies to its planes and contacts too.
pub(crate) fn coordinates(values: impl IntoIterator<Item = f64>, max_abs: f64) -> Result<(), &'static str> {
require(values.into_iter().all(|v| v.is_finite() && v.abs() <= max_abs), "non-finite or excessive coordinate")
@@ -135,39 +90,6 @@ fn controls(points: &[Vec2], max_abs: f64) -> Result<(), &'static str> {
require(rest.iter().any(|p| p != first), "collapsed curve")
}
-impl Seg2 {
- /// Checks a segment read from outside before anything evaluates it: every stored coordinate
- /// finite and at most `max_abs` in size (a Bézier's unused slots too, as they are serialized),
- /// a radius in 1e-12..=`max_abs`, an arc's start within ±1e6 radians and its absolute sweep
- /// 1e-12 to one turn (with 1e-12 radians of allowance), a conic weight in 1e-12..=1e12, a
- /// Bézier degree of 4 to [`MAX_BEZIER_DEGREE`], controls not all at one point, and finite
- /// ends. The limits keep evaluation finite; they promise no accuracy. The caller wraps the
- /// message in its own error.
- pub(crate) fn check(&self, max_abs: f64) -> Result<(), &'static str> {
- match *self {
- Seg2::Line { a, b } => controls(&[a, b], max_abs)?,
- Seg2::Arc { center, radius, start, sweep } => {
- coordinates([center.x, center.y], max_abs)?;
- require(radius.is_finite() && (MIN_POSITIVE..=max_abs).contains(&radius), "arc radius")?;
- require(start.is_finite() && start.abs() <= MAX_START_ANGLE, "arc start angle")?;
- require(sweep.is_finite() && (MIN_POSITIVE..=TAU + 1e-12).contains(&sweep.abs()), "arc sweep")?;
- }
- Seg2::Cubic { p0, p1, p2, p3 } => controls(&[p0, p1, p2, p3], max_abs)?,
- Seg2::Conic { a, apex, b, w } => {
- controls(&[a, apex, b], max_abs)?;
- require(w.is_finite() && (MIN_POSITIVE..=MAX_WEIGHT).contains(&w), "conic weight")?;
- }
- Seg2::Bezier { n, ref p } => {
- require((4..=MAX_BEZIER_DEGREE).contains(&usize::from(n)), "Bezier degree")?;
- // The unused slots are serialized too: reject hidden non-finite/excessive values.
- coordinates(p.iter().flat_map(|q| [q.x, q.y]), max_abs)?;
- controls(p.get(..=usize::from(n)).ok_or("Bezier degree")?, max_abs)?;
- }
- }
- require(self.start().is_finite() && self.end().is_finite(), "non-finite curve endpoint")
- }
-}
-
/// de Casteljau: the point at `t` and the two halves' control points.
fn casteljau(c: &[Vec2], t: f64) -> (Vec2, Vec<Vec2>, Vec<Vec2>) {
let mut w = c.to_vec();
@@ -228,12 +150,233 @@ const GL5: [(f64, f64); 5] = [
(0.953_089_922_969_332, 0.118_463_442_528_095),
];
-impl Seg2 {
- fn bez(n: u8, p: &[Vec2; MAX_BEZIER_CTRL]) -> &[Vec2] {
- &p[..(n as usize).clamp(1, MAX_BEZIER_DEGREE) + 1]
+/// The largest distance from a point inside `loops` (even-odd) to their sides, by a grid search
+/// over their box refined around the best point. Zero for an empty or degenerate outline.
+fn max_clearance(loops: &[Ring<Vec2>]) -> f64 {
+ let sides: Vec<(Vec2, Vec2)> = loops.iter().flat_map(|pl| pl.edges().map(|(a, b)| (*a, *b))).filter(|(a, b)| a.dist(*b) > 0.0).collect();
+ let corners: Aabb2 = sides.iter().map(|s| s.0).collect();
+ if corners.is_empty() {
+ return 0.0;
+ }
+ let Aabb2 { min: lo, max: hi } = corners;
+ let inside = |p: Vec2| {
+ let mut odd = false;
+ for (a, b) in &sides {
+ if (a.y > p.y) != (b.y > p.y) && p.x < a.x + (p.y - a.y) / (b.y - a.y) * (b.x - a.x) {
+ odd = !odd;
+ }
+ }
+ odd
+ };
+ let clearance = |p: Vec2| -> f64 {
+ if !inside(p) {
+ return 0.0;
+ }
+ sides
+ .iter()
+ .map(|(a, b)| {
+ let ab = *b - *a;
+ let t = ((p - *a).dot(ab) / ab.len2()).clamp(0.0, 1.0);
+ p.dist(*a + ab * t)
+ })
+ .fold(f64::INFINITY, f64::min)
+ };
+ const N: usize = 32;
+ let size = hi - lo;
+ let mut best = (0.0, (lo + hi) * 0.5);
+ for i in 0..=N {
+ for j in 0..=N {
+ let p = Vec2::new(lo.x + size.x * i as f64 / N as f64, lo.y + size.y * j as f64 / N as f64);
+ let c = clearance(p);
+ if c > best.0 {
+ best = (c, p);
+ }
+ }
+ }
+ // Refine: try the eight neighbours, halving the step whenever none is better.
+ let mut step = size.x.max(size.y) / N as f64;
+ for _ in 0..60 {
+ if step < size.x.max(size.y) * 1e-9 {
+ break;
+ }
+ let around = [(1.0, 0.0), (-1.0, 0.0), (0.0, 1.0), (0.0, -1.0), (1.0, 1.0), (1.0, -1.0), (-1.0, 1.0), (-1.0, -1.0)];
+ match around.iter().map(|(dx, dy)| best.1 + Vec2::new(dx * step, dy * step)).map(|p| (clearance(p), p)).max_by(|a, b| a.0.total_cmp(&b.0)) {
+ Some(n) if n.0 > best.0 => best = n,
+ _ => step *= 0.5,
+ }
+ }
+ best.0
+}
+
+/// Most boundary segment pairs [`regions_apart`] compares before it gives up (and says no).
+const APART_BUDGET: usize = 50_000_000;
+
+/// Whether no two of the regions meet or come within `gap` of each other (their boundaries
+/// are farther apart than `gap` and none lies inside another; one inside another's hole is
+/// apart). Tools made from them alike (extruded over one interval) are then apart too, and
+/// can be cut as one. False when unsure (a degenerate region, too much to compare).
+pub fn regions_apart(regions: &[Region2], gap: f64) -> bool {
+ if !(gap.is_finite() && gap > 0.0) || regions.len() > 10_000 {
+ return false;
+ }
+ // The polylines lie within `tol` of the curves: boundaries this much farther than the gap
+ // apart are apart.
+ let tol = gap / 4.0;
+ let reach = gap + 2.0 * tol;
+ struct Outline {
+ loops: Vec<Ring<Vec2>>,
+ bounds: Aabb2,
+ inside: Vec2,
}
+ let mut outlines = Vec::with_capacity(regions.len());
+ for r in regions {
+ let loops: Vec<Ring<Vec2>> = std::iter::once(&r.outer).chain(&r.holes).map(|l| l.polyline(tol)).collect();
+ let Some(outer) = loops.first().filter(|l| l.len() >= 2) else { return false };
+ if outer.iter().any(|p| !p.is_finite()) {
+ return false;
+ }
+ let bounds = outer.bounds();
+ let Some(inside) = outer.first().copied() else { return false };
+ outlines.push(Outline { loops, bounds, inside });
+ }
+ let mut order: Vec<usize> = (0..outlines.len()).collect();
+ order.sort_by(|&i, &j| {
+ let x = |k: usize| outlines.get(k).map(|o| o.bounds.min.x).unwrap_or(0.0);
+ x(i).total_cmp(&x(j))
+ });
+ let mut work = 0usize;
+ for (k, &i) in order.iter().enumerate() {
+ let Some(a) = outlines.get(i) else { return false };
+ for &j in order.iter().skip(k + 1) {
+ let Some(b) = outlines.get(j) else { return false };
+ let (a_box, b_box) = (a.bounds, b.bounds);
+ if b_box.min.x > a_box.max.x + reach {
+ break;
+ }
+ if b_box.min.y > a_box.max.y + reach || a_box.min.y > b_box.max.y + reach {
+ continue;
+ }
+ // A boundary point of one inside the other: one holds the other (boundaries that do
+ // not come near each other do not cross).
+ let (Some(ra), Some(rb)) = (regions.get(i), regions.get(j)) else { return false };
+ if ra.contains(b.inside) || rb.contains(a.inside) {
+ return false;
+ }
+ for la in &a.loops {
+ for lb in &b.loops {
+ work = work.saturating_add(la.len().saturating_mul(lb.len()));
+ if work > APART_BUDGET {
+ return false;
+ }
+ // (Each loop closed: its last point back to its first.)
+ for (p, q) in la.iter().zip(la.iter().skip(1).chain(la.first())) {
+ for (r, s) in lb.iter().zip(lb.iter().skip(1).chain(lb.first())) {
+ if segment_distance(*p, *q, *r, *s) <= reach {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ true
+}
+
+/// The distance between segments `ab` and `cd` (0 where they cross).
+fn segment_distance(a: Vec2, b: Vec2, c: Vec2, d: Vec2) -> f64 {
+ let side = |p: Vec2, q: Vec2, r: Vec2| (q - p).cross(r - p);
+ let (d1, d2, d3, d4) = (side(c, d, a), side(c, d, b), side(a, b, c), side(a, b, d));
+ if ((d1 > 0.0 && d2 < 0.0) || (d1 < 0.0 && d2 > 0.0)) && ((d3 > 0.0 && d4 < 0.0) || (d3 < 0.0 && d4 > 0.0)) {
+ return 0.0;
+ }
+ let to = |p: Vec2, s: Vec2, e: Vec2| {
+ let v = e - s;
+ let len2 = v.dot(v);
+ let t = if len2 > 0.0 { ((p - s).dot(v) / len2).clamp(0.0, 1.0) } else { 0.0 };
+ p.dist(s + v * t)
+ };
+ to(a, c, d).min(to(b, c, d)).min(to(c, a, b)).min(to(d, a, b))
+}
+
+/// The geometry of a profile segment ([`Seg2`]): evaluation, derivatives, lengths, splits and
+/// closest points.
+pub trait Seg2Geom {
+ /// Checks a segment read from outside before anything evaluates it: every stored coordinate
+ /// finite and at most `max_abs` in size (a Bézier's unused slots too, as they are serialized),
+ /// a radius in 1e-12..=`max_abs`, an arc's start within ±1e6 radians and its absolute sweep
+ /// 1e-12 to one turn (with 1e-12 radians of allowance), a conic weight in 1e-12..=1e12, a
+ /// Bézier degree of 4 to [`MAX_BEZIER_DEGREE`], controls not all at one point, and finite
+ /// ends. The limits keep evaluation finite; they promise no accuracy. The caller wraps the
+ /// message in its own error.
+ fn check(&self, max_abs: f64) -> Result<(), &'static str>;
/// Derivative with respect to the parameter at `t` (Béziers and conics; lines and arcs too).
- pub fn derivative(&self, t: f64) -> Vec2 {
+ fn derivative(&self, t: f64) -> Vec2;
+ /// Derivatives 1…`order` with respect to the segment's own parameter at `t`, exactly: a line
+ /// and an arc from their analytic form (an arc's are the circular-motion recurrence, zero
+ /// curvature terms included), a cubic and a higher-degree piece from the forward differences
+ /// of their controls, a conic through the quotient rule of its rational form. A blend curve
+ /// reads a reference curve's derivatives here to build a Hermite interpolation, so this is
+ /// exact at both ends (`t` = 0 and 1) and `None` — never a wrong number — when `order` is
+ /// above [`MAX_DERIVATIVE_ORDER`], `t` is not finite or a value is not finite, as with a
+ /// degenerate rational piece.
+ fn derivatives(&self, t: f64, order: usize) -> Option<Vec<Vec2>>;
+ fn start(&self) -> Vec2;
+ fn end(&self) -> Vec2;
+ fn point_at(&self, t: f64) -> Vec2;
+ fn mid(&self) -> Vec2;
+ /// Unit tangent at the start (direction of travel).
+ fn start_tangent(&self) -> Vec2;
+ /// Unit tangent at the end (direction of travel).
+ fn end_tangent(&self) -> Vec2;
+ fn reversed(&self) -> Seg2;
+ /// The segment with each control point mapped by `f`: exact for any affine map of lines,
+ /// Béziers and conics. An arc is returned as it is: only a similarity keeps it an arc
+ /// ([`Seg2Geom::similar`]), and callers that mirror one handle it themselves.
+ fn map_controls(&self, f: impl Fn(Vec2) -> Vec2) -> Seg2;
+ /// The segment moved by the similarity `m`, exactly: an arc's centre maps, its radius scales
+ /// and its start turns; every other kind maps its control points.
+ fn similar(&self, m: &Similarity2) -> Seg2;
+ fn length(&self) -> f64;
+ /// The segment split at parameter `t` in (0, 1) (same kind, exact; conic halves are
+ /// re-normalised so their end weights stay 1).
+ fn split_at(&self, t: f64) -> (Seg2, Seg2);
+ /// Parameter of the closest point: exact projection for lines,
+ /// sampling followed by Newton for the remaining curves.
+ fn closest_param(&self, p: Vec2) -> f64;
+ /// The two halves of the segment (same kind, exact).
+ fn split_half(&self) -> (Seg2, Seg2);
+ /// Contribution to the loop's signed area (shoelace integral ½∮(x dy − y dx)).
+ fn area_term(&self) -> f64;
+ /// Polyline approximation (including both end points) with at most `tol` chord error.
+ fn polyline(&self, tol: f64) -> Vec<Vec2>;
+}
+
+impl Seg2Geom for Seg2 {
+ fn check(&self, max_abs: f64) -> Result<(), &'static str> {
+ match *self {
+ Seg2::Line { a, b } => controls(&[a, b], max_abs)?,
+ Seg2::Arc { center, radius, start, sweep } => {
+ coordinates([center.x, center.y], max_abs)?;
+ require(radius.is_finite() && (MIN_POSITIVE..=max_abs).contains(&radius), "arc radius")?;
+ require(start.is_finite() && start.abs() <= MAX_START_ANGLE, "arc start angle")?;
+ require(sweep.is_finite() && (MIN_POSITIVE..=TAU + 1e-12).contains(&sweep.abs()), "arc sweep")?;
+ }
+ Seg2::Cubic { p0, p1, p2, p3 } => controls(&[p0, p1, p2, p3], max_abs)?,
+ Seg2::Conic { a, apex, b, w } => {
+ controls(&[a, apex, b], max_abs)?;
+ require(w.is_finite() && (MIN_POSITIVE..=MAX_WEIGHT).contains(&w), "conic weight")?;
+ }
+ Seg2::Bezier { n, ref p } => {
+ require((4..=MAX_BEZIER_DEGREE).contains(&usize::from(n)), "Bezier degree")?;
+ // The unused slots are serialized too: reject hidden non-finite/excessive values.
+ coordinates(p.iter().flat_map(|q| [q.x, q.y]), max_abs)?;
+ controls(p.get(..=usize::from(n)).ok_or("Bezier degree")?, max_abs)?;
+ }
+ }
+ require(self.start().is_finite() && self.end().is_finite(), "non-finite curve endpoint")
+ }
+ fn derivative(&self, t: f64) -> Vec2 {
match *self {
Seg2::Line { a, b } => b - a,
Seg2::Arc { radius, start, sweep, .. } => Vec2::from_angle(start + sweep * t).perp() * (radius * sweep),
@@ -248,21 +391,13 @@ impl Seg2 {
(dn * d - n * dd) / (d * d).max(1e-300)
}
Seg2::Bezier { n, ref p } => {
- let c = Self::bez(n, p);
+ let c = bez(n, p);
let diffs: Vec<Vec2> = c.windows(2).map(|w| (w[1] - w[0]) * (c.len() - 1) as f64).collect();
casteljau(&diffs, t).0
}
}
}
- /// Derivatives 1…`order` with respect to the segment's own parameter at `t`, exactly: a line
- /// and an arc from their analytic form (an arc's are the circular-motion recurrence, zero
- /// curvature terms included), a cubic and a higher-degree piece from the forward differences
- /// of their controls, a conic through the quotient rule of its rational form. A blend curve
- /// reads a reference curve's derivatives here to build a Hermite interpolation, so this is
- /// exact at both ends (`t` = 0 and 1) and `None` — never a wrong number — when `order` is
- /// above [`MAX_DERIVATIVE_ORDER`], `t` is not finite or a value is not finite, as with a
- /// degenerate rational piece.
- pub fn derivatives(&self, t: f64, order: usize) -> Option<Vec<Vec2>> {
+ fn derivatives(&self, t: f64, order: usize) -> Option<Vec<Vec2>> {
if !t.is_finite() || order > MAX_DERIVATIVE_ORDER {
return None;
}
@@ -291,7 +426,7 @@ impl Seg2 {
d
}
Seg2::Cubic { p0, p1, p2, p3 } => bezier_derivatives(&[p0, p1, p2, p3], t, MAX_DERIVATIVE_ORDER)?,
- Seg2::Bezier { n, ref p } => bezier_derivatives(Self::bez(n, p), t, MAX_DERIVATIVE_ORDER)?,
+ Seg2::Bezier { n, ref p } => bezier_derivatives(bez(n, p), t, MAX_DERIVATIVE_ORDER)?,
Seg2::Conic { a, apex, b, w } => {
if !a.is_finite() || !apex.is_finite() || !b.is_finite() || !w.is_finite() {
return None;
@@ -334,7 +469,7 @@ impl Seg2 {
d.truncate(order);
d.iter().all(|q| q.is_finite()).then_some(d)
}
- pub fn start(&self) -> Vec2 {
+ fn start(&self) -> Vec2 {
match *self {
Seg2::Line { a, .. } | Seg2::Conic { a, .. } => a,
Seg2::Cubic { p0, .. } => p0,
@@ -342,15 +477,15 @@ impl Seg2 {
Seg2::Arc { center, radius, start, .. } => center + Vec2::from_angle(start) * radius,
}
}
- pub fn end(&self) -> Vec2 {
+ fn end(&self) -> Vec2 {
match *self {
Seg2::Line { b, .. } | Seg2::Conic { b, .. } => b,
Seg2::Cubic { p3, .. } => p3,
- Seg2::Bezier { n, ref p } => Self::bez(n, p).last().copied().unwrap_or(p[0]),
+ Seg2::Bezier { n, ref p } => bez(n, p).last().copied().unwrap_or(p[0]),
Seg2::Arc { center, radius, start, sweep } => center + Vec2::from_angle(start + sweep) * radius,
}
}
- pub fn point_at(&self, t: f64) -> Vec2 {
+ fn point_at(&self, t: f64) -> Vec2 {
match *self {
Seg2::Line { a, b } => a.lerp(b, t),
Seg2::Arc { center, radius, start, sweep } => center + Vec2::from_angle(start + sweep * t) * radius,
@@ -363,40 +498,38 @@ impl Seg2 {
let d = u * u + 2.0 * w * u * t + t * t;
(a * (u * u) + apex * (2.0 * w * u * t) + b * (t * t)) / d.max(1e-300)
}
- Seg2::Bezier { n, ref p } => casteljau(Self::bez(n, p), t).0,
+ Seg2::Bezier { n, ref p } => casteljau(bez(n, p), t).0,
}
}
- pub fn mid(&self) -> Vec2 {
+ fn mid(&self) -> Vec2 {
self.point_at(0.5)
}
- /// Unit tangent at the start (direction of travel).
- pub fn start_tangent(&self) -> Vec2 {
+ fn start_tangent(&self) -> Vec2 {
match *self {
Seg2::Line { a, b } => (b - a).normalized().unwrap_or(Vec2::X),
Seg2::Arc { start, sweep, .. } => Vec2::from_angle(start).perp() * sweep.signum(),
Seg2::Cubic { p0, p1, p2, .. } => (p1 - p0).normalized().or_else(|| (p2 - p0).normalized()).unwrap_or(Vec2::X),
Seg2::Conic { a, apex, b, .. } => (apex - a).normalized().or_else(|| (b - a).normalized()).unwrap_or(Vec2::X),
Seg2::Bezier { n, ref p } => {
- let c = Self::bez(n, p);
+ let c = bez(n, p);
c.iter().skip(1).find_map(|q| (*q - c[0]).normalized()).unwrap_or(Vec2::X)
}
}
}
- /// Unit tangent at the end (direction of travel).
- pub fn end_tangent(&self) -> Vec2 {
+ fn end_tangent(&self) -> Vec2 {
match *self {
Seg2::Line { a, b } => (b - a).normalized().unwrap_or(Vec2::X),
Seg2::Arc { start, sweep, .. } => Vec2::from_angle(start + sweep).perp() * sweep.signum(),
Seg2::Cubic { p1, p2, p3, .. } => (p3 - p2).normalized().or_else(|| (p3 - p1).normalized()).unwrap_or(Vec2::X),
Seg2::Conic { a, apex, b, .. } => (b - apex).normalized().or_else(|| (b - a).normalized()).unwrap_or(Vec2::X),
Seg2::Bezier { n, ref p } => {
- let c = Self::bez(n, p);
+ let c = bez(n, p);
let last = c.last().copied().unwrap_or(p[0]);
c.iter().rev().skip(1).find_map(|q| (last - *q).normalized()).unwrap_or(Vec2::X)
}
}
}
- pub fn reversed(&self) -> Seg2 {
+ fn reversed(&self) -> Seg2 {
match *self {
Seg2::Line { a, b } => Seg2::Line { a: b, b: a },
Seg2::Arc { center, radius, start, sweep } => Seg2::Arc { center, radius, start: start + sweep, sweep: -sweep },
@@ -410,10 +543,7 @@ impl Seg2 {
}
}
}
- /// The segment with each control point mapped by `f`: exact for any affine map of lines,
- /// Béziers and conics. An arc is returned as it is: only a similarity keeps it an arc
- /// ([`Seg2::similar`]), and callers that mirror one handle it themselves.
- pub fn map_controls(&self, f: impl Fn(Vec2) -> Vec2) -> Seg2 {
+ fn map_controls(&self, f: impl Fn(Vec2) -> Vec2) -> Seg2 {
match *self {
Seg2::Line { a, b } => Seg2::Line { a: f(a), b: f(b) },
Seg2::Cubic { p0, p1, p2, p3 } => Seg2::Cubic { p0: f(p0), p1: f(p1), p2: f(p2), p3: f(p3) },
@@ -425,9 +555,7 @@ impl Seg2 {
arc @ Seg2::Arc { .. } => arc,
}
}
- /// The segment moved by the similarity `m`, exactly: an arc's centre maps, its radius scales
- /// and its start turns; every other kind maps its control points.
- pub fn similar(&self, m: &Similarity2) -> Seg2 {
+ fn similar(&self, m: &Similarity2) -> Seg2 {
match *self {
Seg2::Arc { center, radius, start, sweep } => {
Seg2::Arc { center: m.apply(center), radius: radius * m.scale(), start: start + m.angle(), sweep }
@@ -435,16 +563,14 @@ impl Seg2 {
_ => self.map_controls(|p| m.apply(p)),
}
}
- pub fn length(&self) -> f64 {
+ fn length(&self) -> f64 {
match *self {
Seg2::Line { a, b } => a.dist(b),
Seg2::Arc { radius, sweep, .. } => (radius * sweep).abs(),
- Seg2::Cubic { .. } | Seg2::Conic { .. } | Seg2::Bezier { .. } => self.integrate(|s, t| s.derivative(t).len()),
+ Seg2::Cubic { .. } | Seg2::Conic { .. } | Seg2::Bezier { .. } => integrate(self, |s, t| s.derivative(t).len()),
}
}
- /// The segment split at parameter `t` in (0, 1) (same kind, exact; conic halves are
- /// re-normalised so their end weights stay 1).
- pub fn split_at(&self, t: f64) -> (Seg2, Seg2) {
+ fn split_at(&self, t: f64) -> (Seg2, Seg2) {
let t = t.clamp(1e-9, 1.0 - 1e-9);
match *self {
Seg2::Line { a, b } => {
@@ -476,15 +602,13 @@ impl Seg2 {
)
}
Seg2::Bezier { n, ref p } => {
- let (_, l, r) = casteljau(Self::bez(n, p), t);
+ let (_, l, r) = casteljau(bez(n, p), t);
let mk = |c: &[Vec2]| bezier(c).unwrap_or(*self);
(mk(&l), mk(&r))
}
}
}
- /// Parameter of the closest point: exact projection for lines,
- /// sampling followed by Newton for the remaining curves.
- pub fn closest_param(&self, p: Vec2) -> f64 {
+ fn closest_param(&self, p: Vec2) -> f64 {
let finite = |p: Vec2| p.x.is_finite() && p.y.is_finite();
match *self {
Seg2::Line { a, b } if finite(a) && finite(b) && finite(p) => {
@@ -502,42 +626,20 @@ impl Seg2 {
}
let n = 64;
let t = (0..=n).map(|i| i as f64 / n as f64).min_by(|x, y| self.point_at(*x).dist(p).total_cmp(&self.point_at(*y).dist(p))).unwrap_or(0.0);
- let t = self.newton_closest(p, t);
+ let t = newton_closest(self, p, t);
// A closed segment (a full circle) starts where it ends: a point just before its start is
// nearest just before its end, which Newton from the start (held there by the clamp)
// never reaches. Try from the other end too.
let (a, b) = (self.point_at(0.0), self.point_at(1.0));
if (t == 0.0 || t == 1.0) && a.dist(b) <= 1e-12 * (1.0 + a.len()) {
- let other = self.newton_closest(p, 1.0 - t);
+ let other = newton_closest(self, p, 1.0 - t);
if self.point_at(other).dist(p) < self.point_at(t).dist(p) {
return other;
}
}
t
}
-
- /// Newton's method for the parameter of the point nearest `p`, from `t`, within [0, 1].
- fn newton_closest(&self, p: Vec2, mut t: f64) -> f64 {
- for _ in 0..30 {
- let (q, d) = (self.point_at(t), self.derivative(t));
- let (d2, h) = ((self.derivative((t + 1e-6).min(1.0)) - self.derivative((t - 1e-6).max(0.0))) / 2e-6, q - p);
- let f = h.dot(d);
- let df = d.dot(d) + h.dot(d2);
- if df.abs() < 1e-300 {
- break;
- }
- let nt = (t - f / df).clamp(0.0, 1.0);
- if (nt - t).abs() < 1e-14 {
- t = nt;
- break;
- }
- t = nt;
- }
- t
- }
-
- /// The two halves of the segment (same kind, exact).
- pub fn split_half(&self) -> (Seg2, Seg2) {
+ fn split_half(&self) -> (Seg2, Seg2) {
match *self {
Seg2::Line { a, b } => {
let m = a.lerp(b, 0.5);
@@ -563,20 +665,7 @@ impl Seg2 {
Seg2::Bezier { .. } => self.split_at(0.5),
}
}
- /// ∫₀¹ f(t) dt by composite Gauss–Legendre (16 pieces of 5 points).
- fn integrate(&self, f: impl Fn(&Seg2, f64) -> f64) -> f64 {
- let n = 16;
- let mut sum = 0.0;
- for k in 0..n {
- let (t0, h) = (k as f64 / n as f64, 1.0 / n as f64);
- for (x, w) in GL5 {
- sum += w * h * f(self, t0 + x * h);
- }
- }
- sum
- }
- /// Contribution to the loop's signed area (shoelace integral ½∮(x dy − y dx)).
- pub fn area_term(&self) -> f64 {
+ fn area_term(&self) -> f64 {
match *self {
Seg2::Line { a, b } => 0.5 * a.cross(b),
Seg2::Arc { radius, sweep, .. } => {
@@ -584,11 +673,10 @@ impl Seg2 {
// Chord term plus the circular segment between chord and arc.
0.5 * a.cross(b) + 0.5 * radius * radius * (sweep - sweep.sin())
}
- Seg2::Cubic { .. } | Seg2::Conic { .. } | Seg2::Bezier { .. } => self.integrate(|s, t| 0.5 * s.point_at(t).cross(s.derivative(t))),
+ Seg2::Cubic { .. } | Seg2::Conic { .. } | Seg2::Bezier { .. } => integrate(self, |s, t| 0.5 * s.point_at(t).cross(s.derivative(t))),
}
}
- /// Polyline approximation (including both end points) with at most `tol` chord error.
- pub fn polyline(&self, tol: f64) -> Vec<Vec2> {
+ fn polyline(&self, tol: f64) -> Vec<Vec2> {
match *self {
Seg2::Line { a, b } => vec![a, b],
Seg2::Arc { radius, sweep, .. } => {
@@ -610,7 +698,7 @@ impl Seg2 {
}
Seg2::Bezier { n, ref p } => {
// Second derivative ≤ n(n−1) × the largest second difference of the controls.
- let c = Self::bez(n, p);
+ let c = bez(n, p);
let d2 = c.windows(3).map(|w| (w[0] - w[1] * 2.0 + w[2]).len()).fold(0.0, f64::max) * (n as f64) * (n as f64 - 1.0);
let k = ((d2 / (8.0 * tol.max(1e-9))).sqrt().ceil() as usize).clamp(2, 4096);
(0..=k).map(|i| self.point_at(i as f64 / k as f64)).collect()
@@ -619,53 +707,51 @@ impl Seg2 {
}
}
-/// A closed loop of segments, each starting where the previous one ends.
-#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
-pub struct Loop2 {
- pub segs: Vec<Seg2>,
+/// The geometry of a profile loop ([`Loop2`]): area, orientation, containment and polylines.
+pub trait Loop2Geom {
+ /// The radius of the largest circle inside the loop, to about `tol` ([`Region2Geom::inradius`]).
+ fn inradius(&self, tol: f64) -> f64;
+ /// Signed area: positive when counter-clockwise.
+ fn signed_area(&self) -> f64;
+ fn reversed(&self) -> Loop2;
+ /// Whether the loop runs counter-clockwise ([`Loop2::ccw`] keeps it as it is).
+ fn is_ccw(&self) -> bool;
+ /// Counter-clockwise copy.
+ fn ccw(&self) -> Loop2;
+ /// Each segment with the next and the last with the first: the loop's joints, where one
+ /// segment should end on the start of the next.
+ fn joints(&self) -> impl Iterator<Item = (&Seg2, &Seg2)> + Clone;
+ /// The loop as a polyline within `tol`: each segment's points but its last, which the next
+ /// segment starts on.
+ fn polyline(&self, tol: f64) -> Ring<Vec2>;
+ /// Even-odd point containment against the polyline approximation.
+ fn contains(&self, p: Vec2) -> bool;
+ /// Area-weighted centroid (of the polyline approximation).
+ fn centroid(&self) -> Vec2;
+ /// Closed within `tol`?
+ fn is_closed(&self, tol: f64) -> bool;
}
-impl Loop2 {
- /// The radius of the largest circle inside the loop, to about `tol` ([`Region2::inradius`]).
- pub fn inradius(&self, tol: f64) -> f64 {
+impl Loop2Geom for Loop2 {
+ fn inradius(&self, tol: f64) -> f64 {
max_clearance(&[self.polyline(tol)])
}
- /// Full circle as one arc from angle 0 (counter-clockwise): one closed curve, so a solid
- /// swept from it has one wall, and an edge round it is one edge.
- pub fn circle(center: Vec2, radius: f64) -> Loop2 {
- Loop2::circle_from(center, radius, 0.0)
- }
- /// Full circle as one arc starting (and ending) at angle `start`, counter-clockwise.
- pub fn circle_from(center: Vec2, radius: f64, start: f64) -> Loop2 {
- Loop2 { segs: vec![Seg2::Arc { center, radius, start, sweep: TAU }] }
- }
- pub fn polygon(pts: &[Vec2]) -> Loop2 {
- let n = pts.len();
- Loop2 { segs: (0..n).filter_map(|i| Some(Seg2::Line { a: *pts.get(i)?, b: *pts.get((i + 1) % n)? })).collect() }
- }
- /// Signed area: positive when counter-clockwise.
- pub fn signed_area(&self) -> f64 {
+ fn signed_area(&self) -> f64 {
self.segs.iter().map(Seg2::area_term).sum()
}
- pub fn reversed(&self) -> Loop2 {
+ fn reversed(&self) -> Loop2 {
Loop2 { segs: self.segs.iter().rev().map(Seg2::reversed).collect() }
}
- /// Whether the loop runs counter-clockwise ([`Loop2::ccw`] keeps it as it is).
- pub fn is_ccw(&self) -> bool {
+ fn is_ccw(&self) -> bool {
self.signed_area() >= 0.0
}
- /// Counter-clockwise copy.
- pub fn ccw(&self) -> Loop2 {
+ fn ccw(&self) -> Loop2 {
if self.is_ccw() { self.clone() } else { self.reversed() }
}
- /// Each segment with the next and the last with the first: the loop's joints, where one
- /// segment should end on the start of the next.
- pub fn joints(&self) -> impl Iterator<Item = (&Seg2, &Seg2)> + Clone {
+ fn joints(&self) -> impl Iterator<Item = (&Seg2, &Seg2)> + Clone {
crate::chain::around(&self.segs)
}
- /// The loop as a polyline within `tol`: each segment's points but its last, which the next
- /// segment starts on.
- pub fn polyline(&self, tol: f64) -> Ring<Vec2> {
+ fn polyline(&self, tol: f64) -> Ring<Vec2> {
self.segs
.iter()
.flat_map(|s| {
@@ -675,12 +761,10 @@ impl Loop2 {
})
.collect()
}
- /// Even-odd point containment against the polyline approximation.
- pub fn contains(&self, p: Vec2) -> bool {
+ fn contains(&self, p: Vec2) -> bool {
self.polyline(1e-3).contains(p)
}
- /// Area-weighted centroid (of the polyline approximation).
- pub fn centroid(&self) -> Vec2 {
+ fn centroid(&self) -> Vec2 {
let poly = self.polyline(1e-3);
let n = poly.len();
let (mut a2, mut c) = (0.0, Vec2::ZERO);
@@ -692,8 +776,7 @@ impl Loop2 {
}
if a2.abs() < 1e-15 { poly.first().copied().unwrap_or_default() } else { c / (3.0 * a2) }
}
- /// Closed within `tol`?
- pub fn is_closed(&self, tol: f64) -> bool {
+ fn is_closed(&self, tol: f64) -> bool {
let n = self.segs.len();
n > 0
&& (0..n).all(|i| match (self.segs.get(i), self.segs.get((i + 1) % n)) {
@@ -703,23 +786,28 @@ impl Loop2 {
}
}
-/// A planar region: outer loop (counter-clockwise) minus holes (clockwise).
-#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
-pub struct Region2 {
- pub outer: Loop2,
- pub holes: Vec<Loop2>,
+/// The geometry of a profile region ([`Region2`]): area, containment, inradius and triangles.
+pub trait Region2Geom {
+ fn area(&self) -> f64;
+ /// A point strictly inside the region (for picking and labels).
+ fn interior_point(&self) -> Vec2;
+ fn contains(&self, p: Vec2) -> bool;
+ /// The radius of the largest circle inside the region: how far its sides can move inwards
+ /// before they meet (a taper going in closes it there). Found by a grid search refined
+ /// around the best point, to about `tol`.
+ fn inradius(&self, tol: f64) -> f64;
+ /// Triangles covering the region (for filled display), by slabs between the vertex
+ /// heights: inside each slab the boundary edges don't cross, so consecutive crossings pair
+ /// up into trapezoids.
+ fn triangulate(&self, tol: f64) -> Vec<[Vec2; 3]>;
+ fn centroid(&self) -> Vec2;
}
-impl Region2 {
- pub fn area(&self) -> f64 {
+impl Region2Geom for Region2 {
+ fn area(&self) -> f64 {
self.outer.signed_area().abs() - self.holes.iter().map(|h| h.signed_area().abs()).sum::<f64>()
}
- /// The outer loop, then the holes.
- pub fn loops(&self) -> impl Iterator<Item = &Loop2> + Clone {
- std::iter::once(&self.outer).chain(&self.holes)
- }
- /// A point strictly inside the region (for picking and labels).
- pub fn interior_point(&self) -> Vec2 {
+ fn interior_point(&self) -> Vec2 {
let c = self.centroid();
if self.contains(c) {
return c;
@@ -756,81 +844,14 @@ impl Region2 {
}
c
}
- pub fn contains(&self, p: Vec2) -> bool {
+ fn contains(&self, p: Vec2) -> bool {
self.outer.contains(p) && !self.holes.iter().any(|h| h.contains(p))
}
- /// The radius of the largest circle inside the region: how far its sides can move inwards
- /// before they meet (a taper going in closes it there). Found by a grid search refined
- /// around the best point, to about `tol`.
- pub fn inradius(&self, tol: f64) -> f64 {
+ fn inradius(&self, tol: f64) -> f64 {
let loops: Vec<Ring<Vec2>> = std::iter::once(&self.outer).chain(&self.holes).map(|l| l.polyline(tol)).collect();
max_clearance(&loops)
}
-}
-
-/// The largest distance from a point inside `loops` (even-odd) to their sides, by a grid search
-/// over their box refined around the best point. Zero for an empty or degenerate outline.
-fn max_clearance(loops: &[Ring<Vec2>]) -> f64 {
- let sides: Vec<(Vec2, Vec2)> = loops.iter().flat_map(|pl| pl.edges().map(|(a, b)| (*a, *b))).filter(|(a, b)| a.dist(*b) > 0.0).collect();
- let corners: Aabb2 = sides.iter().map(|s| s.0).collect();
- if corners.is_empty() {
- return 0.0;
- }
- let Aabb2 { min: lo, max: hi } = corners;
- let inside = |p: Vec2| {
- let mut odd = false;
- for (a, b) in &sides {
- if (a.y > p.y) != (b.y > p.y) && p.x < a.x + (p.y - a.y) / (b.y - a.y) * (b.x - a.x) {
- odd = !odd;
- }
- }
- odd
- };
- let clearance = |p: Vec2| -> f64 {
- if !inside(p) {
- return 0.0;
- }
- sides
- .iter()
- .map(|(a, b)| {
- let ab = *b - *a;
- let t = ((p - *a).dot(ab) / ab.len2()).clamp(0.0, 1.0);
- p.dist(*a + ab * t)
- })
- .fold(f64::INFINITY, f64::min)
- };
- const N: usize = 32;
- let size = hi - lo;
- let mut best = (0.0, (lo + hi) * 0.5);
- for i in 0..=N {
- for j in 0..=N {
- let p = Vec2::new(lo.x + size.x * i as f64 / N as f64, lo.y + size.y * j as f64 / N as f64);
- let c = clearance(p);
- if c > best.0 {
- best = (c, p);
- }
- }
- }
- // Refine: try the eight neighbours, halving the step whenever none is better.
- let mut step = size.x.max(size.y) / N as f64;
- for _ in 0..60 {
- if step < size.x.max(size.y) * 1e-9 {
- break;
- }
- let around = [(1.0, 0.0), (-1.0, 0.0), (0.0, 1.0), (0.0, -1.0), (1.0, 1.0), (1.0, -1.0), (-1.0, 1.0), (-1.0, -1.0)];
- match around.iter().map(|(dx, dy)| best.1 + Vec2::new(dx * step, dy * step)).map(|p| (clearance(p), p)).max_by(|a, b| a.0.total_cmp(&b.0)) {
- Some(n) if n.0 > best.0 => best = n,
- _ => step *= 0.5,
- }
- }
- best.0
-}
-
-impl Region2 {
- /// Triangles covering the region (for filled display), by slabs between the vertex
- /// heights: inside each slab the boundary edges don't cross, so consecutive crossings pair
- /// up into trapezoids.
- pub fn triangulate(&self, tol: f64) -> Vec<[Vec2; 3]> {
+ fn triangulate(&self, tol: f64) -> Vec<[Vec2; 3]> {
let mut edges: Vec<(Vec2, Vec2)> = Vec::new();
for l in std::iter::once(&self.outer).chain(&self.holes) {
let pl = l.polyline(tol);
@@ -877,7 +898,7 @@ impl Region2 {
}
out
}
- pub fn centroid(&self) -> Vec2 {
+ fn centroid(&self) -> Vec2 {
let ao = self.outer.signed_area().abs();
let mut c = self.outer.centroid() * ao;
let mut a = ao;
@@ -890,95 +911,40 @@ impl Region2 {
}
}
-/// Most boundary segment pairs [`regions_apart`] compares before it gives up (and says no).
-const APART_BUDGET: usize = 50_000_000;
-
-/// Whether no two of the regions meet or come within `gap` of each other (their boundaries
-/// are farther apart than `gap` and none lies inside another; one inside another's hole is
-/// apart). Tools made from them alike (extruded over one interval) are then apart too, and
-/// can be cut as one. False when unsure (a degenerate region, too much to compare).
-pub fn regions_apart(regions: &[Region2], gap: f64) -> bool {
- if !(gap.is_finite() && gap > 0.0) || regions.len() > 10_000 {
- return false;
- }
- // The polylines lie within `tol` of the curves: boundaries this much farther than the gap
- // apart are apart.
- let tol = gap / 4.0;
- let reach = gap + 2.0 * tol;
- struct Outline {
- loops: Vec<Ring<Vec2>>,
- bounds: Aabb2,
- inside: Vec2,
- }
- let mut outlines = Vec::with_capacity(regions.len());
- for r in regions {
- let loops: Vec<Ring<Vec2>> = std::iter::once(&r.outer).chain(&r.holes).map(|l| l.polyline(tol)).collect();
- let Some(outer) = loops.first().filter(|l| l.len() >= 2) else { return false };
- if outer.iter().any(|p| !p.is_finite()) {
- return false;
+// Helpers of Seg2Geom.
+fn bez(n: u8, p: &[Vec2; MAX_BEZIER_CTRL]) -> &[Vec2] {
+ &p[..(n as usize).clamp(1, MAX_BEZIER_DEGREE) + 1]
+}
+/// Newton's method for the parameter of the point nearest `p`, from `t`, within [0, 1].
+fn newton_closest(seg: &Seg2, p: Vec2, mut t: f64) -> f64 {
+ for _ in 0..30 {
+ let (q, d) = (seg.point_at(t), seg.derivative(t));
+ let (d2, h) = ((seg.derivative((t + 1e-6).min(1.0)) - seg.derivative((t - 1e-6).max(0.0))) / 2e-6, q - p);
+ let f = h.dot(d);
+ let df = d.dot(d) + h.dot(d2);
+ if df.abs() < 1e-300 {
+ break;
}
- let bounds = outer.bounds();
- let Some(inside) = outer.first().copied() else { return false };
- outlines.push(Outline { loops, bounds, inside });
- }
- let mut order: Vec<usize> = (0..outlines.len()).collect();
- order.sort_by(|&i, &j| {
- let x = |k: usize| outlines.get(k).map(|o| o.bounds.min.x).unwrap_or(0.0);
- x(i).total_cmp(&x(j))
- });
- let mut work = 0usize;
- for (k, &i) in order.iter().enumerate() {
- let Some(a) = outlines.get(i) else { return false };
- for &j in order.iter().skip(k + 1) {
- let Some(b) = outlines.get(j) else { return false };
- let (a_box, b_box) = (a.bounds, b.bounds);
- if b_box.min.x > a_box.max.x + reach {
- break;
- }
- if b_box.min.y > a_box.max.y + reach || a_box.min.y > b_box.max.y + reach {
- continue;
- }
- // A boundary point of one inside the other: one holds the other (boundaries that do
- // not come near each other do not cross).
- let (Some(ra), Some(rb)) = (regions.get(i), regions.get(j)) else { return false };
- if ra.contains(b.inside) || rb.contains(a.inside) {
- return false;
- }
- for la in &a.loops {
- for lb in &b.loops {
- work = work.saturating_add(la.len().saturating_mul(lb.len()));
- if work > APART_BUDGET {
- return false;
- }
- // (Each loop closed: its last point back to its first.)
- for (p, q) in la.iter().zip(la.iter().skip(1).chain(la.first())) {
- for (r, s) in lb.iter().zip(lb.iter().skip(1).chain(lb.first())) {
- if segment_distance(*p, *q, *r, *s) <= reach {
- return false;
- }
- }
- }
- }
- }
+ let nt = (t - f / df).clamp(0.0, 1.0);
+ if (nt - t).abs() < 1e-14 {
+ t = nt;
+ break;
}
+ t = nt;
}
- true
+ t
}
-
-/// The distance between segments `ab` and `cd` (0 where they cross).
-fn segment_distance(a: Vec2, b: Vec2, c: Vec2, d: Vec2) -> f64 {
- let side = |p: Vec2, q: Vec2, r: Vec2| (q - p).cross(r - p);
- let (d1, d2, d3, d4) = (side(c, d, a), side(c, d, b), side(a, b, c), side(a, b, d));
- if ((d1 > 0.0 && d2 < 0.0) || (d1 < 0.0 && d2 > 0.0)) && ((d3 > 0.0 && d4 < 0.0) || (d3 < 0.0 && d4 > 0.0)) {
- return 0.0;
+/// ∫₀¹ f(t) dt by composite Gauss–Legendre (16 pieces of 5 points).
+fn integrate(seg: &Seg2, f: impl Fn(&Seg2, f64) -> f64) -> f64 {
+ let n = 16;
+ let mut sum = 0.0;
+ for k in 0..n {
+ let (t0, h) = (k as f64 / n as f64, 1.0 / n as f64);
+ for (x, w) in GL5 {
+ sum += w * h * f(seg, t0 + x * h);
+ }
}
- let to = |p: Vec2, s: Vec2, e: Vec2| {
- let v = e - s;
- let len2 = v.dot(v);
- let t = if len2 > 0.0 { ((p - s).dot(v) / len2).clamp(0.0, 1.0) } else { 0.0 };
- p.dist(s + v * t)
- };
- to(a, c, d).min(to(b, c, d)).min(to(c, a, b)).min(to(d, a, b))
+ sum
}
#[cfg(test)]
diff --git a/crates/geom/src/section.rs b/crates/geom/src/section.rs
index ba3dcf6656..2c9d36f1b4 100644
--- a/crates/geom/src/section.rs
+++ b/crates/geom/src/section.rs
@@ -21,10 +21,11 @@
//! exact or certified measures for conics and freeform curves. Profile values contain geometry
//! only: callers retain the original result's accuracy declarations and local identities.
+use crate::prelude::*;
use serde::{Deserialize, Serialize};
use crate::profile::coordinates;
-use crate::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
/// Aggregate input records/references, and the selected conversion's output items, at most.
/// Input counts curves, wires, regions, contacts, curve uses and hole references together.
diff --git a/crates/geom/src/section_tests.rs b/crates/geom/src/section_tests.rs
index 7feb71c72f..2e02b95b75 100644
--- a/crates/geom/src/section_tests.rs
+++ b/crates/geom/src/section_tests.rs
@@ -1,7 +1,8 @@
use std::f64::consts::{PI, TAU};
use super::*;
-use crate::{MAX_BEZIER_CTRL, bezier};
+use crate::bezier;
+use solidcore_record::MAX_BEZIER_CTRL;
const TOL: f64 = 1e-6;
diff --git a/crates/geom/src/simplify.rs b/crates/geom/src/simplify.rs
index 7a4c0f3fb4..f3a834efea 100644
--- a/crates/geom/src/simplify.rs
+++ b/crates/geom/src/simplify.rs
@@ -14,10 +14,11 @@
//! triangle count, with its error measured: how far its vertices and the centres of its triangles
//! lie from the original surface, at most.
+use crate::prelude::*;
use std::cmp::Ordering;
use std::collections::BinaryHeap;
-use crate::Vec3;
+use solidcore_record::Vec3;
/// Most triangles [`levels`] simplifies (more: no levels).
pub const MAX_TRIANGLES: usize = 50_000_000;
diff --git a/crates/geom/src/spline_space.rs b/crates/geom/src/spline_space.rs
index 82ac3efea4..5378dcaca8 100644
--- a/crates/geom/src/spline_space.rs
+++ b/crates/geom/src/spline_space.rs
@@ -17,8 +17,8 @@
//! Input is hostile: constructors check sizes and finiteness and return [`SplineError`]; no
//! function here panics.
-use crate::Vec3;
use crate::bspline::{HPoint, MAX_SPLINE_DEGREE, Side, SplineError, SplineResult, check_knots, find_span, insert_knot, invalid, local_basis};
+use solidcore_record::Vec3;
/// Most basis functions a space used for interpolation may have (its systems are solved densely).
pub const MAX_SPACE_DIMENSION: usize = 2048;
@@ -520,6 +520,7 @@ impl Monotone {
#[cfg(test)]
mod tests {
use super::*;
+ use crate::prelude::*;
fn close(a: f64, b: f64) -> bool {
(a - b).abs() < 1e-10
diff --git a/crates/geom/src/tess.rs b/crates/geom/src/tess.rs
index 07728c36ab..1701bc5972 100644
--- a/crates/geom/src/tess.rs
+++ b/crates/geom/src/tess.rs
@@ -12,8 +12,10 @@
//! functions and derivatives), §4.5 (derivatives of a rational surface). [`uv`] finds the
//! parameters of a point on an evaluator surface.
+use crate::Mesh;
use crate::bspline::MAX_SPLINE_DEGREE;
-use crate::{Mesh, Vec3};
+use crate::prelude::*;
+use solidcore_record::Vec3;
pub mod partials;
pub mod uv;
diff --git a/crates/geom/src/tess/partials.rs b/crates/geom/src/tess/partials.rs
index 569ecfd206..64f390a50a 100644
--- a/crates/geom/src/tess/partials.rs
+++ b/crates/geom/src/tess/partials.rs
@@ -5,8 +5,9 @@
//! Book eq. 4.8 and 4.20); a revolution turns its profile's derivatives by the rotation's own.
use super::{EvalCurve, EvalSurface, affine, linear, onto_knots};
-use crate::Vec3;
use crate::bspline::{MAX_SPLINE_DEGREE, basis_derivatives, binomial};
+use crate::prelude::*;
+use solidcore_record::Vec3;
/// The highest total order of [`Partials`].
pub const MAX_PARTIAL_ORDER: usize = 4;
diff --git a/crates/geom/src/tess/uv.rs b/crates/geom/src/tess/uv.rs
index fe944c43e8..7fe8a9c3a6 100644
--- a/crates/geom/src/tess/uv.rs
+++ b/crates/geom/src/tess/uv.rs
@@ -10,7 +10,8 @@
//! whole circle).
use super::EvalSurface;
-use crate::Vec3;
+use crate::prelude::*;
+use solidcore_record::Vec3;
/// The parameter box of a surface and its periods.
#[derive(Clone, Copy, Debug, PartialEq)]
diff --git a/crates/geom/src/tests.rs b/crates/geom/src/tests.rs
index 2d6a26d2fc..48d130e771 100644
--- a/crates/geom/src/tests.rs
+++ b/crates/geom/src/tests.rs
@@ -1,4 +1,5 @@
use crate::*;
+use solidcore_record::{MAX_BEZIER_CTRL, Plane, Seg2, Vec2, Vec3};
fn cube_mesh(s: f64) -> Mesh {
let p = |x: f64, y: f64, z: f64| Vec3::new(x * s, y * s, z * s);
@@ -334,7 +335,7 @@ fn surface_patches_cross_only_hidden_seams() {
#[test]
fn cubic_and_conic_segments_measure_exactly() {
- use crate::{Loop2, Seg2, Vec2};
+ use solidcore_record::{Loop2, Seg2, Vec2};
// An ellipse (a = 5, b = 3) as four quarter conics: area π a b.
let w = std::f64::consts::FRAC_1_SQRT_2;
let (a, b) = (5.0, 3.0);
@@ -389,7 +390,7 @@ fn cubic_and_conic_segments_measure_exactly() {
#[test]
fn split_at_and_closest_param() {
- use crate::{Seg2, Vec2};
+ use solidcore_record::{Seg2, Vec2};
let w = std::f64::consts::FRAC_1_SQRT_2;
let quarter = Seg2::Conic { a: Vec2::new(10.0, 0.0), apex: Vec2::new(10.0, 10.0), b: Vec2::new(0.0, 10.0), w };
for t in [0.2, 0.5, 0.8] {
diff --git a/crates/geom/src/title_block.rs b/crates/geom/src/title_block.rs
index 8efc6bc72c..f46de0bcde 100644
--- a/crates/geom/src/title_block.rs
+++ b/crates/geom/src/title_block.rs
@@ -18,10 +18,11 @@
use serde::{Deserialize, Serialize};
+use crate::Aabb2;
use crate::cell::{self, Content, Fit, HAlign};
use crate::drawing_sheet::SheetLayout;
use crate::paper::MAX_LINE_MM;
-use crate::{Aabb2, Vec2};
+use solidcore_record::Vec2;
/// The most cells a block may have.
pub const MAX_CELLS: usize = 64;
diff --git a/crates/geom/src/title_block_tests.rs b/crates/geom/src/title_block_tests.rs
index a4005659eb..35b83805db 100644
--- a/crates/geom/src/title_block_tests.rs
+++ b/crates/geom/src/title_block_tests.rs
@@ -1,3 +1,4 @@
+use crate::prelude::*;
use serde_json::json;
use super::*;
diff --git a/crates/geom/src/tspline/mod.rs b/crates/geom/src/tspline/mod.rs
index 531f13b5f8..5affc08be0 100644
--- a/crates/geom/src/tspline/mod.rs
+++ b/crates/geom/src/tspline/mod.rs
@@ -25,8 +25,9 @@ pub use crate::bspline::Dir;
pub use mesh::{Extension, IndexRect, MAX_GRID_POINTS, MAX_INDEX_LINES, Segment, TMesh};
pub use refine::Cut;
-use crate::Vec3;
use crate::bspline::{HPoint, MAX_SPLINE_DEGREE, Side, SplineError, SplineResult, invalid, local_basis, weighted_points};
+use crate::prelude::*;
+use solidcore_record::Vec3;
/// A blending function: its anchor's local knot vectors as line indices and as values, and
/// its support.
diff --git a/crates/geom/src/unit_vec3.rs b/crates/geom/src/unit_vec3.rs
index 450e5e1a86..a5db0206aa 100644
--- a/crates/geom/src/unit_vec3.rs
+++ b/crates/geom/src/unit_vec3.rs
@@ -1,15 +1,16 @@
//! A unit vector: a 3D vector of length 1.
+use crate::prelude::*;
use std::ops::{Add, Deref, Mul, Neg, Sub};
use serde::{Deserialize, Serialize};
-use crate::Vec3;
+use solidcore_record::Vec3;
/// A unit vector: length 1 up to rounding. Made only from a vector with a length
-/// ([`UnitVec3::new`], [`Vec3::unit`]), so a function taking one need not normalise it or
+/// ([`UnitVec3::new`], [`Vec3Geom::unit`]), so a function taking one need not normalise it or
/// handle a zero vector again. It reads as the [`Vec3`] it holds (`d.dot(v)`, `*d`), and
-/// [`Vec3::dot`] and [`Vec3::cross`] take one.
+/// [`Vec3Geom::dot`] and [`Vec3Geom::cross`] take one.
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
#[serde(into = "Vec3", try_from = "Vec3")]
pub struct UnitVec3(Vec3);
@@ -28,13 +29,6 @@ impl UnitVec3 {
}
}
-impl Vec3 {
- /// This vector scaled to length 1 ([`UnitVec3::new`]).
- pub fn unit(self) -> Option<UnitVec3> {
- UnitVec3::new(self)
- }
-}
-
impl Deref for UnitVec3 {
type Target = Vec3;
fn deref(&self) -> &Vec3 {
diff --git a/crates/geom/src/vec.rs b/crates/geom/src/vec.rs
index 87c3ec294d..1550b0b113 100644
--- a/crates/geom/src/vec.rs
+++ b/crates/geom/src/vec.rs
@@ -1,163 +1,126 @@
-use std::ops::{Add, AddAssign, Div, Mul, Neg, Sub, SubAssign};
+//! The geometry of vectors and points ([`Vec2`], [`Vec3`], plain data in the record): dot and
+//! cross products, lengths, distances, directions and interpolation.
+use solidcore_record::{Vec2, Vec3};
-use serde::{Deserialize, Serialize};
+use crate::UnitVec3;
-/// 2D vector / point (sketch space).
-#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)]
-#[serde(from = "[f64; 2]", into = "[f64; 2]")]
-pub struct Vec2 {
- pub x: f64,
- pub y: f64,
-}
-
-/// 3D vector / point (model space, Z up).
-#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)]
-#[serde(from = "[f64; 3]", into = "[f64; 3]")]
-pub struct Vec3 {
- pub x: f64,
- pub y: f64,
- pub z: f64,
-}
-
-impl From<[f64; 2]> for Vec2 {
- fn from(a: [f64; 2]) -> Self {
- Vec2::new(a[0], a[1])
- }
-}
-impl From<Vec2> for [f64; 2] {
- fn from(v: Vec2) -> Self {
- [v.x, v.y]
- }
-}
-impl From<[f64; 3]> for Vec3 {
- fn from(a: [f64; 3]) -> Self {
- Vec3::new(a[0], a[1], a[2])
- }
-}
-impl From<Vec3> for [f64; 3] {
- fn from(v: Vec3) -> Self {
- [v.x, v.y, v.z]
- }
+/// The geometry of a 2D vector or point.
+// `len` is the vector's length, not a count.
+#[allow(clippy::len_without_is_empty)]
+pub trait Vec2Geom {
+ fn dot(self, o: Vec2) -> f64;
+ /// z component of the 3D cross product.
+ fn cross(self, o: Vec2) -> f64;
+ fn len(self) -> f64;
+ fn len2(self) -> f64;
+ fn dist(self, o: Vec2) -> f64;
+ fn normalized(self) -> Option<Vec2>;
+ /// Rotated +90°.
+ fn perp(self) -> Vec2;
+ fn angle(self) -> f64;
+ fn from_angle(a: f64) -> Vec2;
+ fn lerp(self, o: Vec2, t: f64) -> Vec2;
}
-impl Vec2 {
- pub const ZERO: Vec2 = Vec2 { x: 0.0, y: 0.0 };
- pub const X: Vec2 = Vec2 { x: 1.0, y: 0.0 };
- pub const Y: Vec2 = Vec2 { x: 0.0, y: 1.0 };
- pub const fn new(x: f64, y: f64) -> Self {
- Vec2 { x, y }
- }
- pub fn dot(self, o: Vec2) -> f64 {
+impl Vec2Geom for Vec2 {
+ fn dot(self, o: Vec2) -> f64 {
self.x * o.x + self.y * o.y
}
- /// z component of the 3D cross product.
- pub fn cross(self, o: Vec2) -> f64 {
+ fn cross(self, o: Vec2) -> f64 {
self.x * o.y - self.y * o.x
}
- pub fn len(self) -> f64 {
+ fn len(self) -> f64 {
self.x.hypot(self.y)
}
- pub fn len2(self) -> f64 {
+ fn len2(self) -> f64 {
self.dot(self)
}
- pub fn dist(self, o: Vec2) -> f64 {
+ fn dist(self, o: Vec2) -> f64 {
(self - o).len()
}
- pub fn normalized(self) -> Option<Vec2> {
+ fn normalized(self) -> Option<Vec2> {
let l = self.len();
(l > crate::EPS && l.is_finite()).then(|| self / l)
}
- /// Rotated +90°.
- pub fn perp(self) -> Vec2 {
+ fn perp(self) -> Vec2 {
Vec2::new(-self.y, self.x)
}
- pub fn angle(self) -> f64 {
+ fn angle(self) -> f64 {
self.y.atan2(self.x)
}
- pub fn from_angle(a: f64) -> Vec2 {
+ fn from_angle(a: f64) -> Vec2 {
Vec2::new(a.cos(), a.sin())
}
- pub fn lerp(self, o: Vec2, t: f64) -> Vec2 {
+ fn lerp(self, o: Vec2, t: f64) -> Vec2 {
self + (o - self) * t
}
- pub fn is_finite(self) -> bool {
- self.x.is_finite() && self.y.is_finite()
- }
- pub fn extend(self, z: f64) -> Vec3 {
- Vec3::new(self.x, self.y, z)
- }
}
-impl Vec3 {
- pub const ZERO: Vec3 = Vec3 { x: 0.0, y: 0.0, z: 0.0 };
- pub const X: Vec3 = Vec3 { x: 1.0, y: 0.0, z: 0.0 };
- pub const Y: Vec3 = Vec3 { x: 0.0, y: 1.0, z: 0.0 };
- pub const Z: Vec3 = Vec3 { x: 0.0, y: 0.0, z: 1.0 };
- pub const fn new(x: f64, y: f64, z: f64) -> Self {
- Vec3 { x, y, z }
- }
+/// The geometry of a 3D vector or point.
+// `len` is the vector's length, not a count.
+#[allow(clippy::len_without_is_empty)]
+pub trait Vec3Geom {
/// Takes a [`Vec3`] or a [`UnitVec3`](crate::UnitVec3).
- pub fn dot(self, o: impl Into<Vec3>) -> f64 {
+ fn dot(self, o: impl Into<Vec3>) -> f64;
+ /// Takes a [`Vec3`] or a [`UnitVec3`](crate::UnitVec3).
+ fn cross(self, o: impl Into<Vec3>) -> Vec3;
+ fn len(self) -> f64;
+ fn len2(self) -> f64;
+ fn dist(self, o: Vec3) -> f64;
+ fn normalized(self) -> Option<Vec3>;
+ fn lerp(self, o: Vec3, t: f64) -> Vec3;
+ fn min(self, o: Vec3) -> Vec3;
+ fn max(self, o: Vec3) -> Vec3;
+ /// Any unit vector perpendicular to `self` (which should be non-zero).
+ fn any_perp(self) -> Vec3;
+ /// Distance from this point to the segment `a`–`b`.
+ fn dist_to_segment(self, a: Vec3, b: Vec3) -> f64;
+ /// This vector scaled to length 1 ([`UnitVec3::new`]).
+ fn unit(self) -> Option<UnitVec3>;
+}
+
+impl Vec3Geom for Vec3 {
+ fn dot(self, o: impl Into<Vec3>) -> f64 {
let o = o.into();
self.x * o.x + self.y * o.y + self.z * o.z
}
- /// Takes a [`Vec3`] or a [`UnitVec3`](crate::UnitVec3).
- pub fn cross(self, o: impl Into<Vec3>) -> Vec3 {
+ fn cross(self, o: impl Into<Vec3>) -> Vec3 {
let o = o.into();
Vec3::new(self.y * o.z - self.z * o.y, self.z * o.x - self.x * o.z, self.x * o.y - self.y * o.x)
}
- pub fn len(self) -> f64 {
+ fn len(self) -> f64 {
self.len2().sqrt()
}
- pub fn len2(self) -> f64 {
+ fn len2(self) -> f64 {
self.dot(self)
}
- pub fn dist(self, o: Vec3) -> f64 {
+ fn dist(self, o: Vec3) -> f64 {
(self - o).len()
}
- pub fn normalized(self) -> Option<Vec3> {
+ fn normalized(self) -> Option<Vec3> {
let l = self.len();
(l > crate::EPS && l.is_finite()).then(|| self / l)
}
- pub fn lerp(self, o: Vec3, t: f64) -> Vec3 {
+ fn lerp(self, o: Vec3, t: f64) -> Vec3 {
self + (o - self) * t
}
- pub fn is_finite(self) -> bool {
- self.x.is_finite() && self.y.is_finite() && self.z.is_finite()
- }
- pub fn min(self, o: Vec3) -> Vec3 {
+ fn min(self, o: Vec3) -> Vec3 {
Vec3::new(self.x.min(o.x), self.y.min(o.y), self.z.min(o.z))
}
- pub fn max(self, o: Vec3) -> Vec3 {
+ fn max(self, o: Vec3) -> Vec3 {
Vec3::new(self.x.max(o.x), self.y.max(o.y), self.z.max(o.z))
}
- /// Any unit vector perpendicular to `self` (which should be non-zero).
- pub fn any_perp(self) -> Vec3 {
+ fn any_perp(self) -> Vec3 {
let a = if self.x.abs() < 0.9 { Vec3::X } else { Vec3::Y };
self.cross(a).normalized().unwrap_or(Vec3::Z)
}
- pub fn to_f32(self) -> [f32; 3] {
- [self.x as f32, self.y as f32, self.z as f32]
- }
- /// Distance from this point to the segment `a`–`b`.
- pub fn dist_to_segment(self, a: Vec3, b: Vec3) -> f64 {
+ fn dist_to_segment(self, a: Vec3, b: Vec3) -> f64 {
let ab = b - a;
let l2 = ab.len2();
let t = if l2 > 0.0 { ((self - a).dot(ab) / l2).clamp(0.0, 1.0) } else { 0.0 };
self.dist(a + ab * t)
}
+ fn unit(self) -> Option<UnitVec3> {
+ UnitVec3::new(self)
+ }
}
-
-macro_rules! ops {
- ($t:ident, $($f:ident),+) => {
- impl Add for $t { type Output = $t; fn add(self, o: $t) -> $t { $t { $($f: self.$f + o.$f),+ } } }
- impl Sub for $t { type Output = $t; fn sub(self, o: $t) -> $t { $t { $($f: self.$f - o.$f),+ } } }
- impl Mul<f64> for $t { type Output = $t; fn mul(self, k: f64) -> $t { $t { $($f: self.$f * k),+ } } }
- impl Div<f64> for $t { type Output = $t; fn div(self, k: f64) -> $t { $t { $($f: self.$f / k),+ } } }
- impl Neg for $t { type Output = $t; fn neg(self) -> $t { $t { $($f: -self.$f),+ } } }
- impl AddAssign for $t { fn add_assign(&mut self, o: $t) { $(self.$f += o.$f;)+ } }
- impl SubAssign for $t { fn sub_assign(&mut self, o: $t) { $(self.$f -= o.$f;)+ } }
- };
-}
-ops!(Vec2, x, y);
-ops!(Vec3, x, y, z);
diff --git a/crates/gpu/Cargo.toml b/crates/gpu/Cargo.toml
index 759dc816e8..de261ed00c 100644
--- a/crates/gpu/Cargo.toml
+++ b/crates/gpu/Cargo.toml
@@ -9,6 +9,7 @@ license.workspace = true
workspace = true
[dependencies]
+solidcore-record = { workspace = true }
robust = "1.2"
solidcraft-geom = { workspace = true }
solidcraft-render = { workspace = true }
diff --git a/crates/gpu/src/capture.rs b/crates/gpu/src/capture.rs
index f61531ca16..14ba8ce627 100644
--- a/crates/gpu/src/capture.rs
+++ b/crates/gpu/src/capture.rs
@@ -7,11 +7,12 @@
//! renderer that drew it (`gpu`, `gpu-software` or `cpu`); `hardware` and `software` fail with an
//! error that names the policy.
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_render::hatch::Hatch;
use solidcraft_render::{AnalysisMode, Camera, Rgb, SECTION_CAP, Scene, SceneMesh};
use wgpu::util::DeviceExt;
diff --git a/crates/gpu/src/lib.rs b/crates/gpu/src/lib.rs
index 84d2588aae..5b45d6d596 100644
--- a/crates/gpu/src/lib.rs
+++ b/crates/gpu/src/lib.rs
@@ -13,9 +13,9 @@
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
#![forbid(unsafe_code)]
+use solidcore_record::Vec3;
#[cfg(not(target_arch = "wasm32"))]
use solidcraft_geom::Mesh;
-use solidcraft_geom::Vec3;
use solidcraft_geom::tess::{EvalCurve, EvalSurface, TessPlan};
use wgpu::util::DeviceExt;
diff --git a/crates/gpu/src/path/denoise_tests.rs b/crates/gpu/src/path/denoise_tests.rs
index 12bc5f2ab3..71c49ab344 100644
--- a/crates/gpu/src/path/denoise_tests.rs
+++ b/crates/gpu/src/path/denoise_tests.rs
@@ -1,6 +1,7 @@
use super::super::{Executor, JobOptions, Task, open_headless};
use super::*;
-use solidcraft_geom::{Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Mesh;
use solidcraft_render::{
Camera, ProductMesh, ProductScene, StandardView,
job::{CancelToken, ImageRequest, ImageWork, TaskPoll},
diff --git a/crates/gpu/src/path/media_hierarchy.rs b/crates/gpu/src/path/media_hierarchy.rs
index c7a2bbcf48..8cd351cd39 100644
--- a/crates/gpu/src/path/media_hierarchy.rs
+++ b/crates/gpu/src/path/media_hierarchy.rs
@@ -2,7 +2,8 @@
//! only a candidate; parent convexity and child vertices are checked against
//! every outward parent half-space. Intersections and touching boundaries refuse.
use super::scene::{Triangle, reserved};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use solidcraft_render::job::{CancelToken, ErrorCode, JobError, Result};
use std::ops::Range;
diff --git a/crates/gpu/src/path/mod.rs b/crates/gpu/src/path/mod.rs
index 3b08b46260..6215400cc7 100644
--- a/crates/gpu/src/path/mod.rs
+++ b/crates/gpu/src/path/mod.rs
@@ -1,6 +1,6 @@
//! Native progressive product rendering. Software BVH traversal needs no ray-query
//! features. Small measured quanta adapt to the device, then check cancellation.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
#[cfg(test)]
use solidcraft_render::job::ToneMap;
use solidcraft_render::{
diff --git a/crates/gpu/src/path/planar_patches.rs b/crates/gpu/src/path/planar_patches.rs
index bfd7e8cf43..0c81b2fa5e 100644
--- a/crates/gpu/src/path/planar_patches.rs
+++ b/crates/gpu/src/path/planar_patches.rs
@@ -113,7 +113,7 @@ pub(super) fn ids(triangles: &[Triangle], cancel: &CancelToken) -> Result<Vec<u3
#[cfg(test)]
mod tests {
use super::*;
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
use solidcraft_render::surface::OpaqueSurface;
fn triangle(p: [[f64; 3]; 3], body: u32) -> Triangle {
diff --git a/crates/gpu/src/path/scene.rs b/crates/gpu/src/path/scene.rs
index 068b23ac79..b5cf392450 100644
--- a/crates/gpu/src/path/scene.rs
+++ b/crates/gpu/src/path/scene.rs
@@ -1,9 +1,10 @@
//! Original median-split BVH. World geometry is rebased around the camera target for f32.
#[path = "planar_patches.rs"]
mod planar_patches;
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_render::{
ProductScene,
job::{CancelToken, ErrorCode, JobError, Result},
diff --git a/crates/gpu/src/path/scene_bvh_tests.rs b/crates/gpu/src/path/scene_bvh_tests.rs
index 50151a72ac..68793295ed 100644
--- a/crates/gpu/src/path/scene_bvh_tests.rs
+++ b/crates/gpu/src/path/scene_bvh_tests.rs
@@ -1,5 +1,5 @@
use super::{MAX_BVH_DEPTH, Node, Triangle, build};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_render::{job::CancelToken, surface::OpaqueSurface};
// Triangle centres spread over 60 decades: a sixteen-bin SAH split on the
diff --git a/crates/gpu/src/path/scene_weld_tests.rs b/crates/gpu/src/path/scene_weld_tests.rs
index 0b9b2bbaa9..360781c5d4 100644
--- a/crates/gpu/src/path/scene_weld_tests.rs
+++ b/crates/gpu/src/path/scene_weld_tests.rs
@@ -1,7 +1,9 @@
+use solidcraft_geom::prelude::*;
use std::sync::Arc;
use super::{MediumWeld, Triangle, flatten, medium_preparation_bytes};
-use solidcraft_geom::{Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Mesh;
use solidcraft_render::{ProductMesh, ProductScene, job::CancelToken, surface::OpaqueSurface, transmission::Transmission};
fn seam_tetra(offset: Vec3) -> ProductScene {
diff --git a/crates/gpu/src/path/tests.rs b/crates/gpu/src/path/tests.rs
index 24e838ffca..77d6fe18e6 100644
--- a/crates/gpu/src/path/tests.rs
+++ b/crates/gpu/src/path/tests.rs
@@ -1,4 +1,5 @@
use super::*;
+use solidcraft_geom::prelude::*;
use solidcraft_geom::{Aabb3, Mesh};
use solidcraft_render::{Camera, ProductMesh, StandardView, surface::OpaqueSurface};
diff --git a/crates/gpu/src/path/textures.rs b/crates/gpu/src/path/textures.rs
index 135aa340c3..4e6fd9761c 100644
--- a/crates/gpu/src/path/textures.rs
+++ b/crates/gpu/src/path/textures.rs
@@ -1,5 +1,6 @@
//! One read-only storage buffer: body lookup, planar records and linear RGBA pixels.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use solidcraft_render::job::{
CancelToken, ErrorCode, JobError, Result,
textures::{BaseColorMode, RuntimeTextures, TextureMap},
diff --git a/crates/gpu/src/tests.rs b/crates/gpu/src/tests.rs
index 542e1b1eb4..0530bbc00c 100644
--- a/crates/gpu/src/tests.rs
+++ b/crates/gpu/src/tests.rs
@@ -1,4 +1,5 @@
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use solidcraft_kernel::{Body, BoolOp};
use super::*;
@@ -374,7 +375,7 @@ fn tessellation_without_surfaces_does_not_dispatch() {
#[test]
#[ignore]
fn bench_plate() {
- use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2};
let rect = |w: f64| Loop2 {
segs: vec![
Seg2::Line { a: Vec2::new(0.0, 0.0), b: Vec2::new(w, 0.0) },
diff --git a/crates/gpu/src/view.rs b/crates/gpu/src/view.rs
index f2001d488b..e977febc5c 100644
--- a/crates/gpu/src/view.rs
+++ b/crates/gpu/src/view.rs
@@ -9,9 +9,10 @@
//! evaluated on the GPU into the vertex buffer the pass draws (see [`PlannedBody`]), with nothing
//! built or read back on the CPU.
+use solidcraft_geom::prelude::*;
use std::sync::{Arc, Mutex};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::pbr;
use wgpu::util::DeviceExt;
@@ -4345,7 +4346,8 @@ mod tests {
#[test]
fn shared_tris_share_each_vertex_once() {
use super::{SHARED_SIZE, SharedTris};
- use solidcraft_geom::{Mesh, Vec3};
+ use solidcore_record::Vec3;
+ use solidcraft_geom::Mesh;
let p = [Vec3::new(0.0, 0.0, 0.0), Vec3::new(1.0, 0.0, 0.0), Vec3::new(1.0, 1.0, 0.0), Vec3::new(0.0, 1.0, 0.0)];
// Two triangles of a square, each corner its own vertex (as an STL is read).
let mut flat = Mesh::default();
diff --git a/crates/gpu/tests/capture.rs b/crates/gpu/tests/capture.rs
index 19ad41f7d8..b3fee839d1 100644
--- a/crates/gpu/tests/capture.rs
+++ b/crates/gpu/tests/capture.rs
@@ -5,8 +5,8 @@
//! (`SOLIDCRAFT_REQUIRE_GPU=1` makes that a failure).
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Session;
-use solidcraft_engine::geom::Vec3;
use solidcraft_engine::render::{Camera, Rgb, Scene, SceneLine};
use solidcraft_engine::view::{self, Guides, colors};
use solidcraft_gpu::GpuError;
diff --git a/crates/gpu/tests/depth.rs b/crates/gpu/tests/depth.rs
index 6de0f68d0b..3a83305cbe 100644
--- a/crates/gpu/tests/depth.rs
+++ b/crates/gpu/tests/depth.rs
@@ -7,10 +7,12 @@
//! makes that a failure).
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Session;
-use solidcraft_engine::geom::{Mesh, Vec3};
+use solidcraft_engine::geom::Mesh;
use solidcraft_engine::render::{Camera, Rgb, Scene, SceneLine, SceneMesh, StandardView};
use solidcraft_engine::view::{self, Guides};
+use solidcraft_geom::prelude::*;
use solidcraft_gpu::GpuError;
use solidcraft_gpu::capture::{self, Capturer};
use std::sync::{Arc, OnceLock};
diff --git a/crates/gpu/tests/thin_lines.rs b/crates/gpu/tests/thin_lines.rs
index e9b6583f27..9ec5e4bed0 100644
--- a/crates/gpu/tests/thin_lines.rs
+++ b/crates/gpu/tests/thin_lines.rs
@@ -3,7 +3,7 @@
//! falls between two rows, so such lines came and went as the view zoomed. Skipped, with the
//! reason printed, without a GPU adapter (`SOLIDCRAFT_REQUIRE_GPU=1` makes that a failure).
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_engine::render::{Camera, Rgb, Scene, SceneLine, StandardView};
use solidcraft_gpu::GpuError;
use solidcraft_gpu::capture::Capturer;
diff --git a/crates/io/Cargo.toml b/crates/io/Cargo.toml
index afb3001954..76054026ec 100644
--- a/crates/io/Cargo.toml
+++ b/crates/io/Cargo.toml
@@ -13,6 +13,7 @@ workspace = true
trust-unknown-source = []
[dependencies]
+solidcore-record = { workspace = true }
solidcraft-geom = { workspace = true }
solidcraft-kernel = { workspace = true }
solidcraft-doc = { workspace = true }
diff --git a/crates/io/src/design.rs b/crates/io/src/design.rs
index 10148d4632..ed48a0876d 100644
--- a/crates/io/src/design.rs
+++ b/crates/io/src/design.rs
@@ -995,7 +995,7 @@ fn hydrate_hdr_resources<R: Read + Seek>(metadata: &mut Value, reader: &mut Pack
#[cfg(test)]
mod tests {
use super::*;
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
struct CountingReader {
source: Cursor<Vec<u8>>,
@@ -1108,7 +1108,7 @@ mod tests {
}
fn native_geometry() -> solidcraft_doc::SavedModel {
- saved_model(vec![solidcraft_kernel::box_solid(solidcraft_geom::Vec3::ZERO, solidcraft_geom::Vec3::new(10., 20., 30.)).unwrap()])
+ saved_model(vec![solidcraft_kernel::box_solid(solidcore_record::Vec3::ZERO, solidcore_record::Vec3::new(10., 20., 30.)).unwrap()])
}
#[test]
@@ -1173,7 +1173,7 @@ mod tests {
#[test]
fn model_cache_stores_repeated_parts_once_and_keeps_placed_copies() {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let part = solidcraft_kernel::box_solid(Vec3::ZERO, Vec3::new(10., 20., 30.)).unwrap();
let share = solidcraft_kernel::DisplayShare::new(part.clone());
let mut bodies = vec![part.clone(), part.clone()];
@@ -1204,7 +1204,7 @@ mod tests {
/// same (sorted) order, the same numbers.
#[test]
fn the_model_cache_manifest_is_what_a_json_tree_writes() {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let part = solidcraft_kernel::box_solid(Vec3::ZERO, Vec3::new(10., 20., 30.)).unwrap();
let share = solidcraft_kernel::DisplayShare::new(part.clone());
let t = [[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [50.5, -0.25, 1e-7, 1.]];
@@ -1223,7 +1223,7 @@ mod tests {
/// opening the design evaluated every feature again.
#[test]
fn model_cache_keeps_mesh_bodies_with_the_rest_of_the_model() {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let corners = [Vec3::ZERO, Vec3::new(10., 0., 0.), Vec3::new(0., 10., 0.), Vec3::new(0., 0., 10.)];
let tetra = solidcraft_kernel::mesh_body(&corners, &[[0, 2, 1], [0, 1, 3], [0, 3, 2], [1, 2, 3]])
.unwrap()
@@ -1333,7 +1333,7 @@ mod tests {
/// document evaluated it.
fn timeline_model() -> solidcraft_doc::SavedModel {
let bodies: Vec<_> = (0..40)
- .map(|i| solidcraft_kernel::box_solid(solidcraft_geom::Vec3::ZERO, solidcraft_geom::Vec3::new(10. + f64::from(i), 20., 30.)).unwrap())
+ .map(|i| solidcraft_kernel::box_solid(solidcore_record::Vec3::ZERO, solidcore_record::Vec3::new(10. + f64::from(i), 20., 30.)).unwrap())
.collect();
let records: Vec<Value> = (0..40)
.map(|i| json!({"name": format!("Body{i}"), "feature": 1 + i / 8, "component": 0, "key": "0000000000000001", "names": 0, "body": i}))
@@ -1913,7 +1913,7 @@ mod tests {
/// A valid STEP cube, padded with a comment to `length` bytes. `noisy` padding barely
/// compresses; otherwise it is repetitive like the text of a real large export.
fn padded_step(length: usize, noisy: bool) -> String {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let cube = solidcraft_kernel::box_solid(Vec3::ZERO, Vec3::new(10.0, 20.0, 30.0)).unwrap();
let step = solidcraft_kernel::step_export(&[&cube], "padded").unwrap();
let (head, tail) = step.split_at(step.find("DATA;").unwrap() + 5);
@@ -2312,7 +2312,7 @@ mod tests {
#[test]
#[ignore = "manual IO performance measurement"]
fn benchmark_step_storage() {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let bodies: Vec<_> = (0..512)
.map(|i| {
let corner = Vec3::new((i % 32) as f64 * 12.0, (i / 32) as f64 * 12.0, 0.0);
diff --git a/crates/io/src/design/native_cache.rs b/crates/io/src/design/native_cache.rs
index af93aaad12..413300a549 100644
--- a/crates/io/src/design/native_cache.rs
+++ b/crates/io/src/design/native_cache.rs
@@ -175,11 +175,11 @@ fn decode_mesh_body(bytes: &[u8]) -> Option<solidcraft_kernel::Body> {
let (coordinates, corners) = data.split_at_checked(split)?;
let f64_at = |c: &[u8], at: usize| c.get(at..at + 8)?.try_into().ok().map(f64::from_le_bytes);
let u32_at = |c: &[u8], at: usize| c.get(at..at + 4)?.try_into().ok().map(u32::from_le_bytes);
- let positions: Vec<solidcraft_geom::Vec3> = coordinates
+ let positions: Vec<solidcore_record::Vec3> = coordinates
.as_chunks::<24>()
.0
.iter()
- .map(|c| Some(solidcraft_geom::Vec3::new(f64_at(c, 0)?, f64_at(c, 8)?, f64_at(c, 16)?)))
+ .map(|c| Some(solidcore_record::Vec3::new(f64_at(c, 0)?, f64_at(c, 8)?, f64_at(c, 16)?)))
.collect::<Option<_>>()?;
let triangles: Vec<[u32; 3]> =
corners.as_chunks::<12>().0.iter().map(|c| Some([u32_at(c, 0)?, u32_at(c, 4)?, u32_at(c, 8)?])).collect::<Option<_>>()?;
@@ -195,7 +195,7 @@ fn decode_mesh_body(bytes: &[u8]) -> Option<solidcraft_kernel::Body> {
/// colour and paint.
fn same_mesh(a: &solidcraft_kernel::Body, b: &solidcraft_kernel::Body) -> bool {
let (Some((pa, ta)), Some((pb, tb))) = (a.triangle_mesh(), b.triangle_mesh()) else { return false };
- let bits = |p: &[solidcraft_geom::Vec3]| p.iter().map(|v| [v.x.to_bits(), v.y.to_bits(), v.z.to_bits()]).collect::<Vec<_>>();
+ let bits = |p: &[solidcore_record::Vec3]| p.iter().map(|v| [v.x.to_bits(), v.y.to_bits(), v.z.to_bits()]).collect::<Vec<_>>();
ta == tb && bits(pa) == bits(pb) && a.color() == b.color() && a.paint() == b.paint()
}
diff --git a/crates/io/src/dxf.rs b/crates/io/src/dxf.rs
index 7defb594c9..d046035296 100644
--- a/crates/io/src/dxf.rs
+++ b/crates/io/src/dxf.rs
@@ -5,9 +5,10 @@
//! arcs and points (free-form curves as polylines); the flat pattern's drawing, with ELLIPSE and SPLINE, is
//! [`crate::write_dxf_drawing`].
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
-use solidcraft_geom::{MAX_BEZIER_DEGREE, Vec2};
+use solidcore_record::{MAX_BEZIER_DEGREE, Vec2};
use crate::sketch2d::{Geom2, MAX_DRAWING_BYTES, MAX_ENTITIES, bulge_arc};
use crate::{IoError, Result};
diff --git a/crates/io/src/dxf_out.rs b/crates/io/src/dxf_out.rs
index 6a2c93c9f3..56d12dbcd4 100644
--- a/crates/io/src/dxf_out.rs
+++ b/crates/io/src/dxf_out.rs
@@ -11,10 +11,11 @@
//! subclass markers of each entity; the root dictionary and its group dictionary. Layers can be dashed and a drawing can carry TEXT (for annotations). Group
//! codes follow Autodesk's public DXF reference.
+use solidcraft_geom::prelude::*;
use std::f64::consts::TAU;
use std::fmt::Write as _;
-use solidcraft_geom::{Loop2, MAX_BEZIER_DEGREE, Seg2, Vec2};
+use solidcore_record::{Loop2, MAX_BEZIER_DEGREE, Seg2, Vec2};
use crate::{IoError, Result};
@@ -763,7 +764,7 @@ mod tests {
assert!(degree_2(&conic(2.0), Some(vec![1.0, 2.0, 1.0])));
assert!(degree_2(&conic(1.0 - 1e-9), Some(vec![1.0, 1.0 - 1e-9, 1.0])));
// A quintic piece: six control points and twelve knots.
- let mut q = [Vec2::ZERO; solidcraft_geom::MAX_BEZIER_CTRL];
+ let mut q = [Vec2::ZERO; solidcore_record::MAX_BEZIER_CTRL];
for (i, s) in q.iter_mut().enumerate() {
*s = Vec2::new(i as f64, (i * i) as f64);
}
@@ -774,13 +775,13 @@ mod tests {
#[test]
fn a_bezier_is_a_spline_of_its_own_degree_over_all_its_control_points() {
- let mut q = [Vec2::ZERO; solidcraft_geom::MAX_BEZIER_CTRL];
+ let mut q = [Vec2::ZERO; solidcore_record::MAX_BEZIER_CTRL];
for (i, s) in q.iter_mut().enumerate() {
*s = Vec2::new(i as f64, (i * i) as f64);
}
// Every degree a Bézier piece can have, up to a G4 blend's 9: n + 1 control points, all of
// them, and 2(n + 1) clamped knots.
- for n in 4..=solidcraft_geom::MAX_BEZIER_DEGREE as u8 {
+ for n in 4..=solidcore_record::MAX_BEZIER_DEGREE as u8 {
let k = usize::from(n) + 1;
let DxfShape::Spline { degree, knots, ctrl, weights } = seg_shape(&Seg2::Bezier { n, p: q }) else { panic!("degree {n}") };
assert_eq!((degree, knots.len(), weights), (n, 2 * k, None), "degree {n}");
@@ -875,7 +876,7 @@ mod tests {
let Geom2::Spline { pts, control: true, degree: 3 } = &back[5] else { panic!("{:?}", back[5]) };
assert!(pts.iter().zip(&cubic).all(|(a, b)| a.dist(*b) < 1e-9) && pts.len() == 4);
// A degree-9 Bézier (a G4 blend) comes back at its own degree over all ten points.
- let mut q = [Vec2::ZERO; solidcraft_geom::MAX_BEZIER_CTRL];
+ let mut q = [Vec2::ZERO; solidcore_record::MAX_BEZIER_CTRL];
for (i, s) in q.iter_mut().enumerate() {
*s = Vec2::new(i as f64, (i % 3) as f64);
}
diff --git a/crates/io/src/gltf_in.rs b/crates/io/src/gltf_in.rs
index 1b6bd32c8b..a822747b28 100644
--- a/crates/io/src/gltf_in.rs
+++ b/crates/io/src/gltf_in.rs
@@ -17,14 +17,15 @@
//! sRGB here), alpha (blended materials only) and metallic/roughness factors give the body's
//! look. Textures are not read.
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
use gltf::accessor::{DataType, Dimensions};
use gltf::mesh::Mode;
+use solidcore_record::Vec3;
use solidcraft_doc::appearance::Look;
use solidcraft_doc::{Mat, MeshData, mat_mul};
-use solidcraft_geom::Vec3;
use crate::{IoError, MAX_3MF_BYTES, MeshFeature, Result};
diff --git a/crates/io/src/lib.rs b/crates/io/src/lib.rs
index 0cce0c8925..9ba7d27e06 100644
--- a/crates/io/src/lib.rs
+++ b/crates/io/src/lib.rs
@@ -54,8 +54,10 @@ pub use threemf::{
};
pub use urdf::{UrdfOptions, UrdfPackage, urdf};
+use solidcore_record::Vec3;
use solidcraft_doc::{Document, Metadata, ModelState};
-use solidcraft_geom::{MassProperties, Mesh, Vec3};
+use solidcraft_geom::prelude::*;
+use solidcraft_geom::{MassProperties, Mesh};
/// Design file extension: new designs, autosaves and recovery files are written as `.sc`.
pub const DESIGN_EXT: &str = "sc";
@@ -955,8 +957,8 @@ pub const MAX_STL_TRIANGLES: usize = 20_000_000;
#[cfg(test)]
mod tests {
use super::*;
+ use solidcore_record::Vec3;
use solidcraft_doc::{FeatureKind, Model, Operation, point_expr};
- use solidcraft_geom::Vec3;
fn model() -> (Document, Model) {
let mut doc = Document::new("t");
diff --git a/crates/io/src/mutate.rs b/crates/io/src/mutate.rs
index c5dcd68b1e..af0d4e1f06 100644
--- a/crates/io/src/mutate.rs
+++ b/crates/io/src/mutate.rs
@@ -2,7 +2,8 @@
//! case gives an error or a result, never a panic, within the time budget and the reader's own
//! caps. The mutations and the check are `solidcraft_testkit`'s.
-use solidcraft_geom::{Mesh, Vec2, Vec3};
+use solidcore_record::{Vec2, Vec3};
+use solidcraft_geom::Mesh;
use solidcraft_testkit::{mutations, survives};
fn cube() -> Mesh {
@@ -271,8 +272,8 @@ fn drawings_survive_mutation() {
/// never a panic.
#[test]
fn paper_scenes_survive_mutation_into_svg() {
+ use solidcore_record::{Loop2, Region2, Seg2, Vec2};
use solidcraft_geom::paper::{Group, Item, ObjectKind, Scene};
- use solidcraft_geom::{Loop2, Region2, Seg2, Vec2};
let p = Vec2::new;
let border = Loop2::polygon(&[p(20.0, 10.0), p(410.0, 10.0), p(410.0, 287.0), p(20.0, 287.0)]);
let items = vec![
diff --git a/crates/io/src/obj.rs b/crates/io/src/obj.rs
index f09e4e8b03..bcf426efdd 100644
--- a/crates/io/src/obj.rs
+++ b/crates/io/src/obj.rs
@@ -3,7 +3,7 @@
//! are split into fans. Texture coordinates, normals and materials are ignored. The file is
//! untrusted: counts are capped and bad lines become warnings.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::threemf::MeshObject;
use crate::{IoError, Result};
diff --git a/crates/io/src/paper/svg.rs b/crates/io/src/paper/svg.rs
index 474b8c32b4..f169efbdd1 100644
--- a/crates/io/src/paper/svg.rs
+++ b/crates/io/src/paper/svg.rs
@@ -19,10 +19,11 @@
//! written as one, and a piece ending within 10 nanometres of where the path is goes straight on
//! to the next.
+use solidcraft_geom::prelude::*;
use std::fmt::Write;
+use solidcore_record::{Region2, Seg2, Vec2};
use solidcraft_geom::paper::{Item, Prepared, arc_pieces};
-use solidcraft_geom::{Region2, Seg2, Vec2};
use crate::{IoError, MAX_DRAWING_BYTES, Result};
diff --git a/crates/io/src/paper/svg_tests.rs b/crates/io/src/paper/svg_tests.rs
index 6f16b9b259..fabd1b2e52 100644
--- a/crates/io/src/paper/svg_tests.rs
+++ b/crates/io/src/paper/svg_tests.rs
@@ -1,7 +1,7 @@
use std::f64::consts::{FRAC_PI_2, PI, TAU};
+use solidcore_record::{Loop2, Region2};
use solidcraft_geom::paper::{Group, ObjectKind, Scene};
-use solidcraft_geom::{Loop2, Region2};
use super::*;
use crate::{Geom2, read_svg};
diff --git a/crates/io/src/ply.rs b/crates/io/src/ply.rs
index 5b702905b0..83990961d6 100644
--- a/crates/io/src/ply.rs
+++ b/crates/io/src/ply.rs
@@ -5,7 +5,7 @@
//! and property (normals, intensity, edges, …) is passed over. The file is untrusted: counts are
//! checked against its size and capped.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::threemf::MeshObject;
use crate::{IoError, Result};
diff --git a/crates/io/src/point_cloud.rs b/crates/io/src/point_cloud.rs
index 02fb59620b..90b00a46cf 100644
--- a/crates/io/src/point_cloud.rs
+++ b/crates/io/src/point_cloud.rs
@@ -4,8 +4,8 @@
//! points than asked for is thinned evenly (every n-th point). The points are kept relative to
//! the first one, in single precision.
+use solidcore_record::Vec3;
use solidcraft_doc::point_cloud::{MAX_COORD, MAX_POINTS};
-use solidcraft_geom::Vec3;
use crate::{IoError, Result};
diff --git a/crates/io/src/sketch2d.rs b/crates/io/src/sketch2d.rs
index df0e587174..9792e6f368 100644
--- a/crates/io/src/sketch2d.rs
+++ b/crates/io/src/sketch2d.rs
@@ -1,7 +1,8 @@
//! 2D drawing exchange for sketches: DXF (ASCII, read and write) and SVG (read). Readers produce
//! plain 2D geometry in millimetres; the engine turns it into sketch curves.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
/// One imported 2D entity (millimetres, y up).
#[derive(Clone, Debug, PartialEq)]
diff --git a/crates/io/src/svg.rs b/crates/io/src/svg.rs
index 39cc177111..9e474e7c03 100644
--- a/crates/io/src/svg.rs
+++ b/crates/io/src/svg.rs
@@ -5,7 +5,8 @@
use quick_xml::Reader;
use quick_xml::events::{BytesStart, Event};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::sketch2d::{Geom2, MAX_DRAWING_BYTES, MAX_ENTITIES};
use crate::{IoError, Result};
diff --git a/crates/io/src/threemf.rs b/crates/io/src/threemf.rs
index c2c768baf0..02a7bc9b88 100644
--- a/crates/io/src/threemf.rs
+++ b/crates/io/src/threemf.rs
@@ -15,13 +15,14 @@
//! `Metadata/model_settings.config`), and those names are used. Packages are untrusted: sizes,
//! entry counts, model parts, mesh sizes and component nesting are capped.
+use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, HashMap};
use std::fmt::Write as _;
use std::io::{Cursor, Read, Write};
use quick_xml::Reader;
use quick_xml::events::{BytesStart, Event};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::{IoError, Result};
diff --git a/crates/io/src/urdf.rs b/crates/io/src/urdf.rs
index c1ad07b9ae..a5c56e8c8b 100644
--- a/crates/io/src/urdf.rs
+++ b/crates/io/src/urdf.rs
@@ -9,11 +9,13 @@
//! `L = T_A · F_a` and the parent-side joint frame `L · M(q)`, the chain inverted (reversed, axes
//! negated, so each URDF value still equals SolidCraft's).
+use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet, HashSet, VecDeque};
+use solidcore_record::Vec3;
use solidcraft_doc::joints::{self, Joint, JointKind};
use solidcraft_doc::{Document, IDENTITY, MAX_PLACEMENT_DEPTH, MAX_PLACEMENTS, Mat, ModelState, Occurrence, apply_point, mat_inverse, mat_mul};
-use solidcraft_geom::{Mesh, Vec3};
+use solidcraft_geom::Mesh;
use crate::{IoError, Result, export_mesh, stl_binary, weld, weld_eps};
diff --git a/crates/kernel/Cargo.toml b/crates/kernel/Cargo.toml
index 57cc486384..bf07fc5b89 100644
--- a/crates/kernel/Cargo.toml
+++ b/crates/kernel/Cargo.toml
@@ -9,6 +9,7 @@ license.workspace = true
workspace = true
[dependencies]
+solidcore-record = { workspace = true }
solidcraft-geom = { workspace = true }
solidcraft-smlib = { workspace = true }
solidcraft-profile = { workspace = true }
diff --git a/crates/kernel/examples/step_board_fixture.rs b/crates/kernel/examples/step_board_fixture.rs
index 51efadac83..95bb6f38e5 100644
--- a/crates/kernel/examples/step_board_fixture.rs
+++ b/crates/kernel/examples/step_board_fixture.rs
@@ -17,7 +17,7 @@ fn main() {
}
mod run {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
use solidcraft_kernel::{Body, ExportBody, ExportProduct, StepHeader, box_solid, cylinder, fillet, step_export_products};
/// A count from `SOLIDCRAFT_<name>`, or `default` when it is unset.
diff --git a/crates/kernel/src/assemble.rs b/crates/kernel/src/assemble.rs
index 0927d2c27e..4ae6b50146 100644
--- a/crates/kernel/src/assemble.rs
+++ b/crates/kernel/src/assemble.rs
@@ -10,11 +10,13 @@
//! and holes clockwise there; [`Assembly::finish`] stores them relative to the surface's natural
//! normal, as the record does.
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::pcurve::{EdgeUse, pcurves_within};
-use solidcraft_geom::brep::{
- Brep, Curve, Curve2, Edge, Face, Frame, Loop, Natural, OrientedEdge, OrientedFace, Region, Shell, Surface, VERSION, Vertex, form,
+use solidcore_record::Vec3;
+use solidcore_record::brep::{
+ Brep, Curve, Curve2, Edge, Face, Frame, Loop, Natural, OrientedEdge, OrientedFace, Region, Shell, Surface, VERSION, Vertex,
};
+use solidcraft_geom::brep::form;
+use solidcraft_geom::brep::pcurve::{EdgeUse, pcurves_within};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::history::{EdgeOrigin, FaceProv};
@@ -244,7 +246,7 @@ impl Assembly {
let loose =
Brep { version: VERSION, tolerance: self.tolerance, regions, shells, faces, edges: edges.collect(), vertices: self.vertices.clone() };
let part = loose.canonical().map_err(invalid)?;
- part.brep.check_geometry().map_err(invalid)?;
+ solidcraft_geom::brep::geometry::check(&part.brep).map_err(invalid)?;
let mut face_map: Vec<Option<usize>> = vec![None; self.faces.len()];
for (c, &k) in part.faces.iter().enumerate() {
if let Some(slot) = kept.get(k as usize).and_then(|i| face_map.get_mut(*i)) {
@@ -422,7 +424,7 @@ fn domain_of(surface: &Surface, pcurves: &[Vec<Curve2>], kept: Option<[[f64; 2];
}
}
}
- let natural = surface.natural();
+ let natural = solidcraft_geom::brep::label::surface_natural(surface);
let mut out = [[0.0; 2]; 2];
for d in 0..2 {
let (mut a, mut b) = (*lo.get(d)?, *hi.get(d)?);
diff --git a/crates/kernel/src/blend.rs b/crates/kernel/src/blend.rs
index ce7bb00c55..d80590065a 100644
--- a/crates/kernel/src/blend.rs
+++ b/crates/kernel/src/blend.rs
@@ -7,11 +7,12 @@
//! The helpers here read a body's schema 4 record: planar faces' outward normals, the direction
//! into a face across an edge, an edge's tangent at its ends.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeSet;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Brep, Curve, Loop, OrientedEdge, Shell, Surface};
use solidcraft_geom::brep::eval::{CurveEval, SurfaceEval};
-use solidcraft_geom::brep::{Brep, Curve, Loop, OrientedEdge, Shell, Surface};
use crate::body::Body;
use crate::{KernelError, Result};
@@ -1138,7 +1139,7 @@ pub(crate) fn with_continuation(e: KernelError, next: Option<Vec3>) -> KernelErr
#[allow(clippy::unwrap_used, clippy::expect_used)]
mod tests {
use super::*;
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
/// A round (`round`) or an equal-distance chamfer of the edges nearest `pts`.
fn blend(body: &Body, pts: &[Vec3], size: f64, round: bool) -> Result<Body> {
diff --git a/crates/kernel/src/blend_corner.rs b/crates/kernel/src/blend_corner.rs
index 544e2a2eff..ef4efdb390 100644
--- a/crates/kernel/src/blend_corner.rs
+++ b/crates/kernel/src/blend_corner.rs
@@ -15,7 +15,7 @@
use std::collections::BTreeSet;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::body::Body;
use crate::history::{Change, EdgeOrigin, EdgeProv, FaceOrigin, FaceProv, History};
@@ -271,6 +271,7 @@ mod tests {
use crate::blend::Faces;
use crate::{box_solid, fillet, measure};
use solidcraft_geom::brep::eval::CurveEval;
+ use solidcraft_geom::prelude::*;
/// The 20 mm box and the three edges at its corner (20, 0, 20): `a` along y, `b` along x,
/// `c` up.
@@ -551,7 +552,7 @@ mod tests {
#[test]
fn sloped_basin_rim_fillets() {
- use solidcraft_geom::{Loop2, Plane, Vec2};
+ use solidcore_record::{Loop2, Plane, Vec2};
let rectangle = |x0, y0, x1, y1| Loop2::polygon(&[Vec2::new(x0, y0), Vec2::new(x1, y0), Vec2::new(x1, y1), Vec2::new(x0, y1)]);
let slab = box_solid(Vec3::ZERO, Vec3::new(100.0, 60.0, 30.0)).unwrap();
let pocket =
@@ -588,7 +589,7 @@ mod tests {
/// each piece: 375.673069 taken from V0 = 140333.333333 (the prismatoid), 139957.660264.
#[test]
fn a_rim_loop_chamfer_running_off_its_rim_builds() {
- use solidcraft_geom::{Loop2, Plane, Vec2};
+ use solidcore_record::{Loop2, Plane, Vec2};
let rectangle = |x0, y0, x1, y1| Loop2::polygon(&[Vec2::new(x0, y0), Vec2::new(x1, y0), Vec2::new(x1, y1), Vec2::new(x0, y1)]);
let slab = box_solid(Vec3::ZERO, Vec3::new(100.0, 60.0, 30.0)).unwrap();
let pocket =
diff --git a/crates/kernel/src/blend_smlib.rs b/crates/kernel/src/blend_smlib.rs
index d325f42e22..a2bddd8151 100644
--- a/crates/kernel/src/blend_smlib.rs
+++ b/crates/kernel/src/blend_smlib.rs
@@ -13,7 +13,7 @@
//! The history is SMLib's tags, renumbered into the body's orders; a blend face, which SMLib
//! leaves untagged, comes from the edge it replaces ([`solidcraft_smlib::history::blends`]).
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::blend_variable::RadiusSpline;
use crate::body::Body;
@@ -111,9 +111,10 @@ enum Kind {
}
mod imp {
+ use solidcraft_geom::prelude::*;
use std::collections::BTreeSet;
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
use solidcraft_smlib::{Blend, Brep, ChamferSecond, CheckLevel, Error as SmError};
use super::Kind;
@@ -562,7 +563,7 @@ mod imp {
#[cfg(test)]
#[allow(clippy::unwrap_used, clippy::expect_used)]
mod tests {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
use super::*;
use crate::history::{Change, FaceOrigin};
diff --git a/crates/kernel/src/blend_variable.rs b/crates/kernel/src/blend_variable.rs
index 0bbf1f8553..3c6da7a7e3 100644
--- a/crates/kernel/src/blend_variable.rs
+++ b/crates/kernel/src/blend_variable.rs
@@ -5,8 +5,9 @@
//! two planar faces the band a radius law takes from the faces is checked against the faces
//! first, which also gives a [`taper`] its room along the edge.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_geom::brep::eval::CurveEval;
+use solidcraft_geom::prelude::*;
use crate::blend::{Faces, too_large, unsupported};
use crate::body::Body;
@@ -504,8 +505,8 @@ mod tests {
f.loops
.iter()
.map(|l| match l {
- solidcraft_geom::brep::Loop::Edges { edges } => edges.len(),
- solidcraft_geom::brep::Loop::Vertex { .. } => 0,
+ solidcore_record::brep::Loop::Edges { edges } => edges.len(),
+ solidcore_record::brep::Loop::Vertex { .. } => 0,
})
.sum()
})
@@ -651,7 +652,7 @@ mod tests {
/// A prism of the polygon `pts` (in xy) from z = `z0` to `z1`.
fn prism_between(pts: &[(f64, f64)], z0: f64, z1: f64) -> Body {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
let outer = Loop2::polygon(&pts.iter().map(|(x, y)| Vec2::new(*x, *y)).collect::<Vec<_>>());
crate::extrude(&Plane::XY, &[Region2 { outer, holes: vec![] }], z0, z1).unwrap().pop().unwrap()
}
diff --git a/crates/kernel/src/blend_wrong_way_tests.rs b/crates/kernel/src/blend_wrong_way_tests.rs
index 6b80bf0f92..c450929d2f 100644
--- a/crates/kernel/src/blend_wrong_way_tests.rs
+++ b/crates/kernel/src/blend_wrong_way_tests.rs
@@ -1,4 +1,5 @@
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::*;
diff --git a/crates/kernel/src/body.rs b/crates/kernel/src/body.rs
index 8f38f25dba..4459d3dd08 100644
--- a/crates/kernel/src/body.rs
+++ b/crates/kernel/src/body.rs
@@ -1,6 +1,8 @@
use serde::Serialize;
-use solidcraft_geom::brep::{self, Brep, Curve, Loop, Shell, Surface};
-use solidcraft_geom::{Aabb3, Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self, Brep, Curve, Loop, Shell, Surface};
+use solidcraft_geom::prelude::*;
+use solidcraft_geom::{Aabb3, Mesh};
use crate::history::BodyHistory;
use crate::{KernelError, Result, guard};
@@ -147,7 +149,7 @@ fn placed_mesh(m: &Mesh, t: &[[f64; 4]; 4]) -> Option<Mesh> {
t[0][2] * v.x + t[1][2] * v.y + t[2][2] * v.z + w * t[3][2],
)
};
- brep::placement::Rigid::of_matrix(t)?;
+ solidcraft_geom::brep::placement::Rigid::of_matrix(t)?;
Some(Mesh {
positions: m.positions.iter().map(|p| r(*p, 1.0)).collect(),
normals: m.normals.iter().map(|n| r(*n, 0.0)).collect(),
@@ -159,20 +161,20 @@ fn placed_mesh(m: &Mesh, t: &[[f64; 4]; 4]) -> Option<Mesh> {
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
pub enum FaceSource {
ExtrudeSide {
- segment: solidcraft_geom::Seg2,
- plane: Option<solidcraft_geom::Plane>,
+ segment: solidcore_record::Seg2,
+ plane: Option<solidcore_record::Plane>,
coalesced: bool,
},
CertifiedExtrudeSide {
producer: u64,
sketch: u64,
curve: String,
- plane: Option<solidcraft_geom::Plane>,
+ plane: Option<solidcore_record::Plane>,
},
ExtrudeCap {
high: bool,
- region: solidcraft_geom::Region2,
- plane: solidcraft_geom::Plane,
+ region: solidcore_record::Region2,
+ plane: solidcore_record::Plane,
},
CertifiedExtrudeCap {
producer: u64,
@@ -180,25 +182,25 @@ pub enum FaceSource {
high: bool,
outer: Vec<String>,
holes: Vec<Vec<String>>,
- plane: solidcraft_geom::Plane,
+ plane: solidcore_record::Plane,
},
Box {
producer: Option<u64>,
axis: u8,
high: bool,
- plane: solidcraft_geom::Plane,
+ plane: solidcore_record::Plane,
},
/// A cylinder primitive's cap: `high` at the far end (its `top`), else at the base.
CylinderCap {
producer: u64,
high: bool,
- plane: solidcraft_geom::Plane,
+ plane: solidcore_record::Plane,
},
ShellPlanar {
producer: Option<u64>,
source: Box<FaceSource>,
inner: bool,
- plane: solidcraft_geom::Plane,
+ plane: solidcore_record::Plane,
},
Imported {
item: u64,
@@ -212,7 +214,7 @@ pub type CapSignature = (Vec<String>, Vec<Vec<String>>);
type FaceSources = std::sync::Arc<Vec<Option<FaceSource>>>;
impl FaceSource {
- fn plane_mut(&mut self) -> Option<&mut solidcraft_geom::Plane> {
+ fn plane_mut(&mut self) -> Option<&mut solidcore_record::Plane> {
match self {
Self::ExtrudeSide { plane, .. } | Self::CertifiedExtrudeSide { plane, .. } => plane.as_mut(),
Self::ExtrudeCap { plane, .. }
@@ -361,7 +363,7 @@ fn coarse_tolerance(span: f64) -> f64 {
fn span_of(record: &Brep) -> f64 {
let mut bounds: Aabb3 = record.vertices.iter().map(|v| v3(v.point)).collect();
for e in &record.edges {
- if let Ok(c) = brep::eval::CurveEval::new(e.parameters()) {
+ if let Ok(c) = solidcraft_geom::brep::eval::CurveEval::new(e.parameters()) {
let [t0, t1] = e.interval;
for i in 1..4 {
if let Some(p) = c.point(t0 + (t1 - t0) * f64::from(i) / 4.0)
@@ -389,7 +391,7 @@ fn same_shared<T: PartialEq>(a: &Option<std::sync::Arc<T>>, b: &Option<std::sync
/// canonical order) and at least one face. A solid's faces bound material; a surface body's lie
/// in open shells.
fn solid_record(record: Brep) -> Result<Brep> {
- record.validate_built().map_err(|e| KernelError::Invalid(e.to_string()))?;
+ solidcraft_geom::brep::check::validate_built(&record).map_err(|e| KernelError::Invalid(e.to_string()))?;
if record.faces.is_empty() {
return Err(KernelError::Failed("empty result".into()));
}
@@ -467,8 +469,8 @@ impl Refusal {
}
impl SurfaceKind {
- pub(crate) fn of(surface: &solidcraft_geom::brep::Surface) -> SurfaceKind {
- use solidcraft_geom::brep::Surface as S;
+ pub(crate) fn of(surface: &solidcore_record::brep::Surface) -> SurfaceKind {
+ use solidcore_record::brep::Surface as S;
match surface {
S::Plane { .. } | S::PlaneThrough { .. } => SurfaceKind::Plane,
S::Cylinder { .. } => SurfaceKind::Cylinder,
@@ -714,7 +716,7 @@ impl Body {
}
/// An exact construction/import plane; never inferred from tessellation.
- pub fn face_plane(&self, index: usize) -> Option<solidcraft_geom::Plane> {
+ pub fn face_plane(&self, index: usize) -> Option<solidcore_record::Plane> {
if index >= 50_000 {
return None;
}
@@ -732,7 +734,7 @@ impl Body {
/// Exact current planar surface for an explicitly fixed snapshot, without source lineage: the
/// face's plane as the face faces (out of the material in a closed shell).
- pub fn planar_face(&self, index: usize) -> Option<solidcraft_geom::Plane> {
+ pub fn planar_face(&self, index: usize) -> Option<solidcore_record::Plane> {
let face = self.record.faces.get(index)?;
let (o, u, v) = match &face.surface {
Surface::Plane { origin, u_axis, v_axis } => (v3(*origin), v3(*u_axis), v3(*v_axis)),
@@ -743,7 +745,7 @@ impl Body {
_ => return None,
};
let v = if self.face_forward(index) { v } else { -v };
- solidcraft_geom::Plane::new(o, u, v)
+ solidcore_record::Plane::new(o, u, v)
}
/// Certify the two caps of a body built by [`crate::cylinder`]. Its wall stays uncertified.
@@ -853,7 +855,7 @@ impl Body {
let mut sources = sources.as_ref().clone();
for source in sources.iter_mut().flatten() {
if let Some(plane) = source.plane_mut() {
- *plane = solidcraft_geom::Plane::new(
+ *plane = solidcore_record::Plane::new(
vector(plane.origin) + translation,
vector(plane.x),
vector(plane.y) * if reflected { -1. } else { 1. },
@@ -1139,7 +1141,7 @@ impl Body {
// A placed copy is planned as its original, moved (as `Body::mesh` shows the original's
// mesh): the part is planned once for every copy.
if let Some((shared, m)) = self.display_of.as_deref()
- && brep::placement::Rigid::of_matrix(m).is_some()
+ && solidcraft_geom::brep::placement::Rigid::of_matrix(m).is_some()
{
return Ok(remembered(&shared.plans, t, || shared.original.mesh_plan_untimed(t))?.transformed(m));
}
@@ -1298,7 +1300,7 @@ impl Body {
/// B-spline it is, for a sketch to project them. `None` for an edge that doesn't lie in a
/// plane parallel to `plane`, isn't read exactly or isn't there, and for every edge of a mesh
/// body.
- pub fn planar_edges(&self, plane: &solidcraft_geom::Plane, indices: &[usize]) -> Vec<Option<Vec<crate::PlanarPiece>>> {
+ pub fn planar_edges(&self, plane: &solidcore_record::Plane, indices: &[usize]) -> Vec<Option<Vec<crate::PlanarPiece>>> {
if self.is_mesh() {
return vec![None; indices.len()];
}
@@ -1531,7 +1533,7 @@ impl Body {
/// rest at the evaluator's points (capped).
fn edge_points(e: &brep::Edge, chord: f64) -> Result<Vec<Vec3>> {
const MAX_POINTS: usize = 4096;
- let curve = brep::eval::CurveEval::new(e.parameters()).map_err(|err| KernelError::Invalid(err.to_string()))?;
+ let curve = solidcraft_geom::brep::eval::CurveEval::new(e.parameters()).map_err(|err| KernelError::Invalid(err.to_string()))?;
let [t0, t1] = e.interval;
let at = |t: f64| curve.point(t).ok_or_else(|| KernelError::Invalid(format!("edge curve has no point at {t}")));
if let Curve::Line { .. } = e.curve {
@@ -1559,7 +1561,7 @@ fn edge_points(e: &brep::Edge, chord: f64) -> Result<Vec<Vec3>> {
fn curve_hull(c: &Curve, interval: [f64; 2], b: &mut Aabb3) {
match c {
Curve::Line { .. } | Curve::Circle { .. } | Curve::Ellipse { .. } => {
- if let Ok(e) = brep::eval::CurveEval::new(c) {
+ if let Ok(e) = solidcraft_geom::brep::eval::CurveEval::new(c) {
let [t0, t1] = interval;
for i in 0..=16 {
if let Some(p) = e.point(t0 + (t1 - t0) * f64::from(i) / 16.0) {
diff --git a/crates/kernel/src/body_lump_tests.rs b/crates/kernel/src/body_lump_tests.rs
index 95db09a81f..47e8ca8640 100644
--- a/crates/kernel/src/body_lump_tests.rs
+++ b/crates/kernel/src/body_lump_tests.rs
@@ -161,7 +161,7 @@ fn spheres_apart_join_as_two_lumps() {
}
fn certified_lump_witness() -> Body {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
// The current trimmed lower prism: a rectangular tool with a circular stop
// removed. Its cap footprint differs materially from the original sketch.
let region = Region2 {
@@ -176,8 +176,8 @@ fn certified_lump_witness() -> Body {
let inputs = [&named, &unknown, &lower];
let sources: Vec<Option<FaceSource>> =
inputs.iter().flat_map(|b| b.face_sources().map_or_else(|| vec![None; b.face_count()], |s| s.to_vec())).collect();
- let records: Vec<&solidcraft_geom::brep::Brep> = inputs.iter().map(|b| b.record()).collect();
- let part = solidcraft_geom::brep::part::compound(&records).unwrap();
+ let records: Vec<&solidcore_record::brep::Brep> = inputs.iter().map(|b| b.record()).collect();
+ let part = solidcore_record::brep::part::compound(&records).unwrap();
let body = Body::from_record(part.brep).unwrap();
let table = part.faces.iter().map(|f| sources.get(*f as usize).cloned().flatten()).collect();
body.with_face_sources(Some(std::sync::Arc::new(table)))
@@ -249,7 +249,7 @@ fn grouping_lumps_does_not_infer_absent_or_misaligned_sources() {
/// It must still come out outward, or a Cut with it removes the wrong side (#559).
#[test]
fn a_long_thin_cylinder_comes_out_outward() {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
let plane = Plane::from_normal(Vec3::new(0., 24., 30.), Vec3::Z).unwrap();
for (lo, seam) in [(-181.0, 0.613), (-100.0, 0.613), (-10.0, 0.613), (-181.0, 0.0)] {
let disc = Region2 { outer: Loop2::circle_from(Vec2::ZERO, 0.5, seam), holes: vec![] };
diff --git a/crates/kernel/src/boolean_history_tests.rs b/crates/kernel/src/boolean_history_tests.rs
index c739f4fa14..ac40c4540c 100644
--- a/crates/kernel/src/boolean_history_tests.rs
+++ b/crates/kernel/src/boolean_history_tests.rs
@@ -2,9 +2,11 @@
//! of the operands (in tests only: the history itself is recorded, never sampled), and the exact
//! origins asserted where the outcome is known.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeSet;
-use solidcraft_geom::{Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Mesh;
use crate::body::Body;
use crate::history::BodyHistory;
@@ -347,7 +349,7 @@ fn faceted_tool() {
/// one face each past the cutter's floor, untouched (Kept).
#[test]
fn stepped_cut_keeps_the_stock_walls_whole() {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
for curved in [true, false] {
let (outer, inner) = if curved {
(Loop2::circle(Vec2::ZERO, 10.0), Loop2::circle(Vec2::ZERO, 5.0))
@@ -464,7 +466,7 @@ mod smlib {
/// how the two meet.
#[test]
fn cubes_touching_along_an_edge_or_at_a_vertex_unite_into_two_solids() {
- use solidcraft_geom::brep::part::{Contact, RegionContact};
+ use solidcore_record::brep::part::{Contact, RegionContact};
let a = boxed(0.0, 0.0, 0.0, 10.0, 10.0, 10.0);
for (name, b, contact) in [
("edge", boxed(10.0, 10.0, 0.0, 20.0, 20.0, 10.0), Contact::Edge),
diff --git a/crates/kernel/src/boundary.rs b/crates/kernel/src/boundary.rs
index 0a63df1b54..b8aa5bd350 100644
--- a/crates/kernel/src/boundary.rs
+++ b/crates/kernel/src/boundary.rs
@@ -17,7 +17,8 @@
//! exactly; the network there refuses G1/G2 on two sides that meet at a corner for the same
//! reason. Everything this module refuses is an error, never a quietly worse surface.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::bridge::{Continuity, Frame, bridge};
diff --git a/crates/kernel/src/boundary_network.rs b/crates/kernel/src/boundary_network.rs
index d369280063..3291bbc12e 100644
--- a/crates/kernel/src/boundary_network.rs
+++ b/crates/kernel/src/boundary_network.rs
@@ -11,11 +11,12 @@
//! The two-curve bridge with G0–G3 against a sketch's plane is [`crate::boundary`]; this is the
//! general case: three or four sides, interior curves, 3D curves and edges.
-use solidcraft_geom::brep::Brep;
+use solidcore_record::brep::Brep;
+use solidcore_record::{Plane, Seg2, Vec3};
use solidcraft_geom::brep::eval::{CurveEval, SurfaceEval};
use solidcraft_geom::bspline::{CurveN, NurbsSurface, SplineError};
use solidcraft_geom::network::{self, CrossFace, FaceFrame, NetCurve, NetworkCurve, PointCurve, Tolerances};
-use solidcraft_geom::{Plane, Seg2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::continuity_order::{Construction, Continuity};
@@ -336,7 +337,7 @@ impl EdgeFaces {
// How the face's loop (counter-clockwise about its surface's natural normal) runs the edge.
let face = r.faces.get(u.face as usize).ok_or_else(|| KernelError::Failed("boundary surface: an edge's face".into()))?;
let in_loop = match face.loops.get(u.r#loop as usize) {
- Some(solidcraft_geom::brep::Loop::Edges { edges }) => edges.get(u.position as usize).map(|x| x.forward),
+ Some(solidcore_record::brep::Loop::Edges { edges }) => edges.get(u.position as usize).map(|x| x.forward),
_ => None,
};
let in_loop = in_loop.ok_or_else(|| KernelError::Failed("boundary surface: an edge's face".into()))?;
@@ -431,7 +432,7 @@ fn face_of(s: &NurbsSurface, corners: &[Vec3]) -> Result<Body> {
}
let tolerance = (size * 1e-6).max(1e-5);
let mut parts = Parts { tolerance, ..Parts::default() };
- parts.vertices = c.iter().map(|p| solidcraft_geom::brep::Vertex { point: [p.x, p.y, p.z], tolerance }).collect();
+ parts.vertices = c.iter().map(|p| solidcore_record::brep::Vertex { point: [p.x, p.y, p.z], tolerance }).collect();
let mut uses = Vec::new();
for (k, (ctrl, knots, [a, z], forward, fixed)) in sides.into_iter().enumerate() {
if collapsed.get(k).copied().unwrap_or(false) {
@@ -446,7 +447,7 @@ fn face_of(s: &NurbsSurface, corners: &[Vec3]) -> Result<Body> {
let mut ends = vec![vertex_of[a]];
for (_, p) in &cuts {
ends.push(parts.vertices.len());
- parts.vertices.push(solidcraft_geom::brep::Vertex { point: [p.x, p.y, p.z], tolerance });
+ parts.vertices.push(solidcore_record::brep::Vertex { point: [p.x, p.y, p.z], tolerance });
}
ends.push(vertex_of[z]);
let uv = |t: f64| [fixed[0].unwrap_or(t), fixed[1].unwrap_or(t)];
@@ -455,19 +456,19 @@ fn face_of(s: &NurbsSurface, corners: &[Vec3]) -> Result<Body> {
let interval = [w[0], w[1]];
let edge = index(parts.edges.len())?;
let vertices = [index(e[0])?, index(e[1])?];
- parts.edges.push(solidcraft_geom::brep::Edge { nurbs: None, curve: curve.clone(), interval, vertices, tolerance, uses: Vec::new() });
- pieces.push(solidcraft_geom::brep::OrientedEdge { edge, forward, pcurve: uv_line(uv(w[0]), uv(w[1]), interval) });
+ parts.edges.push(solidcore_record::brep::Edge { nurbs: None, curve: curve.clone(), interval, vertices, tolerance, uses: Vec::new() });
+ pieces.push(solidcore_record::brep::OrientedEdge { edge, forward, pcurve: uv_line(uv(w[0]), uv(w[1]), interval) });
}
if !forward {
pieces.reverse();
}
uses.extend(pieces);
}
- let face = solidcraft_geom::brep::Face {
+ let face = solidcore_record::brep::Face {
nurbs: None,
surface: spline_surface(s),
domain: s.domain(),
- loops: vec![solidcraft_geom::brep::Loop::Edges { edges: uses }],
+ loops: vec![solidcore_record::brep::Loop::Edges { edges: uses }],
};
parts.faces.push((face, true));
let body = surface_body(&parts.canonical()?.brep)?;
@@ -513,7 +514,7 @@ fn index(i: usize) -> Result<u32> {
mod tests {
use super::*;
use crate::patch_region;
- use solidcraft_geom::{Loop2, Region2, Vec2};
+ use solidcore_record::{Loop2, Region2, Vec2};
fn sketch(label: &str, plane: Plane, segs: Vec<Seg2>) -> BoundaryCurve<'static> {
BoundaryCurve { label: label.into(), source: CurveSource::Sketch { plane, segs }, continuity: Continuity::G0 }
diff --git a/crates/kernel/src/bridge.rs b/crates/kernel/src/bridge.rs
index 9af6ee4ff3..781a3568a2 100644
--- a/crates/kernel/src/bridge.rs
+++ b/crates/kernel/src/bridge.rs
@@ -16,10 +16,11 @@
//! speed) by finite differences: the second derivative of a surface curve with a unit tangent is
//! its curvature vector, and the third is the arclength derivative of that curvature vector.
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::Brep;
+use solidcore_record::Vec3;
+use solidcore_record::brep::Brep;
use solidcraft_geom::brep::eval::{CurveEval, SurfaceEval};
use solidcraft_geom::bspline::{CurveN, HPoint, NurbsSurface};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::continuity_order::Construction;
@@ -402,7 +403,7 @@ impl Support {
.shells
.iter()
.find_map(|s| match s {
- solidcraft_geom::brep::Shell::Faces { faces, .. } => faces.iter().find(|o| o.face as usize == face).map(|o| o.forward),
+ solidcore_record::brep::Shell::Faces { faces, .. } => faces.iter().find(|o| o.face as usize == face).map(|o| o.forward),
_ => None,
})
.unwrap_or(true);
diff --git a/crates/kernel/src/bridge_tests.rs b/crates/kernel/src/bridge_tests.rs
index ff2980e3e4..052795ec03 100644
--- a/crates/kernel/src/bridge_tests.rs
+++ b/crates/kernel/src/bridge_tests.rs
@@ -80,7 +80,7 @@ fn valley_between_cylinders(count: usize, r: f64) -> (Vec<Frame>, Vec<Frame>) {
/// The edges of `body`'s face `face` chained into one loop (its outer loop, as it runs).
fn loop_of(body: &Body, face: usize) -> Chain {
let r = body.record();
- let solidcraft_geom::brep::Loop::Edges { edges } = &r.faces[face].loops[0] else { panic!("a vertex loop") };
+ let solidcore_record::brep::Loop::Edges { edges } = &r.faces[face].loops[0] else { panic!("a vertex loop") };
edges.iter().map(|u| (u.edge as usize, u.forward)).collect()
}
diff --git a/crates/kernel/src/build.rs b/crates/kernel/src/build.rs
index b87478d027..d4d8d97a91 100644
--- a/crates/kernel/src/build.rs
+++ b/crates/kernel/src/build.rs
@@ -2,7 +2,8 @@
//! through SMLib ([`crate::smlib_sweeps`]); a profile face as its schema 4 record
//! ([`planar_face_record`]).
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::draft_corners::DraftCorner;
@@ -50,7 +51,7 @@ fn seg_ok(s: &Seg2) -> bool {
}
Seg2::Cubic { p0, p1, p2, p3 } => p0.is_finite() && p1.is_finite() && p2.is_finite() && p3.is_finite(),
Seg2::Conic { a, apex, b, w } => a.is_finite() && apex.is_finite() && b.is_finite() && w.is_finite() && w > 1e-9,
- Seg2::Bezier { n, p } => (4..=solidcraft_geom::MAX_BEZIER_DEGREE as u8).contains(&n) && p.iter().all(|q| q.is_finite()),
+ Seg2::Bezier { n, p } => (4..=solidcore_record::MAX_BEZIER_DEGREE as u8).contains(&n) && p.iter().all(|q| q.is_finite()),
}
}
@@ -494,7 +495,7 @@ fn offset_curve(s: &Seg2, a: Vec2, b: Vec2, d: f64) -> Option<Seg2> {
q
}
Seg2::Bezier { n, p } => {
- let k = (n as usize).clamp(1, solidcraft_geom::MAX_BEZIER_DEGREE);
+ let k = (n as usize).clamp(1, solidcore_record::MAX_BEZIER_DEGREE);
let mut q = offset_polygon(p.get(..=k)?, n0, n1, d)?;
let mut all = p;
for (dst, src) in all.iter_mut().zip(&q) {
@@ -730,7 +731,7 @@ fn with_end(s: &Seg2, x: Vec2) -> Seg2 {
Seg2::Conic { a, apex, w, .. } => Seg2::Conic { a, apex, b: x, w },
Seg2::Bezier { n, p } => {
let mut q = p;
- if let Some(last) = q.get_mut((n as usize).clamp(1, solidcraft_geom::MAX_BEZIER_DEGREE)) {
+ if let Some(last) = q.get_mut((n as usize).clamp(1, solidcore_record::MAX_BEZIER_DEGREE)) {
*last = x;
}
Seg2::Bezier { n, p: q }
@@ -872,8 +873,9 @@ fn smlib_tapered(plane: &Plane, region: &Region2, from: f64, to: f64, foot: f64,
/// counter-clockwise and the holes clockwise, each sketch segment one edge of its exact record
/// curve ([`crate::point_path::sketch_record_curve`]) with its exact pcurve on the plane. The record
/// equivalent of a profile face: SMLib takes it with `Brep::from_record`.
-pub fn planar_face_record(plane: &Plane, r: &Region2) -> Result<solidcraft_geom::brep::Brep> {
- use solidcraft_geom::brep::{self as rec, pcurve};
+pub fn planar_face_record(plane: &Plane, r: &Region2) -> Result<solidcore_record::brep::Brep> {
+ use solidcore_record::brep::{self as rec};
+ use solidcraft_geom::brep::pcurve;
if !frame_ok(plane) {
return Err(KernelError::Invalid("the face's plane is not finite and orthonormal".into()));
}
@@ -948,7 +950,7 @@ pub fn planar_face_record(plane: &Plane, r: &Region2) -> Result<solidcraft_geom:
edges,
vertices,
};
- brep.validate().map_err(|e| KernelError::Failed(format!("profile face: {e}")))?;
+ solidcraft_geom::brep::check::validate(&brep).map_err(|e| KernelError::Failed(format!("profile face: {e}")))?;
Ok(brep)
}
diff --git a/crates/kernel/src/chamfer_sides_curved_tests.rs b/crates/kernel/src/chamfer_sides_curved_tests.rs
index 64d43ce9ba..6486162d53 100644
--- a/crates/kernel/src/chamfer_sides_curved_tests.rs
+++ b/crates/kernel/src/chamfer_sides_curved_tests.rs
@@ -5,7 +5,7 @@
use std::f64::consts::PI;
-use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
use crate::build::{box_solid, extrude, extrude_tapered};
use crate::{Body, BoolOp, ChamferSide, boolean, chamfer, chamfer_sides};
diff --git a/crates/kernel/src/continuity.rs b/crates/kernel/src/continuity.rs
index 80eb1e6bbe..ebd266091c 100644
--- a/crates/kernel/src/continuity.rs
+++ b/crates/kernel/src/continuity.rs
@@ -20,9 +20,11 @@
//! the join, and backs the engine's `inspect.continuity`.
use serde::Serialize;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self as b};
use solidcraft_geom::brep::normal_section::{SectionJet, normal_section};
-use solidcraft_geom::brep::{self as b, eval::CurveEval, eval::SurfaceEval};
+use solidcraft_geom::brep::{eval::CurveEval, eval::SurfaceEval};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::continuity_order::Continuity;
@@ -493,7 +495,7 @@ impl FaceSurface {
#[allow(clippy::unwrap_used)]
mod tests {
use super::*;
- use solidcraft_geom::{Plane, Seg2};
+ use solidcore_record::{Plane, Seg2};
fn tolerances() -> ContinuityTolerances {
ContinuityTolerances::default()
@@ -548,7 +550,7 @@ mod tests {
#[test]
fn a_line_tangent_into_an_arc_reports_one_over_its_radius() {
- use solidcraft_geom::{Loop2, Region2, Seg2, Vec2};
+ use solidcore_record::{Loop2, Region2, Seg2, Vec2};
let v = |x: f64, y: f64| Vec2::new(x, y);
let outer = Loop2 {
segs: vec![
@@ -575,7 +577,7 @@ mod tests {
/// into `transition` (starting at the origin, leaving along +x), and back straight to
/// (-20, 20): its one tangent wall seam is the line meeting the transition.
fn line_into(transition: Seg2) -> Body {
- use solidcraft_geom::{Loop2, Region2, Vec2};
+ use solidcore_record::{Loop2, Region2, Vec2};
let end = match transition {
Seg2::Cubic { p3, .. } => p3,
Seg2::Bezier { n, p } => p[usize::from(n)],
@@ -607,7 +609,7 @@ mod tests {
/// L = H = 10, 2 / 900 per mm².
#[test]
fn a_plane_into_a_g2_transition_is_curvature_continuous_but_not_g3() {
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
let v = Vec2::new;
let body = line_into(Seg2::Cubic { p0: v(0.0, 0.0), p1: v(10.0, 0.0), p2: v(20.0, 0.0), p3: v(30.0, 10.0) });
let seam = tangent_seam(&body);
@@ -625,8 +627,8 @@ mod tests {
/// with L = 5, H = 10, 3 / 2000 per mm³.
#[test]
fn a_plane_into_a_g3_transition_holds_the_change_of_curvature_but_not_g4() {
- use solidcraft_geom::Vec2;
- let mut p = [Vec2::new(0.0, 0.0); solidcraft_geom::MAX_BEZIER_CTRL];
+ use solidcore_record::Vec2;
+ let mut p = [Vec2::new(0.0, 0.0); solidcore_record::MAX_BEZIER_CTRL];
for (k, q) in [(5.0, 0.0), (10.0, 0.0), (15.0, 0.0), (20.0, 10.0)].into_iter().enumerate() {
p[k + 1] = Vec2::new(q.0, q.1);
}
diff --git a/crates/kernel/src/coplanar_tests.rs b/crates/kernel/src/coplanar_tests.rs
index 4c8209a792..a1a21fedda 100644
--- a/crates/kernel/src/coplanar_tests.rs
+++ b/crates/kernel/src/coplanar_tests.rs
@@ -2,7 +2,7 @@
//! define.
#![allow(clippy::unwrap_used, clippy::panic)]
use crate::*;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
/// An l x w x h block with two bottom edges chamfered by 1 mm: no prism along any axis, so
/// its booleans are not done on sections.
diff --git a/crates/kernel/src/corner_g2_tests.rs b/crates/kernel/src/corner_g2_tests.rs
index 325741826e..f0d14d1838 100644
--- a/crates/kernel/src/corner_g2_tests.rs
+++ b/crates/kernel/src/corner_g2_tests.rs
@@ -1,5 +1,6 @@
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep as b;
+use solidcore_record::Vec3;
+use solidcore_record::brep as b;
+use solidcraft_geom::prelude::*;
use crate::*;
@@ -135,7 +136,8 @@ fn past_the_box(rec: &b::Brep, face: usize) -> (f64, f64, [f64; 2]) {
let mut ring = Vec::new();
for oe in edges {
let [t0, t1] = oe.pcurve.interval().unwrap();
- let mut seg: Vec<[f64; 2]> = (0..=400).map(|k| oe.pcurve.eval(t0 + (t1 - t0) * f64::from(k) / 400.0).unwrap()).collect();
+ let mut seg: Vec<[f64; 2]> =
+ (0..=400).map(|k| solidcraft_geom::brep::pcurve::eval(&oe.pcurve, t0 + (t1 - t0) * f64::from(k) / 400.0).unwrap()).collect();
if !oe.forward {
seg.reverse();
}
diff --git a/crates/kernel/src/curvature_comb.rs b/crates/kernel/src/curvature_comb.rs
index 1e72b72711..0f3d71d1e6 100644
--- a/crates/kernel/src/curvature_comb.rs
+++ b/crates/kernel/src/curvature_comb.rs
@@ -9,8 +9,9 @@
//! curvature in the line's direction times the surface normal, `κₙ n` with
//! `κₙ = n · S_tt / |S_t|²` (the second fundamental form over the first, in that direction).
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_geom::brep::eval::{CurveEval, SurfaceEval};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::iso::IsoLine;
diff --git a/crates/kernel/src/curvecorner_tests.rs b/crates/kernel/src/curvecorner_tests.rs
index 54be9b5e34..6cc984552c 100644
--- a/crates/kernel/src/curvecorner_tests.rs
+++ b/crates/kernel/src/curvecorner_tests.rs
@@ -1,4 +1,5 @@
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::Body;
diff --git a/crates/kernel/src/delete_face.rs b/crates/kernel/src/delete_face.rs
index d4655d0475..7d938b0eca 100644
--- a/crates/kernel/src/delete_face.rs
+++ b/crates/kernel/src/delete_face.rs
@@ -10,10 +10,12 @@
//! straight edge between the moved corners. Anything else (curved neighbours, a gap the
//! neighbours cannot close) is refused, naming the face.
+use solidcraft_geom::prelude::*;
use std::collections::{BTreeSet, HashMap};
-use solidcraft_geom::brep::Curve;
-use solidcraft_geom::{Aabb3, Vec3};
+use solidcore_record::Vec3;
+use solidcore_record::brep::Curve;
+use solidcraft_geom::Aabb3;
use crate::assemble::{AFace, AUse, Assembly};
use crate::body::Body;
@@ -325,7 +327,7 @@ pub fn delete_faces(body: &Body, faces: &[usize]) -> Result<Body> {
#[cfg(test)]
mod tests {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
use super::delete_faces;
use crate::{BoolOp, boolean, box_solid, chamfer, cylinder, fillet};
diff --git a/crates/kernel/src/display_mesh_tests.rs b/crates/kernel/src/display_mesh_tests.rs
index 6a6e16762e..a4ea0dcdb9 100644
--- a/crates/kernel/src/display_mesh_tests.rs
+++ b/crates/kernel/src/display_mesh_tests.rs
@@ -1,10 +1,12 @@
//! The display mesh of a large body with small radii: bends and holes look round, the mesh
//! stays closed, and the cost stays bounded.
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
use std::f64::consts::{FRAC_PI_2, PI, TAU};
-use solidcraft_geom::{Loop2, Mesh, Plane, Region2, Seg2, UnitVec3, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcraft_geom::{Mesh, UnitVec3};
use super::{Body, DISPLAY_ANGLE};
use crate::{FaceSurface, extrude, face_surface};
diff --git a/crates/kernel/src/distance.rs b/crates/kernel/src/distance.rs
index 4de1202f60..71dccde701 100644
--- a/crates/kernel/src/distance.rs
+++ b/crates/kernel/src/distance.rs
@@ -10,12 +10,14 @@
//! the record curve's own points. A point that settles off its face (past the
//! face's boundary) is dropped: the face's edges, offered too, then carry the minimum.
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
use std::sync::OnceLock;
+use solidcore_record::Vec3;
use solidcraft_geom::brep::eval::{CurveEval, SurfaceEval};
use solidcraft_geom::mesh_distance::{MeshClosest, TriangleSet};
-use solidcraft_geom::{Aabb3, Mesh, Vec3};
+use solidcraft_geom::{Aabb3, Mesh};
use crate::body::Body;
use crate::surface_kind::{FaceSurface, surface_of};
diff --git a/crates/kernel/src/draft_corners.rs b/crates/kernel/src/draft_corners.rs
index 5ad6b7ba09..885c5d4d63 100644
--- a/crates/kernel/src/draft_corners.rs
+++ b/crates/kernel/src/draft_corners.rs
@@ -10,7 +10,8 @@
//! corner turns into the offset the offset curves overlap and every rule trims them where they
//! cross.
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Region2, Seg2, Vec2};
+use solidcore_record::{Region2, Seg2, Vec2};
+use solidcraft_geom::prelude::*;
use crate::Result;
diff --git a/crates/kernel/src/emboss.rs b/crates/kernel/src/emboss.rs
index be32fce8b5..80dfd54be0 100644
--- a/crates/kernel/src/emboss.rs
+++ b/crates/kernel/src/emboss.rs
@@ -8,9 +8,11 @@ use crate::history::Change;
use crate::numbered::NumberedRegion;
use crate::offset::{Surf, face_edges, surf_of};
use crate::{KernelError, Result, guard};
+use solidcore_record::brep::{Brep, Curve, Frame, Loop, Surface};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
use solidcraft_geom::brep::eval::CurveEval;
-use solidcraft_geom::brep::{Brep, Curve, Frame, Loop, Surface, form};
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcraft_geom::brep::form;
+use solidcraft_geom::prelude::*;
fn fail(s: &str) -> KernelError {
KernelError::Invalid(format!("cylinder emboss: {s}"))
@@ -44,7 +46,7 @@ fn wall_angles(b: &Brep, face: usize, o: Vec3, axis: Vec3, radial: Vec3, tangent
// (`interval` is on its NURBS form where it has one) about the angle of its middle (a
// whole turn, from the seam, for a wall in one piece).
let c = CurveEval::new(&e.curve).ok()?;
- let [t0, t1] = e.curve_interval()?;
+ let [t0, t1] = solidcraft_geom::brep::label::edge_curve_interval(e)?;
let am = angle(c.point(0.5 * (t0 + t1))?, o, axis, radial, tangent);
let half = 0.5 * (t1 - t0);
return Some((am - half, am + half));
@@ -607,7 +609,7 @@ fn profile_interval_overlaps(plane: &Plane, regions: &[Region2], o: Vec3, axis:
add(p)?;
}
}
- Seg2::Bezier { n, p } if (1..=solidcraft_geom::MAX_BEZIER_DEGREE as u8).contains(&n) => {
+ Seg2::Bezier { n, p } if (1..=solidcore_record::MAX_BEZIER_DEGREE as u8).contains(&n) => {
for p in p.iter().take(usize::from(n) + 1) {
add(*p)?;
}
diff --git a/crates/kernel/src/face_source_tests.rs b/crates/kernel/src/face_source_tests.rs
index a612a97c47..eafdd4848a 100644
--- a/crates/kernel/src/face_source_tests.rs
+++ b/crates/kernel/src/face_source_tests.rs
@@ -1,5 +1,6 @@
use crate::{FaceSource, extrude, transform_matrix};
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
fn assert_exact_planes(body: &crate::Body) {
let mesh = body.mesh(&crate::MeshTolerance::chord(0.001)).unwrap();
diff --git a/crates/kernel/src/fair.rs b/crates/kernel/src/fair.rs
index eabec47ece..d584e69b16 100644
--- a/crates/kernel/src/fair.rs
+++ b/crates/kernel/src/fair.rs
@@ -43,9 +43,10 @@
//! control point that does not change the geometry at all — is reported as an error and the
//! geometry is left alone.
-use solidcraft_geom::brep as b;
+use solidcore_record::Vec3;
+use solidcore_record::brep as b;
+use solidcraft_geom::Grid;
use solidcraft_geom::bspline::{HPoint, MAX_SPLINE_DEGREE, NurbsSurface, Side, SplineError, check_knots, local_basis};
-use solidcraft_geom::{Grid, Vec3};
use crate::body::Body;
use crate::history::Change;
@@ -962,6 +963,7 @@ fn held_face(surface: &b::Surface, opts: &FairOptions) -> Result<Option<FairRepo
mod tests {
use super::*;
use solidcraft_geom::brep::eval::CurveEval;
+ use solidcraft_geom::prelude::*;
/// A clamped uniform knot vector over `[0, spans]` of degree `degree`: `spans + degree`
/// control points.
diff --git a/crates/kernel/src/fill.rs b/crates/kernel/src/fill.rs
index 3a8b5ea9a1..c10d602830 100644
--- a/crates/kernel/src/fill.rs
+++ b/crates/kernel/src/fill.rs
@@ -14,13 +14,15 @@
//! order asked: the neighbour as a height over its tangent plane to that order
//! (`solidcraft_geom::linkage`).
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self as b, Curve2};
+use solidcraft_geom::brep::eval::CurveEval;
use solidcraft_geom::brep::eval::SurfaceEval;
-use solidcraft_geom::brep::{self as b, Curve2, eval::CurveEval};
use solidcraft_geom::bspline::{HPoint, SplineError};
use solidcraft_geom::fill_general::{Across, MAX_FILL_POINTS, Station};
use solidcraft_geom::fill_iso::{IsoEdge, IsoFill, IsoSpec};
use solidcraft_geom::fill_matched::{MatchedFill, MatchedSpec};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::bridge::Continuity;
@@ -1030,8 +1032,10 @@ pub(crate) fn face_tolerance(body: &Body) -> f64 {
#[cfg(test)]
mod tests {
- use solidcraft_geom::brep::{self as b, eval::CurveEval, eval::SurfaceEval};
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+ use solidcore_record::brep::{self as b};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
+ use solidcraft_geom::brep::{eval::CurveEval, eval::SurfaceEval};
+ use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::boolean_record::tests::{Reach, checked};
diff --git a/crates/kernel/src/fill_general_tests.rs b/crates/kernel/src/fill_general_tests.rs
index 08e886dea9..a7716e729c 100644
--- a/crates/kernel/src/fill_general_tests.rs
+++ b/crates/kernel/src/fill_general_tests.rs
@@ -3,8 +3,10 @@
//! against the analytic surface the loop was cut from, or against a quadrature of the fitted
//! surface itself, never against the mesher alone.
-use solidcraft_geom::brep::{self as b, eval::CurveEval, eval::SurfaceEval};
-use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcore_record::brep::{self as b};
+use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcraft_geom::brep::{eval::CurveEval, eval::SurfaceEval};
+use solidcraft_geom::prelude::*;
use super::{PATCH_ANGLE_TOL_DEG, PatchReport, PatchSpec, face_tolerance, patch_edges_report};
use crate::body::Body;
@@ -35,7 +37,11 @@ impl Faces {
let [t0, t1] = r.edges[u.edge as usize].interval;
(0..64).map(move |k| {
let x = k as f64 / 64.0;
- u.pcurve.eval(if u.forward { t0 + (t1 - t0) * x } else { t1 - (t1 - t0) * x }).unwrap()
+ solidcraft_geom::brep::pcurve::eval(
+ &u.pcurve,
+ if u.forward { t0 + (t1 - t0) * x } else { t1 - (t1 - t0) * x },
+ )
+ .unwrap()
})
})
.collect(),
diff --git a/crates/kernel/src/fillet_setback_tests.rs b/crates/kernel/src/fillet_setback_tests.rs
index 37d3132705..f12b4da01c 100644
--- a/crates/kernel/src/fillet_setback_tests.rs
+++ b/crates/kernel/src/fillet_setback_tests.rs
@@ -1,4 +1,5 @@
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use crate::*;
diff --git a/crates/kernel/src/freeform.rs b/crates/kernel/src/freeform.rs
index 1f1f496b20..f608aecb74 100644
--- a/crates/kernel/src/freeform.rs
+++ b/crates/kernel/src/freeform.rs
@@ -5,8 +5,9 @@
//! cubic and higher Béziers B-splines on their own control points; conics rational quadratic
//! Béziers (exact ellipses, parabolas and hyperbolas).
-use solidcraft_geom::brep::{Curve, Curve2, Surface};
-use solidcraft_geom::{Plane, Seg2, Vec2, Vec3};
+use solidcore_record::brep::{Curve, Curve2, Surface};
+use solidcore_record::{Plane, Seg2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::{KernelError, Result};
@@ -62,7 +63,7 @@ fn net(s: &Seg2) -> Result<(Vec<Vec2>, Vec<f64>, Vec<f64>)> {
}
Seg2::Bezier { n, ref p } => {
let n = usize::from(n);
- let pts = p.get(..=n).filter(|_| (1..=solidcraft_geom::MAX_BEZIER_DEGREE).contains(&n));
+ let pts = p.get(..=n).filter(|_| (1..=solidcore_record::MAX_BEZIER_DEGREE).contains(&n));
let pts = pts.ok_or_else(|| KernelError::Invalid("Bézier degree".into()))?;
(pts.to_vec(), vec![1.0; n + 1], bezier_knots(n))
}
diff --git a/crates/kernel/src/fuzz.rs b/crates/kernel/src/fuzz.rs
index e6075cf2af..4219a2b5d6 100644
--- a/crates/kernel/src/fuzz.rs
+++ b/crates/kernel/src/fuzz.rs
@@ -3,7 +3,7 @@
//! placed on a coarse grid, so coincident faces and tangencies come up often.
use serde::Serialize;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::{Body, BoolOp, boolean, box_solid, cylinder, measure, sphere, torus};
diff --git a/crates/kernel/src/heal.rs b/crates/kernel/src/heal.rs
index 8ff27ba462..45f1f7f667 100644
--- a/crates/kernel/src/heal.rs
+++ b/crates/kernel/src/heal.rs
@@ -3,9 +3,10 @@
//! (`Brep::merge_faces`, its `SmBrep::RemoveTopologicalEdgesAndVertices`; its booleans do the
//! same at their end), keeping apart the faces split on purpose along the body's split lines.
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::Brep;
+use solidcore_record::Vec3;
+use solidcore_record::brep::Brep;
use solidcraft_geom::brep::eval::CurveEval;
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::{KernelError, Result};
diff --git a/crates/kernel/src/helix.rs b/crates/kernel/src/helix.rs
index 7667b09a4a..f774f4ce10 100644
--- a/crates/kernel/src/helix.rs
+++ b/crates/kernel/src/helix.rs
@@ -1,6 +1,8 @@
//! Helical sweeps (coils, springs) and lofts to a point (pyramids, cones).
-use solidcraft_geom::{Loop2, Mesh, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcraft_geom::Mesh;
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::{KernelError, Result};
diff --git a/crates/kernel/src/history.rs b/crates/kernel/src/history.rs
index 051ce3572a..b50d9e339b 100644
--- a/crates/kernel/src/history.rs
+++ b/crates/kernel/src/history.rs
@@ -15,20 +15,20 @@
//! history here gives its faces attachments with no attachment code of its own. An operation
//! that can't should leave its result without one (`Body::without_history`), never guess.
-pub use solidcraft_geom::brep::history::{Change, EdgeOrigin, EdgeProv, FaceOrigin, FaceProv, History, Side};
+pub use solidcore_record::brep::history::{Change, EdgeOrigin, EdgeProv, FaceOrigin, FaceProv, History, Side};
use crate::body::{Body, FaceSource};
use crate::{KernelError, Result};
-use solidcraft_geom::brep::{Brep, part::Part};
+use solidcore_record::brep::{Brep, part::Part};
-impl From<solidcraft_geom::brep::history::Failed> for KernelError {
- fn from(e: solidcraft_geom::brep::history::Failed) -> KernelError {
+impl From<solidcore_record::brep::history::Failed> for KernelError {
+ fn from(e: solidcore_record::brep::history::Failed) -> KernelError {
KernelError::Failed(e.to_string())
}
}
/// What a [`History`] needs a kernel body for: the history types belong to
-/// `solidcraft_geom::brep::history`, so a backend can report them without this crate.
+/// `solidcore_record::brep::history`, so a backend can report them without this crate.
pub trait BodyHistory {
/// The history of an operation that keeps every face and edge of its one operand in place
/// (a rigid move, a rebuild that keeps the topology's order).
diff --git a/crates/kernel/src/history_tests.rs b/crates/kernel/src/history_tests.rs
index a989e8e07c..398da9c065 100644
--- a/crates/kernel/src/history_tests.rs
+++ b/crates/kernel/src/history_tests.rs
@@ -1,4 +1,5 @@
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use super::{Change, EdgeOrigin, EdgeProv, FaceOrigin, FaceProv, History, Side};
use crate::history::BodyHistory;
@@ -250,7 +251,7 @@ fn face_sources_follow_kept_split_and_agreeing_merged_faces() {
/// side face over both pieces, not two coplanar faces with an edge between them (#1788).
#[test]
fn collinear_profile_lines_extrude_into_one_side_face() {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
let pts = [(0.0, 0.0), (10.0, 0.0), (20.0, 0.0), (20.0, 10.0), (0.0, 10.0)].map(|(x, y)| Vec2::new(x, y));
let region = Region2 { outer: Loop2::polygon(&pts), holes: vec![] };
// Plain `extrude` keeps a face per segment (sheet metal's flat pattern relies on it).
@@ -283,7 +284,7 @@ fn collinear_profile_lines_extrude_into_one_side_face() {
/// (#1788): one sloped face generated by both pieces, and the same solid as a side in one piece.
#[test]
fn collinear_profile_lines_taper_into_one_side_face() {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
let polygon =
|pts: &[(f64, f64)]| Region2 { outer: Loop2::polygon(&pts.iter().map(|&(x, y)| Vec2::new(x, y)).collect::<Vec<_>>()), holes: vec![] };
let split = polygon(&[(0.0, 0.0), (10.0, 0.0), (20.0, 0.0), (20.0, 10.0), (0.0, 10.0)]);
diff --git a/crates/kernel/src/iges_in/tests.rs b/crates/kernel/src/iges_in/tests.rs
index 35decbef8f..1d181b0fda 100644
--- a/crates/kernel/src/iges_in/tests.rs
+++ b/crates/kernel/src/iges_in/tests.rs
@@ -1,6 +1,7 @@
use super::*;
use crate::{Body, BoolOp, ExportBody, StepHeader, boolean, box_solid, cylinder, fillet, iges_export_bodies, measure, sphere, torus};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
fn rel(a: f64, b: f64) -> f64 {
(a - b).abs() / b.abs().max(1e-9)
@@ -413,7 +414,7 @@ fn trim_pieces_that_miss_their_corner_are_closed_onto_it() {
fn a_drill_point_round_trips_through_iges() {
// A blind hole with a cone tip: the tip's face closes at its apex (its seam runs out to the
// apex and straight back).
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
let plate = box_solid(Vec3::new(-20.0, -15.0, 0.0), Vec3::new(20.0, 15.0, 10.0)).unwrap();
let profile =
Region2 { outer: Loop2::polygon(&[Vec2::new(0.0, 2.0), Vec2::new(4.0, 5.0), Vec2::new(4.0, 11.0), Vec2::new(0.0, 11.0)]), holes: vec![] };
diff --git a/crates/kernel/src/iges_out.rs b/crates/kernel/src/iges_out.rs
index 90fac84f8c..a537685128 100644
--- a/crates/kernel/src/iges_out.rs
+++ b/crates/kernel/src/iges_out.rs
@@ -9,7 +9,7 @@
use std::collections::HashMap;
use std::fmt::Write as _;
-use solidcraft_geom::brep::{Brep, Loop, Shell};
+use solidcore_record::brep::{Brep, Loop, Shell};
use solidcraft_step::geom::{Curve, Placement, Surface};
use solidcraft_step::write::topology;
diff --git a/crates/kernel/src/intersection.rs b/crates/kernel/src/intersection.rs
index fe5af4a989..4cb74586e1 100644
--- a/crates/kernel/src/intersection.rs
+++ b/crates/kernel/src/intersection.rs
@@ -5,8 +5,8 @@
//! tolerance, or the line, circle or ellipse it is) on its interval. Which edges are new comes from
//! the imprint's own history: an edge no edge of either operand became.
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::Curve;
+use solidcore_record::Vec3;
+use solidcore_record::brep::Curve;
use crate::body::{Body, MeshTolerance};
use crate::{KernelError, Result};
diff --git a/crates/kernel/src/intersection_curve_tests.rs b/crates/kernel/src/intersection_curve_tests.rs
index 6d17f2e80b..9ee9c851eb 100644
--- a/crates/kernel/src/intersection_curve_tests.rs
+++ b/crates/kernel/src/intersection_curve_tests.rs
@@ -1,7 +1,7 @@
//! A face whose edge is an intersection curve that does not evaluate (#1252): meshing it neither
//! panics nor gives non-finite points.
-use solidcraft_geom::brep::{self as b, Curve, Curve2, Surface};
+use solidcore_record::brep::{self as b, Curve, Curve2, Surface};
/// A plane at height `z` with its parameters along x and y.
fn plane(z: f64) -> Surface {
diff --git a/crates/kernel/src/iso.rs b/crates/kernel/src/iso.rs
index cb82704d16..820a5cfb32 100644
--- a/crates/kernel/src/iso.rs
+++ b/crates/kernel/src/iso.rs
@@ -10,9 +10,10 @@
//! box's side, where the outer loop's polygon closes. Every iso line of a closed surface is
//! therefore one line across the box, cut where it crosses the loops.
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep;
+use solidcore_record::Vec3;
+use solidcore_record::brep;
use solidcraft_geom::brep::eval::SurfaceEval;
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::point_path::{MAX_CURVE_POINTS, curve_path};
@@ -129,13 +130,13 @@ impl<'a> FaceTrims<'a> {
let (mut x, mut y) = (ta, tb);
for _ in 0..80 {
let m = 0.5 * (x + y);
- match c.eval(m).map(across) {
+ match solidcraft_geom::brep::pcurve::eval(c, m).map(across) {
Some(k) if (k < 0.0) == (ka < 0.0) => x = m,
Some(_) => y = m,
None => break,
}
}
- if let Some(t) = c.eval(0.5 * (x + y)).map(along).filter(|t| *t > lo && *t < hi) {
+ if let Some(t) = solidcraft_geom::brep::pcurve::eval(c, 0.5 * (x + y)).map(along).filter(|t| *t > lo && *t < hi) {
cuts.push(t);
}
}
@@ -260,7 +261,7 @@ fn pcurve_samples(c: &brep::Curve2) -> Vec<(f64, [f64; 2])> {
(0..=n)
.filter_map(|i| {
let t = a + (b - a) * i as f64 / n as f64;
- c.eval(t).map(|q| (t, q))
+ solidcraft_geom::brep::pcurve::eval(c, t).map(|q| (t, q))
})
.collect()
}
@@ -280,7 +281,7 @@ fn crosses_right(q: [f64; 2], l: &[[f64; 2]]) -> bool {
/// The iso curve of `surface` at `fixed` (the other parameter) as a record curve on `[a, b]` of
/// its own parameter: the surface's own line or circle, or its B-spline row.
fn iso_record(surface: &brep::Surface, along_u: bool, fixed: f64, (a, b): (f64, f64)) -> Result<(brep::Curve, [f64; 2])> {
- use solidcraft_geom::brep::{Curve, Frame, Surface};
+ use solidcore_record::brep::{Curve, Frame, Surface};
let v = |q: [f64; 3]| Vec3::new(q[0], q[1], q[2]);
let d = |q: Vec3| [q.x, q.y, q.z];
let line = |p: Vec3, q: Vec3| (Curve::Line { start: d(p), end: d(q) }, [0.0, 1.0]);
diff --git a/crates/kernel/src/issue_1038_tests.rs b/crates/kernel/src/issue_1038_tests.rs
index 5f944df39f..71e1630a56 100644
--- a/crates/kernel/src/issue_1038_tests.rs
+++ b/crates/kernel/src/issue_1038_tests.rs
@@ -1,8 +1,9 @@
//! #1038: a small hole on a large curved face cuts cleanly, its rim on the face an intersection
//! edge.
-use solidcraft_geom::brep::Curve;
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::brep::Curve;
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::{Body, BoolOp, build::extrude, cylinder, ops::boolean};
diff --git a/crates/kernel/src/issue_1080_tests.rs b/crates/kernel/src/issue_1080_tests.rs
index 290e07ae71..9b3c3fc762 100644
--- a/crates/kernel/src/issue_1080_tests.rs
+++ b/crates/kernel/src/issue_1080_tests.rs
@@ -5,7 +5,7 @@
//! large, and the largest size that fits is found by searching ([`crate::fillet_max`],
//! [`crate::chamfer_max`]).
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::{Body, BoolOp, ChamferSide, KernelError, build::box_solid, ops::boolean};
diff --git a/crates/kernel/src/issue_1510_tests.rs b/crates/kernel/src/issue_1510_tests.rs
index 9d0b6ee147..a908d647b5 100644
--- a/crates/kernel/src/issue_1510_tests.rs
+++ b/crates/kernel/src/issue_1510_tests.rs
@@ -1,7 +1,8 @@
//! #1510: a body split by a plane that a face of the body lies in: the parts meet in the plane
//! and together are the body.
-use solidcraft_geom::{Plane, Vec3};
+use solidcore_record::{Plane, Vec3};
+use solidcraft_geom::prelude::*;
use crate::{Body, BoolOp, build::box_solid, build::cylinder, ops::boolean, ops::split_by_plane};
@@ -52,13 +53,13 @@ fn a_split_in_the_plane_of_a_face_keeps_all_of_the_body() {
fn a_face_only_nearly_in_the_plane_is_not_moved() {
let x = Vec3::new(700.0, 0.0, 0.03).normalized().unwrap();
let bottom = Plane::new(Vec3::ZERO, x, Vec3::Y).unwrap();
- let outer = solidcraft_geom::Loop2::polygon(&[
- solidcraft_geom::Vec2::new(0.0, 0.0),
- solidcraft_geom::Vec2::new(Vec3::new(700.0, 0.0, 0.03).len(), 0.0),
- solidcraft_geom::Vec2::new(Vec3::new(700.0, 0.0, 0.03).len(), 100.0),
- solidcraft_geom::Vec2::new(0.0, 100.0),
+ let outer = solidcore_record::Loop2::polygon(&[
+ solidcore_record::Vec2::new(0.0, 0.0),
+ solidcore_record::Vec2::new(Vec3::new(700.0, 0.0, 0.03).len(), 0.0),
+ solidcore_record::Vec2::new(Vec3::new(700.0, 0.0, 0.03).len(), 100.0),
+ solidcore_record::Vec2::new(0.0, 100.0),
]);
- let b = crate::extrude(&bottom, &[solidcraft_geom::Region2 { outer, holes: vec![] }], 0.0, 10.0).unwrap().pop().unwrap();
+ let b = crate::extrude(&bottom, &[solidcore_record::Region2 { outer, holes: vec![] }], 0.0, 10.0).unwrap().pop().unwrap();
let plane = Plane::from_normal(Vec3::ZERO, Vec3::Z).unwrap();
let v0 = b.volume_at(1e-2).unwrap();
let up = crate::ops::half_space(&b, &plane, true).unwrap().0.unwrap();
diff --git a/crates/kernel/src/issue_2005_tests.rs b/crates/kernel/src/issue_2005_tests.rs
index 98c67eda9d..2db4e70366 100644
--- a/crates/kernel/src/issue_2005_tests.rs
+++ b/crates/kernel/src/issue_2005_tests.rs
@@ -5,7 +5,7 @@
use std::f64::consts::{FRAC_PI_2, PI, TAU};
-use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
use crate::{Body, BoolOp, PathSeg, SweepControl, boolean, measure, sweep_with};
diff --git a/crates/kernel/src/issue_616_tests.rs b/crates/kernel/src/issue_616_tests.rs
index 866dfee3ce..ec7a118b45 100644
--- a/crates/kernel/src/issue_616_tests.rs
+++ b/crates/kernel/src/issue_616_tests.rs
@@ -1,7 +1,9 @@
//! Issue #616: small boxes joined flush to the walls and floor of a part never change it away
//! from the box, and a retry that would is refused.
-use solidcraft_geom::{Aabb3, Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
+use solidcraft_geom::{Aabb3, Mesh};
use crate::*;
diff --git a/crates/kernel/src/issue_674_tests.rs b/crates/kernel/src/issue_674_tests.rs
index c6db48fe17..7f9a423ff7 100644
--- a/crates/kernel/src/issue_674_tests.rs
+++ b/crates/kernel/src/issue_674_tests.rs
@@ -1,6 +1,7 @@
//! Partial planar contact must sew a solid without displacing or inventing material.
use crate::*;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
#[test]
@@ -12,7 +13,7 @@ fn split_contact_arc_crossing_one_edge_twice_preserves_the_body() {
.record()
.faces
.iter()
- .position(|f| !matches!(f.surface, solidcraft_geom::brep::Surface::Plane { .. } | solidcraft_geom::brep::Surface::PlaneThrough { .. }))
+ .position(|f| !matches!(f.surface, solidcore_record::brep::Surface::Plane { .. } | solidcore_record::brep::Surface::PlaneThrough { .. }))
.unwrap();
let r = split_faces(&a, &[face], &SplitTool::Face { body: &b, face: side }).unwrap();
assert_eq!(r.face_count(), a.face_count() + 1);
@@ -27,7 +28,7 @@ fn split_contact_arc_crossing_one_edge_twice_preserves_the_body() {
fn partial_contact_retains_an_authored_split_away_from_the_contact() {
let a = box_solid(Vec3::ZERO, Vec3::new(25.0, 47.5, 37.5)).unwrap();
let face = a.faces(0.01).unwrap().iter().position(|f| f.plane_normal.is_some_and(|n| n.dot(Vec3::X) > 0.99)).unwrap();
- let a = split_faces(&a, &[face], &SplitTool::Plane(solidcraft_geom::Plane { origin: Vec3::new(0.0, 0.0, 15.0), ..solidcraft_geom::Plane::XY }))
+ let a = split_faces(&a, &[face], &SplitTool::Plane(solidcore_record::Plane { origin: Vec3::new(0.0, 0.0, 15.0), ..solidcore_record::Plane::XY }))
.unwrap();
let b = cylinder(Vec3::new(0.0, 7.5, 0.0), -Vec3::X, 5.0, 2.5).unwrap();
let r = boolean(&a, &b, BoolOp::Union).unwrap().unwrap();
diff --git a/crates/kernel/src/issue_679_tests.rs b/crates/kernel/src/issue_679_tests.rs
index 81ea537578..a1dc7bd8ed 100644
--- a/crates/kernel/src/issue_679_tests.rs
+++ b/crates/kernel/src/issue_679_tests.rs
@@ -2,7 +2,7 @@
//! grid extruded up and down (#679), a pad half past the edge of the face it stands on (#674),
//! several contact regions, contact beside a shared edge, and random rectangles.
-use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
use crate::*;
diff --git a/crates/kernel/src/issue_788_tests.rs b/crates/kernel/src/issue_788_tests.rs
index cdc5cbb41c..7a3d5ab528 100644
--- a/crates/kernel/src/issue_788_tests.rs
+++ b/crates/kernel/src/issue_788_tests.rs
@@ -2,7 +2,7 @@
//! of the crossing meet, which a mesh intersection cannot trace and a boolean cannot take in the
//! middle of a face.
use crate::*;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use std::f64::consts::PI;
const SIDE: f64 = 45.0;
diff --git a/crates/kernel/src/issue_851_tests.rs b/crates/kernel/src/issue_851_tests.rs
index 44a83a481b..8190730b58 100644
--- a/crates/kernel/src/issue_851_tests.rs
+++ b/crates/kernel/src/issue_851_tests.rs
@@ -1,6 +1,6 @@
//! Fillets and chamfers where a curved wall runs out into a flat face in a knife edge (#851).
use crate::*;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use std::f64::consts::PI;
const R_WALL: f64 = 21.0;
diff --git a/crates/kernel/src/issue_871_tests.rs b/crates/kernel/src/issue_871_tests.rs
index 8695a15835..ba65f4bd94 100644
--- a/crates/kernel/src/issue_871_tests.rs
+++ b/crates/kernel/src/issue_871_tests.rs
@@ -1,6 +1,6 @@
//! #871: a fillet that opened holes in the model must be refused, not accepted.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::{Body, BoolOp, build::box_solid, ops::boolean};
diff --git a/crates/kernel/src/join_between_caps_tests.rs b/crates/kernel/src/join_between_caps_tests.rs
index ed21d42a55..810441ff86 100644
--- a/crates/kernel/src/join_between_caps_tests.rs
+++ b/crates/kernel/src/join_between_caps_tests.rs
@@ -7,7 +7,7 @@
use std::f64::consts::PI;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::*;
diff --git a/crates/kernel/src/lib.rs b/crates/kernel/src/lib.rs
index 5921862d2e..54a83b3c57 100644
--- a/crates/kernel/src/lib.rs
+++ b/crates/kernel/src/lib.rs
@@ -279,7 +279,7 @@ impl Cause for str {}
impl Cause for String {}
impl Cause for solidcraft_smlib::CheckReport {}
impl Cause for solidcraft_smlib::export::ExportError {}
-impl Cause for solidcraft_geom::brep::history::Failed {}
+impl Cause for solidcore_record::brep::history::Failed {}
impl Cause for solidcraft_geom::brep::pcurve::Error {}
impl<T: Cause + ?Sized> Cause for &T {
fn panic(&self) -> Option<&str> {
diff --git a/crates/kernel/src/lip.rs b/crates/kernel/src/lip.rs
index f3df8e7b66..80feb20451 100644
--- a/crates/kernel/src/lip.rs
+++ b/crates/kernel/src/lip.rs
@@ -3,8 +3,10 @@
//! directly on the body's schema 4 record (the band's walls continue the walls below, which a
//! boolean union can't join: their faces would coincide).
-use solidcraft_geom::brep::{Brep, Curve, Frame, Surface};
-use solidcraft_geom::{Loop2, Plane, Region2, Ring, Seg2, Vec3};
+use solidcore_record::brep::{Brep, Curve, Frame, Surface};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec3};
+use solidcraft_geom::Ring;
+use solidcraft_geom::prelude::*;
use crate::assemble::{AFace, AUse, Assembly};
use crate::body::Body;
@@ -150,7 +152,7 @@ fn pieces(asm: &Assembly, lp: &[AUse], n: Vec3) -> Result<Vec<Piece>> {
let (s, t) = asm.ends(u).ok_or_else(|| fail("edge"))?;
let (a, b) = (asm.point(s).ok_or_else(|| fail("vertex"))?, asm.point(t).ok_or_else(|| fail("vertex"))?);
// The arc's angles, on the circle itself (its NURBS form, if any, is parameterised otherwise).
- let [t0, t1] = solidcraft_geom::brep::curve_interval(&e.curve, e.nurbs.as_ref(), e.interval).ok_or_else(|| fail("edge"))?;
+ let [t0, t1] = solidcraft_geom::brep::label::curve_interval(&e.curve, e.nurbs.as_ref(), e.interval).ok_or_else(|| fail("edge"))?;
match &e.curve {
Curve::Line { .. } => Ok(Piece { a, b, arc: None }),
Curve::Circle { frame, .. } => {
diff --git a/crates/kernel/src/loft_blend.rs b/crates/kernel/src/loft_blend.rs
index 3c1899dbfc..6e5c1bf19c 100644
--- a/crates/kernel/src/loft_blend.rs
+++ b/crates/kernel/src/loft_blend.rs
@@ -40,9 +40,10 @@
//! to 3 fuller, down to −0.9 flatter), exactly as a bridge's crown does. It shapes the middle of
//! each end span and leaves every joint's conditions alone.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_geom::brep::eval::SurfaceEval;
use solidcraft_geom::bspline::{CurveN, HPoint, MAX_SPLINE_DEGREE, NurbsSurface};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::bridge::{Continuity, Frame};
diff --git a/crates/kernel/src/loft_rails.rs b/crates/kernel/src/loft_rails.rs
index 15fa73a7a4..b0ffbfb963 100644
--- a/crates/kernel/src/loft_rails.rs
+++ b/crates/kernel/src/loft_rails.rs
@@ -12,8 +12,9 @@
//! Sections are exact NURBS curves ([`Section`], from the sketch segments' record curves); a
//! station is the plain loft's control points moved by an affine map, so each is exact too.
+use solidcore_record::{Plane, Seg2, Vec3};
use solidcraft_geom::bspline::CurveN;
-use solidcraft_geom::{Plane, Seg2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::sweep_path::RailFit;
use crate::{KernelError, Result};
@@ -42,8 +43,8 @@ impl Section {
}
/// A record line or (rational) B-spline as a homogeneous NURBS curve.
-fn nurbs(c: &solidcraft_geom::brep::Curve) -> Result<CurveN<4>> {
- use solidcraft_geom::brep::Curve;
+fn nurbs(c: &solidcore_record::brep::Curve) -> Result<CurveN<4>> {
+ use solidcore_record::brep::Curve;
let degree = |knots: &[f64], n: usize| knots.len().checked_sub(n + 1).ok_or_else(|| KernelError::Invalid("spline degree".into()));
Ok(match c {
Curve::Line { start, end } => {
diff --git a/crates/kernel/src/loft_rails_tests.rs b/crates/kernel/src/loft_rails_tests.rs
index a978100eb8..d4c206aa8e 100644
--- a/crates/kernel/src/loft_rails_tests.rs
+++ b/crates/kernel/src/loft_rails_tests.rs
@@ -5,9 +5,10 @@
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
+use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
-use solidcraft_geom::{Loop2, Plane, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Seg2, Vec2, Vec3};
use crate::{KernelError, RailFit, loft, loft_sheet_with_rails, loft_with_rails, measure};
diff --git a/crates/kernel/src/loft_region_tests.rs b/crates/kernel/src/loft_region_tests.rs
index e20400c4ee..02e9b7b8a6 100644
--- a/crates/kernel/src/loft_region_tests.rs
+++ b/crates/kernel/src/loft_region_tests.rs
@@ -1,8 +1,9 @@
//! Analytic regressions for lofted passages (#2435).
+use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
-use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
use crate::{Body, loft_regions, measure, step_export, step_import};
@@ -90,7 +91,7 @@ fn loft_regions_bound_segments_after_matching() {
// would exceed it in every section. Refuse before allocating the topology.
let circle = |x, n| Loop2 {
segs: (0..n)
- .map(|i| solidcraft_geom::Seg2::Arc {
+ .map(|i| solidcore_record::Seg2::Arc {
center: Vec2::new(x, 0.0),
radius: 1.0,
start: i as f64 * std::f64::consts::TAU / n as f64,
diff --git a/crates/kernel/src/matchsurf.rs b/crates/kernel/src/matchsurf.rs
index f1ad7af3df..dbdee8a935 100644
--- a/crates/kernel/src/matchsurf.rs
+++ b/crates/kernel/src/matchsurf.rs
@@ -16,8 +16,10 @@
//! of the target meet, with shapes that part company, is a seam the target itself does not hold
//! beyond that order, and no surface can be told to carry a condition the target has not got.
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::{self as b, eval::CurveEval, eval::SurfaceEval};
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self as b};
+use solidcraft_geom::brep::{eval::CurveEval, eval::SurfaceEval};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::bridge::{self, Continuity, Frame};
diff --git a/crates/kernel/src/matchsurf_tests.rs b/crates/kernel/src/matchsurf_tests.rs
index 9699b80244..1d55e1de35 100644
--- a/crates/kernel/src/matchsurf_tests.rs
+++ b/crates/kernel/src/matchsurf_tests.rs
@@ -6,7 +6,7 @@ use super::*;
use crate::bridge::{Continuity, Frame};
use crate::build::SEAM_ANGLE;
use crate::{cylinder, stitch};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
/// The radius of the cylinder a sheet is matched to, the radius the sheet starts at, its height,
/// and how far round the cylinder the sheet runs.
diff --git a/crates/kernel/src/measure.rs b/crates/kernel/src/measure.rs
index cad99b239b..233aca3a1e 100644
--- a/crates/kernel/src/measure.rs
+++ b/crates/kernel/src/measure.rs
@@ -1,5 +1,6 @@
use serde::Serialize;
-use solidcraft_geom::{Aabb3, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Aabb3;
use crate::Result;
use crate::body::Body;
@@ -112,6 +113,7 @@ pub fn measure_mass(b: &Body) -> Result<MassMeasure> {
mod tests {
use super::*;
use crate::{BoolOp, boolean, cylinder, torus};
+ use solidcraft_geom::prelude::*;
/// The mass properties alone are [`measure`]'s, to the bit; and on a curved intersection
/// they are the textbook ones.
@@ -139,7 +141,7 @@ mod tests {
// A body's measured volume does not depend on where it sits: the same revolved ring of cones
// and cylinders, moved far from the origin, measures what it measures at the origin.
use crate::{revolve, transform};
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
use std::f64::consts::{PI, TAU};
/// Ring cross-section in (radius, height): cones top and bottom, cylinders inside and out.
diff --git a/crates/kernel/src/mesh_convert.rs b/crates/kernel/src/mesh_convert.rs
index 7d6545c604..862bdb2701 100644
--- a/crates/kernel/src/mesh_convert.rs
+++ b/crates/kernel/src/mesh_convert.rs
@@ -1,9 +1,10 @@
//! Conservative reconstruction of constant-section mechanical mesh parts.
//! Geometry is inferred from closed, manifold input, never from a display mesh.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
-use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
use crate::{Body, KernelError, Result};
@@ -260,7 +261,7 @@ fn extrusion(mesh: &crate::meshbody::TriMesh, axis: Vec3, tolerance: f64) -> Res
}
let p = plane.to_local(*p);
if !boundary_segments.iter().any(|&(a, b)| {
- solidcraft_geom::Seg2::Line { a, b }.point_at(solidcraft_geom::Seg2::Line { a, b }.closest_param(p)).dist(p) <= epsilon * 3.
+ solidcore_record::Seg2::Line { a, b }.point_at(solidcore_record::Seg2::Line { a, b }.closest_param(p)).dist(p) <= epsilon * 3.
}) {
return Ok(None);
}
@@ -411,7 +412,7 @@ fn fit_loop(points: &[Vec2], tolerance: f64, epsilon: f64) -> Loop2 {
}
let remove = (0..n).find(|&i| {
let (Some(a), Some(b), Some(c)) = (points.get((i + n - 1) % n), points.get(i), points.get((i + 1) % n)) else { return false };
- let edge = solidcraft_geom::Seg2::Line { a: *a, b: *c };
+ let edge = solidcore_record::Seg2::Line { a: *a, b: *c };
edge.point_at(edge.closest_param(*b)).dist(*b) <= linear_tolerance
});
let Some(index) = remove else { break };
@@ -483,7 +484,7 @@ mod tests {
/// The loop is the exact circle: one full turn of an arc round `center` at `radius`.
fn assert_exact_circle(fitted: &Loop2, center: Vec2, radius: f64) {
- let [solidcraft_geom::Seg2::Arc { center: c, radius: r, sweep, .. }] = fitted.segs.as_slice() else { panic!("not one arc: {fitted:?}") };
+ let [solidcore_record::Seg2::Arc { center: c, radius: r, sweep, .. }] = fitted.segs.as_slice() else { panic!("not one arc: {fitted:?}") };
assert!(c.dist(center) < 1e-9 && (r - radius).abs() < 1e-9, "centre {c:?}, radius {r}");
assert!((sweep.abs() - std::f64::consts::TAU).abs() < 1e-9, "sweep {sweep}");
}
diff --git a/crates/kernel/src/meshbody.rs b/crates/kernel/src/meshbody.rs
index 5a6b57a555..f6bfae1c6a 100644
--- a/crates/kernel/src/meshbody.rs
+++ b/crates/kernel/src/meshbody.rs
@@ -1,9 +1,11 @@
//! Mesh bodies: triangles without a B-rep (imported 3MF/STL). They render, measure, move and
//! export; B-rep features refuse them.
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
-use solidcraft_geom::{Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Mesh;
use crate::body::Body;
use crate::{KernelError, Result};
diff --git a/crates/kernel/src/modify_history_tests.rs b/crates/kernel/src/modify_history_tests.rs
index 4f5e6144ff..883da77274 100644
--- a/crates/kernel/src/modify_history_tests.rs
+++ b/crates/kernel/src/modify_history_tests.rs
@@ -2,7 +2,8 @@
//! face and edge origin checked against the geometry of the operands (in tests only: the history
//! itself is recorded, never sampled), and the exact origins asserted where the outcome is known.
-use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::boolean_record::tests::{self, Reach, changes, to_edge, to_face};
diff --git a/crates/kernel/src/native.rs b/crates/kernel/src/native.rs
index 6856a52061..5409ee0aac 100644
--- a/crates/kernel/src/native.rs
+++ b/crates/kernel/src/native.rs
@@ -1,45 +1,19 @@
//! SolidCraft native, versioned binary geometry. No STEP conversion or display meshes.
//! Exact: a decoded body is the encoded one, number for number, for the same producer.
use crate::{Body, KernelError, Result, guard};
-use serde::{Deserialize, Serialize};
-use serde_json::{Map, Number, Value};
+use solidcore_record::native::{self as file, Runtime, Saved};
-mod binary;
mod metadata;
mod preview;
pub use preview::native_preview_mesh;
-// 01/02 were development-only prototypes; independent metadata records start at 03; 04 stores
-// procedural intersections and placed revolutions exactly, and the measured runtime values; 05
-// nests geometry schema 4 (regions, unbounded geometry, pcurves, canonical order).
-const MAGIC: &[u8; 8] = b"SCBREP05";
-// A body's own limits. A design's cache holds many bodies within the container's budgets, and
-// decoding is linear in the bytes, so one large part (an imported casting) fits.
-const MAX_BYTES: usize = 256 << 20;
-const MAX_ITEMS: usize = 1_000_000;
-const MAX_VALUES: usize = 20_000_000;
-
-#[derive(Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-struct SavedBody {
- solid: solidcraft_geom::brep::Brep,
- metadata: solidcraft_geom::brep::envelope::Metadata,
- runtime: Runtime,
-}
-
-/// What a body measured about itself that later operations read: kept so a decoded body works
-/// to the same tolerances as the one encoded, without measuring again.
-#[derive(Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-struct Runtime {
- /// [`Body::size`] as stored (0: not measured).
- size: f64,
- /// Saved by earlier versions (an orientation mesh's missing-face count); read and ignored.
- coarse_missing: Option<(f64, u64)>,
-}
fn invalid(detail: impl std::fmt::Display) -> KernelError {
KernelError::Invalid(format!("native B-rep: {detail}"))
}
+/// A refusal of the native file (its own message, "native B-rep: ...").
+fn refused(e: file::Error) -> KernelError {
+ KernelError::Invalid(e.to_string())
+}
/// Explicit topology, spatial geometry, construction certificates and history, exactly: the
/// body's own record and what it carries. Failure is a cache miss at the IO boundary, never a
@@ -61,22 +35,20 @@ pub fn encode_native_body(body: &Body) -> Result<Vec<u8>> {
if body.mesh.is_some() {
return Err(invalid("mesh bodies are source blobs, not B-rep"));
}
- if body.face_count() > MAX_ITEMS || body.edge_count() > MAX_ITEMS {
+ if body.face_count() > file::MAX_ITEMS || body.edge_count() > file::MAX_ITEMS {
return Err(invalid("native geometry budget"));
}
let runtime = Runtime { size: body.size, coarse_missing: None };
- let saved = SavedBody { solid: body.record().clone(), metadata: metadata::encode(body)?, runtime };
- // Structural validation does not invoke another geometric reconstruction.
- validate_topology(&saved)?;
- let mut out = MAGIC.to_vec();
- binary::write_serialized(&saved, &mut out)?;
- Ok(out)
+ let saved = Saved { solid: body.record().clone(), metadata: metadata::encode(body)?, runtime };
+ // The record's own checks: no geometric reconstruction.
+ check(&saved)?;
+ file::encode(&saved).map_err(refused)
})
}
/// The schema 4 record of a solid body, in canonical order with its pcurves: the body itself.
/// Mesh bodies have none.
-pub fn brep_record(body: &Body) -> Result<solidcraft_geom::brep::Brep> {
+pub fn brep_record(body: &Body) -> Result<solidcore_record::brep::Brep> {
let _span = solidcraft_profile::span("kernel", "brep_record");
if body.mesh.is_some() {
return Err(invalid("mesh bodies are source blobs, not B-rep"));
@@ -94,23 +66,10 @@ pub fn smlib_body(body: &Body) -> Result<solidcraft_smlib::Brep> {
/// Only a caller that has checked who produced the data may treat it as evaluated geometry.
pub fn decode_native_body(bytes: &[u8]) -> Result<Body> {
let _span = solidcraft_profile::span("kernel", "decode_native_body");
- if bytes.len() > MAX_BYTES || bytes.get(..8) != Some(MAGIC.as_slice()) {
- return Err(invalid("version or size"));
- }
guard("decode native B-rep", || {
- let mut input = bytes.get(8..).ok_or_else(|| invalid("header"))?;
- let mut remaining = MAX_VALUES;
- let value = binary::read(&mut input, 0, &mut remaining)?;
- if !input.is_empty() {
- return Err(invalid("trailing data"));
- }
- validate_value(&value, 0)?;
- let saved: SavedBody = serde_json::from_value(value).map_err(invalid)?;
- validate_topology(&saved)?;
- let Runtime { size, .. } = saved.runtime;
- if !(size.is_finite() && size >= 0.0) {
- return Err(invalid("runtime values"));
- }
+ let saved = file::decode(bytes).map_err(refused)?;
+ check(&saved)?;
+ let size = saved.runtime.size;
let mut body = Body::from_record(saved.solid)?;
if size > 0.0 {
body.size = size;
@@ -146,7 +105,7 @@ pub(crate) fn smlib_body_ordered(body: &Body) -> Result<(solidcraft_smlib::Brep,
/// `record` in SMLib, imported as given (SMLib's own form; a record it refuses is an error that
/// names why), with where each of SMLib's faces and edges is in the record's order.
pub(crate) fn smlib_record_ordered(
- record: &solidcraft_geom::brep::Brep,
+ record: &solidcore_record::brep::Brep,
) -> Result<(solidcraft_smlib::Brep, Option<solidcraft_smlib::history::Order>)> {
let _span = solidcraft_profile::span("kernel", "smlib_record_ordered");
let brep = solidcraft_smlib::Brep::from_record(record, true).map_err(|e| KernelError::smlib("SMLib", e))?;
@@ -163,7 +122,7 @@ pub(crate) fn smlib_record_ordered(
/// SMLib's faces and edges in the record's order, and canonical order can list them otherwise,
/// a tube's seam edges among them): the export put back in SMLib's order then numbers them as
/// `record` does, and SMLib's face and edge `i` are the record's `i`.
-fn numbering(record: &solidcraft_geom::brep::Brep, brep: &solidcraft_smlib::Brep) -> Option<solidcraft_smlib::history::Order> {
+fn numbering(record: &solidcore_record::brep::Brep, brep: &solidcraft_smlib::Brep) -> Option<solidcraft_smlib::history::Order> {
match brep.to_native_ordered() {
Ok((back, order)) => {
if same_numbering(record, &back) {
@@ -183,8 +142,8 @@ fn numbering(record: &solidcraft_geom::brep::Brep, brep: &solidcraft_smlib::Brep
/// SMLib's face and edge `i` are in `back`), each loop naming its edges by SMLib's numbers.
/// `None` where `order` is not a renumbering of `back`'s faces and edges (an edge split into
/// pieces where solids touch along it is more than one record edge).
-fn in_smlib_order(back: &solidcraft_geom::brep::Brep, order: &solidcraft_smlib::history::Order) -> Option<solidcraft_geom::brep::Brep> {
- use solidcraft_geom::brep::Loop;
+fn in_smlib_order(back: &solidcore_record::brep::Brep, order: &solidcraft_smlib::history::Order) -> Option<solidcore_record::brep::Brep> {
+ use solidcore_record::brep::Loop;
let permutation = |to: &[usize], n: usize| -> Option<Vec<usize>> {
if to.is_empty() {
return Some((0..n).collect());
@@ -225,8 +184,8 @@ fn in_smlib_order(back: &solidcraft_geom::brep::Brep, order: &solidcraft_smlib::
/// Whether two records of one body number its faces, edges and vertices alike: the same loops of
/// the same edges, the same edge ends, and each vertex where the other's is.
-fn same_numbering(a: &solidcraft_geom::brep::Brep, b: &solidcraft_geom::brep::Brep) -> bool {
- use solidcraft_geom::brep::Loop;
+fn same_numbering(a: &solidcore_record::brep::Brep, b: &solidcore_record::brep::Brep) -> bool {
+ use solidcore_record::brep::Loop;
if a.faces.len() != b.faces.len() || a.edges.len() != b.edges.len() || a.vertices.len() != b.vertices.len() {
return false;
}
@@ -250,7 +209,7 @@ fn same_numbering(a: &solidcraft_geom::brep::Brep, b: &solidcraft_geom::brep::Br
/// opposite order with each edge the other way round. SMLib walks a face whose surface it turned
/// (a hole's wall) the other way, starting where it likes; its faces and edges are numbered
/// alike all the same.
-fn same_cycle(x: &[solidcraft_geom::brep::OrientedEdge], y: &[solidcraft_geom::brep::OrientedEdge]) -> bool {
+fn same_cycle(x: &[solidcore_record::brep::OrientedEdge], y: &[solidcore_record::brep::OrientedEdge]) -> bool {
let n = x.len();
if n != y.len() {
return false;
@@ -264,72 +223,16 @@ fn same_cycle(x: &[solidcraft_geom::brep::OrientedEdge], y: &[solidcraft_geom::b
})
}
-fn validate_topology(saved: &SavedBody) -> Result<()> {
- saved.solid.validate().map_err(invalid)?;
- let (faces, edges) = (saved.solid.faces.len(), saved.solid.edges.len());
- let saved = &saved.metadata;
- if saved.version != solidcraft_geom::brep::envelope::VERSION {
- return Err(invalid("metadata version"));
- }
- if saved.face_sources.as_ref().is_some_and(|s| s.len() != faces) {
- return Err(invalid("face source count"));
- }
- if let Some(history) = &saved.history
- && (history.faces.len() != faces
- || history.edges.len() != edges
- || history.operands as usize > MAX_ITEMS
- || history.edges.iter().flat_map(|e| &e.faces).any(|&f| f as usize >= faces))
- {
- return Err(invalid("history topology"));
- }
- if saved.color.is_some_and(|c| c.iter().any(|v| !v.is_finite() || !(0.0..=1.0).contains(v))) {
- return Err(invalid("colour"));
- }
- if let Some(paint) = &saved.paint
- && (!paint.opacity.is_finite()
- || !(0.0..=1.0).contains(&paint.opacity)
- || paint.faces.iter().any(|p| {
- p.face as usize >= faces
- || !p.opacity.is_finite()
- || !(0.0..=1.0).contains(&p.opacity)
- || p.color.iter().any(|v| !v.is_finite() || !(0.0..=1.0).contains(v))
- }))
- {
- return Err(invalid("face paint"));
- }
- Ok(())
-}
-
-// The binary reader bounds allocation before deserialization. Geometry semantics
-// are checked by the independent schema validator, not by backend serde internals.
-fn validate_value(v: &Value, depth: usize) -> Result<()> {
- if depth > 48 {
- return Err(invalid("nesting"));
- }
- match v {
- Value::String(s) if s.len() > 1 << 20 => return Err(invalid("string budget")),
- Value::Number(n) if n.is_f64() && n.as_f64().is_none_or(|x| !x.is_finite() || x.abs() > 1e12) => return Err(invalid("non-finite metadata")),
- Value::Array(a) => {
- if a.len() > MAX_ITEMS {
- return Err(invalid("array budget"));
- }
- for x in a {
- validate_value(x, depth + 1)?;
- }
- }
- Value::Object(o) => {
- for x in o.values() {
- validate_value(x, depth + 1)?;
- }
- }
- _ => {}
- }
- Ok(())
+/// The kernel's checks of a saved body's record that the file's own structural checks leave to
+/// it ([`solidcraft_geom::brep::check::geometry`]: frames, planes, placements).
+fn check(saved: &Saved) -> Result<()> {
+ solidcraft_geom::brep::check::geometry(&saved.solid).map_err(invalid)
}
-/// How many values `v` is (a collection and each of its items): [`MAX_VALUES`] at most.
+/// How many values `v` is (a collection and each of its items): [`file::MAX_VALUES`] at most.
#[cfg(test)]
-fn value_nodes(v: &Value) -> usize {
+fn value_nodes(v: &serde_json::Value) -> usize {
+ use serde_json::Value;
match v {
Value::Array(a) => a.iter().fold(1usize, |n, v| n.saturating_add(value_nodes(v))),
Value::Object(o) => o.values().fold(1usize, |n, v| n.saturating_add(value_nodes(v))),
@@ -342,7 +245,9 @@ mod smlib_import_tests;
#[cfg(test)]
mod tests {
use super::*;
- use solidcraft_geom::Vec3;
+ use serde_json::Value;
+ use solidcore_record::Vec3;
+ use solidcraft_geom::prelude::*;
use std::sync::Arc;
fn equal(a: &Body, b: &Body) {
assert_eq!(a.face_count(), b.face_count());
@@ -366,7 +271,7 @@ mod tests {
for body in [cube, rounded, cut] {
let body = body.with_color(Some([0.1, 0.5, 0.9]));
let bytes = encode_native_body(&body).unwrap();
- assert!(bytes.starts_with(MAGIC));
+ assert!(bytes.starts_with(file::MAGIC));
let decoded = decode_native_body(&bytes).unwrap();
equal(&body, &decoded);
let a = crate::boolean(&body, &bore, crate::BoolOp::Cut).unwrap().unwrap();
@@ -396,15 +301,16 @@ mod tests {
/// a JSON value, checked, then written.
fn encoded_through_a_value(body: &Body) -> Result<Vec<u8>> {
let runtime = Runtime { size: body.size, coarse_missing: None };
- let saved = SavedBody { solid: body.record().clone(), metadata: metadata::encode(body)?, runtime };
- validate_topology(&saved)?;
+ let saved = Saved { solid: body.record().clone(), metadata: metadata::encode(body)?, runtime };
+ check(&saved)?;
+ file::check(&saved).map_err(refused)?;
let value = serde_json::to_value(saved).map_err(invalid)?;
- validate_value(&value, 0)?;
- if value_nodes(&value) > MAX_VALUES {
+ file::check_value(&value).map_err(refused)?;
+ if value_nodes(&value) > file::MAX_VALUES {
return Err(invalid("value budget"));
}
- let mut out = MAGIC.to_vec();
- binary::write(&value, &mut out, 0)?;
+ let mut out = file::MAGIC.to_vec();
+ file::write_value(&value, &mut out).map_err(refused)?;
Ok(out)
}
@@ -413,7 +319,7 @@ mod tests {
/// along lines, round (spline forms), open, and placed far off.
#[test]
fn the_encoding_is_the_bytes_of_the_record_as_a_json_value() {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
let cube = crate::box_solid(Vec3::ZERO, Vec3::new(40., 30., 10.)).unwrap();
let rounded = crate::fillet(&cube, &[Vec3::new(20., 0., 10.)], 2.).unwrap();
let bore = crate::cylinder(Vec3::new(10., 10., -1.), Vec3::Z, 3., 12.).unwrap();
@@ -459,7 +365,7 @@ mod tests {
let bytes = encode_native_body(body).unwrap();
assert_eq!(&bytes[..8], b"SCBREP05");
let mut raw = &bytes[8..];
- let value = binary::read(&mut raw, 0, &mut 2_000_000).unwrap();
+ let value = file::read_value(&mut raw, &mut 2_000_000).unwrap();
assert!(raw.is_empty());
value
})
@@ -509,7 +415,7 @@ mod tests {
assert!(std::panic::catch_unwind(|| decode_native_body(&bad)).is_ok());
}
let mut raw = &bytes[8..];
- let value = binary::read(&mut raw, 0, &mut 2_000_000).unwrap();
+ let value = file::read_value(&mut raw, &mut 2_000_000).unwrap();
for key in ["vertices", "index"] {
let mut v = value.clone();
if key == "vertices" {
@@ -517,11 +423,11 @@ mod tests {
} else {
v["solid"]["faces"][0]["loops"][0]["edges"][0]["edge"] = serde_json::json!(u64::MAX);
}
- let mut bad = MAGIC.to_vec();
- binary::write(&v, &mut bad, 0).unwrap();
+ let mut bad = file::MAGIC.to_vec();
+ file::write_value(&v, &mut bad).unwrap();
assert!(decode_native_body(&bad).is_err());
}
- let mut huge = MAGIC.to_vec();
+ let mut huge = file::MAGIC.to_vec();
huge.push(7);
huge.extend(u32::MAX.to_le_bytes());
assert!(decode_native_body(&huge).is_err());
@@ -534,13 +440,13 @@ mod tests {
let body = crate::box_solid(Vec3::ZERO, Vec3::new(10., 20., 30.)).unwrap();
let mut record = body.record().clone();
let [t0, t1] = record.edges[0].interval;
- let n = solidcraft_geom::brep::MAX_ITEMS;
+ let n = solidcore_record::brep::MAX_ITEMS;
let points = (0..n).map(|i| [i as f64 * 1e-6, 0., 0.]).collect();
- record.edges[0].curve = solidcraft_geom::brep::Curve::Polyline { points };
+ record.edges[0].curve = solidcore_record::brep::Curve::Polyline { points };
assert!(t0 >= 0.0 && t1 <= (n - 1) as f64);
Body::from_record(record.clone()).unwrap();
- let saved = SavedBody { solid: record, metadata: metadata::encode(&body).unwrap(), runtime: Runtime { size: 0.0, coarse_missing: None } };
- let refused = validate_topology(&saved).err().map(|e| e.to_string()).unwrap_or_default();
+ let saved = Saved { solid: record, metadata: metadata::encode(&body).unwrap(), runtime: Runtime { size: 0.0, coarse_missing: None } };
+ let refused = file::check(&saved).err().map(|e| e.to_string()).unwrap_or_default();
assert!(refused.contains("item budget"), "{refused}");
}
diff --git a/crates/kernel/src/native/analytic.rs b/crates/kernel/src/native/analytic.rs
deleted file mode 100644
index c59b8cfdd1..0000000000
--- a/crates/kernel/src/native/analytic.rs
+++ /dev/null
@@ -1,64 +0,0 @@
-//! Analytic wire records are mathematical loci, independent of backend parameterizations.
-use super::*;
-
-/// Exact rational conic locus. The adapter reparameterizes angle by rational spans.
-pub(super) fn arc(frame: &b::Frame, radii: [f64; 2], angle: [f64; 2]) -> Result<mt::Curve> {
- let span = angle[1] - angle[0];
- let count = (span / std::f64::consts::FRAC_PI_2).ceil().clamp(1., 4.) as usize;
- let step = span / count as f64;
- let weight = (step / 2.).cos();
- let at = |t: f64, scale: f64| p(frame.origin) + v(frame.x_axis) * (radii[0] * t.cos() / scale) + v(frame.y_axis) * (radii[1] * t.sin() / scale);
- let mut controls = vec![at(angle[0], 1.).to_homogeneous()];
- let mut knots = vec![0.; 3];
- for i in 0..count {
- let start = angle[0] + i as f64 * step;
- controls.push(at(start + step / 2., weight).to_homogeneous() * weight);
- controls.push(at(start + step, 1.).to_homogeneous());
- knots.extend(std::iter::repeat_n((i + 1) as f64 / count as f64, if i + 1 == count { 3 } else { 2 }));
- }
- Ok(mt::Curve::NurbsCurve(mt::NurbsCurve::new(mt::BSplineCurve::try_new(knots.into(), controls).map_err(invalid)?)))
-}
-
-pub(super) fn revolved(profile: mt::Curve, origin: mt::Point3, axis: mt::Vector3, normal_flip: bool) -> mt::Surface {
- let mut s = mt::Processor::new(mt::RevolutedCurve::by_revolution(profile, origin, axis));
- // Internal parameter swapping is allowed; no such flag is persisted in a surface record.
- if normal_flip {
- s.invert();
- }
- mt::Surface::RevolutedCurve(s)
-}
-
-/// An unbounded analytic surface as a truck revolution, its profile over `height` (the face's
-/// v range) for a cylinder or cone, and the whole meridian for a sphere or torus. Truck's
-/// revolution has its own (u, v); the record's loops, not its parameters, bound the face. The
-/// profile runs against the record's v so the revolution's (profile, angle) has the record's
-/// natural normal unswapped, as truck's own revolutions are: the tessellator meets a cone's
-/// apex or a sphere's pole at the profile's end, where it places it right (swapped, a drilled
-/// hole's tip came out 41 % too large).
-pub(super) fn load_analytic(surface: b::Surface, height: [f64; 2]) -> Result<mt::Surface> {
- use std::f64::consts::{FRAC_PI_2, TAU};
- let axis = |f: &b::Frame| v(f.x_axis).cross(v(f.y_axis));
- Ok(match surface {
- b::Surface::Cylinder { frame, radius } => {
- let z = axis(&frame);
- let at = |h| p(frame.origin) + v(frame.x_axis) * radius + z * h;
- revolved(mt::Curve::Line(mt::Line(at(height[1]), at(height[0]))), p(frame.origin), z, false)
- }
- b::Surface::Cone { frame, radius_at_origin, half_angle } => {
- let z = axis(&frame);
- let at = |h| p(frame.origin) + v(frame.x_axis) * (radius_at_origin + h * half_angle.tan()) + z * h;
- revolved(mt::Curve::Line(mt::Line(at(height[1]), at(height[0]))), p(frame.origin), z, false)
- }
- b::Surface::Sphere { frame, radius } => {
- let z = axis(&frame);
- let meridian = b::Frame { origin: frame.origin, x_axis: frame.x_axis, y_axis: vector(z) };
- revolved(arc(&meridian, [radius; 2], [-FRAC_PI_2, FRAC_PI_2])?.inverse(), p(frame.origin), z, false)
- }
- b::Surface::Torus { frame, major_radius, minor_radius, .. } => {
- let z = axis(&frame);
- let profile = b::Frame { origin: point(p(frame.origin) + v(frame.x_axis) * major_radius), x_axis: frame.x_axis, y_axis: vector(z) };
- revolved(arc(&profile, [minor_radius; 2], [0., TAU])?.inverse(), p(frame.origin), z, false)
- }
- _ => return Err(invalid("expected analytic surface")),
- })
-}
diff --git a/crates/kernel/src/native/binary.rs b/crates/kernel/src/native/binary.rs
deleted file mode 100644
index bedb25b1f6..0000000000
--- a/crates/kernel/src/native/binary.rs
+++ /dev/null
@@ -1,635 +0,0 @@
-//! Bounded tagged binary values: integer and f64 bits stay exact, no base64/text numbers.
-use super::*;
-fn bytes<'a>(input: &mut &'a [u8], n: usize) -> Result<&'a [u8]> {
- let head = input.get(..n).ok_or_else(|| invalid("truncated value"))?;
- *input = input.get(n..).ok_or_else(|| invalid("truncated value"))?;
- Ok(head)
-}
-fn length(input: &mut &[u8]) -> Result<usize> {
- let raw: [u8; 4] = bytes(input, 4)?.try_into().map_err(invalid)?;
- usize::try_from(u32::from_le_bytes(raw)).map_err(invalid)
-}
-fn string(input: &mut &[u8]) -> Result<String> {
- let n = length(input)?;
- if n > 1 << 20 {
- return Err(invalid("string budget"));
- }
- Ok(std::str::from_utf8(bytes(input, n)?).map_err(invalid)?.to_owned())
-}
-pub(super) fn read(input: &mut &[u8], depth: usize, budget: &mut usize) -> Result<Value> {
- if depth > 48 || *budget == 0 {
- return Err(invalid("value budget/depth"));
- }
- *budget -= 1;
- let tag = *bytes(input, 1)?.first().ok_or_else(|| invalid("tag"))?;
- Ok(match tag {
- 0 => Value::Null,
- 1 => Value::Bool(false),
- 2 => Value::Bool(true),
- 3..=5 => {
- let raw: [u8; 8] = bytes(input, 8)?.try_into().map_err(invalid)?;
- Value::Number(match tag {
- 3 => Number::from(i64::from_le_bytes(raw)),
- 4 => Number::from(u64::from_le_bytes(raw)),
- _ => Number::from_f64(f64::from_le_bytes(raw)).ok_or_else(|| invalid("non-finite number"))?,
- })
- }
- 6 => Value::String(string(input)?),
- 7 | 8 => {
- let n = length(input)?;
- if n > MAX_ITEMS || n > input.len() || n > *budget {
- return Err(invalid("collection budget"));
- }
- if tag == 7 {
- let mut a = Vec::new();
- for _ in 0..n {
- a.push(read(input, depth + 1, budget)?);
- }
- Value::Array(a)
- } else {
- let mut map = Map::new();
- for _ in 0..n {
- let key = string(input)?;
- if map.contains_key(&key) {
- return Err(invalid("duplicate key"));
- }
- map.insert(key, read(input, depth + 1, budget)?);
- }
- Value::Object(map)
- }
- }
- _ => return Err(invalid("unknown binary tag")),
- })
-}
-#[cfg(test)]
-fn count(n: usize, out: &mut Vec<u8>) -> Result<()> {
- out.extend_from_slice(&u32::try_from(n).map_err(invalid)?.to_le_bytes());
- Ok(())
-}
-#[cfg(test)]
-fn text(s: &str, out: &mut Vec<u8>) -> Result<()> {
- count(s.len(), out)?;
- out.extend_from_slice(s.as_bytes());
- Ok(())
-}
-/// `value` appended to `out`. The encoder writes a body as it serializes
-/// ([`write_serialized`]); this writes a value already built, as tests build hostile ones.
-#[cfg(test)]
-pub(super) fn write(value: &Value, out: &mut Vec<u8>, depth: usize) -> Result<()> {
- if depth > 48 || out.len() > MAX_BYTES {
- return Err(invalid("encoding budget"));
- }
- match value {
- Value::Null => out.push(0),
- Value::Bool(b) => out.push(if *b { 2 } else { 1 }),
- Value::Number(n) => {
- if n.is_f64() {
- out.push(5);
- out.extend_from_slice(&n.as_f64().ok_or_else(|| invalid("number"))?.to_le_bytes());
- } else if let Some(n) = n.as_u64() {
- out.push(4);
- out.extend_from_slice(&n.to_le_bytes());
- } else {
- out.push(3);
- out.extend_from_slice(&n.as_i64().ok_or_else(|| invalid("integer"))?.to_le_bytes());
- }
- }
- Value::String(s) => {
- out.push(6);
- text(s, out)?;
- }
- Value::Array(a) => {
- out.push(7);
- count(a.len(), out)?;
- for v in a {
- write(v, out, depth + 1)?;
- }
- }
- Value::Object(map) => {
- out.push(8);
- count(map.len(), out)?;
- for (k, v) in map {
- text(k, out)?;
- write(v, out, depth + 1)?;
- }
- }
- }
- if out.len() > MAX_BYTES {
- return Err(invalid("encoding size"));
- }
- Ok(())
-}
-
-/// Why a value could not be written (a serde error carries only its message).
-#[derive(Debug)]
-pub(super) struct WriteError(String);
-
-impl std::fmt::Display for WriteError {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- f.write_str(&self.0)
- }
-}
-
-impl std::error::Error for WriteError {}
-
-impl serde::ser::Error for WriteError {
- fn custom<T: std::fmt::Display>(msg: T) -> Self {
- WriteError(msg.to_string())
- }
-}
-
-fn refuse(what: &str) -> WriteError {
- WriteError(what.into())
-}
-
-type Written<T = ()> = std::result::Result<T, WriteError>;
-
-/// `value` appended to `out` as the tagged binary value it is as JSON: the bytes [`write`] gives
-/// for `serde_json::to_value(value)`, refused where that, the checks on its result
-/// (`validate_value`, the [`MAX_VALUES`] budget) or [`write`] refuse. Written as it is
-/// serialized, with no JSON value in between: a body's record is millions of values, and building
-/// them all first was most of the cost of encoding it.
-///
-/// As JSON: a struct or a map is an object of its entries in key order (a JSON object's), its
-/// keys strings (a map's keys may be strings, characters, booleans or integers, written as JSON
-/// writes such keys); an enum variant without data its name, one with data an object of its name
-/// and the data; an option its value or null; bytes an array of numbers. A number is an integer
-/// (unsigned from 0 up, signed below) or a finite float; a float that is not finite is null.
-///
-/// Refused: nesting past 48, a string over 1 MiB, an array of more than [`MAX_ITEMS`], a float
-/// over 1e12 in size, more than [`MAX_VALUES`] values, more than [`MAX_BYTES`] in `out`.
-pub(super) fn write_serialized<T: serde::Serialize + ?Sized>(value: &T, out: &mut Vec<u8>) -> Result<()> {
- let mut w = Writer { out, values: 0 };
- value.serialize(Ser { w: &mut w, depth: 0 }).map_err(invalid)
-}
-
-struct Writer<'a> {
- out: &'a mut Vec<u8>,
- values: usize,
-}
-
-impl Writer<'_> {
- /// Count a value at `depth` and write its tag.
- fn start(&mut self, depth: usize, tag: u8) -> Written {
- if depth > 48 {
- return Err(refuse("nesting"));
- }
- self.values = self.values.saturating_add(1);
- if self.values > MAX_VALUES {
- return Err(refuse("value budget"));
- }
- self.out.push(tag);
- self.fits()
- }
- fn fits(&self) -> Written {
- if self.out.len() > MAX_BYTES { Err(refuse("encoding size")) } else { Ok(()) }
- }
- fn number(&mut self, depth: usize, tag: u8, bits: [u8; 8]) -> Written {
- self.start(depth, tag)?;
- self.out.extend_from_slice(&bits);
- self.fits()
- }
- fn unsigned(&mut self, depth: usize, v: u64) -> Written {
- self.number(depth, 4, v.to_le_bytes())
- }
- fn signed(&mut self, depth: usize, v: i64) -> Written {
- match u64::try_from(v) {
- Ok(u) => self.unsigned(depth, u),
- Err(_) => self.number(depth, 3, v.to_le_bytes()),
- }
- }
- fn float(&mut self, depth: usize, v: f64) -> Written {
- if !v.is_finite() {
- return self.start(depth, 0);
- }
- if v.abs() > 1e12 {
- return Err(refuse("non-finite metadata"));
- }
- self.number(depth, 5, v.to_le_bytes())
- }
- fn length(&mut self, n: usize) -> Written {
- self.out.extend_from_slice(&u32::try_from(n).map_err(|_| refuse("length"))?.to_le_bytes());
- self.fits()
- }
- fn text(&mut self, s: &str) -> Written {
- self.length(s.len())?;
- self.out.extend_from_slice(s.as_bytes());
- self.fits()
- }
- fn string(&mut self, depth: usize, s: &str) -> Written {
- if s.len() > 1 << 20 {
- return Err(refuse("string budget"));
- }
- self.start(depth, 6)?;
- self.text(s)
- }
- /// Open a collection at `depth`: its tag and room for its count, which goes at the place
- /// returned.
- fn open(&mut self, depth: usize, tag: u8) -> Written<usize> {
- self.start(depth, tag)?;
- let at = self.out.len();
- self.out.extend_from_slice(&[0; 4]);
- self.fits()?;
- Ok(at)
- }
- fn count_at(&mut self, at: usize, n: usize) -> Written {
- let n = u32::try_from(n).map_err(|_| refuse("length"))?.to_le_bytes();
- self.out.get_mut(at..at + 4).ok_or_else(|| refuse("count"))?.copy_from_slice(&n);
- Ok(())
- }
-}
-
-/// A value to write at a depth.
-pub(super) struct Ser<'w, 'a> {
- w: &'w mut Writer<'a>,
- depth: usize,
-}
-
-impl<'w, 'a> Ser<'w, 'a> {
- /// An object of one entry, named `variant`, whose value comes next (at the depth returned).
- fn variant(self, variant: &str) -> Written<Ser<'w, 'a>> {
- let at = self.w.open(self.depth, 8)?;
- self.w.count_at(at, 1)?;
- self.w.text(variant)?;
- Ok(Ser { w: self.w, depth: self.depth + 1 })
- }
- fn array(self) -> Written<Array<'w, 'a>> {
- let at = self.w.open(self.depth, 7)?;
- Ok(Array { w: self.w, depth: self.depth, at, items: 0 })
- }
- fn object(self) -> Written<Object<'w, 'a>> {
- let at = self.w.open(self.depth, 8)?;
- Ok(Object { w: self.w, depth: self.depth, at, entries: Vec::new(), key: None })
- }
-}
-
-/// An array being written: where its count goes, and how many items it has.
-pub(super) struct Array<'w, 'a> {
- w: &'w mut Writer<'a>,
- depth: usize,
- at: usize,
- items: usize,
-}
-
-impl Array<'_, '_> {
- fn item<T: serde::Serialize + ?Sized>(&mut self, value: &T) -> Written {
- self.items += 1;
- if self.items > MAX_ITEMS {
- return Err(refuse("array budget"));
- }
- value.serialize(Ser { w: self.w, depth: self.depth + 1 })
- }
- fn close(self) -> Written {
- self.w.count_at(self.at, self.items)
- }
-}
-
-/// An object being written: where its count goes, and each entry's key and where it ends. The
-/// entries are written as they come and put in key order when it closes.
-pub(super) struct Object<'w, 'a> {
- w: &'w mut Writer<'a>,
- depth: usize,
- at: usize,
- entries: Vec<(String, usize)>,
- /// The key of the entry whose value comes next.
- key: Option<String>,
-}
-
-impl Object<'_, '_> {
- fn key(&mut self, key: String) -> Written {
- self.w.text(&key)?;
- self.key = Some(key);
- Ok(())
- }
- fn value<T: serde::Serialize + ?Sized>(&mut self, value: &T) -> Written {
- let key = self.key.take().ok_or_else(|| refuse("an object's value without its key"))?;
- value.serialize(Ser { w: self.w, depth: self.depth + 1 })?;
- self.entries.push((key, self.w.out.len()));
- Ok(())
- }
- fn entry<T: serde::Serialize + ?Sized>(&mut self, key: &str, value: &T) -> Written {
- self.key(key.to_owned())?;
- self.value(value)
- }
- fn close(self) -> Written {
- let Object { w, at, entries, .. } = self;
- let first = at + 4;
- if !entries.windows(2).all(|p| p[0].0 < p[1].0) {
- // In key order, as a JSON object (a map by key) holds them. A key twice would keep
- // only its last value there; no record repeats one.
- let mut spans: Vec<(&str, usize, usize)> = Vec::with_capacity(entries.len());
- let mut start = first;
- for (key, end) in &entries {
- spans.push((key.as_str(), start, *end));
- start = *end;
- }
- spans.sort_by(|a, b| a.0.cmp(b.0));
- if spans.windows(2).any(|p| p[0].0 == p[1].0) {
- return Err(refuse("duplicate key"));
- }
- let written = w.out.split_off(first);
- for (_, start, end) in spans {
- w.out.extend_from_slice(written.get(start - first..end - first).ok_or_else(|| refuse("object"))?);
- }
- }
- w.count_at(at, entries.len())
- }
-}
-
-/// A map key as JSON writes it: a string.
-struct Key;
-
-impl serde::Serializer for Key {
- type Ok = String;
- type Error = WriteError;
- type SerializeSeq = serde::ser::Impossible<String, WriteError>;
- type SerializeTuple = serde::ser::Impossible<String, WriteError>;
- type SerializeTupleStruct = serde::ser::Impossible<String, WriteError>;
- type SerializeTupleVariant = serde::ser::Impossible<String, WriteError>;
- type SerializeMap = serde::ser::Impossible<String, WriteError>;
- type SerializeStruct = serde::ser::Impossible<String, WriteError>;
- type SerializeStructVariant = serde::ser::Impossible<String, WriteError>;
-
- fn serialize_bool(self, v: bool) -> Written<String> {
- Ok(v.to_string())
- }
- fn serialize_i8(self, v: i8) -> Written<String> {
- Ok(v.to_string())
- }
- fn serialize_i16(self, v: i16) -> Written<String> {
- Ok(v.to_string())
- }
- fn serialize_i32(self, v: i32) -> Written<String> {
- Ok(v.to_string())
- }
- fn serialize_i64(self, v: i64) -> Written<String> {
- Ok(v.to_string())
- }
- fn serialize_i128(self, v: i128) -> Written<String> {
- Ok(v.to_string())
- }
- fn serialize_u8(self, v: u8) -> Written<String> {
- Ok(v.to_string())
- }
- fn serialize_u16(self, v: u16) -> Written<String> {
- Ok(v.to_string())
- }
- fn serialize_u32(self, v: u32) -> Written<String> {
- Ok(v.to_string())
- }
- fn serialize_u64(self, v: u64) -> Written<String> {
- Ok(v.to_string())
- }
- fn serialize_u128(self, v: u128) -> Written<String> {
- Ok(v.to_string())
- }
- fn serialize_f32(self, _: f32) -> Written<String> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_f64(self, _: f64) -> Written<String> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_char(self, v: char) -> Written<String> {
- Ok(v.to_string())
- }
- fn serialize_str(self, v: &str) -> Written<String> {
- Ok(v.to_owned())
- }
- fn serialize_bytes(self, _: &[u8]) -> Written<String> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_none(self) -> Written<String> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_some<T: serde::Serialize + ?Sized>(self, _: &T) -> Written<String> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_unit(self) -> Written<String> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_unit_struct(self, _: &'static str) -> Written<String> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_unit_variant(self, _: &'static str, _: u32, variant: &'static str) -> Written<String> {
- Ok(variant.to_owned())
- }
- fn serialize_newtype_struct<T: serde::Serialize + ?Sized>(self, _: &'static str, value: &T) -> Written<String> {
- value.serialize(self)
- }
- fn serialize_newtype_variant<T: serde::Serialize + ?Sized>(self, _: &'static str, _: u32, _: &'static str, _: &T) -> Written<String> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_seq(self, _: Option<usize>) -> Written<Self::SerializeSeq> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_tuple(self, _: usize) -> Written<Self::SerializeTuple> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_tuple_struct(self, _: &'static str, _: usize) -> Written<Self::SerializeTupleStruct> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_tuple_variant(self, _: &'static str, _: u32, _: &'static str, _: usize) -> Written<Self::SerializeTupleVariant> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_map(self, _: Option<usize>) -> Written<Self::SerializeMap> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_struct(self, _: &'static str, _: usize) -> Written<Self::SerializeStruct> {
- Err(refuse("a map key must be a string"))
- }
- fn serialize_struct_variant(self, _: &'static str, _: u32, _: &'static str, _: usize) -> Written<Self::SerializeStructVariant> {
- Err(refuse("a map key must be a string"))
- }
-}
-
-impl<'w, 'a> serde::Serializer for Ser<'w, 'a> {
- type Ok = ();
- type Error = WriteError;
- type SerializeSeq = Array<'w, 'a>;
- type SerializeTuple = Array<'w, 'a>;
- type SerializeTupleStruct = Array<'w, 'a>;
- type SerializeTupleVariant = Array<'w, 'a>;
- type SerializeMap = Object<'w, 'a>;
- type SerializeStruct = Object<'w, 'a>;
- type SerializeStructVariant = Object<'w, 'a>;
-
- fn serialize_bool(self, v: bool) -> Written {
- self.w.start(self.depth, if v { 2 } else { 1 })
- }
- fn serialize_i8(self, v: i8) -> Written {
- self.w.signed(self.depth, v.into())
- }
- fn serialize_i16(self, v: i16) -> Written {
- self.w.signed(self.depth, v.into())
- }
- fn serialize_i32(self, v: i32) -> Written {
- self.w.signed(self.depth, v.into())
- }
- fn serialize_i64(self, v: i64) -> Written {
- self.w.signed(self.depth, v)
- }
- fn serialize_i128(self, v: i128) -> Written {
- match (u64::try_from(v), i64::try_from(v)) {
- (Ok(u), _) => self.w.unsigned(self.depth, u),
- (_, Ok(i)) => self.w.signed(self.depth, i),
- _ => Err(refuse("number out of range")),
- }
- }
- fn serialize_u8(self, v: u8) -> Written {
- self.w.unsigned(self.depth, v.into())
- }
- fn serialize_u16(self, v: u16) -> Written {
- self.w.unsigned(self.depth, v.into())
- }
- fn serialize_u32(self, v: u32) -> Written {
- self.w.unsigned(self.depth, v.into())
- }
- fn serialize_u64(self, v: u64) -> Written {
- self.w.unsigned(self.depth, v)
- }
- fn serialize_u128(self, v: u128) -> Written {
- self.w.unsigned(self.depth, u64::try_from(v).map_err(|_| refuse("number out of range"))?)
- }
- fn serialize_f32(self, v: f32) -> Written {
- self.w.float(self.depth, v.into())
- }
- fn serialize_f64(self, v: f64) -> Written {
- self.w.float(self.depth, v)
- }
- fn serialize_char(self, v: char) -> Written {
- self.w.string(self.depth, v.encode_utf8(&mut [0; 4]))
- }
- fn serialize_str(self, v: &str) -> Written {
- self.w.string(self.depth, v)
- }
- fn serialize_bytes(self, v: &[u8]) -> Written {
- let mut a = self.array()?;
- for b in v {
- a.item(b)?;
- }
- a.close()
- }
- fn serialize_none(self) -> Written {
- self.w.start(self.depth, 0)
- }
- fn serialize_some<T: serde::Serialize + ?Sized>(self, value: &T) -> Written {
- value.serialize(self)
- }
- fn serialize_unit(self) -> Written {
- self.w.start(self.depth, 0)
- }
- fn serialize_unit_struct(self, _: &'static str) -> Written {
- self.w.start(self.depth, 0)
- }
- fn serialize_unit_variant(self, _: &'static str, _: u32, variant: &'static str) -> Written {
- self.w.string(self.depth, variant)
- }
- fn serialize_newtype_struct<T: serde::Serialize + ?Sized>(self, _: &'static str, value: &T) -> Written {
- value.serialize(self)
- }
- fn serialize_newtype_variant<T: serde::Serialize + ?Sized>(self, _: &'static str, _: u32, variant: &'static str, value: &T) -> Written {
- value.serialize(self.variant(variant)?)
- }
- fn serialize_seq(self, _: Option<usize>) -> Written<Array<'w, 'a>> {
- self.array()
- }
- fn serialize_tuple(self, _: usize) -> Written<Array<'w, 'a>> {
- self.array()
- }
- fn serialize_tuple_struct(self, _: &'static str, _: usize) -> Written<Array<'w, 'a>> {
- self.array()
- }
- fn serialize_tuple_variant(self, _: &'static str, _: u32, variant: &'static str, _: usize) -> Written<Array<'w, 'a>> {
- self.variant(variant)?.array()
- }
- fn serialize_map(self, _: Option<usize>) -> Written<Object<'w, 'a>> {
- self.object()
- }
- fn serialize_struct(self, _: &'static str, _: usize) -> Written<Object<'w, 'a>> {
- self.object()
- }
- fn serialize_struct_variant(self, _: &'static str, _: u32, variant: &'static str, _: usize) -> Written<Object<'w, 'a>> {
- self.variant(variant)?.object()
- }
-}
-
-impl serde::ser::SerializeSeq for Array<'_, '_> {
- type Ok = ();
- type Error = WriteError;
- fn serialize_element<T: serde::Serialize + ?Sized>(&mut self, value: &T) -> Written {
- self.item(value)
- }
- fn end(self) -> Written {
- self.close()
- }
-}
-
-impl serde::ser::SerializeTuple for Array<'_, '_> {
- type Ok = ();
- type Error = WriteError;
- fn serialize_element<T: serde::Serialize + ?Sized>(&mut self, value: &T) -> Written {
- self.item(value)
- }
- fn end(self) -> Written {
- self.close()
- }
-}
-
-impl serde::ser::SerializeTupleStruct for Array<'_, '_> {
- type Ok = ();
- type Error = WriteError;
- fn serialize_field<T: serde::Serialize + ?Sized>(&mut self, value: &T) -> Written {
- self.item(value)
- }
- fn end(self) -> Written {
- self.close()
- }
-}
-
-impl serde::ser::SerializeTupleVariant for Array<'_, '_> {
- type Ok = ();
- type Error = WriteError;
- fn serialize_field<T: serde::Serialize + ?Sized>(&mut self, value: &T) -> Written {
- self.item(value)
- }
- fn end(self) -> Written {
- self.close()
- }
-}
-
-impl serde::ser::SerializeMap for Object<'_, '_> {
- type Ok = ();
- type Error = WriteError;
- fn serialize_key<T: serde::Serialize + ?Sized>(&mut self, key: &T) -> Written {
- let key = key.serialize(Key)?;
- self.key(key)
- }
- fn serialize_value<T: serde::Serialize + ?Sized>(&mut self, value: &T) -> Written {
- self.value(value)
- }
- fn end(self) -> Written {
- self.close()
- }
-}
-
-impl serde::ser::SerializeStruct for Object<'_, '_> {
- type Ok = ();
- type Error = WriteError;
- fn serialize_field<T: serde::Serialize + ?Sized>(&mut self, key: &'static str, value: &T) -> Written {
- self.entry(key, value)
- }
- fn end(self) -> Written {
- self.close()
- }
-}
-
-impl serde::ser::SerializeStructVariant for Object<'_, '_> {
- type Ok = ();
- type Error = WriteError;
- fn serialize_field<T: serde::Serialize + ?Sized>(&mut self, key: &'static str, value: &T) -> Written {
- self.entry(key, value)
- }
- fn end(self) -> Written {
- self.close()
- }
-}
diff --git a/crates/kernel/src/native/metadata.rs b/crates/kernel/src/native/metadata.rs
index 3e49d1fe14..49eb812d8b 100644
--- a/crates/kernel/src/native/metadata.rs
+++ b/crates/kernel/src/native/metadata.rs
@@ -1,7 +1,8 @@
//! Explicit conversions between runtime metadata and the versioned wire records.
use super::{Result, invalid};
use crate::{Body, FaceSource, history as h};
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3, brep::envelope as w};
+use solidcore_record::brep::envelope as w;
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
fn index(n: usize) -> Result<u32> {
u32::try_from(n).map_err(invalid)
@@ -32,7 +33,8 @@ fn segment(s: &Seg2) -> Result<w::Segment> {
Seg2::Conic { a, apex, b, w } => w::Segment::Conic { points: [a, apex, b].map(point2), middle_weight: w },
Seg2::Bezier { n, p } => {
let count = usize::from(n) + 1;
- if !(5..=solidcraft_geom::MAX_BEZIER_CTRL).contains(&count) || p.get(count..).is_none_or(|unused| unused.iter().any(|p| *p != Vec2::ZERO))
+ if !(5..=solidcore_record::MAX_BEZIER_CTRL).contains(&count)
+ || p.get(count..).is_none_or(|unused| unused.iter().any(|p| *p != Vec2::ZERO))
{
return Err(invalid("unsupported certificate Bezier layout"));
}
@@ -47,10 +49,10 @@ fn load_segment(s: w::Segment) -> Result<Seg2> {
w::Segment::Cubic { points: [a, b, c, d] } => Seg2::Cubic { p0: p2(a), p1: p2(b), p2: p2(c), p3: p2(d) },
w::Segment::Conic { points: [a, apex, b], middle_weight } => Seg2::Conic { a: p2(a), apex: p2(apex), b: p2(b), w: middle_weight },
w::Segment::Bezier { points } => {
- if !(5..=solidcraft_geom::MAX_BEZIER_CTRL).contains(&points.len()) {
+ if !(5..=solidcore_record::MAX_BEZIER_CTRL).contains(&points.len()) {
return Err(invalid("certificate Bezier degree"));
}
- let mut p = [Vec2::ZERO; solidcraft_geom::MAX_BEZIER_CTRL];
+ let mut p = [Vec2::ZERO; solidcore_record::MAX_BEZIER_CTRL];
let n = (points.len() - 1) as u8;
for (slot, value) in p.iter_mut().zip(points) {
*slot = p2(value);
@@ -325,7 +327,7 @@ mod tests {
for value in sources {
assert_eq!(value, source(&load_source(value.clone(), 0).unwrap(), 0).unwrap());
}
- assert!(load_segment(w::Segment::Bezier { points: vec![[0., 0.]; solidcraft_geom::MAX_BEZIER_CTRL + 1] }).is_err());
+ assert!(load_segment(w::Segment::Bezier { points: vec![[0., 0.]; solidcore_record::MAX_BEZIER_CTRL + 1] }).is_err());
}
#[test]
diff --git a/crates/kernel/src/native/preview.rs b/crates/kernel/src/native/preview.rs
index 726911f36f..4a4dce9e6c 100644
--- a/crates/kernel/src/native/preview.rs
+++ b/crates/kernel/src/native/preview.rs
@@ -25,7 +25,7 @@ pub fn native_preview_mesh(body: &Body, detail: usize, remaining: &mut usize) ->
#[cfg(test)]
mod tests {
use super::*;
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
#[test]
fn native_preview_is_finite_and_budgeted_before_meshing() {
for body in [
diff --git a/crates/kernel/src/native/smlib_import_tests.rs b/crates/kernel/src/native/smlib_import_tests.rs
index c71e1732dd..7c5adc8cb6 100644
--- a/crates/kernel/src/native/smlib_import_tests.rs
+++ b/crates/kernel/src/native/smlib_import_tests.rs
@@ -2,7 +2,7 @@
//! volume.
use std::f64::consts::PI;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::{Body, box_solid, cylinder, sphere, torus};
@@ -69,7 +69,7 @@ fn extruded_circles_go_as_cylinders() {
use solidcraft_smlib::flat;
let body = cylinder(v(0., 50., -60.), v(0., 0., 1.), 40.0, 120.0).unwrap();
let record = super::brep_record(&body).unwrap();
- let walls = record.faces.iter().filter(|f| matches!(f.surface, solidcraft_geom::brep::Surface::Cylinder { .. })).count();
+ let walls = record.faces.iter().filter(|f| matches!(f.surface, solidcore_record::brep::Surface::Cylinder { .. })).count();
assert_eq!((walls, record.faces.len()), (1, 3));
let arrays = solidcraft_smlib::import::arrays(&record, true).unwrap();
let kinds = &arrays.ints[&flat::FACE_SURFACE_TYPE];
@@ -99,7 +99,7 @@ fn a_cavity_comes_back_from_smlib() {
/// square to the axis (annular sectors), its walls cylinders.
#[test]
fn a_revolved_annulus_goes_with_its_flat_faces() {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
let square =
Region2 { outer: Loop2::polygon(&[Vec2::new(4., 12.), Vec2::new(12., 12.), Vec2::new(12., 20.), Vec2::new(4., 20.)]), holes: vec![] };
let plane = Plane { y: v(0., 0., 1.), ..Plane::XZ };
@@ -114,7 +114,7 @@ fn a_revolved_annulus_goes_with_its_flat_faces() {
/// A drill point (a cone ending in its apex) through SMLib and back measures as it went in.
#[test]
fn a_cone_apex_comes_back_measuring_as_it_went() {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
let r = 3.4;
let h = r / (59f64.to_radians()).tan();
let profile =
diff --git a/crates/kernel/src/numbered.rs b/crates/kernel/src/numbered.rs
index d713ef67ac..8115ec1584 100644
--- a/crates/kernel/src/numbered.rs
+++ b/crates/kernel/src/numbered.rs
@@ -4,9 +4,10 @@
//! numbers are defined here: the segments of the caller's regions in order, each region its outer
//! loop and then its holes ([`profile_loops`]).
+use solidcraft_geom::prelude::*;
use std::collections::BTreeSet;
-use solidcraft_geom::{Loop2, Region2, Seg2};
+use solidcore_record::{Loop2, Region2, Seg2};
/// The loops of `regions` in profile order: each region's outer loop, then its holes.
pub(crate) fn profile_loops(regions: &[Region2]) -> impl Iterator<Item = &Loop2> {
diff --git a/crates/kernel/src/offset.rs b/crates/kernel/src/offset.rs
index cb21f42fde..bd65c92e42 100644
--- a/crates/kernel/src/offset.rs
+++ b/crates/kernel/src/offset.rs
@@ -3,8 +3,9 @@
//! Moving faces along their normals (offset faces, shell, draft) is SMLib's
//! (`crate::offset_backend`).
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::{Brep, Frame, Loop, Surface};
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Brep, Frame, Loop, Surface};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
@@ -38,7 +39,7 @@ fn axes(f: &Frame) -> Option<(Vec3, Vec3)> {
pub(crate) fn surf_of(b: &Brep, face: usize) -> Option<Surf> {
let f = b.faces.get(face)?;
// `forward` is about the face's NURBS form, which may run against its surface.
- let out = crate::assemble::natural_out(b, face)? != f.form_turns()?;
+ let out = crate::assemble::natural_out(b, face)? != solidcraft_geom::brep::label::form_turns(f)?;
let sign = if out { 1.0 } else { -1.0 };
Some(match &f.surface {
Surface::Plane { origin, u_axis, v_axis } => {
diff --git a/crates/kernel/src/offset_backend.rs b/crates/kernel/src/offset_backend.rs
index e21bd7dbd4..1f72ed2d86 100644
--- a/crates/kernel/src/offset_backend.rs
+++ b/crates/kernel/src/offset_backend.rs
@@ -12,9 +12,10 @@
//! ([`FaceOrigin::Offset`]), and its edges as where its faces meet. A face SMLib makes new along
//! a sheet's open edge (a thickened sheet's wall) is recorded as made in place of that edge.
+use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_smlib::{Brep, CheckLevel, Error as SmError};
use crate::body::Body;
@@ -145,7 +146,7 @@ pub(crate) fn thicken(b: &Body, thickness: f64, symmetric: bool) -> Result<Body>
/// tilted by `angle` about their lines on `neutral`, leaning in going along `pull`; the faces
/// around them extended or trimmed to meet them. A tilted face is the face itself (Modified).
/// A face SMLib can't draft (not flat, or not parallel to the pull) is "not supported yet".
-pub(crate) fn draft(b: &Body, at: &[Vec3], neutral: &solidcraft_geom::Plane, pull: Vec3, angle: f64) -> Result<Body> {
+pub(crate) fn draft(b: &Body, at: &[Vec3], neutral: &solidcore_record::Plane, pull: Vec3, angle: f64) -> Result<Body> {
if !angle.is_finite() || angle.abs() >= std::f64::consts::FRAC_PI_2 - 1e-3 {
return Err(KernelError::Invalid("draft angle must be between −90° and 90°".into()));
}
diff --git a/crates/kernel/src/ops.rs b/crates/kernel/src/ops.rs
index ff3c22f69a..f238f9628a 100644
--- a/crates/kernel/src/ops.rs
+++ b/crates/kernel/src/ops.rs
@@ -2,8 +2,10 @@
//! from each other join without any intersection work, their records side by side.
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::{part, placement::Rigid};
+use solidcore_record::Vec3;
+use solidcore_record::brep::part;
+use solidcraft_geom::brep::placement::Rigid;
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::history::{BodyHistory, History};
@@ -136,7 +138,7 @@ pub(crate) fn join_pieces(pieces: Vec<Body>) -> Result<Option<Body>> {
/// The records of `bodies` side by side, as one body, and where its items come from.
fn joined(bodies: &[Body]) -> Result<(Body, part::Part)> {
- let records: Vec<&solidcraft_geom::brep::Brep> = bodies.iter().map(Body::record).collect();
+ let records: Vec<&solidcore_record::brep::Brep> = bodies.iter().map(Body::record).collect();
let part = part::compound(&records).map_err(|e| KernelError::Failed(format!("pieces: {e}")))?;
// Each face's source, numbered as `compound` numbers the inputs: one after another.
let sources: Vec<Option<crate::FaceSource>> =
@@ -166,7 +168,7 @@ pub fn transform_matrix(body: &Body, m: [[f64; 4]; 4]) -> Result<Body> {
let sources = body.transformed_sources(m)?;
let (placed, sources, paint) = match Rigid::of_matrix(&m) {
Some(motion) => {
- let moved = Body::from_record(body.record().moved(&motion))?;
+ let moved = Body::from_record(solidcraft_geom::brep::placement::moved(body.record(), &motion))?;
let history = History::identity(&moved);
(moved.with_history(history, &[body])?, sources, body.paint().cloned())
}
@@ -248,7 +250,7 @@ pub fn transform(body: &Body, translate: Vec3, origin: Vec3, axis: Vec3, angle:
/// Split a body with a plane: the parts on the positive and the negative side of the plane
/// (only the non-empty ones).
-pub fn split_by_plane(body: &Body, plane: &solidcraft_geom::Plane) -> Result<Vec<Body>> {
+pub fn split_by_plane(body: &Body, plane: &solidcore_record::Plane) -> Result<Vec<Body>> {
let _span = solidcraft_profile::span("kernel", "split_by_plane");
let mut out = Vec::new();
for positive in [true, false] {
@@ -261,7 +263,7 @@ pub fn split_by_plane(body: &Body, plane: &solidcraft_geom::Plane) -> Result<Vec
/// cut with: the part is the body's intersection with [`half_box`] (the tool), whose history it
/// carries, over the body and the box. The box's face in the plane, the part's cut face, is its
/// start cap on the positive side and its end cap on the negative side.
-pub fn half_space(body: &Body, plane: &solidcraft_geom::Plane, positive: bool) -> Result<(Option<Body>, Body)> {
+pub fn half_space(body: &Body, plane: &solidcore_record::Plane, positive: bool) -> Result<(Option<Body>, Body)> {
let _span = solidcraft_profile::span("kernel", "half_space");
// The box's own construction roles describe no face of the design: the cut face has none.
let tool = half_box(body, plane, positive)?.with_face_sources(None);
@@ -269,17 +271,17 @@ pub fn half_space(body: &Body, plane: &solidcraft_geom::Plane, positive: bool) -
}
/// A box covering everything of `body` on one side of a plane, its start cap in the plane.
-pub(crate) fn half_box(body: &Body, plane: &solidcraft_geom::Plane, positive: bool) -> Result<Body> {
+pub(crate) fn half_box(body: &Body, plane: &solidcore_record::Plane, positive: bool) -> Result<Body> {
body.require_brep("split")?;
let bb = body.exact_bounds()?;
let reach = (bb.diagonal() + plane.origin.dist(bb.center())) * 2.0 + body.size();
let c = plane.to_local(bb.center());
- let sq = solidcraft_geom::Region2 {
- outer: solidcraft_geom::Loop2::polygon(&[
- solidcraft_geom::Vec2::new(c.x - reach, c.y - reach),
- solidcraft_geom::Vec2::new(c.x + reach, c.y - reach),
- solidcraft_geom::Vec2::new(c.x + reach, c.y + reach),
- solidcraft_geom::Vec2::new(c.x - reach, c.y + reach),
+ let sq = solidcore_record::Region2 {
+ outer: solidcore_record::Loop2::polygon(&[
+ solidcore_record::Vec2::new(c.x - reach, c.y - reach),
+ solidcore_record::Vec2::new(c.x + reach, c.y - reach),
+ solidcore_record::Vec2::new(c.x + reach, c.y + reach),
+ solidcore_record::Vec2::new(c.x - reach, c.y + reach),
]),
holes: vec![],
};
diff --git a/crates/kernel/src/outline_tests.rs b/crates/kernel/src/outline_tests.rs
index c1579db16c..d583f14631 100644
--- a/crates/kernel/src/outline_tests.rs
+++ b/crates/kernel/src/outline_tests.rs
@@ -1,9 +1,10 @@
//! A lip swept along the rim of a round body joins it, flush with its side or set in from it:
//! the lip's foot lies on the body's top, and its sides are round where the rim is.
+use solidcraft_geom::prelude::*;
use std::f64::consts::{FRAC_PI_2, PI};
-use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
use crate::*;
diff --git a/crates/kernel/src/pinch_tests.rs b/crates/kernel/src/pinch_tests.rs
index 18222c0e31..c98155a72a 100644
--- a/crates/kernel/src/pinch_tests.rs
+++ b/crates/kernel/src/pinch_tests.rs
@@ -3,7 +3,7 @@
//! along a line give separate shells, and near-tangent numbers from the sketch solver (a
//! circle 1e-13 mm past the side) behave like exact ones.
-use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
use crate::*;
diff --git a/crates/kernel/src/placement_tests.rs b/crates/kernel/src/placement_tests.rs
index 239281caef..cb451dda5a 100644
--- a/crates/kernel/src/placement_tests.rs
+++ b/crates/kernel/src/placement_tests.rs
@@ -48,8 +48,8 @@ fn periodic_step_seam_survives_identity_rotation_and_translation() {
// A face whose loop uses an edge twice (the seam).
let seamed = body.record().faces.iter().any(|f| {
f.loops.iter().any(|l| match l {
- solidcraft_geom::brep::Loop::Edges { edges } => edges.iter().any(|u| edges.iter().filter(|w| w.edge == u.edge).count() > 1),
- solidcraft_geom::brep::Loop::Vertex { .. } => false,
+ solidcore_record::brep::Loop::Edges { edges } => edges.iter().any(|u| edges.iter().filter(|w| w.edge == u.edge).count() > 1),
+ solidcore_record::brep::Loop::Vertex { .. } => false,
})
});
assert!(seamed);
diff --git a/crates/kernel/src/planar_faces_tests.rs b/crates/kernel/src/planar_faces_tests.rs
index eb995cc148..10bac46918 100644
--- a/crates/kernel/src/planar_faces_tests.rs
+++ b/crates/kernel/src/planar_faces_tests.rs
@@ -2,9 +2,10 @@
//! A wall swept along a spiral has a flat top and bottom that are B-spline faces: a join of two
//! such walls, whose tops and bottoms coincide.
+use solidcraft_geom::prelude::*;
use std::f64::consts::TAU;
-use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
use crate::*;
@@ -114,12 +115,12 @@ fn interleaved_spiral_walls_join() {
#[test]
fn a_cut_of_an_extruded_spline_keeps_its_spline_wall() {
let p = Vec2::new;
- let line = |a: Vec2, b: Vec2| solidcraft_geom::Seg2::Line { a, b };
+ let line = |a: Vec2, b: Vec2| solidcore_record::Seg2::Line { a, b };
let outline = Loop2 {
segs: vec![
line(p(0.0, 0.0), p(40.0, 0.0)),
line(p(40.0, 0.0), p(40.0, 20.0)),
- solidcraft_geom::Seg2::Cubic { p0: p(40.0, 20.0), p1: p(30.0, 35.0), p2: p(10.0, 5.0), p3: p(0.0, 20.0) },
+ solidcore_record::Seg2::Cubic { p0: p(40.0, 20.0), p1: p(30.0, 35.0), p2: p(10.0, 5.0), p3: p(0.0, 20.0) },
line(p(0.0, 20.0), p(0.0, 0.0)),
],
};
diff --git a/crates/kernel/src/planar_regularize.rs b/crates/kernel/src/planar_regularize.rs
index ea2b6e61fe..09394b8686 100644
--- a/crates/kernel/src/planar_regularize.rs
+++ b/crates/kernel/src/planar_regularize.rs
@@ -4,8 +4,9 @@
//! every other edge kept by a point at its middle).
use super::Body;
use crate::{KernelError, Result, guard};
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::{self, eval::CurveEval};
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self};
+use solidcraft_geom::brep::eval::CurveEval;
use std::sync::Arc;
/// Points along a record edge (ends and three inside).
diff --git a/crates/kernel/src/planar_sources.rs b/crates/kernel/src/planar_sources.rs
index 29b75daf76..cca32a03ea 100644
--- a/crates/kernel/src/planar_sources.rs
+++ b/crates/kernel/src/planar_sources.rs
@@ -2,8 +2,9 @@
//! No tessellated face names, centroids, or nearest-plane choices are used.
use super::{Body, FaceSource};
use crate::{KernelError, Result, guard};
-use solidcraft_geom::brep::{self, Surface};
-use solidcraft_geom::{Plane, Vec3};
+use solidcore_record::brep::{self, Surface};
+use solidcore_record::{Plane, Vec3};
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
use std::sync::Arc;
@@ -735,7 +736,7 @@ mod tests {
#[test]
fn pocket_cut_removes_internal_wall_faces_in_actual_topology() {
- use solidcraft_geom::{Loop2, Region2, Vec2};
+ use solidcore_record::{Loop2, Region2, Vec2};
let region = Region2 {
outer: Loop2::polygon(&[Vec2::new(-30., -27.), Vec2::new(30., -27.), Vec2::new(30., 27.), Vec2::new(-30., 27.)]),
holes: vec![],
diff --git a/crates/kernel/src/plane_fit.rs b/crates/kernel/src/plane_fit.rs
index 7b3a828348..de4a22cac5 100644
--- a/crates/kernel/src/plane_fit.rs
+++ b/crates/kernel/src/plane_fit.rs
@@ -1,6 +1,6 @@
//! The area vector of a loop of points (Newell's method): its normal and the area it encloses.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
/// The area vector of a closed polygon (Newell's method): normal to the loop, as long as the area
/// it encloses, pointing the way the loop runs round by the right-hand rule.
diff --git a/crates/kernel/src/point_path.rs b/crates/kernel/src/point_path.rs
index 94bb0384e9..c125bc860e 100644
--- a/crates/kernel/src/point_path.rs
+++ b/crates/kernel/src/point_path.rs
@@ -6,10 +6,11 @@
//! [`PathSeg::Bezier`] ([`SpaceBezier`]); [`PointPath::points`] is its polyline, for what takes
//! points (rails, curve networks).
-use solidcraft_geom::brep;
+use solidcore_record::brep;
+use solidcore_record::{MAX_BEZIER_CTRL, MAX_BEZIER_DEGREE, Plane, Region2, Vec3};
use solidcraft_geom::bspline::{HPoint, bezier_point, segment};
use solidcraft_geom::catmull_rom;
-use solidcraft_geom::{MAX_BEZIER_CTRL, MAX_BEZIER_DEGREE, Plane, Region2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::{KernelError, PathSeg, Result, SweepControl};
@@ -189,7 +190,7 @@ pub fn project_onto_face(
body: &Body,
face_at: Vec3,
plane: &Plane,
- segs: &[solidcraft_geom::Seg2],
+ segs: &[solidcore_record::Seg2],
direction: Vec3,
) -> Result<Vec<(brep::Curve, [f64; 2])>> {
if !(face_at.is_finite() && direction.is_finite() && direction.len() > 1e-12) || segs.is_empty() || segs.len() > 4096 {
@@ -306,14 +307,14 @@ pub fn curve_path(c: &brep::Curve, [t0, t1]: [f64; 2]) -> Result<Vec<PathSeg>> {
/// segment's way: a line, a circle (an arc's; clockwise ones on the frame turned over), a cubic
/// or Bézier as a spline of its degree, a conic as a rational quadratic. `None` for a segment
/// with non-finite numbers.
-pub fn sketch_record_curve(plane: &Plane, s: &solidcraft_geom::Seg2) -> Option<(brep::Curve, [f64; 2])> {
- use solidcraft_geom::Seg2;
- let w = |p: solidcraft_geom::Vec2| {
+pub fn sketch_record_curve(plane: &Plane, s: &solidcore_record::Seg2) -> Option<(brep::Curve, [f64; 2])> {
+ use solidcore_record::Seg2;
+ let w = |p: solidcore_record::Vec2| {
let q = plane.to_world(p);
[q.x, q.y, q.z]
};
let d = |v: Vec3| [v.x, v.y, v.z];
- let bezier = |pts: &[solidcraft_geom::Vec2]| {
+ let bezier = |pts: &[solidcore_record::Vec2]| {
let n = pts.len().checked_sub(1)?;
let knots = std::iter::repeat_n(0.0, n + 1).chain(std::iter::repeat_n(1.0, n + 1)).collect();
Some((brep::Curve::Spline { knots, points: pts.iter().map(|p| w(*p)).collect() }, [0.0, 1.0]))
@@ -328,7 +329,7 @@ pub fn sketch_record_curve(plane: &Plane, s: &solidcraft_geom::Seg2) -> Option<(
Seg2::Cubic { p0, p1, p2, p3 } => bezier(&[p0, p1, p2, p3])?,
Seg2::Bezier { n, p } => bezier(p.get(..=usize::from(n))?)?,
Seg2::Conic { a, apex, b, w: wt } => {
- let h = |p: solidcraft_geom::Vec2, k: f64| {
+ let h = |p: solidcore_record::Vec2, k: f64| {
let q = w(p);
[q[0] * k, q[1] * k, q[2] * k, k]
};
diff --git a/crates/kernel/src/polybool.rs b/crates/kernel/src/polybool.rs
index 59deb92792..ce4b8952c0 100644
--- a/crates/kernel/src/polybool.rs
+++ b/crates/kernel/src/polybool.rs
@@ -3,9 +3,11 @@
//! SMLib's boolean takes with the body as it is. The result's history is over the body and the
//! mesh, the mesh's faces being its triangles.
+use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
-use solidcraft_geom::{Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Mesh;
use crate::body::Body;
use crate::heal::find;
diff --git a/crates/kernel/src/polyhedron.rs b/crates/kernel/src/polyhedron.rs
index 2718ba001b..5434253606 100644
--- a/crates/kernel/src/polyhedron.rs
+++ b/crates/kernel/src/polyhedron.rs
@@ -4,10 +4,11 @@
//! planes (vertices are triple-plane intersections, edges lines, faces planes, pcurves exact),
//! taken by SMLib and checked there.
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::{self as rec, Curve2, EdgeUseRef, Loop, OrientedEdge, OrientedFace};
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self as rec, Curve2, EdgeUseRef, Loop, OrientedEdge, OrientedFace};
use crate::body::Body;
use crate::{KernelError, Result};
@@ -180,7 +181,7 @@ fn polyhedron_record(hs: &[HalfSpace], verts: &[Vec3], faces: &[(usize, Vec<usiz
edges,
vertices,
};
- brep.validate().map_err(|e| KernelError::Failed(format!("polyhedron: {e}")))?;
+ solidcraft_geom::brep::check::validate(&brep).map_err(|e| KernelError::Failed(format!("polyhedron: {e}")))?;
Ok(brep)
}
@@ -196,7 +197,7 @@ pub fn shell(b: &Body, open: &[Vec3], thickness: f64) -> Result<Body> {
/// Tilt the faces near `faces` by `angle` about their line on the neutral plane, so that they
/// lean in (positive angle) going along `pull` (SMLib's draft).
-pub fn draft(b: &Body, faces: &[Vec3], neutral: &solidcraft_geom::Plane, pull: Vec3, angle: f64) -> Result<Body> {
+pub fn draft(b: &Body, faces: &[Vec3], neutral: &solidcore_record::Plane, pull: Vec3, angle: f64) -> Result<Body> {
let _span = solidcraft_profile::span("kernel", "draft");
b.require_brep("draft")?;
crate::offset_backend::draft(b, faces, neutral, pull, angle)
diff --git a/crates/kernel/src/prism.rs b/crates/kernel/src/prism.rs
index e89b188b13..9a1386b999 100644
--- a/crates/kernel/src/prism.rs
+++ b/crates/kernel/src/prism.rs
@@ -4,7 +4,8 @@
//! result's boundaries are the operands' curves, cut at their crossings and never refitted.
//! Also the test of whether a record surface is a wall swept along a direction.
-use solidcraft_geom::{Plane, Region2, Seg2, Vec2};
+use solidcore_record::{Plane, Region2, Seg2, Vec2};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::{BoolOp, KernelError, Result};
@@ -109,10 +110,10 @@ struct Regions {
}
mod sheets {
- use solidcraft_geom::Loop2;
- use solidcraft_geom::Vec3;
- use solidcraft_geom::brep::Loop;
- use solidcraft_geom::brep::Surface;
+ use solidcore_record::Loop2;
+ use solidcore_record::Vec3;
+ use solidcore_record::brep::Loop;
+ use solidcore_record::brep::Surface;
use solidcraft_smlib::{BooleanOp, Brep};
use super::*;
@@ -292,7 +293,7 @@ mod sheets {
#[allow(clippy::unwrap_used, clippy::panic)]
mod planar_tests {
use super::*;
- use solidcraft_geom::Loop2;
+ use solidcore_record::Loop2;
#[test]
fn single_prism_intersection_uses_common_height_in_both_orders() {
for k in [1.0, 0.05] {
@@ -303,9 +304,9 @@ mod planar_tests {
(22.5, 10.0, None),
(25.0, 10.0, None),
] {
- let a = crate::cylinder(solidcraft_geom::Vec3::new(12.5, 5.0, 5.0) * k, solidcraft_geom::Vec3::Z, 2.5 * k, 17.5 * k).unwrap();
- let b =
- crate::box_solid(solidcraft_geom::Vec3::new(10.0, 5.0, lo) * k, solidcraft_geom::Vec3::new(22.5, 10.0, lo + height) * k).unwrap();
+ let a = crate::cylinder(solidcore_record::Vec3::new(12.5, 5.0, 5.0) * k, solidcore_record::Vec3::Z, 2.5 * k, 17.5 * k).unwrap();
+ let b = crate::box_solid(solidcore_record::Vec3::new(10.0, 5.0, lo) * k, solidcore_record::Vec3::new(22.5, 10.0, lo + height) * k)
+ .unwrap();
for (lhs, rhs) in [(&a, &b), (&b, &a)] {
let result = crate::boolean(lhs, rhs, BoolOp::Intersect).unwrap();
if let Some((bottom, top)) = expected {
diff --git a/crates/kernel/src/prism_curve.rs b/crates/kernel/src/prism_curve.rs
index 4b4e47aa0a..e6b11f7001 100644
--- a/crates/kernel/src/prism_curve.rs
+++ b/crates/kernel/src/prism_curve.rs
@@ -2,10 +2,11 @@
//! record edges. A record's lines and circles are read as they are; a spline is read span by
//! span (its Bézier pieces): samples propose a circle, and only positive rational Bernstein
//! bounds accept it.
+use solidcore_record::brep::{Brep, Curve};
+use solidcore_record::{Plane, Seg2, Vec2, Vec3};
use solidcraft_geom::brep::eval::CurveEval;
-use solidcraft_geom::brep::{Brep, Curve};
use solidcraft_geom::bspline::{self, HPoint};
-use solidcraft_geom::{Plane, Seg2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
const MAX_DEGREE: usize = 32;
/// How far an arc read off a curve may end from the curve's end (mm): half the gap a profile
@@ -587,7 +588,7 @@ fn off_chord(pts: &[Vec2]) -> f64 {
/// One Bézier span that is neither a line nor an arc, as the exact free-form segment it is
/// (a font's quadratic or cubic, a conic), its ends `a` and `b`. `None` for several spans (a
-/// curve that may wind about more than once), degrees past [`solidcraft_geom::MAX_BEZIER_DEGREE`],
+/// curve that may wind about more than once), degrees past [`solidcore_record::MAX_BEZIER_DEGREE`],
/// rational spans other than conics, and control polygons with no area (a curve doubling back
/// along a line).
fn free_form(spans: &[Vec<H>], a: Vec2, b: Vec2, tol: f64) -> Option<Vec<Seg2>> {
@@ -755,8 +756,8 @@ mod tests {
/// `c` over its whole domain, run forward (or back).
fn run(c: &Curve, forward: bool) -> Run<'_> {
let interval = match c.natural() {
- solidcraft_geom::brep::Natural::Range(a, b) => [a, b],
- solidcraft_geom::brep::Natural::Periodic => [0., std::f64::consts::TAU],
+ solidcore_record::brep::Natural::Range(a, b) => [a, b],
+ solidcore_record::brep::Natural::Periodic => [0., std::f64::consts::TAU],
};
let ends = [at(c, interval[0]), at(c, interval[1])];
Run { curve: c, interval, forward, ends: if forward { ends } else { [ends[1], ends[0]] } }
diff --git a/crates/kernel/src/prism_measure.rs b/crates/kernel/src/prism_measure.rs
index 3c5b5de0bd..3fa7047522 100644
--- a/crates/kernel/src/prism_measure.rs
+++ b/crates/kernel/src/prism_measure.rs
@@ -1,9 +1,11 @@
//! Independent current-geometry intervals for uniform prisms, read off the body's schema 4
//! record. These are not mesh measurements or certificates of construction history.
use crate::prism_curve::{Run, segment};
+use solidcore_record::brep::{Brep, Curve, Loop, Shell, Surface};
+use solidcore_record::{Plane, Seg2, Vec2, Vec3};
+use solidcraft_geom::Ring;
use solidcraft_geom::brep::eval::CurveEval;
-use solidcraft_geom::brep::{Brep, Curve, Loop, Shell, Surface};
-use solidcraft_geom::{Plane, Ring, Seg2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
fn v3(p: [f64; 3]) -> Vec3 {
Vec3::new(p[0], p[1], p[2])
@@ -645,7 +647,7 @@ pub struct PrismSection {
pub lo: f64,
pub hi: f64,
/// Its section, exact: lines and arcs, the outer loop counter-clockwise, the holes clockwise.
- pub region: solidcraft_geom::Region2,
+ pub region: solidcore_record::Region2,
/// How far the levels may be off the body's caps (the caps' vertices lie within it of them).
pub tolerance: f64,
}
@@ -668,7 +670,7 @@ pub fn certified_prism_section(body: &crate::Body, plane: &Plane) -> crate::Resu
let mut holes = Vec::new();
for lp in c.loops {
let positive = lp.area.lo > 0.;
- let lp = solidcraft_geom::Loop2 { segs: lp.segments.into_vec() };
+ let lp = solidcore_record::Loop2 { segs: lp.segments.into_vec() };
if positive {
if outer.replace(lp).is_some() {
return Ok(None);
@@ -681,7 +683,7 @@ pub fn certified_prism_section(body: &crate::Body, plane: &Plane) -> crate::Resu
// The caps' vertices are within twice the tolerance of their levels (`certificate`), and
// the levels are worked out from the plane's origin.
let tolerance = 2. * tol + 128. * f64::EPSILON * (plane.origin.len() + c.lo.abs() + c.hi.abs()).max(1.);
- Ok(Some(PrismSection { lo: c.lo, hi: c.hi, region: solidcraft_geom::Region2 { outer, holes }, tolerance }))
+ Ok(Some(PrismSection { lo: c.lo, hi: c.hi, region: solidcore_record::Region2 { outer, holes }, tolerance }))
})
}
@@ -850,7 +852,7 @@ mod tests {
use super::*;
fn drilled(radius: f64, shift: f64) -> crate::Body {
- use solidcraft_geom::{Loop2, Region2};
+ use solidcore_record::{Loop2, Region2};
let region = Region2 {
outer: Loop2::polygon(&[Vec2::ZERO, Vec2::new(20., 0.), Vec2::new(20., 20.), Vec2::new(0., 20.)]),
holes: vec![Loop2::circle(Vec2::new(10. + shift, 10.), radius)],
@@ -877,7 +879,7 @@ mod tests {
/// above it steps (the pin stands up through it) and is no prism.
#[test]
fn a_trimmed_tool_reads_as_the_prism_of_its_current_section() {
- use solidcraft_geom::{Loop2, Region2};
+ use solidcore_record::{Loop2, Region2};
let pin = crate::cylinder(Vec3::new(25., 25., 0.), Vec3::Z, 2., 20.).unwrap();
let stop = crate::box_solid(Vec3::new(19., 19., 1.), Vec3::new(31., 31., 2.)).unwrap();
let roof = crate::boolean(&pin, &stop, crate::BoolOp::Union).unwrap().unwrap();
@@ -1026,7 +1028,7 @@ mod tests {
let retraced =
CapLoop { segments: Ring::from([arc, arc.reversed(), arc]), area: Interval::enclosing(36. * std::f64::consts::PI, 1e-8).unwrap() };
assert!(circle(&retraced, 1e-6).is_none());
- let region = solidcraft_geom::Loop2::polygon(&[Vec2::ZERO, Vec2::new(20., 0.), Vec2::new(20., 20.), Vec2::new(0., 20.)]);
+ let region = solidcore_record::Loop2::polygon(&[Vec2::ZERO, Vec2::new(20., 0.), Vec2::new(20., 20.), Vec2::new(0., 20.)]);
let doubled = CapLoop { segments: region.segs.iter().chain(&region.segs).copied().collect(), area: Interval::enclosing(800., 1e-8).unwrap() };
assert!(separated_material(&[doubled], 1e-6, &mut 16_000_000).is_none());
// Thinner than a body's tolerance (2e-5): SMLib refuses it as a solid; built, it gets none.
diff --git a/crates/kernel/src/profile.rs b/crates/kernel/src/profile.rs
index b4665560c9..7f61c7ee72 100644
--- a/crates/kernel/src/profile.rs
+++ b/crates/kernel/src/profile.rs
@@ -166,7 +166,7 @@ mod tests {
#[test]
fn a_faceted_boolean_is_boolean_time_and_a_reference_mesh_tessellation() {
use crate::{BoolOp, box_solid, faceted_boolean};
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let a = box_solid(Vec3::ZERO, Vec3::new(10.0, 10.0, 10.0)).unwrap();
let tool = box_solid(Vec3::new(5.0, 5.0, 5.0), Vec3::new(15.0, 15.0, 15.0)).unwrap().mesh(&crate::MeshTolerance::chord(0.1)).unwrap();
// The thread groove's route: the faceting it does first is the boolean's time too.
@@ -181,7 +181,7 @@ mod tests {
#[test]
fn kernel_operations_are_profiler_spans_with_smlib_calls_inside() {
use crate::{BoolOp, boolean, box_solid};
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
solidcraft_profile::set_enabled(true);
let mark = solidcraft_profile::mark();
let a = box_solid(Vec3::ZERO, Vec3::new(10.0, 10.0, 10.0)).unwrap();
diff --git a/crates/kernel/src/provenance.rs b/crates/kernel/src/provenance.rs
index 4a47d718bb..c39b7e5327 100644
--- a/crates/kernel/src/provenance.rs
+++ b/crates/kernel/src/provenance.rs
@@ -8,9 +8,11 @@
//! name the same one. Operations that know more (which profile segment a side face sweeps,
//! which edge a blend replaces) fill in generated faces' origins themselves.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeSet;
-use solidcraft_geom::{Aabb3, Mesh, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Plane, Region2, Seg2, Vec2, Vec3};
+use solidcraft_geom::{Aabb3, Mesh};
use crate::Result;
use crate::body::Body;
@@ -376,7 +378,8 @@ pub fn compose(prov: &mut History, operand: usize, tool: &[FaceOrigin]) {
#[cfg(test)]
mod tests {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
+ use solidcraft_geom::prelude::*;
use super::{Change, FaceOrigin, trace};
use crate::{BoolOp, boolean, box_solid, cylinder};
@@ -437,7 +440,7 @@ mod tests {
#[test]
fn provenance_of_sweeps_blends_and_shells() {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
use super::{History, blend_origins, compose, extrude_origins, offset_origins, revolve_origins};
let plane = Plane::named("XY").unwrap();
diff --git a/crates/kernel/src/record.rs b/crates/kernel/src/record.rs
index 1fa9ba3822..279cf096c5 100644
--- a/crates/kernel/src/record.rs
+++ b/crates/kernel/src/record.rs
@@ -7,7 +7,7 @@
use std::collections::BTreeSet;
-use solidcraft_geom::brep::Brep;
+use solidcore_record::brep::Brep;
use crate::body::Body;
use crate::history::{Change, EdgeOrigin, EdgeProv, FaceOrigin, FaceProv, History, edge_faces};
@@ -39,7 +39,7 @@ pub(crate) fn generated(origins: Vec<FaceOrigin>) -> FaceProv {
FaceProv { origins, change: Change::Generated }
}
-pub(crate) use solidcraft_geom::brep::history::mark_shared_split;
+pub(crate) use solidcore_record::brep::history::mark_shared_split;
/// The origins of a result edge that is (a piece of, or the moved) edges `edges` of operand
/// `operand`.
diff --git a/crates/kernel/src/record_tests.rs b/crates/kernel/src/record_tests.rs
index b99d1db8e2..124cfa3899 100644
--- a/crates/kernel/src/record_tests.rs
+++ b/crates/kernel/src/record_tests.rs
@@ -1,9 +1,10 @@
//! The creation builders' histories: every face's origin checked against the geometry the
//! builder made it from.
+use solidcraft_geom::prelude::*;
use std::f64::consts::{FRAC_PI_2, PI, TAU};
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
use crate::body::Body;
use crate::build::PathSeg;
diff --git a/crates/kernel/src/regularization_protection_tests.rs b/crates/kernel/src/regularization_protection_tests.rs
index c87be57cf0..860c9f38d3 100644
--- a/crates/kernel/src/regularization_protection_tests.rs
+++ b/crates/kernel/src/regularization_protection_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use solidcraft_geom::Plane;
+use solidcore_record::Plane;
fn stamped_stock() -> Body {
crate::box_solid(Vec3::new(-20., -15., 0.), Vec3::new(20., 15., 24.)).unwrap().with_box_certificate(7).unwrap()
diff --git a/crates/kernel/src/repair.rs b/crates/kernel/src/repair.rs
index 348ae38980..81a3565935 100644
--- a/crates/kernel/src/repair.rs
+++ b/crates/kernel/src/repair.rs
@@ -16,9 +16,10 @@
//! Nothing is moved: a face rebuilt keeps its surface, a sewn edge keeps its curve (SMLib keeps
//! one of the pair), a patch is a new face. What was done comes back in [`RepairReport`].
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self as b, Brep};
use solidcraft_geom::brep::eval::CurveEval;
-use solidcraft_geom::brep::{self as b, Brep};
+use solidcraft_geom::prelude::*;
use crate::body::{Body, SurfaceKind};
use crate::{Continuity, KernelError, Result};
@@ -250,12 +251,12 @@ fn rebuild_refused(record: &mut Brep, report: &mut RepairReport) -> Result<()> {
/// Face `f` of `r` rebuilt on its own surface: a cylinder, cone, sphere or torus face on a
/// NURBS form of the surface laid on arcs from where the face starts
-/// ([`b::form::surface_on_own_arcs`]) instead of its frame's quarter grid, the same surface
+/// ([`solidcraft_geom::brep::form::surface_on_own_arcs`]) instead of its frame's quarter grid, the same surface
/// exactly, with SMLib's own trims of the face's edges on it (`SmlibTrims`, as the import makes the
/// trims it has no closed form for). The face's edges and loops stay as they were. `None` for a
/// face on another surface.
fn rebuilt_face(r: &Brep, f: usize) -> Result<Option<b::Face>> {
- use b::pcurve::{TrimEdge, TrimFace, TrimUse, Trims};
+ use solidcraft_geom::brep::pcurve::{TrimEdge, TrimFace, TrimUse, Trims};
let face = r.faces.get(f).ok_or_else(|| invalid(format!("no face {f}")))?;
if !matches!(face.surface, b::Surface::Cylinder { .. } | b::Surface::Cone { .. } | b::Surface::Sphere { .. } | b::Surface::Torus { .. }) {
return Ok(None);
@@ -304,8 +305,8 @@ fn rebuilt_face(r: &Brep, f: usize) -> Result<Option<b::Face>> {
.iter()
.map(|&v| r.vertices.get(v as usize).map(|v| v.point).ok_or_else(|| invalid(format!("no vertex {v}"))))
.collect::<Result<Vec<_>>>()?;
- let extent = b::form::extent(&face.surface, &boundary).ok_or_else(|| invalid("its boundary does not lie on its surface"))?;
- let (form, domain) = b::form::surface_on_own_arcs(
+ let extent = solidcraft_geom::brep::form::extent(&face.surface, &boundary).ok_or_else(|| invalid("its boundary does not lie on its surface"))?;
+ let (form, domain) = solidcraft_geom::brep::form::surface_on_own_arcs(
&face.surface,
extent,
local.iter().filter_map(|&e| r.edges.get(e as usize)).map(|e| e.tolerance).fold(r.tolerance, f64::max),
diff --git a/crates/kernel/src/seam_faces_tests.rs b/crates/kernel/src/seam_faces_tests.rs
index f8c56a8968..80cd8c736c 100644
--- a/crates/kernel/src/seam_faces_tests.rs
+++ b/crates/kernel/src/seam_faces_tests.rs
@@ -1,7 +1,7 @@
//! Round faces read from STEP: a whole turn bounded by one wire that runs along its seam twice.
//! A boolean whose intersection loop lies wholly inside such a face is exact.
use crate::*;
-use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
use std::f64::consts::PI;
const R: f64 = 4.5;
diff --git a/crates/kernel/src/sew.rs b/crates/kernel/src/sew.rs
index 81d6ad68be..85372dfdb2 100644
--- a/crates/kernel/src/sew.rs
+++ b/crates/kernel/src/sew.rs
@@ -10,12 +10,15 @@
//! body from. No tolerance stitching is involved: two sheets of material meeting along one
//! geometric edge keep an edge each.
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
use std::sync::Arc;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self as b, Curve2};
+use solidcraft_geom::Ring;
use solidcraft_geom::brep::eval::{SurfaceEval, face_flux};
-use solidcraft_geom::brep::{self as b, Curve2, pcurve};
-use solidcraft_geom::{Ring, Vec3};
+use solidcraft_geom::brep::pcurve;
use crate::body::Body;
use crate::{KernelError, Result, guard};
@@ -1379,7 +1382,7 @@ pub(crate) fn assemble(parts: Parts, solid: bool) -> Result<Assembled> {
// keeps it, and an edge the caller gave a pcurve for keeps the parameter that pcurve is on.
let mut frames_of: Vec<Vec<b::Frame>> = vec![Vec::new(); edges.len()];
for f in &faces {
- let Some(frame) = b::form::frame_of(&f.surface) else { continue };
+ let Some(frame) = solidcraft_geom::brep::form::frame_of(&f.surface) else { continue };
for u in f.loops.iter().flatten() {
if let Some(slot) = frames_of.get_mut(u.edge as usize) {
slot.push(frame.clone());
@@ -1390,8 +1393,8 @@ pub(crate) fn assemble(parts: Parts, solid: bool) -> Result<Assembled> {
let mut forms: Vec<Option<(b::Curve, [f64; 2])>> = Vec::with_capacity(edges.len());
for ((e, frames), given) in edges.iter().zip(&frames_of).zip(&given_on) {
if let Some(form) = &e.nurbs {
- let on_label =
- b::curve_interval(&e.curve, Some(form), e.interval).ok_or_else(|| fail("an edge's NURBS form does not evaluate".into()))?;
+ let on_label = solidcraft_geom::brep::label::curve_interval(&e.curve, Some(form), e.interval)
+ .ok_or_else(|| fail("an edge's NURBS form does not evaluate".into()))?;
labels.push((e.curve.clone(), on_label));
forms.push(Some((form.clone(), e.interval)));
continue;
@@ -1402,7 +1405,7 @@ pub(crate) fn assemble(parts: Parts, solid: bool) -> Result<Assembled> {
continue;
}
let (label, interval, form) =
- b::form::edge(&e.curve, e.interval, frames.iter(), tol).ok_or_else(|| fail("an arc of more than one turn".into()))?;
+ solidcraft_geom::brep::form::edge(&e.curve, e.interval, frames.iter(), tol).ok_or_else(|| fail("an arc of more than one turn".into()))?;
labels.push((label, interval));
forms.push(form);
}
@@ -1432,8 +1435,9 @@ pub(crate) fn assemble(parts: Parts, solid: bool) -> Result<Assembled> {
.iter()
.map(|l| l.iter().filter_map(|&(e, forward, _)| labels.get(e as usize).map(|(c, i)| (c, *i, forward))).collect())
.collect();
- let extent = b::form::extent(&f.surface, &boundary).ok_or_else(|| fail(format!("face {fi}: its boundary is not on its surface")))?;
- Some(b::form::surface(&f.surface, extent).ok_or_else(|| fail(format!("face {fi}: more than one turn")))?)
+ let extent = solidcraft_geom::brep::form::extent(&f.surface, &boundary)
+ .ok_or_else(|| fail(format!("face {fi}: its boundary is not on its surface")))?;
+ Some(solidcraft_geom::brep::form::surface(&f.surface, extent).ok_or_else(|| fail(format!("face {fi}: more than one turn")))?)
}
_ => None,
};
@@ -1636,7 +1640,7 @@ fn domain_of(surface: &b::Surface, pcs: &[Vec<Curve2>]) -> Option<[[f64; 2]; 2]>
}
}
}
- let natural = surface.natural();
+ let natural = solidcraft_geom::brep::label::surface_natural(surface);
let mut out = [[0.0; 2]; 2];
for d in 0..2 {
let (mut a, mut z) = (lo[d], hi[d]);
diff --git a/crates/kernel/src/shell_groups.rs b/crates/kernel/src/shell_groups.rs
index ac1fa3bab3..0873705aca 100644
--- a/crates/kernel/src/shell_groups.rs
+++ b/crates/kernel/src/shell_groups.rs
@@ -1,7 +1,9 @@
//! Group disconnected material regions without moving a cavity to another enclosing shell.
//! A valid shell hierarchy alternates material and void at every nesting level.
-use solidcraft_geom::{Aabb3, BoxedTriangle, Mesh, Vec3, find_close_pair};
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
+use solidcraft_geom::{Aabb3, BoxedTriangle, Mesh, find_close_pair};
use crate::{KernelError, Result};
diff --git a/crates/kernel/src/smlib_sweeps.rs b/crates/kernel/src/smlib_sweeps.rs
index e326203bc3..984fde86fc 100644
--- a/crates/kernel/src/smlib_sweeps.rs
+++ b/crates/kernel/src/smlib_sweeps.rs
@@ -17,7 +17,8 @@
//! revolutions); the face in the start plane is the start cap, the one in the end plane (or,
//! where the sweep has no end plane, the planar face left over) the end cap.
-use solidcraft_geom::{Plane, Region2, Seg2, Vec3};
+use solidcore_record::{Plane, Region2, Seg2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::numbered::{NumberedLoop, NumberedRegion};
@@ -86,7 +87,7 @@ mod imp {
use solidcraft_smlib::sweeps::{Affine, Curve, DraftCorner, Ends, SweepFrame};
use solidcraft_smlib::{Brep, CheckLevel};
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
use super::*;
use crate::history::FaceProv;
@@ -172,7 +173,7 @@ mod imp {
/// The body (a solid or a sheet) a schema 4 record describes, taken by SMLib as a
/// modeller's own record (no healing) and checked there.
- pub(crate) fn body_from_record(record: &solidcraft_geom::brep::Brep, what: &str) -> Result<Body> {
+ pub(crate) fn body_from_record(record: &solidcore_record::brep::Brep, what: &str) -> Result<Body> {
let brep = Brep::from_record(record, true).map_err(|e| failed(what, e))?;
body_of(brep, what)
}
@@ -187,7 +188,7 @@ mod imp {
plane: &Plane,
segs: &[Seg2],
direction: Vec3,
- ) -> Result<Vec<(solidcraft_geom::brep::Curve, [f64; 2])>> {
+ ) -> Result<Vec<(solidcore_record::brep::Curve, [f64; 2])>> {
let c = segs.iter().map(|s| curve(plane, s)).collect::<Result<Vec<_>>>()?;
let out = body
.smlib()?
@@ -198,7 +199,12 @@ mod imp {
/// The face of `body` at `face_at` cut by the plane through `plane_point` square to `normal`,
/// SMLib's section curves on that face, as record curves on their intervals.
- pub(crate) fn face_section(body: &Body, face_at: Vec3, plane_point: Vec3, normal: Vec3) -> Result<Vec<(solidcraft_geom::brep::Curve, [f64; 2])>> {
+ pub(crate) fn face_section(
+ body: &Body,
+ face_at: Vec3,
+ plane_point: Vec3,
+ normal: Vec3,
+ ) -> Result<Vec<(solidcore_record::brep::Curve, [f64; 2])>> {
let out = body
.smlib()?
.face_section(p(face_at), pick_reach(body), p(plane_point), p(normal), curve_tolerance(body))
@@ -226,12 +232,12 @@ mod imp {
}
/// SMLib's NURBS curves as record curves (rational splines) on their intervals.
- fn record_curves(out: Vec<(Curve, [f64; 2])>, what: &str) -> Result<Vec<(solidcraft_geom::brep::Curve, [f64; 2])>> {
+ fn record_curves(out: Vec<(Curve, [f64; 2])>, what: &str) -> Result<Vec<(solidcore_record::brep::Curve, [f64; 2])>> {
out.into_iter()
.map(|(c, interval)| match c {
Curve::Nurbs { points, knots, .. } => {
let homogeneous = points.iter().map(|q| [q[0] * q[3], q[1] * q[3], q[2] * q[3], q[3]]).collect();
- Ok((solidcraft_geom::brep::Curve::RationalSpline { knots, homogeneous }, interval))
+ Ok((solidcore_record::brep::Curve::RationalSpline { knots, homogeneous }, interval))
}
_ => Err(failed(what, "a curve SMLib made is not a B-spline")),
})
@@ -1083,7 +1089,7 @@ mod imp {
/// The centre and radius of `lp` when it is one circle (in one or several arcs) centred on the
/// line through `start` along the unit `k`.
- fn circle_on_axis(plane: &Plane, lp: &solidcraft_geom::Loop2, start: Vec3, k: Vec3) -> Option<(Vec3, f64)> {
+ fn circle_on_axis(plane: &Plane, lp: &solidcore_record::Loop2, start: Vec3, k: Vec3) -> Option<(Vec3, f64)> {
let mut circle: Option<(Vec3, f64)> = None;
let mut turn = 0.0;
for s in &lp.segs {
diff --git a/crates/kernel/src/smlib_sweeps_tests.rs b/crates/kernel/src/smlib_sweeps_tests.rs
index 4ce441d73a..ea1443cda2 100644
--- a/crates/kernel/src/smlib_sweeps_tests.rs
+++ b/crates/kernel/src/smlib_sweeps_tests.rs
@@ -1,9 +1,10 @@
//! The sweeps through SMLib ([`crate::smlib_sweeps`]): analytic volumes, and the history and
//! construction sources the builders' vocabulary gives each face.
+use solidcraft_geom::prelude::*;
use std::f64::consts::{PI, TAU};
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
use crate::FaceSource;
use crate::body::Body;
diff --git a/crates/kernel/src/smooth_edges.rs b/crates/kernel/src/smooth_edges.rs
index b5ab06441c..ae718e6df7 100644
--- a/crates/kernel/src/smooth_edges.rs
+++ b/crates/kernel/src/smooth_edges.rs
@@ -14,9 +14,11 @@
//! display-only: the edge keeps its identity, stays pickable and stays in the wireframe, and its
//! faces stay apart (pieces of one surface are [`crate::topo::seam_flags`]'s business). Unknown
//! geometry (a station that does not evaluate) keeps its existing presentation.
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Brep, Loop, Shell};
+use solidcraft_geom::Mesh;
use solidcraft_geom::brep::eval::{CurveEval, SurfaceEval};
-use solidcraft_geom::brep::{Brep, Loop, Shell};
-use solidcraft_geom::{Mesh, Vec3};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
@@ -163,7 +165,7 @@ fn join(record: &Brep, faces: &[Option<FaceEval>], e: usize, length: f64, work:
let unknown = Join::default();
let Some(edge) = record.edges.get(e) else { return unknown };
let [a, b] = edge.uses.as_slice() else { return unknown };
- let side = |u: &solidcraft_geom::brep::EdgeUseRef| {
+ let side = |u: &solidcore_record::brep::EdgeUseRef| {
let face = faces.get(u.face as usize)?.as_ref()?;
let Loop::Edges { edges } = record.faces.get(u.face as usize)?.loops.get(u.r#loop as usize)? else { return None };
let used = edges.get(u.position as usize)?;
@@ -180,7 +182,7 @@ fn join(record: &Brep, faces: &[Option<FaceEval>], e: usize, length: f64, work:
let Some(left) = work.checked_sub(2) else { return unknown };
*work = left;
let t = t0 + (t1 - t0) * (k as f64 + 0.5) / STATIONS as f64;
- let (Some(ua), Some(ub)) = (pa.eval(t), pb.eval(t)) else { return unknown };
+ let (Some(ua), Some(ub)) = (solidcraft_geom::brep::pcurve::eval(pa, t), solidcraft_geom::brep::pcurve::eval(pb, t)) else { return unknown };
let (Some(sa), Some(sb)) = (station(fa, ua), station(fb, ub)) else { return unknown };
let (Some(sa), Some(sb)) = (sa, sb) else { continue };
let angle = sa.normal.cross(sb.normal).len().atan2(sa.normal.dot(sb.normal));
@@ -344,8 +346,8 @@ fn whole_joins(record: &Brep, measured: &[usize], smooth: &mut [bool], mut work:
#[allow(clippy::unwrap_used)]
mod tests {
use super::*;
- use solidcraft_geom::brep::Surface;
- use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2};
+ use solidcore_record::brep::Surface;
+ use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2};
fn circle(radius: f64, count: usize) -> Loop2 {
let step = std::f64::consts::TAU / count as f64;
@@ -584,7 +586,7 @@ mod tests {
fn a_degenerate_normal_says_nothing() {
let face = FaceEval {
surface: SurfaceEval::new(&Surface::Sphere {
- frame: solidcraft_geom::brep::Frame { origin: [0.; 3], x_axis: [1., 0., 0.], y_axis: [0., 1., 0.] },
+ frame: solidcore_record::brep::Frame { origin: [0.; 3], x_axis: [1., 0., 0.], y_axis: [0., 1., 0.] },
radius: 2.,
})
.unwrap(),
diff --git a/crates/kernel/src/sphere_lens_tests.rs b/crates/kernel/src/sphere_lens_tests.rs
index d12e7a3422..c090233345 100644
--- a/crates/kernel/src/sphere_lens_tests.rs
+++ b/crates/kernel/src/sphere_lens_tests.rs
@@ -2,7 +2,7 @@
//! cylinders encloses the target and only touches the sphere.
use crate::history::BodyHistory;
use crate::{Body, BoolOp};
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
use std::f64::consts::{FRAC_PI_2, PI};
fn dome() -> Body {
diff --git a/crates/kernel/src/splitface.rs b/crates/kernel/src/splitface.rs
index 1fc8031929..0da42b23d3 100644
--- a/crates/kernel/src/splitface.rs
+++ b/crates/kernel/src/splitface.rs
@@ -17,12 +17,14 @@
//! point. Every patch's normal points to the tool's positive side: a plane's normal, a face's
//! outward side, the left of a sketch curve (inside a closed one, counter-clockwise).
+use solidcraft_geom::prelude::*;
use std::f64::consts::TAU;
+use solidcore_record::brep::{self, Frame, Surface};
+use solidcore_record::{Plane, Seg2, Vec2, Vec3};
+use solidcraft_geom::Aabb3;
use solidcraft_geom::brep::eval::{CurveEval, SurfaceEval};
-use solidcraft_geom::brep::{self, Frame, Surface};
use solidcraft_geom::tess::uv::Starts;
-use solidcraft_geom::{Aabb3, Plane, Seg2, Vec2, Vec3};
use crate::body::Body;
use crate::history::{EdgeOrigin, FaceOrigin, History};
diff --git a/crates/kernel/src/step_in/parallel.rs b/crates/kernel/src/step_in/parallel.rs
index e2b32c13db..378324e921 100644
--- a/crates/kernel/src/step_in/parallel.rs
+++ b/crates/kernel/src/step_in/parallel.rs
@@ -118,7 +118,7 @@ fn solid_part(solid: &solidcraft_step::topology::Solid) -> std::result::Result<P
let mut reversed = vec![false; r.faces.len()];
if solid.sheet {
for s in &r.shells {
- if let solidcraft_geom::brep::Shell::Faces { faces, .. } = s {
+ if let solidcore_record::brep::Shell::Faces { faces, .. } = s {
for f in faces.iter().filter(|f| !f.forward) {
if let Some(slot) = reversed.get_mut(f.face as usize) {
*slot = true;
@@ -155,7 +155,7 @@ fn renumbered() -> Failure {
}
/// The body SMLib makes of `record` as given, and the record's face each of its faces is.
-fn smlib_body(record: &solidcraft_geom::brep::Brep) -> std::result::Result<(Body, Vec<usize>), Failure> {
+fn smlib_body(record: &solidcore_record::brep::Brep) -> std::result::Result<(Body, Vec<usize>), Failure> {
let failed = |e: KernelError| Failure { read: false, msg: e.to_string().trim_start_matches("the operation failed: ").to_string() };
let (brep, smlib_order) = crate::native::smlib_record_ordered(record).map_err(failed)?;
let (body, body_order) = crate::native::body_from_smlib_ordered(&brep).map_err(failed)?;
diff --git a/crates/kernel/src/step_in/tests.rs b/crates/kernel/src/step_in/tests.rs
index cb0d13751a..e0972f14d2 100644
--- a/crates/kernel/src/step_in/tests.rs
+++ b/crates/kernel/src/step_in/tests.rs
@@ -1,4 +1,5 @@
-use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use super::*;
use crate::{BoolOp, boolean, box_solid, cylinder, extrude, fillet, measure, revolve, sphere, step_export, torus};
@@ -451,7 +452,7 @@ fn shelled_three_quarter_tube_round_trips() {
/// which SMLib does not take for a torus: the part came in as a mesh of its faces.
#[test]
fn half_tube_a_hair_off_its_torus_imports_as_a_solid() {
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
use std::f64::consts::PI;
let (major, minor) = (10.75, 1.25);
let d = Loop2 {
@@ -1442,7 +1443,7 @@ fn glued_halves_export_as_whole_faces() {
/// Read back, the part has its exact volume.
#[test]
fn rounded_slot_exports_cylinders() {
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
use std::f64::consts::{FRAC_PI_2, PI};
let outer = Loop2 {
segs: vec![
@@ -1477,7 +1478,7 @@ fn rounded_slot_exports_cylinders() {
/// by its surfaces saw a 60 mm part as 130 mm long), and the part reads back whole.
#[test]
fn ramp_cut_slot_exports_sheets_bounded_by_their_faces() {
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
use std::f64::consts::{FRAC_PI_2, PI};
let outer = Loop2 {
segs: vec![
@@ -2335,7 +2336,7 @@ fn a_refused_solid_comes_in_as_a_surface_body_of_the_faces_that_read() {
.shells
.iter()
.flat_map(|s| match s {
- solidcraft_geom::brep::Shell::Faces { faces, .. } => faces.iter().filter(|f| f.face as usize == bottom).map(|f| f.forward).collect(),
+ solidcore_record::brep::Shell::Faces { faces, .. } => faces.iter().filter(|f| f.face as usize == bottom).map(|f| f.forward).collect(),
_ => Vec::new(),
})
.collect();
@@ -2488,7 +2489,7 @@ fn a_round_face_off_its_frames_quarter_lines_is_formed_within_one_turn() {
let b = &imp.bodies[0];
assert!(b.closed && b.refused.is_none(), "{start} {sweep}: {:?} {:?}", b.refused, imp.warnings);
let wall = b.face_origin.iter().position(|f| *f == 53).unwrap();
- let Some(solidcraft_geom::brep::Surface::RationalSpline { u_knots, .. }) = &b.body.record().faces[wall].nurbs else {
+ let Some(solidcore_record::brep::Surface::RationalSpline { u_knots, .. }) = &b.body.record().faces[wall].nurbs else {
panic!("the wall's form")
};
assert!(u_knots[u_knots.len() - 1] - u_knots[0] <= 4.0, "{start}: the wall's form spans {u_knots:?}");
@@ -2604,7 +2605,7 @@ fn a_balls_halves_with_seams_off_each_others_quarter_lines_each_form_within_one_
let meshed = b.body.faces(0.005).unwrap();
for half in [56, 66] {
let fi = b.face_origin.iter().position(|f| *f == half).unwrap();
- let Some(solidcraft_geom::brep::Surface::RationalSpline { u_knots, .. }) = &b.body.record().faces[fi].nurbs else {
+ let Some(solidcore_record::brep::Surface::RationalSpline { u_knots, .. }) = &b.body.record().faces[fi].nurbs else {
panic!("the half's form")
};
assert!(u_knots[u_knots.len() - 1] - u_knots[0] <= 4.0, "{lower_first}: face #{half}'s form spans {u_knots:?}");
@@ -2843,7 +2844,7 @@ fn a_torus_face_round_most_of_its_tube_is_formed_within_one_turn_of_it() {
assert!(b.closed && b.refused.is_none(), "{tube:?}: {:?} {:?}", b.refused, imp.warnings);
let face = b.face_origin.iter().position(|f| *f == 53).unwrap();
let record = b.body.record();
- let Some(solidcraft_geom::brep::Surface::RationalSpline { v_knots, .. }) = &record.faces[face].nurbs else { panic!("the tube's form") };
+ let Some(solidcore_record::brep::Surface::RationalSpline { v_knots, .. }) = &record.faces[face].nurbs else { panic!("the tube's form") };
assert!(v_knots[v_knots.len() - 1] - v_knots[0] <= 4.0, "{tube:?}: the tube's form spans {v_knots:?}");
let m = measure(&b.body).unwrap();
let (volume, area) = match tube {
diff --git a/crates/kernel/src/step_out.rs b/crates/kernel/src/step_out.rs
index 795a0a8499..55f61abc4a 100644
--- a/crates/kernel/src/step_out.rs
+++ b/crates/kernel/src/step_out.rs
@@ -308,13 +308,14 @@ pub fn step_export_bodies(bodies: &[ExportBody], header: &StepHeader) -> Result<
#[cfg(test)]
mod tests {
use super::*;
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
+ use solidcraft_geom::prelude::*;
use solidcraft_step::p21;
use solidcraft_step::write::real;
#[test]
fn islands_are_solids_of_their_own_not_voids() {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
let square = |a: f64, b: f64| Loop2::polygon(&[Vec2::new(a, a), Vec2::new(b, a), Vec2::new(b, b), Vec2::new(a, b)]);
// A plate with a square hole, and an island inside the hole (a letter's counter).
let plate = Region2 { outer: square(0.0, 30.0), holes: vec![square(10.0, 20.0).reversed()] };
@@ -362,8 +363,8 @@ mod tests {
#[test]
fn assembly_names_colours_round_trip() {
use crate::{box_solid, cylinder, measure, step_import, step_validate};
- let bx = box_solid(solidcraft_geom::Vec3::ZERO, solidcraft_geom::Vec3::new(10.0, 20.0, 5.0)).unwrap();
- let pin = cylinder(solidcraft_geom::Vec3::ZERO, solidcraft_geom::Vec3::Z, 2.0, 8.0).unwrap();
+ let bx = box_solid(solidcore_record::Vec3::ZERO, solidcore_record::Vec3::new(10.0, 20.0, 5.0)).unwrap();
+ let pin = cylinder(solidcore_record::Vec3::ZERO, solidcore_record::Vec3::Z, 2.0, 8.0).unwrap();
let rot90 = [[0.0, 1.0, 0.0, 0.0], [-1.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [50.0, 0.0, 0.0, 1.0]];
let shift = [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 5.0, 1.0]];
let products = vec![
@@ -391,7 +392,7 @@ mod tests {
let m: Vec<_> = imp.bodies.iter().map(|b| measure(&b.body).unwrap()).collect();
assert!((m[1].bbox.min.z - 5.0).abs() < 1e-6 && (m[1].bbox.max.z - 13.0).abs() < 1e-6);
// Rotated 90° about Z and moved 50 along X: centre at (50, 0).
- assert!(m[2].centroid.dist(solidcraft_geom::Vec3::new(50.0, 0.0, 4.0)) < 1e-3, "{:?}", m[2].centroid);
+ assert!(m[2].centroid.dist(solidcore_record::Vec3::new(50.0, 0.0, 4.0)) < 1e-3, "{:?}", m[2].centroid);
// Recursion and bad placements are errors.
let cyc = vec![ExportProduct {
name: "A".into(),
diff --git a/crates/kernel/src/surface_extend.rs b/crates/kernel/src/surface_extend.rs
index 8f8a04bf07..e3ff4499a0 100644
--- a/crates/kernel/src/surface_extend.rs
+++ b/crates/kernel/src/surface_extend.rs
@@ -29,10 +29,12 @@
//! an edge that is not a whole side of its surface's box (a trimmed edge, whose extension is no
//! curve SMLib holds exactly).
+use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::{self, eval::CurveEval};
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self};
+use solidcraft_geom::brep::eval::CurveEval;
use solidcraft_smlib::trim::Continuation;
use crate::body::Body;
@@ -395,7 +397,7 @@ fn failed(what: &str, e: impl crate::Cause) -> KernelError {
mod tests {
use super::*;
use crate::{measure, patch_region};
- use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2};
use std::f64::consts::{FRAC_PI_2, FRAC_PI_4, PI};
fn rel(a: f64, b: f64) -> f64 {
diff --git a/crates/kernel/src/surface_kind.rs b/crates/kernel/src/surface_kind.rs
index 94e65c7ac5..d7af0187bc 100644
--- a/crates/kernel/src/surface_kind.rs
+++ b/crates/kernel/src/surface_kind.rs
@@ -1,9 +1,11 @@
//! What surface a face lies on (plane, cylinder, cone, sphere, torus), for construction
//! geometry: axes through round faces, centres of spheres and tori.
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Brep, Curve};
+use solidcraft_geom::UnitVec3;
use solidcraft_geom::brep::eval::CurveEval;
-use solidcraft_geom::brep::{Brep, Curve};
-use solidcraft_geom::{UnitVec3, Vec3};
+use solidcraft_geom::prelude::*;
use crate::Body;
use crate::offset::{Surf, surf_of};
@@ -91,7 +93,7 @@ pub fn edge_circle(b: &Body, edge: usize) -> Option<EdgeCircle> {
// angles of its interval on the circle itself (a NURBS form is parameterised otherwise).
let axis = Vec3::from(frame.x_axis).cross(Vec3::from(frame.y_axis)).unit()?;
let closed = e.vertices[0] == e.vertices[1];
- let [a0, a1] = e.curve_interval()?;
+ let [a0, a1] = solidcraft_geom::brep::label::edge_curve_interval(e)?;
let angle = if closed { std::f64::consts::TAU } else { (a1 - a0).min(std::f64::consts::TAU) };
return Some(EdgeCircle { center: Vec3::from(frame.origin), axis, radius: *radius, start, end, angle });
}
diff --git a/crates/kernel/src/surface_offset.rs b/crates/kernel/src/surface_offset.rs
index cac4217595..bbe565ab46 100644
--- a/crates/kernel/src/surface_offset.rs
+++ b/crates/kernel/src/surface_offset.rs
@@ -41,7 +41,8 @@ pub fn offset_surface(body: &Body, faces: &[usize], distance: f64, tolerance: f6
mod tests {
use super::*;
use crate::{box_solid, cylinder, measure, sphere};
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
+ use solidcraft_geom::prelude::*;
fn rel(a: f64, b: f64) -> f64 {
(a - b).abs() / b.abs().max(1e-9)
diff --git a/crates/kernel/src/surface_ruled.rs b/crates/kernel/src/surface_ruled.rs
index 5604e814f3..475a398b70 100644
--- a/crates/kernel/src/surface_ruled.rs
+++ b/crates/kernel/src/surface_ruled.rs
@@ -20,11 +20,12 @@
//! edge's own curve as a NURBS where it stands on the body), and the faces are stitched by SMLib
//! along the side edges they share.
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self as b, Brep};
use solidcraft_geom::brep::eval::SurfaceEval;
-use solidcraft_geom::brep::{self as b, Brep};
use solidcraft_geom::bspline::{CurveN, HPoint, NurbsSurface};
use crate::body::Body;
@@ -362,7 +363,8 @@ fn normal_at(surface: &SurfaceEval, forward: bool, p: Vec3) -> Option<Vec3> {
fn base_curve(r: &Brep, e: usize, forward: bool) -> Result<CurveN<4>> {
let edge = r.edges.get(e).ok_or_else(|| KernelError::Invalid("an edge reference".into()))?;
// On the curve itself: a conic's angles (its NURBS form, if any, is parameterised otherwise).
- let [t0, t1] = edge.curve_interval().ok_or_else(|| KernelError::Invalid("an edge's NURBS form cannot be evaluated".into()))?;
+ let [t0, t1] = solidcraft_geom::brep::label::edge_curve_interval(edge)
+ .ok_or_else(|| KernelError::Invalid("an edge's NURBS form cannot be evaluated".into()))?;
let c = match &edge.curve {
b::Curve::Line { start, end } => {
let at = |t: f64| [start[0] + (end[0] - start[0]) * t, start[1] + (end[1] - start[1]) * t, start[2] + (end[2] - start[2]) * t, 1.0];
@@ -1021,8 +1023,8 @@ impl Strip {
let side = top_start - bs;
let Some(x) = side.normalized() else { return Ok(None) };
let Some(y) = (flat(bs) - x * flat(bs).dot(x)).normalized().or_else(|| (axis - x * axis.dot(x)).normalized()) else { return Ok(None) };
- let plane = solidcraft_geom::Plane { origin: bs, x, y };
- let line = solidcraft_geom::Seg2::Line { a: solidcraft_geom::Vec2::ZERO, b: solidcraft_geom::Vec2::new(side.len(), 0.0) };
+ let plane = solidcore_record::Plane { origin: bs, x, y };
+ let line = solidcore_record::Seg2::Line { a: solidcore_record::Vec2::ZERO, b: solidcore_record::Vec2::new(side.len(), 0.0) };
// SMLib turns right-handed about the axis it is given.
let (axis, turn) = if turn < 0.0 { (axis * -1.0, -turn) } else { (axis, turn) };
Ok(Some(crate::surfaces::revolved_record(&plane, &[line], c, axis, turn)?))
@@ -1050,10 +1052,18 @@ fn face_of(mut parts: Parts, surface: b::Surface, uses: Vec<(b::Curve, [f64; 2],
.enumerate()
.map(|(i, (e, (forward, pc)))| {
let edge = u32::try_from(i).map_err(|_| KernelError::Failed("ruled surface: an edge".into()))?;
- Ok(b::pcurve::EdgeUse { edge, curve: e.parameters(), interval: e.interval, forward: *forward, tolerance, given: pc.as_ref() })
+ Ok(solidcraft_geom::brep::pcurve::EdgeUse {
+ edge,
+ curve: e.parameters(),
+ interval: e.interval,
+ forward: *forward,
+ tolerance,
+ given: pc.as_ref(),
+ })
})
.collect::<Result<Vec<_>>>()?;
- let pcurves = b::pcurve::pcurves(&surface, &[loop_uses], tolerance).map_err(|e| KernelError::Failed(format!("ruled surface: {e}")))?;
+ let pcurves =
+ solidcraft_geom::brep::pcurve::pcurves(&surface, &[loop_uses], tolerance).map_err(|e| KernelError::Failed(format!("ruled surface: {e}")))?;
let edges = given
.iter()
.zip(pcurves.into_iter().flatten())
@@ -1322,8 +1332,8 @@ impl Joint {
let side = incoming - at;
let x = side.normalized().ok_or_else(|| KernelError::Failed("ruled surface: a round corner".into()))?;
let y = (axis - x * axis.dot(x)).normalized().ok_or_else(|| KernelError::Failed("ruled surface: a round corner".into()))?;
- let plane = solidcraft_geom::Plane { origin: at, x, y };
- let line = solidcraft_geom::Seg2::Line { a: solidcraft_geom::Vec2::ZERO, b: solidcraft_geom::Vec2::new(side.len(), 0.0) };
+ let plane = solidcore_record::Plane { origin: at, x, y };
+ let line = solidcore_record::Seg2::Line { a: solidcore_record::Vec2::ZERO, b: solidcore_record::Vec2::new(side.len(), 0.0) };
Ok(vec![crate::surfaces::revolved_record(&plane, &[line], at, axis, turn)?])
}
}
@@ -1335,7 +1345,7 @@ mod tests {
use std::collections::HashMap;
use std::f64::consts::{FRAC_1_SQRT_2, PI};
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
use super::*;
use crate::history::FaceOrigin;
@@ -1358,7 +1368,7 @@ mod tests {
fn on_edges_of(s: &Body, b: &Body) -> usize {
let on = |p: Vec3| {
b.record().edges.iter().any(|e| match e.curve {
- solidcraft_geom::brep::Curve::Line { start, end } => {
+ solidcore_record::brep::Curve::Line { start, end } => {
let (a, z) = (Vec3::new(start[0], start[1], start[2]), Vec3::new(end[0], end[1], end[2]));
p.dist_to_segment(a, z) < 1e-6
}
diff --git a/crates/kernel/src/surface_second_derivative_tests.rs b/crates/kernel/src/surface_second_derivative_tests.rs
index 95c6e13b97..c284243961 100644
--- a/crates/kernel/src/surface_second_derivative_tests.rs
+++ b/crates/kernel/src/surface_second_derivative_tests.rs
@@ -3,8 +3,10 @@
//! every curvature the kernel reads (continuity, the G2 fill's frames) comes from them (#763: a G2
//! boundary surface once measured half the cylinder's curvature it does carry).
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::{Surface, eval::SurfaceEval};
+use solidcore_record::Vec3;
+use solidcore_record::brep::Surface;
+use solidcraft_geom::brep::eval::SurfaceEval;
+use solidcraft_geom::prelude::*;
/// A degree-`p` × degree-`q` surface on a net of `p + 3` × `q + 3` points with interior knots each
/// way, bent in z: its knots and points (`rows[i][j]`, i along u).
diff --git a/crates/kernel/src/surface_trim.rs b/crates/kernel/src/surface_trim.rs
index 8edd018588..a8eeec34d4 100644
--- a/crates/kernel/src/surface_trim.rs
+++ b/crates/kernel/src/surface_trim.rs
@@ -3,8 +3,9 @@
//! Trim: two surfaces cut by each other, each keeping its picked side, extended to meet first
//! when one stops short of the other.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_geom::brep::eval::CurveEval;
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::splitface::{SplitTool, ToolSide};
@@ -211,7 +212,7 @@ mod tests {
use super::*;
use crate::history::{Change, FaceOrigin};
use crate::{extrude_sheet, measure, patch_region, stitch};
- use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2};
use std::f64::consts::PI;
fn rel(a: f64, b: f64) -> f64 {
diff --git a/crates/kernel/src/surface_untrim.rs b/crates/kernel/src/surface_untrim.rs
index ef09381476..717db115d9 100644
--- a/crates/kernel/src/surface_untrim.rs
+++ b/crates/kernel/src/surface_untrim.rs
@@ -10,7 +10,8 @@
//! own edges. The body goes to SMLib tagged as operand 0, so the result's history comes from
//! SMLib's tags: the untrimmed face is the face it was, trimmed differently.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use solidcraft_smlib::trim::Holes;
use crate::body::Body;
@@ -124,7 +125,7 @@ pub(crate) fn face_point(body: &Body, face: usize) -> Result<Vec3> {
mod tests {
use super::*;
use crate::{extrude, measure};
- use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2};
use std::f64::consts::PI;
fn rel(a: f64, b: f64) -> f64 {
@@ -261,7 +262,9 @@ mod tests {
assert!(bb.min.x.abs() < 1e-9 && bb.min.y.abs() < 1e-9 && bb.min.z.abs() < 1e-9, "{bb:?}");
assert!((bb.max.x - 10.0).abs() < 1e-9 && (bb.max.y - 10.0).abs() < 1e-9 && (bb.max.z - 10.0).abs() < 1e-9, "{bb:?}");
let record = crate::native::brep_record(&whole).unwrap();
- assert!(matches!(record.faces.first().and_then(|f| f.loops.first()), Some(solidcraft_geom::brep::Loop::Edges { edges }) if edges.len() == 4));
+ assert!(
+ matches!(record.faces.first().and_then(|f| f.loops.first()), Some(solidcore_record::brep::Loop::Edges { edges }) if edges.len() == 4)
+ );
}
/// The plate exported to STEP and read back: its imported top face untrims to the whole
diff --git a/crates/kernel/src/surfaces.rs b/crates/kernel/src/surfaces.rs
index 6151ce9cc1..53a65fa064 100644
--- a/crates/kernel/src/surfaces.rs
+++ b/crates/kernel/src/surfaces.rs
@@ -15,12 +15,13 @@
//! wall comes from the profile segments its edges in the start plane lie along; a stitched or
//! offset face carries the tag of the face it was made from through SMLib.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeSet;
+use solidcore_record::brep::{self as b, Brep, Curve2};
+use solidcore_record::{Plane, Region2, Seg2, Vec2, Vec3};
use solidcraft_geom::brep::eval::CurveEval;
-use solidcraft_geom::brep::{self as b, Brep, Curve2};
use solidcraft_geom::bspline::{HPoint, NurbsSurface};
-use solidcraft_geom::{Plane, Region2, Seg2, Vec2, Vec3};
use crate::body::Body;
use crate::history::{Change, EdgeOrigin, EdgeProv, FaceOrigin, FaceProv, History};
@@ -686,7 +687,8 @@ fn without_t_junctions(c: Canonical, offsets: &Offsets, tol: f64) -> Result<Cano
if splits.is_empty() {
return Ok(c);
}
- let split = r.split_edges(&splits).map_err(|e| failed(format!("stitch: splitting edges at the other sheets' vertices: {e}")))?;
+ let split =
+ solidcraft_geom::brep::split_edges(r, &splits).map_err(|e| failed(format!("stitch: splitting edges at the other sheets' vertices: {e}")))?;
let faces =
split.faces.iter().map(|f| c.faces.get(*f as usize).copied().ok_or_else(|| failed("stitch: a face reference"))).collect::<Result<_>>()?;
let edges =
@@ -856,7 +858,7 @@ pub fn extend(body: &Body, at: &[Vec3], distance: f64) -> Result<Body> {
.iter()
.enumerate()
.map(|(i, e)| {
- Ok(b::pcurve::EdgeUse {
+ Ok(solidcraft_geom::brep::pcurve::EdgeUse {
edge: index(i)?,
curve: e.parameters(),
interval: e.interval,
@@ -867,7 +869,7 @@ pub fn extend(body: &Body, at: &[Vec3], distance: f64) -> Result<Body> {
})
.collect::<Result<Vec<_>>>()?;
let surface = b::Surface::Plane { origin: a3(origin), u_axis: a3(du), v_axis: a3(dv) };
- let pcurves = b::pcurve::pcurves(&surface, &[uses], r.tolerance).map_err(|e| failed(format!("extend: {e}")))?;
+ let pcurves = solidcraft_geom::brep::pcurve::pcurves(&surface, &[uses], r.tolerance).map_err(|e| failed(format!("extend: {e}")))?;
let edges = pcurves
.into_iter()
.flatten()
@@ -1189,7 +1191,7 @@ pub fn loft_sheet_with_rails(sections: &[(Plane, Vec<Seg2>)], rails: &[Vec<Vec3>
/// Closed sections matched as the solid loft matches them ([`crate::build::loft_numbered_loops`]),
/// in loft order.
fn closed_sections(sections: &[(Plane, Vec<Seg2>)]) -> Result<Vec<crate::loft_rails::Section>> {
- let loops: Vec<(Plane, solidcraft_geom::Loop2)> = sections.iter().map(|(p, c)| (*p, solidcraft_geom::Loop2 { segs: c.clone() })).collect();
+ let loops: Vec<(Plane, solidcore_record::Loop2)> = sections.iter().map(|(p, c)| (*p, solidcore_record::Loop2 { segs: c.clone() })).collect();
let reversed = crate::build::loft_reversed(&loops)?;
let numbered = loops.iter().map(|(p, _)| *p).zip(crate::numbered::number_loops(loops.iter().map(|(_, l)| l))).collect::<Vec<_>>();
crate::build::loft_numbered_loops(&numbered, reversed)?
@@ -1612,7 +1614,7 @@ mod imp {
mod tests {
use super::*;
use crate::{box_solid, cylinder, measure, trim};
- use solidcraft_geom::Loop2;
+ use solidcore_record::Loop2;
fn rel(a: f64, b: f64) -> f64 {
(a - b).abs() / b.abs().max(1e-9)
diff --git a/crates/kernel/src/sweep_path.rs b/crates/kernel/src/sweep_path.rs
index c5504368e7..d0f98a8090 100644
--- a/crates/kernel/src/sweep_path.rs
+++ b/crates/kernel/src/sweep_path.rs
@@ -4,7 +4,8 @@
//! SMLib's controlled sweeps skin through ([`crate::smlib_sweeps`]). A solid along points is
//! SMLib's sweep along the lines between them ([`sweep_path_with`]).
-use solidcraft_geom::{Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Plane, Region2, Seg2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::body::Body;
use crate::numbered::NumberedLoop;
@@ -440,9 +441,10 @@ pub(crate) fn smlib_sweep_points(plane: &Plane, region: &Region2, path: &crate::
#[cfg(test)]
mod tests {
+ use solidcraft_geom::prelude::*;
use std::f64::consts::{FRAC_PI_2, FRAC_PI_4, PI};
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2, Vec3};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
use super::{SweepControl, SweepOrientation, sweep_path, sweep_path_with};
diff --git a/crates/kernel/src/sweep_rails_tests.rs b/crates/kernel/src/sweep_rails_tests.rs
index 76d2f9feea..744e81ff59 100644
--- a/crates/kernel/src/sweep_rails_tests.rs
+++ b/crates/kernel/src/sweep_rails_tests.rs
@@ -5,9 +5,10 @@
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
+use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
use crate::{RailFit, SweepControl, measure, sweep_path_with};
diff --git a/crates/kernel/src/tangent_edge.rs b/crates/kernel/src/tangent_edge.rs
index 4ca6afe67f..fa687bc89a 100644
--- a/crates/kernel/src/tangent_edge.rs
+++ b/crates/kernel/src/tangent_edge.rs
@@ -25,10 +25,11 @@
//! of the pcurve, isolated by subdividing its Bernstein coefficients (no sign change: no root;
//! one: exactly one) and found to rounding by bisection.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Brep, Curve2, Face, Surface};
use solidcraft_geom::brep::eval::SurfaceEval;
-use solidcraft_geom::brep::{Brep, Curve2, Face, Surface};
use solidcraft_geom::bspline::{HPoint, segment};
+use solidcraft_geom::prelude::*;
use crate::{KernelError, Result};
@@ -115,7 +116,7 @@ impl<'a> Use<'a> {
/// The outward unit normal at the pcurve's point at `t`; `Ok(None)` where it is undefined (a
/// pole: a zero of the normal).
fn normal(&self, t: f64) -> Result<Option<Vec3>> {
- let uv = self.pcurve.eval(t).ok_or_else(|| failed(format!("a pcurve at {t}")))?;
+ let uv = solidcraft_geom::brep::pcurve::eval(self.pcurve, t).ok_or_else(|| failed(format!("a pcurve at {t}")))?;
let (_, su, sv) = self.surface.derivs(uv[0], uv[1]).ok_or_else(|| failed(format!("a face at ({}, {})", uv[0], uv[1])))?;
let n = su.cross(sv);
if !(n.len() > DEGENERATE * su.len() * sv.len()) {
@@ -274,10 +275,10 @@ fn bernstein_roots(c: &[f64], lo: f64, hi: f64, depth: u32, work: &mut usize, ou
fn normal_pairs(rec: &Brep, sign: impl Fn(usize) -> Option<f64>, e: usize, mut visit: impl FnMut(Vec3, Vec3) -> bool) -> Result<Option<bool>> {
let edge = rec.edges.get(e).ok_or_else(|| failed(format!("edge {e}")))?;
let [ua, ub] = edge.uses.as_slice() else { return Ok(None) };
- let use_of = |u: &solidcraft_geom::brep::EdgeUseRef| -> Result<Use<'_>> {
+ let use_of = |u: &solidcore_record::brep::EdgeUseRef| -> Result<Use<'_>> {
let face = rec.faces.get(u.face as usize).ok_or_else(|| failed(format!("face {}", u.face)))?;
let oriented = match face.loops.get(u.r#loop as usize) {
- Some(solidcraft_geom::brep::Loop::Edges { edges }) => edges.get(u.position as usize),
+ Some(solidcore_record::brep::Loop::Edges { edges }) => edges.get(u.position as usize),
_ => None,
}
.ok_or_else(|| failed(format!("a use of edge {e}")))?;
diff --git a/crates/kernel/src/taper_mesh_tests.rs b/crates/kernel/src/taper_mesh_tests.rs
index 12287b7c86..9e0d754dea 100644
--- a/crates/kernel/src/taper_mesh_tests.rs
+++ b/crates/kernel/src/taper_mesh_tests.rs
@@ -2,7 +2,7 @@ use super::*;
/// A wedge 40 x 20, 15 high, its top front edge along x from 0 to 40.
fn wedge_body() -> Body {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
let outer = Loop2::polygon(&[Vec2::new(0., 0.), Vec2::new(40., 0.), Vec2::new(0., 20.)]);
crate::extrude(&Plane::XY, &[Region2 { outer, holes: vec![] }], 0., 15.).unwrap().pop().unwrap()
}
diff --git a/crates/kernel/src/tess/cdt.rs b/crates/kernel/src/tess/cdt.rs
index e7d80f9b46..465956ed6f 100644
--- a/crates/kernel/src/tess/cdt.rs
+++ b/crates/kernel/src/tess/cdt.rs
@@ -5,9 +5,10 @@
//! the facet angle, then Ruppert refinement for shape. Constraint edges are never split, so the
//! boundary stays exactly the shared edge nodes.
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use super::size::Turn;
use spade::handles::FixedVertexHandle;
diff --git a/crates/kernel/src/tess/coons.rs b/crates/kernel/src/tess/coons.rs
index e803f7dc4f..56d4ecee3a 100644
--- a/crates/kernel/src/tess/coons.rs
+++ b/crates/kernel/src/tess/coons.rs
@@ -4,7 +4,8 @@
//! A blend that folds (a strongly non-convex boundary) is refused, and the face goes to the
//! constrained Delaunay path.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
/// Smallest turn (radians) of the boundary at a corner, in the tolerance metric.
const CORNER_TURN: f64 = 0.6;
diff --git a/crates/kernel/src/tess/edges.rs b/crates/kernel/src/tess/edges.rs
index 52c48fc4cb..f67c4f28c2 100644
--- a/crates/kernel/src/tess/edges.rs
+++ b/crates/kernel/src/tess/edges.rs
@@ -1,9 +1,10 @@
//! Edge nodes: every edge of a body sampled once, so the faces on either side share the very
//! same boundary points (watertight by construction).
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self, Curve};
use solidcraft_geom::brep::eval::CurveEval;
-use solidcraft_geom::brep::{self, Curve};
+use solidcraft_geom::prelude::*;
use super::size::Rules;
use crate::{KernelError, Result};
@@ -315,7 +316,7 @@ mod tests {
let oe = &loop_edges[u.position as usize];
let Ok((s, map)) = crate::tess::surface::eval_surface(face.parameters(), face.domain) else { panic!("evaluates") };
for (t, p) in n.params.iter().zip(&n.points) {
- let Some(q) = oe.pcurve.eval(*t) else { panic!("pcurve at {t}") };
+ let Some(q) = solidcraft_geom::brep::pcurve::eval(&oe.pcurve, *t) else { panic!("pcurve at {t}") };
let q = map.to_eval(q);
let Some((at, _, _)) = s.derivs(q[0], q[1]) else { panic!("evaluates") };
assert!(at.dist(*p) < 1e-6 + e.tolerance, "{at:?} vs {p:?}");
diff --git a/crates/kernel/src/tess/mod.rs b/crates/kernel/src/tess/mod.rs
index 35165bd7ea..92824dfc69 100644
--- a/crates/kernel/src/tess/mod.rs
+++ b/crates/kernel/src/tess/mod.rs
@@ -38,10 +38,11 @@ pub(crate) mod surface;
pub(crate) mod tangle;
pub(crate) mod uv;
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::{self, Curve, Loop, Shell};
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self, Curve, Loop, Shell};
use solidcraft_geom::tess::{EvalSurface, FacePlan, TessPlan};
use crate::{KernelError, Result};
@@ -280,7 +281,7 @@ fn boundary(
for oe in face_edges(face) {
let (Some(edge), Some([p0, p1])) = (b.edges.get(oe.edge as usize), oe.pcurve.interval()) else { continue };
let tol = edge.vertices.get(usize::from(!oe.forward)).and_then(|v| b.vertices.get(*v as usize)).map_or(0.0, |v| v.tolerance.min(rules.tol));
- let Some(q) = oe.pcurve.eval(if oe.forward { p0 } else { p1 }).map(|q| map.to_eval(q)) else { continue };
+ let Some(q) = solidcraft_geom::brep::pcurve::eval(&oe.pcurve, if oe.forward { p0 } else { p1 }).map(|q| map.to_eval(q)) else { continue };
if tol.is_finite() && tol > reach && (0..2).any(|d| uv::degenerate_within(s, &dom, q, d, tol)) {
reach = tol;
}
@@ -319,7 +320,8 @@ fn boundary(
let mut es: Vec<bool> = n.params.iter().map(|t| n.snapped.contains(t)).collect();
let mut eq: Vec<[f64; 2]> = Vec::with_capacity(ep.len());
for (k, (t, p)) in n.params.iter().zip(&n.points).enumerate() {
- let q = oe.pcurve.eval(t.clamp(p0, p1)).ok_or_else(|| fail(oe.edge, format!("its pcurve does not evaluate at t = {t}")))?;
+ let q = solidcraft_geom::brep::pcurve::eval(&oe.pcurve, t.clamp(p0, p1))
+ .ok_or_else(|| fail(oe.edge, format!("its pcurve does not evaluate at t = {t}")))?;
let q = map.to_eval(q);
let on =
s.derivs(q[0], q[1]).map(|d| d.0).ok_or_else(|| fail(oe.edge, format!("node {k}: the surface does not evaluate at {q:?}")))?;
diff --git a/crates/kernel/src/tess/sag.rs b/crates/kernel/src/tess/sag.rs
index 4082c4aedf..b786162897 100644
--- a/crates/kernel/src/tess/sag.rs
+++ b/crates/kernel/src/tess/sag.rs
@@ -7,9 +7,10 @@
//! conforming. Sides on the face's boundary are never split: they are the edges' own nodes,
//! which the neighbouring face shares.
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_geom::tess::EvalSurface;
/// Split the triangles `tris` of a face (indices into `uv`; the first `fixed.len()` points sit
diff --git a/crates/kernel/src/tess/seam.rs b/crates/kernel/src/tess/seam.rs
index dcd2c3923f..f1bc48e0e7 100644
--- a/crates/kernel/src/tess/seam.rs
+++ b/crates/kernel/src/tess/seam.rs
@@ -7,7 +7,7 @@
//! the two lines inside the face join the pieces into closed loops. Both lines are one curve
//! on the surface, so their nodes are made once and shared: the face stays closed across it.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_geom::tess::EvalSurface;
use super::size::Rules;
diff --git a/crates/kernel/src/tess/size.rs b/crates/kernel/src/tess/size.rs
index a7e6a2b4d9..6fd8804e89 100644
--- a/crates/kernel/src/tess/size.rs
+++ b/crates/kernel/src/tess/size.rs
@@ -6,7 +6,8 @@
//! sags the tolerance; an edge takes the smaller size of its two faces, so a curved face and
//! its flat neighbour meet at the same spacing.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use solidcraft_geom::tess::EvalSurface;
use super::uv::Domain;
diff --git a/crates/kernel/src/tess/surface.rs b/crates/kernel/src/tess/surface.rs
index e096245375..63851cecdd 100644
--- a/crates/kernel/src/tess/surface.rs
+++ b/crates/kernel/src/tess/surface.rs
@@ -7,9 +7,10 @@
//! record's angle u; the generator's parameter is −v on a line and, on an arc, the rational
//! parameter of the record's angle v (closed form, [`Arc::param`]).
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self, Frame};
use solidcraft_geom::brep::eval::SurfaceEval;
-use solidcraft_geom::brep::{self, Frame};
+use solidcraft_geom::prelude::*;
use solidcraft_geom::tess::{EvalCurve, EvalSurface};
use crate::{KernelError, Result};
diff --git a/crates/kernel/src/tess/tests.rs b/crates/kernel/src/tess/tests.rs
index 6b8207ea06..287bb9db22 100644
--- a/crates/kernel/src/tess/tests.rs
+++ b/crates/kernel/src/tess/tests.rs
@@ -1,6 +1,7 @@
use std::collections::HashMap;
-use solidcraft_geom::{Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Mesh;
use super::*;
use crate::{Body, BoolOp};
@@ -27,7 +28,7 @@ fn assert_watertight(m: &Mesh, name: &str) {
}
/// The body's schema 4 record, which the planner takes.
-fn record(b: &Body) -> solidcraft_geom::brep::Brep {
+fn record(b: &Body) -> solidcore_record::brep::Brep {
ok(crate::brep_record(b))
}
@@ -271,7 +272,7 @@ fn draw(m: &Mesh, x0: f64) -> String {
/// such a triangle carried a boundary side of the cone.
#[test]
fn a_drill_point_apex_leaves_no_zero_area_triangles() {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
// (box size, hole position, radius, depth)
let cases =
[(Vec3::new(40.0, 30.0, 15.0), Vec3::new(20.0, 15.0, 15.0), 3.4, 8.0), (Vec3::new(60.0, 40.0, 15.0), Vec3::new(50.0, 20.0, 15.0), 3.0, 10.0)];
@@ -423,14 +424,14 @@ fn an_smlib_torus_stays_within_the_chord_tolerance() {
/// A groove of trapezoid `section` (radius, axial offset) in the plane through the z axis along
/// y, carried `turns` turns of `pitch` about z from `base`, as an SMLib solid.
fn smlib_groove(section: [(f64, f64); 4], base: f64, pitch: f64, turns: f64) -> solidcraft_smlib::Brep {
- use solidcraft_geom::{Loop2, Vec2};
+ use solidcore_record::{Loop2, Vec2};
smlib_screw(Loop2::polygon(&section.map(|(r, z)| Vec2::new(r, z))), base, pitch, turns)
}
/// The `section` (radius, axial offset) in the plane through the z axis along y, carried
/// `turns` turns of `pitch` about z from `base`, as an SMLib solid.
-fn smlib_screw(section: solidcraft_geom::Loop2, base: f64, pitch: f64, turns: f64) -> solidcraft_smlib::Brep {
- use solidcraft_geom::{Plane, Region2};
+fn smlib_screw(section: solidcore_record::Loop2, base: f64, pitch: f64, turns: f64) -> solidcraft_smlib::Brep {
+ use solidcore_record::{Plane, Region2};
let origin = Vec3::new(0.0, 0.0, base);
let plane = Plane { origin, x: Vec3::Y, y: Vec3::Z };
let region = Region2 { outer: section, holes: Vec::new() };
@@ -580,7 +581,7 @@ fn a_thread_root_band_running_out_through_an_end_face_lies_on_its_surface() {
/// halves measured 1.5% short of the whole). The cut grid now thins its lines to fit.
#[test]
fn the_halves_of_a_split_smlib_coil_measure_as_the_whole() {
- use solidcraft_geom::{Loop2, Vec2};
+ use solidcore_record::{Loop2, Vec2};
use solidcraft_smlib::{BooleanOp, Brep as S};
let coil = smlib_screw(Loop2::circle(Vec2::new(20.0, 0.0), 1.0), 0.0, 4.0, 6.0);
let Ok(top) = S::make_box([-30.0, -30.0, 12.5], [60.0, 60.0, 30.0]) else { panic!("box") };
@@ -701,7 +702,7 @@ fn a_slit_in_a_trimmed_face_has_the_face_on_both_sides() {
/// halved on their edges until none cross.
#[test]
fn a_thin_lune_whose_chords_cross_meshes() {
- use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2};
let (r, gap, h, tol) = (2.5, 0.03, 5.0, 0.1);
// The inner circle: centre (−d, 0) and radius r + d·…, through (0, ±r), its middle at r − gap.
let d = (r * r - (r - gap) * (r - gap)) / (2.0 * (r - gap));
@@ -816,7 +817,7 @@ fn a_face_bounded_by_two_short_arcs_keeps_an_area_to_mesh() {
// inside a 0.5 mm tolerance, so each samples as one segment and the two chords lie on one
// line, a boundary of no area. Its loop's segments are split until it encloses one.
use crate::sew::{PartEdge, PartFace, PartUse, Parts, assemble};
- use solidcraft_geom::brep::{Curve, Frame, Surface};
+ use solidcore_record::brep::{Curve, Frame, Surface};
use std::f64::consts::{PI, TAU};
let (r, half) = (1000.0f64, 10.0f64);
let c = (r * r - half * half).sqrt();
@@ -873,8 +874,8 @@ fn a_face_bounded_by_two_short_arcs_keeps_an_area_to_mesh() {
/// base to u = 2 and up again, then across the top back to the corner it started at, half a
/// period along. Taken for no pole, that step is taken as the nearest copy, and the loop winds
/// once round the surface with no partner to cut it along.
-fn pyramid_past_a_near_pole(pole_tolerance: f64) -> solidcraft_geom::brep::Brep {
- use solidcraft_geom::brep::{self as b, Curve, Curve2, Surface};
+fn pyramid_past_a_near_pole(pole_tolerance: f64) -> solidcore_record::brep::Brep {
+ use solidcore_record::brep::{self as b, Curve, Curve2, Surface};
let top = 1e-7;
let corner = |u: usize, r: f64, z: f64| {
let [x, y] = [[1.0, 0.0], [0.0, 1.0], [-1.0, 0.0], [0.0, -1.0]][u % 4];
@@ -1043,7 +1044,7 @@ fn triangles_standing_across_a_curved_sheet_are_flipped_along_it() {
/// halved, and the ring meshes strictly, to its area (300 pi), not the inner disc's.
#[test]
fn a_ring_touching_itself_at_a_vertex_meshes_strictly() {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
let prism = |c: Vec2, r: f64, z0: f64, z1: f64| {
ok(crate::extrude(&Plane::XY, &[Region2 { outer: Loop2::circle(c, r), holes: vec![] }], z0, z1)).pop().unwrap()
};
diff --git a/crates/kernel/src/tess/uv.rs b/crates/kernel/src/tess/uv.rs
index b51b23b175..8e72f0868d 100644
--- a/crates/kernel/src/tess/uv.rs
+++ b/crates/kernel/src/tess/uv.rs
@@ -2,6 +2,7 @@
//! the plan stores are the ones the evaluators use), and the tolerance-driven divisions of a
//! face's parameter box.
+use solidcraft_geom::prelude::*;
use solidcraft_geom::tess::EvalSurface;
pub(crate) use solidcraft_geom::tess::uv::{Domain, degenerate_within, domain, unwrap};
@@ -126,7 +127,7 @@ fn limits<'a>(s: &'a EvalSurface, d: usize, across: (f64, f64), rules: &'a Rules
#[cfg(test)]
mod tests {
use super::*;
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
use solidcraft_geom::tess::EvalCurve;
fn cylinder() -> EvalSurface {
diff --git a/crates/kernel/src/tests.rs b/crates/kernel/src/tests.rs
index da7f929744..ec600e11b9 100644
--- a/crates/kernel/src/tests.rs
+++ b/crates/kernel/src/tests.rs
@@ -1,6 +1,7 @@
+use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
use crate::*;
@@ -779,7 +780,7 @@ fn moving_a_body_with_an_intersection_curve_edge_ends() {
cut.record()
.edges
.iter()
- .any(|e| !matches!(e.curve, solidcraft_geom::brep::Curve::Line { .. } | solidcraft_geom::brep::Curve::Circle { .. }))
+ .any(|e| !matches!(e.curve, solidcore_record::brep::Curve::Line { .. } | solidcore_record::brep::Curve::Circle { .. }))
);
let t = Vec3::new(0.6911, -0.3337, -0.6127) * 2.334;
let moved = crate::ops::transform(&cut, t, Vec3::ZERO, Vec3::Z, 0.0).unwrap();
@@ -1328,7 +1329,7 @@ fn circle_loop_fillets_and_chamfers() {
#[test]
fn trimmed_revolved_faces_measure_exactly() {
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
use std::f64::consts::FRAC_PI_2;
// A slot with concave ends sketched on the plane x = 12.5, cut 4 deep into a revolved shaft
// of radius 12.5 (the cut faces' triangulation spans wide angles unless refined).
@@ -1384,7 +1385,7 @@ fn shell_with_cylindrical_faces() {
#[test]
fn draft_of_a_round_ended_pocket() {
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
use std::f64::consts::FRAC_PI_2;
let block = box_solid(Vec3::ZERO, Vec3::new(80.0, 60.0, 25.0)).unwrap();
let segs = vec![
@@ -1576,7 +1577,7 @@ fn fillet_where_a_branch_pipe_meets_a_main_pipe() {
#[test]
fn fillet_an_open_curved_edge() {
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
// A D-shaped block: the round top edge only, ending at the flat wall's sharp corners.
let d = Loop2 {
segs: vec![
@@ -1595,7 +1596,7 @@ fn fillet_an_open_curved_edge() {
}
fn mixed_arc_and_line_prism() -> Body {
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
let d = Loop2 {
segs: vec![
Seg2::Arc { center: Vec2::ZERO, radius: 10.0, start: 0.0, sweep: PI },
@@ -1607,7 +1608,7 @@ fn mixed_arc_and_line_prism() -> Body {
#[test]
fn fillet_smooth_arc_and_line_loop_keeps_exact_removal() {
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
// A stadium: four tangent joints, none of which should use a sharp-corner mitre.
let outline = Loop2 {
segs: vec![
@@ -1680,7 +1681,7 @@ fn fillet_rounded_rectangle_with_tiny_end_edges() {
#[test]
fn fillet_sharp_arc_and_arc_loop() {
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
// The intersection of two radius-10 disks whose centres are 10 mm apart.
let outline = Loop2 {
segs: vec![
@@ -1727,7 +1728,7 @@ fn tabbed_plate_area(da: f64, dt: f64) -> f64 {
/// The tabbed plate's outer outline, reconstructed from its seven public pick coordinates: an R25
/// plate, x = ±4 tab sides, R2 corners centred at (±2, 280/9) and a 4 mm straight top.
fn tabbed_plate_outline() -> Loop2 {
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
let theta = (4.0_f64 / 25.0).acos();
let y = (625.0_f64 - 16.0).sqrt();
let corner_y = 280.0 / 9.0;
@@ -1846,7 +1847,7 @@ fn fillet_tabbed_plate_outer_loop_and_partial_selection_after_hole() {
}
fn partial_mixed_run_prism() -> Body {
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
let outline = Loop2 {
segs: vec![
Seg2::Line { a: Vec2::new(0.0, 0.0), b: Vec2::new(40.0, 0.0) },
@@ -2022,7 +2023,7 @@ fn fillet_three_edges_at_a_corner() {
#[test]
fn shell_with_spherical_and_conical_faces() {
// A cylinder capped by a hemisphere (a dome), revolved, opened at the bottom.
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
let xz = Plane::new(Vec3::ZERO, Vec3::X, Vec3::new(0.0, 0.0, -1.0)).unwrap();
let segs = vec![
Seg2::Line { a: Vec2::new(0.0, 0.0), b: Vec2::new(10.0, 0.0) },
diff --git a/crates/kernel/src/thin_face_tests.rs b/crates/kernel/src/thin_face_tests.rs
index cdbcb2269e..5b5d89bab1 100644
--- a/crates/kernel/src/thin_face_tests.rs
+++ b/crates/kernel/src/thin_face_tests.rs
@@ -5,10 +5,11 @@
//! So does a face pinched to a point, where its boundary touches itself within the tolerance (a
//! sphere touching a box's edge leaves one on the box, #1648).
+use solidcraft_geom::prelude::*;
use std::collections::HashMap;
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::{Curve, Loop, Surface};
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Curve, Loop, Surface};
use crate::body::Body;
use crate::sew::{PartEdge, PartFace, PartUse, Parts, assemble};
diff --git a/crates/kernel/src/thread_display_tests.rs b/crates/kernel/src/thread_display_tests.rs
index f8107f0b09..024ec5480b 100644
--- a/crates/kernel/src/thread_display_tests.rs
+++ b/crates/kernel/src/thread_display_tests.rs
@@ -1,7 +1,9 @@
//! Issue 1289: the display mesh of a modelled screw thread (helical B-spline flanks).
+use solidcore_record::Vec3;
+use solidcraft_geom::Mesh;
+use solidcraft_geom::prelude::*;
use solidcraft_geom::tess::TessPlan;
-use solidcraft_geom::{Mesh, Vec3};
use std::f64::consts::{PI, TAU};
@@ -14,7 +16,7 @@ use crate::{Body, DISPLAY_ANGLE};
/// trim along helices. The section reaches a tenth of a pitch into the core along its flanks, so
/// the join cuts it at the core rather than meeting it face to face.
fn ridge_thread(major: f64, pitch: f64, turns: f64) -> Body {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
let h = pitch * 3f64.sqrt() / 2.0;
let (rc, rm) = (major / 2.0 - 5.0 * h / 8.0, major / 2.0);
let (foot, crest) = ((pitch - pitch / 4.0) / 2.0, pitch / 16.0);
diff --git a/crates/kernel/src/thread_tests.rs b/crates/kernel/src/thread_tests.rs
index 4816ba298e..ee1e763734 100644
--- a/crates/kernel/src/thread_tests.rs
+++ b/crates/kernel/src/thread_tests.rs
@@ -2,7 +2,7 @@
use std::f64::consts::PI;
-use solidcraft_geom::{Plane, Vec2, Vec3};
+use solidcore_record::{Plane, Vec2, Vec3};
use crate::{BoolOp, cylinder, faceted_boolean, sweep_helix_mesh};
diff --git a/crates/kernel/src/topo.rs b/crates/kernel/src/topo.rs
index be2929ed0e..0e07474168 100644
--- a/crates/kernel/src/topo.rs
+++ b/crates/kernel/src/topo.rs
@@ -6,11 +6,13 @@
//! are merged, edges between merged faces disappear, and chains of edges through vertices that
//! only join two pieces of one edge are counted once.
+use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, HashMap, HashSet};
use serde::Serialize;
-use solidcraft_geom::brep::{Brep, Loop};
-use solidcraft_geom::{Mesh, UnitVec3, Vec3};
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Brep, Loop};
+use solidcraft_geom::{Mesh, UnitVec3};
use crate::Result;
use crate::body::Body;
@@ -360,7 +362,7 @@ impl CylinderFace {
/// A thread asks this past a face's end: a free end has nothing there (a cap, a chamfer the
/// groove runs out through), a shoulder, a head or a blind hole's bottom has.
pub fn material_in_ring(b: &Body, c: &CylinderFace, r_in: f64, r_out: f64, along: (f64, f64)) -> Result<bool> {
- use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
+ use solidcore_record::{Loop2, Plane, Region2, Vec2};
let (a0, a1) = along;
if !(r_in >= 0.0 && r_out > r_in && a1 > a0 && r_out.is_finite() && a0.is_finite() && a1.is_finite()) {
return Err(crate::KernelError::Invalid(format!("ring r {r_in}..{r_out} over {a0}..{a1}")));
diff --git a/crates/kernel/src/trimmed_face_mesh_tests.rs b/crates/kernel/src/trimmed_face_mesh_tests.rs
index 5ca8e41006..a83838be86 100644
--- a/crates/kernel/src/trimmed_face_mesh_tests.rs
+++ b/crates/kernel/src/trimmed_face_mesh_tests.rs
@@ -1,9 +1,10 @@
//! Tessellation of trimmed loft faces after a boolean: no triangle may leave the face.
+use solidcraft_geom::prelude::*;
use std::f64::consts::FRAC_PI_2;
+use solidcore_record::{Loop2, Plane, Seg2, Vec2, Vec3};
use solidcraft_geom::brep::eval::SurfaceEval;
-use solidcraft_geom::{Loop2, Plane, Seg2, Vec2, Vec3};
use crate::*;
diff --git a/crates/kernel/src/tspline.rs b/crates/kernel/src/tspline.rs
index 79a75d7f54..0f1631fd9d 100644
--- a/crates/kernel/src/tspline.rs
+++ b/crates/kernel/src/tspline.rs
@@ -8,7 +8,7 @@
use std::collections::{BTreeMap, BTreeSet, HashMap};
-use solidcraft_geom::brep as b;
+use solidcore_record::brep as b;
use solidcraft_geom::bspline::{BezierPatch, HPoint, NurbsSurface, SplineError, bezier_segment};
use solidcraft_geom::tspline::TSpline;
@@ -144,7 +144,7 @@ fn patch_faces(patches: &[BezierPatch]) -> Result<Parts> {
}
let mut bounds = solidcraft_geom::Aabb3::EMPTY;
for c in &corners {
- bounds.add(solidcraft_geom::Vec3::new(c[0], c[1], c[2]));
+ bounds.add(solidcore_record::Vec3::new(c[0], c[1], c[2]));
}
parts.tolerance = (bounds.diagonal() * 1e-6).max(1e-5);
parts.vertices = corners.into_iter().map(|point| b::Vertex { point, tolerance: parts.tolerance }).collect();
@@ -156,8 +156,9 @@ fn patch_faces(patches: &[BezierPatch]) -> Result<Parts> {
#[cfg(test)]
mod tests {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
use solidcraft_geom::bspline::NurbsSurface;
+ use solidcraft_geom::prelude::*;
use solidcraft_geom::tspline::{Cut, TSpline};
use super::tspline_sheet;
diff --git a/crates/kernel/src/untouched_faces_tests.rs b/crates/kernel/src/untouched_faces_tests.rs
index f82bf960c8..0fe18a75e1 100644
--- a/crates/kernel/src/untouched_faces_tests.rs
+++ b/crates/kernel/src/untouched_faces_tests.rs
@@ -1,7 +1,8 @@
//! A cut or a join never splits faces it doesn't touch: a flat wall with an opening cut into
//! it stays one face with an inner loop, whatever is cut or joined elsewhere afterwards.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use crate::{Body, BoolOp, FaceSurface, boolean, box_solid, face_surface, fillet, shell};
@@ -168,7 +169,7 @@ fn stations(b: &Body) -> usize {
}
let point = |v: u32| Vec3::from(r.vertices[v as usize].point);
let dir = |e: usize| (point(r.edges[e].vertices[1]) - point(r.edges[e].vertices[0])).normalized();
- let line = |e: usize| matches!(r.edges[e].curve, solidcraft_geom::brep::Curve::Line { .. });
+ let line = |e: usize| matches!(r.edges[e].curve, solidcore_record::brep::Curve::Line { .. });
at.iter()
.filter(|es| match es.as_slice() {
[a, b] => line(*a) && line(*b) && dir(*a).zip(dir(*b)).is_some_and(|(u, w)| u.dot(w).abs() > 1. - 1e-9),
diff --git a/crates/kernel/src/validation.rs b/crates/kernel/src/validation.rs
index 3f03bbad9d..d23f9f60d2 100644
--- a/crates/kernel/src/validation.rs
+++ b/crates/kernel/src/validation.rs
@@ -137,7 +137,7 @@ pub(crate) enum Checked {
/// at the end is the step's own, of the result the step made.
#[derive(Debug)]
pub(crate) struct Unchecked {
- record: std::sync::Weak<solidcraft_geom::brep::Brep>,
+ record: std::sync::Weak<solidcore_record::brep::Brep>,
/// The step, as its own refusal names it (`SMLib fillet`).
what: String,
how: Checked,
@@ -145,12 +145,12 @@ pub(crate) struct Unchecked {
}
impl Unchecked {
- pub(crate) fn new(record: &Arc<solidcraft_geom::brep::Brep>, what: &str, how: Checked, result: solidcraft_smlib::Brep) -> Unchecked {
+ pub(crate) fn new(record: &Arc<solidcore_record::brep::Brep>, what: &str, how: Checked, result: solidcraft_smlib::Brep) -> Unchecked {
Unchecked { record: Arc::downgrade(record), what: what.to_string(), how, result: std::sync::Mutex::new(Some(result)) }
}
/// The step's result, taken (once), when this is `record`'s.
- fn take(&self, record: &Arc<solidcraft_geom::brep::Brep>) -> Option<solidcraft_smlib::Brep> {
+ fn take(&self, record: &Arc<solidcore_record::brep::Brep>) -> Option<solidcraft_smlib::Brep> {
if !std::ptr::eq(self.record.as_ptr(), Arc::as_ptr(record)) {
return None;
}
@@ -228,7 +228,7 @@ mod tests {
/// says the check was left for later, and the check of the body kept refuses it.
#[test]
fn a_body_the_check_refuses_is_refused_at_the_step_or_at_the_end() {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let good = crate::box_solid(Vec3::new(0.0, 0.0, 0.0), Vec3::new(10.0, 10.0, 10.0)).unwrap();
assert!(check_kept(&good).is_ok());
let mut record = good.record().clone();
diff --git a/crates/kernel/src/validity.rs b/crates/kernel/src/validity.rs
index 28a46cfccf..7bbb419d23 100644
--- a/crates/kernel/src/validity.rs
+++ b/crates/kernel/src/validity.rs
@@ -33,8 +33,8 @@ impl Validity {
pub fn validity(body: &Body) -> Validity {
let record = brep_record(body).map_err(|e| e.to_string());
let checked = record.as_ref().map_err(Clone::clone).and_then(|r| {
- r.validate_built().map_err(|e| format!("structure: {e}"))?;
- r.check_geometry().map_err(|e| format!("geometry: {e}"))
+ solidcraft_geom::brep::check::validate_built(r).map_err(|e| format!("structure: {e}"))?;
+ solidcraft_geom::brep::geometry::check(r).map_err(|e| format!("geometry: {e}"))
});
Validity { record: checked, smlib: smlib_validity(body) }
}
diff --git a/crates/kernel/tests/boolean_props.rs b/crates/kernel/tests/boolean_props.rs
index 9d0703b702..2393c14170 100644
--- a/crates/kernel/tests/boolean_props.rs
+++ b/crates/kernel/tests/boolean_props.rs
@@ -13,7 +13,7 @@
//! copy the shrunk case into a `#[test]` below (ignored, with its issue, until the kernel is fixed).
use proptest::prelude::*;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_kernel::{Body, BoolOp, boolean, box_solid, cylinder, measure, sphere, transform};
/// Relative volume tolerance. The same 0.2 % that `fuzz::boolean_case` uses.
diff --git a/crates/kernel/tests/chamfer_curved_holder.rs b/crates/kernel/tests/chamfer_curved_holder.rs
index e4fb8e2274..7467f981d2 100644
--- a/crates/kernel/tests/chamfer_curved_holder.rs
+++ b/crates/kernel/tests/chamfer_curved_holder.rs
@@ -3,7 +3,8 @@
//! meets the tangent junction of the bar's straight and round walls. The chamfer must trim
//! against the round wall instead of extending that short seam outside the solid.
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use solidcraft_kernel::{Body, BoolOp, boolean, chamfer, cylinder, extrude, tangent_chain};
use std::f64::consts::PI;
diff --git a/crates/kernel/tests/hidden_lines.rs b/crates/kernel/tests/hidden_lines.rs
index 7fbf98f457..92bed7eca5 100644
--- a/crates/kernel/tests/hidden_lines.rs
+++ b/crates/kernel/tests/hidden_lines.rs
@@ -1,9 +1,11 @@
//! Hidden lines of bodies the kernel makes, through the production `prepare`, against closed forms.
+use solidcraft_geom::prelude::*;
use std::f64::consts::{FRAC_PI_3, PI};
+use solidcore_record::brep;
+use solidcore_record::{Seg2, Vec2, Vec3};
use solidcraft_geom::hlr::{Line, Options, Placement, Source, View, Visibility, hidden_lines, prepare};
-use solidcraft_geom::{Seg2, Vec2, Vec3, brep};
use solidcraft_kernel::*;
const TOLERANCE: f64 = 1e-3;
diff --git a/crates/kernel/tests/revolve_on_axis.rs b/crates/kernel/tests/revolve_on_axis.rs
index 100aede34e..2adc094c16 100644
--- a/crates/kernel/tests/revolve_on_axis.rs
+++ b/crates/kernel/tests/revolve_on_axis.rs
@@ -3,7 +3,7 @@
//! axis, a drill point whose tip does. Their volumes are analytic, and a half slot revolved about
//! a centreline lying in a face of a plate, as a cut, takes what it should.
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
use solidcraft_kernel::{BoolOp, boolean, box_solid, measure, revolve};
use std::f64::consts::{FRAC_PI_2, PI, TAU};
diff --git a/crates/kernel/tests/shell_barrel.rs b/crates/kernel/tests/shell_barrel.rs
index d424c71c8a..957a99eb27 100644
--- a/crates/kernel/tests/shell_barrel.rs
+++ b/crates/kernel/tests/shell_barrel.rs
@@ -1,8 +1,9 @@
//! #2421: shelling a circular-meridian barrel must retain its curved wall through the rim.
+use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
-use solidcraft_geom::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
+use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
use solidcraft_kernel::history::FaceOrigin;
use solidcraft_kernel::*;
diff --git a/crates/render/Cargo.toml b/crates/render/Cargo.toml
index 68de22ec80..bb8d17aaa9 100644
--- a/crates/render/Cargo.toml
+++ b/crates/render/Cargo.toml
@@ -13,6 +13,7 @@ default = []
raytrace-cpu = []
[dependencies]
+solidcore-record = { workspace = true }
solidcraft-geom = { workspace = true }
serde = { workspace = true }
image = { workspace = true, features = ["jpeg"] }
diff --git a/crates/render/examples/cpu_resource_smoke.rs b/crates/render/examples/cpu_resource_smoke.rs
index 937585f726..0bff9d38a9 100644
--- a/crates/render/examples/cpu_resource_smoke.rs
+++ b/crates/render/examples/cpu_resource_smoke.rs
@@ -1,7 +1,8 @@
//! Bounded native acceptance probe for explicit CPU profiles. This is not a speed
//! benchmark or an application/UI test. Writes only to a new caller-selected folder.
use serde_json::json;
-use solidcraft_geom::{Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Mesh;
use solidcraft_render::job::{CpuBudget, CpuHost, DirectionalLightOptions, ImageRequest, Integrator, JobId, JobOptions, Phase, RaytraceOptions};
use solidcraft_render::{Camera, ProductMesh, ProductScene, StandardView, surface::OpaqueSurface};
use std::{error::Error, fs, path::PathBuf, sync::Arc, time::Duration};
diff --git a/crates/render/examples/validate_starter.rs b/crates/render/examples/validate_starter.rs
index c177e5bf8d..7526755ffd 100644
--- a/crates/render/examples/validate_starter.rs
+++ b/crates/render/examples/validate_starter.rs
@@ -6,7 +6,8 @@
use image::ImageDecoder;
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use solidcraft_render::{
lighting::{DecodedHdr, HdrDecodeTask, HdrSource, HdrTaskPoll},
surface::unit_direction,
diff --git a/crates/render/src/analysis.rs b/crates/render/src/analysis.rs
index b4c49a7bae..d8cd1191a8 100644
--- a/crates/render/src/analysis.rs
+++ b/crates/render/src/analysis.rs
@@ -1,6 +1,6 @@
//! Surface analysis as a view draws it: the shading mode and the colours it uses.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
/// Surface analysis colours, straight sRGB 0..1 as the shader takes them.
#[derive(Clone, Copy, Debug, PartialEq)]
diff --git a/crates/render/src/anisotropic_surface.rs b/crates/render/src/anisotropic_surface.rs
index 1b8746e1fa..25dfb47c92 100644
--- a/crates/render/src/anisotropic_surface.rs
+++ b/crates/render/src/anisotropic_surface.rs
@@ -15,9 +15,10 @@
//! Consumers retain geometric normals for ray spawning and optical boundaries.
//! No shading-normal energy correction, multiple scattering or transmission is modeled.
+use solidcraft_geom::prelude::*;
use std::f64::consts::{PI, TAU};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use crate::surface::{MIN_ROUGHNESS, OpaqueSurface, SurfaceError, unit_direction};
diff --git a/crates/render/src/camera.rs b/crates/render/src/camera.rs
index bc32aacdea..0ba3aa5ebe 100644
--- a/crates/render/src/camera.rs
+++ b/crates/render/src/camera.rs
@@ -1,5 +1,7 @@
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Aabb3, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Aabb3;
+use solidcraft_geom::prelude::*;
/// Column-major 4×4 matrix.
#[derive(Clone, Copy, Debug, PartialEq)]
diff --git a/crates/render/src/clear_coat.rs b/crates/render/src/clear_coat.rs
index 4461d3d724..0d3929e151 100644
--- a/crates/render/src/clear_coat.rs
+++ b/crates/render/src/clear_coat.rs
@@ -3,7 +3,8 @@
//! and refraction of substrate directions are omitted. This is a bounded preview
//! model, not a full layered random walk. See docs/render-clear-coat.md.
use crate::surface::{MIN_ROUGHNESS, OpaqueSurface, SurfaceError, unit_direction};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
#[derive(Clone, Copy, Debug, PartialEq)]
diff --git a/crates/render/src/curve_display.rs b/crates/render/src/curve_display.rs
index 6e97692a1a..31e754b213 100644
--- a/crates/render/src/curve_display.rs
+++ b/crates/render/src/curve_display.rs
@@ -1,6 +1,7 @@
//! Pixel-bounded display paths. CAD segments remain untouched; positive homogeneous
//! control hulls bound perspective projection, including looping and rational curves.
-use solidcraft_geom::{Plane, Seg2, Vec2, Vec3};
+use solidcore_record::{Plane, Seg2, Vec2, Vec3};
+use solidcraft_geom::prelude::*;
use crate::Mat4;
@@ -57,7 +58,7 @@ fn mix(a: H, b: H, t: f64) -> H {
}
/// The most control points of one span: a Bézier of the highest degree.
-const MAX_CONTROLS: usize = solidcraft_geom::MAX_BEZIER_DEGREE + 1;
+const MAX_CONTROLS: usize = solidcore_record::MAX_BEZIER_DEGREE + 1;
/// One span's homogeneous control points, kept inline: the sampler splits and projects
/// thousands of them per curve and view, and a `Vec` each was most of its allocations.
@@ -141,7 +142,7 @@ fn controls(segment: &Seg2, plane: &Plane) -> Option<(Vec<Hull>, H)> {
Seg2::Line { a, b } => vec![Hull::new(&[h(a, 1.0), h(b, 1.0)])?],
Seg2::Cubic { p0, p1, p2, p3 } => vec![Hull::new(&[h(p0, 1.0), h(p1, 1.0), h(p2, 1.0), h(p3, 1.0)])?],
Seg2::Conic { a, apex, b, w } if w > 0.0 => vec![Hull::new(&[h(a, 1.0), h(apex, w), h(b, 1.0)])?],
- Seg2::Bezier { n, p } if (1..=solidcraft_geom::MAX_BEZIER_DEGREE as u8).contains(&n) => {
+ Seg2::Bezier { n, p } if (1..=solidcore_record::MAX_BEZIER_DEGREE as u8).contains(&n) => {
let mut hull = Hull { len: n as usize + 1, p: [[0.0; 4]; MAX_CONTROLS] };
for (out, p) in hull.p.iter_mut().zip(&p[..=n as usize]) {
*out = h(*p, 1.0);
diff --git a/crates/render/src/curve_display_tests.rs b/crates/render/src/curve_display_tests.rs
index e41e84f577..4ca741f282 100644
--- a/crates/render/src/curve_display_tests.rs
+++ b/crates/render/src/curve_display_tests.rs
@@ -27,7 +27,7 @@ fn dense_error(s: &Seg2, plane: &Plane, v: &PixelCurveView, path: &SampledPath)
#[test]
fn exact_arcs_ellipses_rational_and_looping_control_hulls_bound_pixels() {
- let mut degree7 = [Vec2::ZERO; solidcraft_geom::MAX_BEZIER_CTRL];
+ let mut degree7 = [Vec2::ZERO; solidcore_record::MAX_BEZIER_CTRL];
for (i, p) in degree7.iter_mut().enumerate() {
*p = Vec2::new(i as f64 / 4.0 - 0.875, if i % 2 == 0 { -0.8 } else { 0.8 });
}
@@ -139,7 +139,7 @@ fn reference_controls(segment: &Seg2, plane: &Plane) -> Option<(Vec<Vec<H>>, H)>
Seg2::Line { a, b } => vec![vec![h(a, 1.0), h(b, 1.0)]],
Seg2::Cubic { p0, p1, p2, p3 } => vec![vec![h(p0, 1.0), h(p1, 1.0), h(p2, 1.0), h(p3, 1.0)]],
Seg2::Conic { a, apex, b, w } if w > 0.0 => vec![vec![h(a, 1.0), h(apex, w), h(b, 1.0)]],
- Seg2::Bezier { n, p } if (1..=solidcraft_geom::MAX_BEZIER_DEGREE as u8).contains(&n) => {
+ Seg2::Bezier { n, p } if (1..=solidcore_record::MAX_BEZIER_DEGREE as u8).contains(&n) => {
vec![p[..=n as usize].iter().map(|p| h(*p, 1.0)).collect()]
}
Seg2::Arc { center, radius, start, sweep }
@@ -323,7 +323,7 @@ fn same_path(a: &SampledPath, b: &SampledPath) -> bool {
/// unclipped, with ample and with nearly spent budgets.
#[test]
fn samples_the_same_points_bit_for_bit_as_the_reference() {
- let mut degree9 = [Vec2::ZERO; solidcraft_geom::MAX_BEZIER_CTRL];
+ let mut degree9 = [Vec2::ZERO; solidcore_record::MAX_BEZIER_CTRL];
for (i, p) in degree9.iter_mut().enumerate().take(10) {
let t = i as f64 / 9.0;
*p = Vec2::new(t * 2.0 - 1.0, ((i % 3) as f64 - 1.0) * 0.8);
diff --git a/crates/render/src/film_png.rs b/crates/render/src/film_png.rs
index c23227e0a0..13a12057f5 100644
--- a/crates/render/src/film_png.rs
+++ b/crates/render/src/film_png.rs
@@ -9,7 +9,8 @@
use super::{CompletePass, MAX_BYTES, invalid, limit};
use crate::job::encoding::PngEncoding;
use crate::job::{CancelToken, CpuHost, ErrorCode, JobError, Phase, Progress, Reservation, Result};
-use solidcraft_geom::{Vec3, srgb::encode8};
+use solidcore_record::Vec3;
+use solidcraft_geom::srgb::encode8;
/// Encoded bytes retain the actual existing host lease. No detached byte getter.
pub struct CompletedPng {
diff --git a/crates/render/src/hatch.rs b/crates/render/src/hatch.rs
index 60af8d4714..b2efeb4acb 100644
--- a/crates/render/src/hatch.rs
+++ b/crates/render/src/hatch.rs
@@ -5,9 +5,10 @@
//! the same from frame to frame and as the plane moves. Spacing and line width are the same for
//! every hatch; only the angle and the colour change.
+use solidcraft_geom::prelude::*;
use std::collections::{HashMap, HashSet};
-use solidcraft_geom::{Vec2, Vec3};
+use solidcore_record::{Vec2, Vec3};
/// The colours a cut is hatched in: the section cap's own, then the others of its family.
pub const HATCH_COLOURS: usize = 3;
diff --git a/crates/render/src/job/host.rs b/crates/render/src/job/host.rs
index c8ee940dfd..7494212642 100644
--- a/crates/render/src/job/host.rs
+++ b/crates/render/src/job/host.rs
@@ -1600,8 +1600,8 @@ mod retained_request_tests {
request.raytrace.as_mut().unwrap().emissions = Some(values);
let expected = retained_request_bytes(&request).unwrap();
let mesh = solidcraft_geom::Mesh {
- positions: vec![solidcraft_geom::Vec3::ZERO, solidcraft_geom::Vec3::X, solidcraft_geom::Vec3::Y],
- normals: vec![solidcraft_geom::Vec3::Z; 3],
+ positions: vec![solidcore_record::Vec3::ZERO, solidcore_record::Vec3::X, solidcore_record::Vec3::Y],
+ normals: vec![solidcore_record::Vec3::Z; 3],
triangles: vec![[0, 1, 2]],
tri_face: vec![0],
..Default::default()
@@ -1786,7 +1786,7 @@ mod surface_request_metadata_tests {
bump_amplitude_mm: 0.0,
});
}
- let scene = ProductScene { meshes, bounds: Aabb3 { min: solidcraft_geom::Vec3::ZERO, max: solidcraft_geom::Vec3::ZERO } };
+ let scene = ProductScene { meshes, bounds: Aabb3 { min: solidcore_record::Vec3::ZERO, max: solidcore_record::Vec3::ZERO } };
let mut request = request();
request.integrator = Integrator::Raytrace;
request.raytrace = Some(super::super::RaytraceOptions { surface_effects: Some(effects), ..Default::default() });
diff --git a/crates/render/src/job/image.rs b/crates/render/src/job/image.rs
index de4a4f0db6..460f4582a5 100644
--- a/crates/render/src/job/image.rs
+++ b/crates/render/src/job/image.rs
@@ -1,9 +1,10 @@
//! Incremental product rasterization. Every phase yields between bounded work units.
+use solidcraft_geom::prelude::*;
use std::collections::BTreeMap;
use serde::Serialize;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use super::{CancelToken, ErrorCode, ImageRequest, JobError, Phase, Progress, Result};
use crate::{FaceAppearance, Mat4, ProductScene, RenderFormat, RenderMode, RenderOperation, RenderRequest};
diff --git a/crates/render/src/job/led_strip.rs b/crates/render/src/job/led_strip.rs
index 08becb5f27..8615d05ed5 100644
--- a/crates/render/src/job/led_strip.rs
+++ b/crates/render/src/job/led_strip.rs
@@ -2,7 +2,8 @@
//! No source mesh, visible emission, spectral/CCT calibration or separate transport.
use super::{ErrorCode, JobError, RaytraceOptions, RectangleLightOptions, Result};
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
/// Illustrative linear RGB choices, not measured LED spectra or calibrated CCT.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
diff --git a/crates/render/src/job/lighting.rs b/crates/render/src/job/lighting.rs
index 11f4832858..61ca559d10 100644
--- a/crates/render/src/job/lighting.rs
+++ b/crates/render/src/job/lighting.rs
@@ -2,7 +2,8 @@
//! world-space millimetres; radiance is linear RGB. Saved setups reuse these bounds.
use super::{ErrorCode, JobError, Result};
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
pub const MAX_AREA_LIGHTS: usize = 4;
diff --git a/crates/render/src/job/mod.rs b/crates/render/src/job/mod.rs
index 055c7cb17d..58fa1d8426 100644
--- a/crates/render/src/job/mod.rs
+++ b/crates/render/src/job/mod.rs
@@ -1,6 +1,7 @@
//! Product-image work and its device-independent, session-scoped protocol.
//! Hosts own execution; documents and history never contain these values.
+use solidcraft_geom::prelude::*;
use std::fmt;
use std::sync::{
Arc,
@@ -963,7 +964,7 @@ impl RaytraceOptions {
}
if let Some(lights) = &self.area_lights {
for light in lights {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let vec = |v: [f64; 3]| Vec3::new(v[0], v[1], v[2]);
let c = vec(light.center_mm);
let u = vec(light.edge_u_mm);
diff --git a/crates/render/src/job/punctual.rs b/crates/render/src/job/punctual.rs
index 8e3549614e..2f95a4e736 100644
--- a/crates/render/src/job/punctual.rs
+++ b/crates/render/src/job/punctual.rs
@@ -60,7 +60,7 @@ impl PunctualLightOptions {
#[cfg(feature = "raytrace-cpu")]
pub(crate) fn light(self) -> crate::raytrace::Result<crate::raytrace::punctual::PunctualLight> {
use crate::raytrace::punctual::{PunctualLight, SpotCone};
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let [x, y, z] = self.position_mm;
let [r, g, b] = self.color;
let cone = self
diff --git a/crates/render/src/job/textures.rs b/crates/render/src/job/textures.rs
index 24bd45619f..210db6f1de 100644
--- a/crates/render/src/job/textures.rs
+++ b/crates/render/src/job/textures.rs
@@ -8,7 +8,8 @@ use crate::{
};
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
pub const MAX_TEXTURE_BINDINGS: usize = 128;
pub const MAX_TEXTURE_PIXELS_BYTES: u64 = 96 * 1024 * 1024;
diff --git a/crates/render/src/lighting/environment.rs b/crates/render/src/lighting/environment.rs
index 6b534ae391..099bb24014 100644
--- a/crates/render/src/lighting/environment.rs
+++ b/crates/render/src/lighting/environment.rs
@@ -4,7 +4,7 @@ use super::{HdrDecodeTask, HdrSource, HdrTaskPoll};
use crate::job::{CancelToken, ErrorCode, JobError, Result};
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
use std::{
f64::consts::{PI, TAU},
sync::Arc,
diff --git a/crates/render/src/lighting/environment_sampling.rs b/crates/render/src/lighting/environment_sampling.rs
index 06e5c91877..2511643368 100644
--- a/crates/render/src/lighting/environment_sampling.rs
+++ b/crates/render/src/lighting/environment_sampling.rs
@@ -2,7 +2,8 @@
//! Uniform solid-angle sampling deliberately has no luminance CDF or extra pixel copy.
use super::{DecodedHdr, HdrError, HdrErrorCode, MAX_HDR_HEIGHT, MAX_HDR_PIXELS, MAX_HDR_WIDTH, Result};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use std::f64::consts::{PI, TAU};
fn invalid(message: &str) -> HdrError {
diff --git a/crates/render/src/mapping.rs b/crates/render/src/mapping.rs
index 4e34f4aaed..cf20c21da8 100644
--- a/crates/render/src/mapping.rs
+++ b/crates/render/src/mapping.rs
@@ -1,7 +1,9 @@
//! Definition-local visual coordinates, independent of geometry and engineering axes.
//! This numerical foundation installs no texture sampler, shader or persistent record.
-use solidcraft_geom::{Aabb3, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Aabb3;
+use solidcraft_geom::prelude::*;
/// Admission bounds, not a GPU precision or engineering applicability guarantee.
pub const MAX_LOCAL_MM: f64 = 1e9;
diff --git a/crates/render/src/raster.rs b/crates/render/src/raster.rs
index ab65ffc943..4f09a4b8d8 100644
--- a/crates/render/src/raster.rs
+++ b/crates/render/src/raster.rs
@@ -1,7 +1,8 @@
//! CPU rasterizer for headless snapshots: z-buffered, smooth-shaded triangles and depth-tested
//! lines, rendered at 2× and downsampled for anti-aliasing.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use crate::Camera;
use crate::scene::{Rgb, SECTION_CAP, Scene, png};
diff --git a/crates/render/src/raytrace/anisotropic_faces.rs b/crates/render/src/raytrace/anisotropic_faces.rs
index 6362304f56..7295724904 100644
--- a/crates/render/src/raytrace/anisotropic_faces.rs
+++ b/crates/render/src/raytrace/anisotropic_faces.rs
@@ -2,7 +2,8 @@
//! Captured ordinal/name and mesh face tag must match. Strict plane equality is
//! conservative: rotated or imported roundoff may refuse instead of guessing.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use crate::{
ProductScene,
diff --git a/crates/render/src/raytrace/area.rs b/crates/render/src/raytrace/area.rs
index b58796082a..76301aa256 100644
--- a/crates/render/src/raytrace/area.rs
+++ b/crates/render/src/raytrace/area.rs
@@ -2,7 +2,8 @@
//! Sampling estimates the area integral; it is not an exact solid-angle integral.
//! No emitter geometry, indirect bounce or calibrated photometric units are implied.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use super::lighting::MAX_LINEAR_RADIANCE;
use super::{MAX_COORDINATE_MM, MAX_DISTANCE_MM, Ray, Result, TraceError};
diff --git a/crates/render/src/raytrace/dielectric.rs b/crates/render/src/raytrace/dielectric.rs
index 21a23478f1..b12116ccdf 100644
--- a/crates/render/src/raytrace/dielectric.rs
+++ b/crates/render/src/raytrace/dielectric.rs
@@ -2,7 +2,8 @@
//! Air is 1.0. Distances and absorption coefficients use millimetres.
use super::{Bounds, Result, TraceError, Triangle, unit};
use crate::{ProductScene, job::DielectricOptions};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
pub const MAX_OVERRIDES: usize = 8;
pub const MAX_BOUNDARIES: u8 = 8;
diff --git a/crates/render/src/raytrace/emission.rs b/crates/render/src/raytrace/emission.rs
index ff08b10b35..883212ea4a 100644
--- a/crates/render/src/raytrace/emission.rs
+++ b/crates/render/src/raytrace/emission.rs
@@ -1,6 +1,6 @@
//! Visible surface radiance only: no mesh-light sampling or neighboring illumination.
use crate::job::{EmissionSides, SurfaceEmission};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
#[derive(Clone, Copy, Debug)]
pub struct Emission {
diff --git a/crates/render/src/raytrace/image.rs b/crates/render/src/raytrace/image.rs
index 9f8f5077f4..eb3e12c402 100644
--- a/crates/render/src/raytrace/image.rs
+++ b/crates/render/src/raytrace/image.rs
@@ -13,7 +13,9 @@ use crate::{
film::primary::PrimaryFilm,
surface::{OpaqueSurface, srgb8_to_linear},
};
-use solidcraft_geom::{Vec3, srgb::encode8};
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
+use solidcraft_geom::srgb::encode8;
#[cfg(test)]
#[path = "environment_image_tests.rs"]
diff --git a/crates/render/src/raytrace/lighting.rs b/crates/render/src/raytrace/lighting.rs
index 0b9bdf1bf8..a5ba5adcb2 100644
--- a/crates/render/src/raytrace/lighting.rs
+++ b/crates/render/src/raytrace/lighting.rs
@@ -2,7 +2,8 @@
//! Colours are linear sRGB; intensity is relative radiance, not watts or illuminance.
//! Visibility is supplied separately for every light by the ray-tracing consumer.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use crate::surface::{OpaqueSurface, unit_direction};
diff --git a/crates/render/src/raytrace/mod.rs b/crates/render/src/raytrace/mod.rs
index bce13e9800..45a834fc14 100644
--- a/crates/render/src/raytrace/mod.rs
+++ b/crates/render/src/raytrace/mod.rs
@@ -5,7 +5,8 @@
//! or third-party ray-tracer implementation is used. See `docs/render-raytrace-core.md`.
use crate::job::CancelToken;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
mod anisotropic_faces;
pub mod area;
diff --git a/crates/render/src/raytrace/prepared.rs b/crates/render/src/raytrace/prepared.rs
index 14cd870acd..89bf9904d6 100644
--- a/crates/render/src/raytrace/prepared.rs
+++ b/crates/render/src/raytrace/prepared.rs
@@ -1,7 +1,8 @@
//! Borrowed prepared-scene contract shared by bounded transport consumers.
use super::{Bvh, Hit, MAX_DISTANCE_MM, Ray, Result, TraceError};
use crate::{ProductScene, surface::OpaqueSurface};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
#[derive(Clone, Copy)]
pub struct PreparedPrimitive {
diff --git a/crates/render/src/raytrace/punctual.rs b/crates/render/src/raytrace/punctual.rs
index 4eed08f9e4..5cc3201fb3 100644
--- a/crates/render/src/raytrace/punctual.rs
+++ b/crates/render/src/raytrace/punctual.rs
@@ -1,7 +1,8 @@
//! Original relative point/spot response. Coordinates/reference distances are mm.
//! No lumen, lux, watts, measured CCT, IES or glTF photometry is implied.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use super::{Ray, Result, TraceError, bounded, lighting::MAX_LIGHT_INTENSITY, prepared::SharedHit, unit};
diff --git a/crates/render/src/raytrace/reflection.rs b/crates/render/src/raytrace/reflection.rs
index 1c04ca84cd..958f36267d 100644
--- a/crates/render/src/raytrace/reflection.rs
+++ b/crates/render/src/raytrace/reflection.rs
@@ -2,7 +2,8 @@
use super::{Result, TraceError};
use crate::anisotropic_surface::{AnisotropicSurface, VisualFrame};
use crate::surface::{OpaqueSurface, unit_direction};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
#[cfg(test)]
use std::f64::consts::{PI, TAU};
#[derive(Clone, Copy, Debug)]
@@ -133,6 +134,7 @@ mod vndf_tests;
#[cfg(test)]
mod tests {
use super::{OpaqueSurface, PI, Vec3, hash_variates as variates, mirror, rough_specular};
+ use solidcraft_geom::prelude::*;
fn white() -> OpaqueSurface {
OpaqueSurface::new(Vec3::new(1.0, 1.0, 1.0), 1.0, 1.0, 1.5).unwrap()
}
diff --git a/crates/render/src/scene.rs b/crates/render/src/scene.rs
index a87d233019..f0699ebcdb 100644
--- a/crates/render/src/scene.rs
+++ b/crates/render/src/scene.rs
@@ -4,7 +4,8 @@
use std::sync::Arc;
-use solidcraft_geom::{Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::Mesh;
use crate::SceneAnalysis;
use crate::hatch::{HATCH_COLOURS, Hatch};
diff --git a/crates/render/src/stage.rs b/crates/render/src/stage.rs
index 56ec8808b4..134860bc79 100644
--- a/crates/render/src/stage.rs
+++ b/crates/render/src/stage.rs
@@ -7,7 +7,9 @@ use crate::{
surface::OpaqueSurface,
};
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Aabb3, Mesh, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
+use solidcraft_geom::{Aabb3, Mesh};
use std::{collections::BTreeSet, fmt, sync::Arc};
pub const MAX_STAGE_PANELS: usize = 32;
diff --git a/crates/render/src/studio.rs b/crates/render/src/studio.rs
index 435c5daaae..99c883db60 100644
--- a/crates/render/src/studio.rs
+++ b/crates/render/src/studio.rs
@@ -1,7 +1,8 @@
//! Original fixed direct-light studio used by opaque product preview consumers.
//! Relative linear radiance, not a calibrated illuminance or an HDRI environment.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use crate::surface::{OpaqueSurface, SurfaceError, unit_direction};
diff --git a/crates/render/src/surface.rs b/crates/render/src/surface.rs
index 0ebb8612bd..69a629b612 100644
--- a/crates/render/src/surface.rs
+++ b/crates/render/src/surface.rs
@@ -1,9 +1,10 @@
//! Bounded opaque metallic/roughness surfaces in linear sRGB.
//! This numerical contract does not enable a renderer or persist appearances.
+use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
/// Lowest admitted perceptual roughness. Perfect delta mirrors need another integrator.
pub const MIN_ROUGHNESS: f64 = 0.045;
diff --git a/crates/render/src/surface_patterns.rs b/crates/render/src/surface_patterns.rs
index cac18ae265..9f8c20da03 100644
--- a/crates/render/src/surface_patterns.rs
+++ b/crates/render/src/surface_patterns.rs
@@ -1,7 +1,8 @@
//! Original periodic preview fields in an explicit world-space millimetre frame.
//! Only roughness and shading normals change; geometry and visibility do not.
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use std::f64::consts::TAU;
use crate::job::{ErrorCode, JobError, Result};
diff --git a/crates/render/src/transmission.rs b/crates/render/src/transmission.rs
index d53ab1c615..895df0376a 100644
--- a/crates/render/src/transmission.rs
+++ b/crates/render/src/transmission.rs
@@ -1,5 +1,6 @@
//! Bounded optical data and original f64 dielectric transport oracles. Units are mm.
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
#[path = "subsurface.rs"]
pub mod subsurface;
use subsurface::Subsurface;
diff --git a/crates/sketch/Cargo.toml b/crates/sketch/Cargo.toml
index ba238d5a25..268a2de749 100644
--- a/crates/sketch/Cargo.toml
+++ b/crates/sketch/Cargo.toml
@@ -17,6 +17,7 @@ name = "solve_profile"
required-features = ["solver-profiling"]
[dependencies]
+solidcore-record = { workspace = true }
harfrust = "0.12"
solidcraft-geom = { workspace = true }
serde = { workspace = true }
diff --git a/crates/sketch/examples/solve_bench.rs b/crates/sketch/examples/solve_bench.rs
index 19ee338482..c81595b652 100644
--- a/crates/sketch/examples/solve_bench.rs
+++ b/crates/sketch/examples/solve_bench.rs
@@ -5,7 +5,7 @@
use std::time::Instant;
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use solidcraft_sketch::{
Analysis, Budget, ConstraintKind, Hold, PatternAlignment, Sketch, SketchPattern, SketchPatternKind, SolveReport, solve, solve_with,
};
diff --git a/crates/sketch/examples/solve_profile.rs b/crates/sketch/examples/solve_profile.rs
index f41e12af60..068b56a3d1 100644
--- a/crates/sketch/examples/solve_profile.rs
+++ b/crates/sketch/examples/solve_profile.rs
@@ -3,7 +3,7 @@
use std::{error::Error, io::Write, path::PathBuf, time::Instant};
use serde::Serialize;
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use solidcraft_sketch::{
Analysis, ConstraintKind, DrivingValues, Hold, Sketch, SolveReport,
profiling::{Counters, SolveProfile, Timings, capture},
diff --git a/crates/sketch/src/circle_edge_tests.rs b/crates/sketch/src/circle_edge_tests.rs
index 506c57f933..65184756a0 100644
--- a/crates/sketch/src/circle_edge_tests.rs
+++ b/crates/sketch/src/circle_edge_tests.rs
@@ -2,7 +2,8 @@
//! arcs (#4064): solved numerically and by construction, measured, drawn between the edge points
//! that face each other, saved, and refused on other kinds of curve.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::tests::v;
use crate::*;
diff --git a/crates/sketch/src/coincident_tangent_tests.rs b/crates/sketch/src/coincident_tangent_tests.rs
index da4e15a2ed..f865bda5ed 100644
--- a/crates/sketch/src/coincident_tangent_tests.rs
+++ b/crates/sketch/src/coincident_tangent_tests.rs
@@ -3,7 +3,8 @@
//! (distance from the centre equals the radius) is a double root there, so it converged to only
//! sqrt(residual) of tangent and lost a row of rank when the start already was tangent.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::tests::{Lcg, v};
use crate::*;
diff --git a/crates/sketch/src/construct.rs b/crates/sketch/src/construct.rs
index 53be92b625..80de1b8a02 100644
--- a/crates/sketch/src/construct.rs
+++ b/crates/sketch/src/construct.rs
@@ -40,7 +40,7 @@
use std::collections::{BTreeMap, BTreeSet, VecDeque};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use crate::decompose::{Budget, Decomposition, enqueue};
use crate::loci::{MAX_LOCI, Reading, Rel, View, place, radii, read};
diff --git a/crates/sketch/src/construct_rounds_tests.rs b/crates/sketch/src/construct_rounds_tests.rs
index ec7442d993..566eeb6333 100644
--- a/crates/sketch/src/construct_rounds_tests.rs
+++ b/crates/sketch/src/construct_rounds_tests.rs
@@ -5,7 +5,8 @@
//! and its sweep, every line its direction, every point its side of its lines.
//! Deterministic (fixed LCG seeds), no timing.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::construct::{Placement, seed};
use crate::decompose::Budget;
diff --git a/crates/sketch/src/construct_tests.rs b/crates/sketch/src/construct_tests.rs
index 503a1152bd..13e9e8d84a 100644
--- a/crates/sketch/src/construct_tests.rs
+++ b/crates/sketch/src/construct_tests.rs
@@ -2,7 +2,8 @@
//! points that keep a degree of freedom, drag continuity, and hostile input. Deterministic
//! (fixed LCG seeds), no timing.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::construct::{Placement, seed};
use crate::decompose::Budget;
diff --git a/crates/sketch/src/continuation_tests.rs b/crates/sketch/src/continuation_tests.rs
index 13c418058b..4c530ed8e6 100644
--- a/crates/sketch/src/continuation_tests.rs
+++ b/crates/sketch/src/continuation_tests.rs
@@ -2,7 +2,8 @@
//! triangles joined by three links, left to the iteration by the construction) under random
//! dimension edits from its previous solved state, with every failure that remains proven
//! infeasible; and the solve without continuation when nothing it could help with changed.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::construct::switch;
use crate::model::{ConstraintKind, Sketch};
diff --git a/crates/sketch/src/cursor.rs b/crates/sketch/src/cursor.rs
index 366f7c5d9c..3a22b0dcce 100644
--- a/crates/sketch/src/cursor.rs
+++ b/crates/sketch/src/cursor.rs
@@ -9,7 +9,8 @@ use crate::{
linalg::{Mat, rref},
union_find::{find, union},
};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
const MAX_VARIABLES: usize = 400;
const MAX_STEPS: usize = 96;
diff --git a/crates/sketch/src/curves.rs b/crates/sketch/src/curves.rs
index e35bc07116..0ef36d7f56 100644
--- a/crates/sketch/src/curves.rs
+++ b/crates/sketch/src/curves.rs
@@ -2,9 +2,10 @@
//! control points) and conics (rational quadratic Béziers). Evaluation works on positions so
//! the solver can use it with trial values.
+use solidcraft_geom::prelude::*;
use std::f64::consts::TAU;
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
/// Polyline samples per spline span / conic / ellipse quarter.
const SPAN_SAMPLES: usize = 24;
@@ -153,7 +154,7 @@ pub fn spline_point(p: &[Vec2], control: bool, degree: u8, t: f64) -> Vec2 {
return p.first().copied().unwrap_or_default();
}
if control {
- return bspline_at(p, degree.clamp(1, solidcraft_geom::MAX_BEZIER_DEGREE as u8) as usize, t);
+ return bspline_at(p, degree.clamp(1, solidcore_record::MAX_BEZIER_DEGREE as u8) as usize, t);
}
let spans = fit_spans(p);
let n = spans.len().max(1);
@@ -301,7 +302,7 @@ pub fn spline_polyline(p: &[Vec2], control: bool, degree: u8) -> Vec<Vec2> {
return p.to_vec();
}
if control {
- return bspline_polyline(p, degree.clamp(1, solidcraft_geom::MAX_BEZIER_DEGREE as u8) as usize);
+ return bspline_polyline(p, degree.clamp(1, solidcore_record::MAX_BEZIER_DEGREE as u8) as usize);
}
let mut out = Vec::new();
for (p0, p1, t0, t1) in fit_spans(p) {
diff --git a/crates/sketch/src/decompose.rs b/crates/sketch/src/decompose.rs
index 0e85462a0a..859ab2868e 100644
--- a/crates/sketch/src/decompose.rs
+++ b/crates/sketch/src/decompose.rs
@@ -55,10 +55,11 @@
//! down well and a branch the reference does not decide is unknown, so neither is merged
//! (the solver starts those points where they are).
+use solidcraft_geom::prelude::*;
use std::collections::btree_map::Entry;
use std::collections::{BTreeMap, BTreeSet, VecDeque};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use crate::loci::{Locus, Reading, Rel, Span, View, crossing, mag, place, side};
use crate::union_find::{find, union};
diff --git a/crates/sketch/src/degenerate_line_tests.rs b/crates/sketch/src/degenerate_line_tests.rs
index 065028290e..c96cabcd55 100644
--- a/crates/sketch/src/degenerate_line_tests.rs
+++ b/crates/sketch/src/degenerate_line_tests.rs
@@ -7,7 +7,8 @@
//! are ~1. Dragging an endpoint of `l1` must keep the sketch solved: the cursor may not leave the
//! constraint manifold, and the rank analysis may not hide `l1`'s coupling below its tolerance.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::{Analysis, ConstraintKind, Hold, Sketch, move_point_towards, solve_with};
diff --git a/crates/sketch/src/dims.rs b/crates/sketch/src/dims.rs
index 3a45d61702..427570ffc9 100644
--- a/crates/sketch/src/dims.rs
+++ b/crates/sketch/src/dims.rs
@@ -8,7 +8,8 @@
//!
//! [`Constraint::text`]: crate::Constraint::text
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::model::{ConstraintKind, CurveKind, Sketch, TwoCircles};
use crate::union_find::{find, union};
@@ -75,7 +76,7 @@ pub fn dim_frame(sk: &Sketch, k: &ConstraintKind) -> Option<DimFrame> {
}
}
ArcSweep { c, .. } => match sk.segs(c).first()? {
- solidcraft_geom::Seg2::Arc { center, start, sweep, .. } => {
+ solidcore_record::Seg2::Arc { center, start, sweep, .. } => {
DimFrame::Angular { vertex: *center, d0: Vec2::from_angle(*start), sweep: *sweep }
}
_ => return None,
@@ -128,7 +129,7 @@ pub fn dim_frame(sk: &Sketch, k: &ConstraintKind) -> Option<DimFrame> {
let (radius, arc) = match sk.curves.get(c)?.kind {
CurveKind::Ellipse { r, .. } => (r, None),
CurveKind::Arc { .. } => match sk.segs(c).first()? {
- solidcraft_geom::Seg2::Arc { radius, start, sweep, .. } => (*radius, Some((*start, *sweep))),
+ solidcore_record::Seg2::Arc { radius, start, sweep, .. } => (*radius, Some((*start, *sweep))),
_ => return None,
},
_ => (sk.radius(c)?, None),
@@ -136,7 +137,7 @@ pub fn dim_frame(sk: &Sketch, k: &ConstraintKind) -> Option<DimFrame> {
DimFrame::Radial { center: sk.center(c)?, radius, diameter: matches!(k, Diameter { .. }), arc }
}
ArcLength { c, .. } => match sk.segs(c).first()? {
- solidcraft_geom::Seg2::Arc { center, radius, start, sweep } => {
+ solidcore_record::Seg2::Arc { center, radius, start, sweep } => {
DimFrame::ArcLength { center: *center, radius: *radius, start: *start, sweep: *sweep }
}
_ => return None,
diff --git a/crates/sketch/src/ends.rs b/crates/sketch/src/ends.rs
index f63328141f..30dfa2eb73 100644
--- a/crates/sketch/src/ends.rs
+++ b/crates/sketch/src/ends.rs
@@ -9,7 +9,9 @@
//! An end is tied when it is shared with another curve's end, joined to one by coincident
//! constraints, or held on a curve (point on curve, midpoint).
-use solidcraft_geom::{Aabb2, Seg2, Vec2};
+use solidcore_record::{Seg2, Vec2};
+use solidcraft_geom::Aabb2;
+use solidcraft_geom::prelude::*;
use crate::model::{ConstraintKind, CurveKind, Sketch};
use crate::union_find::{find, union};
diff --git a/crates/sketch/src/ends_tests.rs b/crates/sketch/src/ends_tests.rs
index 9cd7606ec3..75f208e94c 100644
--- a/crates/sketch/src/ends_tests.rs
+++ b/crates/sketch/src/ends_tests.rs
@@ -1,6 +1,6 @@
//! Open and untied ends of profile curves.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use crate::{ConstraintKind, EndTouch, Sketch, find_profiles, loose_ends};
diff --git a/crates/sketch/src/equation.rs b/crates/sketch/src/equation.rs
index b37275de94..d36c3b5dc8 100644
--- a/crates/sketch/src/equation.rs
+++ b/crates/sketch/src/equation.rs
@@ -5,7 +5,7 @@
//! still share its end points.
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use crate::model::{CurveKind, Result, Sketch, SketchError};
diff --git a/crates/sketch/src/font_tests.rs b/crates/sketch/src/font_tests.rs
index fc1c1ac466..1fd162d899 100644
--- a/crates/sketch/src/font_tests.rs
+++ b/crates/sketch/src/font_tests.rs
@@ -2,9 +2,10 @@
//! known by hand; the repository's second font (BIZ UDPGothic, `assets/fonts/biz-udp-gothic`) stands for
//! a real one.
+use solidcraft_geom::prelude::*;
use std::path::PathBuf;
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use crate::fonts::find_family_in;
use crate::tests::v;
diff --git a/crates/sketch/src/freeform_offset.rs b/crates/sketch/src/freeform_offset.rs
index 68bf0d8e6d..5226d3e51b 100644
--- a/crates/sketch/src/freeform_offset.rs
+++ b/crates/sketch/src/freeform_offset.rs
@@ -6,7 +6,8 @@
//! identical parameter speeds; stored nodes and interpolation remain unchanged.
use crate::{CurveKind, Sketch, SketchError, fit_beziers_mode};
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Seg2, Vec2};
+use solidcore_record::{Seg2, Vec2};
+use solidcraft_geom::prelude::*;
mod trim;
pub use trim::FreeformOffsetOutput;
@@ -140,7 +141,7 @@ impl H {
let (points, weights) = match *seg {
Seg2::Line { a, b } => (vec![a, b], vec![1.0; 2]),
Seg2::Cubic { p0, p1, p2, p3 } => (vec![p0, p1, p2, p3], vec![1.0; 4]),
- Seg2::Bezier { n, p } if (1..=solidcraft_geom::MAX_BEZIER_DEGREE as u8).contains(&n) => {
+ Seg2::Bezier { n, p } if (1..=solidcore_record::MAX_BEZIER_DEGREE as u8).contains(&n) => {
(p[..=usize::from(n)].to_vec(), vec![1.0; usize::from(n) + 1])
}
Seg2::Conic { a, apex, b, w } if w.is_finite() && w > 0.0 => (vec![a, apex, b], vec![1.0, w, 1.0]),
diff --git a/crates/sketch/src/freeform_offset/trim.rs b/crates/sketch/src/freeform_offset/trim.rs
index 070e3b60d0..3939cf50bf 100644
--- a/crates/sketch/src/freeform_offset/trim.rs
+++ b/crates/sketch/src/freeform_offset/trim.rs
@@ -12,7 +12,8 @@
//! to its source.
use super::{Certificate, H, MAX_OFFSET_WORK, MAX_PIECES, OFFSET_TOLERANCE, Result, bad, certify, normal_point};
use crate::{CurveKind, Sketch, fit_beziers};
-use solidcraft_geom::{Seg2, Vec2};
+use solidcore_record::{Seg2, Vec2};
+use solidcraft_geom::prelude::*;
/// Samples of the plain offset used to find its crossings (whole chain).
const MAX_SAMPLES: usize = 32_768;
diff --git a/crates/sketch/src/least_motion_tests.rs b/crates/sketch/src/least_motion_tests.rs
index 875c7cd712..3960701690 100644
--- a/crates/sketch/src/least_motion_tests.rs
+++ b/crates/sketch/src/least_motion_tests.rs
@@ -1,6 +1,7 @@
//! A solve with geometry held moves the rest as little as it can.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::{Analysis, ConstraintKind, Hold, Sketch, solve_with};
diff --git a/crates/sketch/src/line_circle_tests.rs b/crates/sketch/src/line_circle_tests.rs
index 0acbc3b4d0..73a728ed92 100644
--- a/crates/sketch/src/line_circle_tests.rs
+++ b/crates/sketch/src/line_circle_tests.rs
@@ -2,7 +2,8 @@
//! construction, measured, kept on its side of the line through edits, and refused on other
//! kinds of curve.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::tests::v;
use crate::*;
diff --git a/crates/sketch/src/link.rs b/crates/sketch/src/link.rs
index a53ca3df7f..d048bbeb80 100644
--- a/crates/sketch/src/link.rs
+++ b/crates/sketch/src/link.rs
@@ -7,7 +7,9 @@
//! constants; they still bound profiles and take constraints and dimensions like any curve.
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Aabb2, Vec2, Vec3};
+use solidcore_record::{Vec2, Vec3};
+use solidcraft_geom::Aabb2;
+use solidcraft_geom::prelude::*;
use crate::model::{Curve, CurveKind, Result, Sketch, SketchError, in_range, radius_in_range};
@@ -271,7 +273,7 @@ impl LinkGeom {
&& nurbs.as_ref().is_none_or(|k| *control && !*periodic && k.check(pts.len(), *degree).is_ok())
&& (2..=crate::curves::MAX_SPLINE_POINTS).contains(&pts.len())
&& pts.iter().all(ok)
- && (1..=solidcraft_geom::MAX_BEZIER_DEGREE as u8).contains(degree)
+ && (1..=solidcore_record::MAX_BEZIER_DEGREE as u8).contains(degree)
}
}
}
diff --git a/crates/sketch/src/link_loops.rs b/crates/sketch/src/link_loops.rs
index 0125ed95eb..5c732652aa 100644
--- a/crates/sketch/src/link_loops.rs
+++ b/crates/sketch/src/link_loops.rs
@@ -2,7 +2,9 @@
//! Endpoint walks exclude support centres. Crossings/touches refuse before nesting.
use super::{LCurve, curve_points};
use crate::{Shape, intersections};
-use solidcraft_geom::{Aabb2, Vec2};
+use solidcore_record::Vec2;
+use solidcraft_geom::Aabb2;
+use solidcraft_geom::prelude::*;
use std::f64::consts::TAU;
struct Boundary {
diff --git a/crates/sketch/src/loci.rs b/crates/sketch/src/loci.rs
index b8215ecb39..3537048772 100644
--- a/crates/sketch/src/loci.rs
+++ b/crates/sketch/src/loci.rs
@@ -32,7 +32,8 @@
//! Tolerances are relative to the loci's own size plus the rounding of the coordinates they
//! are computed from, so a construction far from the origin behaves like the same one near it.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::model::{ConstraintKind, CurveKind, MAX_COORD, Sketch, in_range, radius_in_range};
use crate::union_find::{find, union};
diff --git a/crates/sketch/src/model.rs b/crates/sketch/src/model.rs
index 55fbfc5b20..18a238df14 100644
--- a/crates/sketch/src/model.rs
+++ b/crates/sketch/src/model.rs
@@ -1,5 +1,7 @@
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Aabb2, Seg2, Vec2, Vec3};
+use solidcore_record::{Seg2, Vec2, Vec3};
+use solidcraft_geom::Aabb2;
+use solidcraft_geom::prelude::*;
use crate::union_find::{find, union};
@@ -1496,7 +1498,7 @@ impl Sketch {
_ => Vec::new(),
},
CurveKind::Circle { c, r } => match self.point(c) {
- Some(c) => solidcraft_geom::Loop2::circle(c, r).segs,
+ Some(c) => solidcore_record::Loop2::circle(c, r).segs,
None => Vec::new(),
},
CurveKind::Arc { c, a, b } => match (self.point(c), self.point(a), self.point(b)) {
@@ -1548,7 +1550,7 @@ impl Sketch {
let p: Vec<Vec2> = pts.iter().map(pt).collect::<Option<_>>()?;
nurbs.segs(&p, *degree)
}
- CurveKind::Spline { pts, control: true, degree, nurbs: None, .. } if (*degree as usize) <= solidcraft_geom::MAX_BEZIER_DEGREE => {
+ CurveKind::Spline { pts, control: true, degree, nurbs: None, .. } if (*degree as usize) <= solidcore_record::MAX_BEZIER_DEGREE => {
let p: Vec<Vec2> = pts.iter().map(pt).collect::<Option<_>>()?;
let k = (*degree as usize).min(p.len().saturating_sub(1)).max(1);
Some(crate::curves::bspline_beziers(&p, k).iter().filter_map(|c| solidcraft_geom::bezier(c)).collect())
@@ -1560,7 +1562,7 @@ impl Sketch {
/// The exact [`Seg2`] pieces of a curve of any kind, in the curve's own direction of travel:
/// lines, circles and arcs from their analytic form, free-form curves through
/// [`Sketch::exact_segs`]. Empty for a curve with no exact pieces (a spline above
- /// `solidcraft_geom::MAX_BEZIER_DEGREE`).
+ /// `solidcore_record::MAX_BEZIER_DEGREE`).
pub fn exact_pieces(&self, ci: usize) -> Vec<Seg2> {
match self.exact_segs(ci) {
Some(segs) => segs,
@@ -1623,10 +1625,11 @@ impl Sketch {
}
nurbs.check(pts.len(), *degree)?;
}
- if pts.len() < 2 || pts.len() > crate::curves::MAX_SPLINE_POINTS || !(1..=solidcraft_geom::MAX_BEZIER_DEGREE as u8).contains(degree) {
+ if pts.len() < 2 || pts.len() > crate::curves::MAX_SPLINE_POINTS || !(1..=solidcore_record::MAX_BEZIER_DEGREE as u8).contains(degree)
+ {
return Err(SketchError::Invalid(format!(
"a spline needs 2 to 500 points and degree 1 to {}",
- solidcraft_geom::MAX_BEZIER_DEGREE
+ solidcore_record::MAX_BEZIER_DEGREE
)));
}
if *periodic {
diff --git a/crates/sketch/src/nurbs.rs b/crates/sketch/src/nurbs.rs
index a3eae65110..977854e80a 100644
--- a/crates/sketch/src/nurbs.rs
+++ b/crates/sketch/src/nurbs.rs
@@ -3,13 +3,13 @@
//! control spline without them is the clamped uniform B-spline over its points.
use serde::{Deserialize, Serialize};
+use solidcore_record::{Seg2, Vec2, Vec3};
use solidcraft_geom::bspline::{self, HPoint};
-use solidcraft_geom::{Seg2, Vec2, Vec3};
use crate::model::{Result, SketchError};
/// Most knots a spline may have (its points are capped at [`crate::MAX_SPLINE_POINTS`]).
-const MAX_KNOTS: usize = crate::curves::MAX_SPLINE_POINTS + solidcraft_geom::MAX_BEZIER_DEGREE + 1;
+const MAX_KNOTS: usize = crate::curves::MAX_SPLINE_POINTS + solidcore_record::MAX_BEZIER_DEGREE + 1;
/// Most a weight may exceed another by: past it the curve is all but its heaviest points.
const MAX_WEIGHT_RATIO: f64 = 1e12;
/// Polyline samples per knot span.
@@ -33,7 +33,7 @@ impl Nurbs {
/// Whether these knots and weights fit a control spline of `degree` over `n` points.
pub fn check(&self, n: usize, degree: u8) -> Result<()> {
let d = usize::from(degree);
- if !(1..=solidcraft_geom::MAX_BEZIER_DEGREE).contains(&d) || n <= d || n > crate::curves::MAX_SPLINE_POINTS {
+ if !(1..=solidcore_record::MAX_BEZIER_DEGREE).contains(&d) || n <= d || n > crate::curves::MAX_SPLINE_POINTS {
return bad("a knotted spline needs more points than its degree, 1 to 9");
}
let k = &self.knots;
diff --git a/crates/sketch/src/offset.rs b/crates/sketch/src/offset.rs
index 6508162b35..5fdda5589d 100644
--- a/crates/sketch/src/offset.rs
+++ b/crates/sketch/src/offset.rs
@@ -1,7 +1,8 @@
//! Associative offsets keep their output entity ids while their source curves move.
use crate::{ConstraintKind, CurveKind, Shape, Sketch, SketchError, intersections};
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct OffsetChain {
diff --git a/crates/sketch/src/offset_topology.rs b/crates/sketch/src/offset_topology.rs
index 2d04e071c0..6467d42fc6 100644
--- a/crates/sketch/src/offset_topology.rs
+++ b/crates/sketch/src/offset_topology.rs
@@ -1,9 +1,10 @@
//! Exact convex parallel boundaries with persistent extinct arc identities.
+use solidcraft_geom::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
use std::f64::consts::TAU;
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Seg2, Vec2};
+use solidcore_record::{Seg2, Vec2};
use crate::{Curve, CurveKind, OffsetChain, Sketch, SketchError};
type Result<T> = std::result::Result<T, SketchError>;
diff --git a/crates/sketch/src/pattern.rs b/crates/sketch/src/pattern.rs
index 92ebc1d4e0..ad2a9d98f1 100644
--- a/crates/sketch/src/pattern.rs
+++ b/crates/sketch/src/pattern.rs
@@ -1,7 +1,8 @@
//! Stored parameters and stable entity ids for editing an existing sketch pattern.
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::{ConstraintKind, Curve, CurveKind, Sketch, SketchError};
diff --git a/crates/sketch/src/periodic.rs b/crates/sketch/src/periodic.rs
index b4f4ff2f42..614df9be15 100644
--- a/crates/sketch/src/periodic.rs
+++ b/crates/sketch/src/periodic.rs
@@ -1,7 +1,8 @@
//! Explicit cyclic C2 fit splines. Missing periodic markers retain natural interpolation.
use crate::model::in_range;
use crate::{MAX_SPLINE_POINTS, Sketch, SketchError};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
type Result<T> = std::result::Result<T, SketchError>;
fn bad() -> SketchError {
diff --git a/crates/sketch/src/profiles.rs b/crates/sketch/src/profiles.rs
index 4a6da1d79b..419c143a8d 100644
--- a/crates/sketch/src/profiles.rs
+++ b/crates/sketch/src/profiles.rs
@@ -7,11 +7,13 @@
//! the innermost loop containing it, so a circle inside a rectangle gives two profiles: the
//! rectangle with a hole, and the disc.
+use solidcraft_geom::prelude::*;
use std::f64::consts::TAU;
use std::sync::Arc;
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Loop2, Region2, Ring, Seg2, Vec2};
+use solidcore_record::{Loop2, Region2, Seg2, Vec2};
+use solidcraft_geom::Ring;
use crate::model::{CurveKind, Sketch};
use crate::shape::{Shape, intersections_within};
@@ -906,7 +908,7 @@ fn seg_boxes(s: &Seg2, out: &mut Vec<solidcraft_geom::Aabb2>) {
}
Seg2::Cubic { p0, p1, p2, p3 } => out.push(hull(&[p0, p1, p2, p3])),
Seg2::Conic { a, apex, b, w } if w.is_finite() && w > 0.0 => out.push(hull(&[a, apex, b])),
- Seg2::Bezier { n, ref p } if (1..=solidcraft_geom::MAX_BEZIER_DEGREE).contains(&(n as usize)) => {
+ Seg2::Bezier { n, ref p } if (1..=solidcore_record::MAX_BEZIER_DEGREE).contains(&(n as usize)) => {
out.push(hull(p.get(..=n as usize).unwrap_or(p)));
}
// Anything else: the very points the search samples.
diff --git a/crates/sketch/src/profiling.rs b/crates/sketch/src/profiling.rs
index 38d002b0ea..dbb7dd190a 100644
--- a/crates/sketch/src/profiling.rs
+++ b/crates/sketch/src/profiling.rs
@@ -312,7 +312,7 @@ pub(crate) fn trial(record: Trial) {
mod tests {
use super::*;
use crate::{Analysis, ConstraintKind, Hold, Sketch, solve_with};
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
fn distance(x: f64) -> Sketch {
let mut sk = Sketch::new();
diff --git a/crates/sketch/src/redundancy_tests.rs b/crates/sketch/src/redundancy_tests.rs
index 3b284b52f6..81feb2423d 100644
--- a/crates/sketch/src/redundancy_tests.rs
+++ b/crates/sketch/src/redundancy_tests.rs
@@ -80,7 +80,7 @@ fn sparse_and_dense_rows_match_over_seeded_mixed_rank_matrices() {
#[test]
fn real_sketch_jacobians_keep_redundant_blocks_and_support() {
use crate::ConstraintKind;
- use solidcraft_geom::Vec2;
+ use solidcore_record::Vec2;
for seed in 0..8 {
let mut sk = Sketch::new();
diff --git a/crates/sketch/src/shape.rs b/crates/sketch/src/shape.rs
index 0b19dbf7c2..ae73cbc8a1 100644
--- a/crates/sketch/src/shape.rs
+++ b/crates/sketch/src/shape.rs
@@ -1,8 +1,9 @@
//! Analytic curve shapes for geometry operations (profiles, trim, extend, fillet…).
+use solidcraft_geom::prelude::*;
use std::f64::consts::TAU;
-use solidcraft_geom::{Seg2, Vec2};
+use solidcore_record::{Seg2, Vec2};
use crate::model::{CurveKind, Sketch};
diff --git a/crates/sketch/src/solver.rs b/crates/sketch/src/solver.rs
index abe70b0635..a6e2de8c2c 100644
--- a/crates/sketch/src/solver.rs
+++ b/crates/sketch/src/solver.rs
@@ -14,7 +14,8 @@
//! analysis runs only on what remains.
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Seg2, Vec2};
+use solidcore_record::{Seg2, Vec2};
+use solidcraft_geom::prelude::*;
use crate::decompose::Budget;
use crate::linalg::{Mat, determined_vars, solve as lin_solve};
@@ -316,7 +317,7 @@ impl State<'_> {
if let Some(nurbs) = nurbs {
nurbs.segs(&p, *degree).unwrap_or_default()
} else if *control {
- let k = (*degree as usize).min(solidcraft_geom::MAX_BEZIER_DEGREE).min(p.len().saturating_sub(1)).max(1);
+ let k = (*degree as usize).min(solidcore_record::MAX_BEZIER_DEGREE).min(p.len().saturating_sub(1)).max(1);
crate::curves::bspline_beziers(&p, k).iter().filter_map(|span| solidcraft_geom::bezier(span)).collect()
} else {
crate::curves::fit_beziers_mode(&p, *periodic)
diff --git a/crates/sketch/src/spline_points.rs b/crates/sketch/src/spline_points.rs
index bd8e28e67e..57ecf85555 100644
--- a/crates/sketch/src/spline_points.rs
+++ b/crates/sketch/src/spline_points.rs
@@ -8,7 +8,8 @@
//! Control point splines take no new points yet: their knots are uniform, so one more control
//! point re-spreads every span and the whole curve moves, wherever the point goes.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use crate::model::{ConstraintKind, CurveKind, Result, Sketch, SketchError};
diff --git a/crates/sketch/src/tests.rs b/crates/sketch/src/tests.rs
index 2ce12ec81a..fbc85c223d 100644
--- a/crates/sketch/src/tests.rs
+++ b/crates/sketch/src/tests.rs
@@ -1,6 +1,7 @@
+use solidcraft_geom::prelude::*;
use std::f64::consts::{FRAC_PI_2, PI};
-use solidcraft_geom::{Seg2, Vec2};
+use solidcore_record::{Seg2, Vec2};
use crate::*;
@@ -787,13 +788,15 @@ fn curves_lying_on_one_another_do_not_chain_past_the_tolerance() {
#[test]
fn merging_adjacent_regions() {
- let a =
- solidcraft_geom::Region2 { outer: solidcraft_geom::Loop2::polygon(&[v(0.0, 0.0), v(10.0, 0.0), v(10.0, 10.0), v(0.0, 10.0)]), holes: vec![] };
- let b = solidcraft_geom::Region2 {
- outer: solidcraft_geom::Loop2::polygon(&[v(10.0, 0.0), v(20.0, 0.0), v(20.0, 10.0), v(10.0, 10.0)]),
+ let a = solidcore_record::Region2 {
+ outer: solidcore_record::Loop2::polygon(&[v(0.0, 0.0), v(10.0, 0.0), v(10.0, 10.0), v(0.0, 10.0)]),
holes: vec![],
};
- let c = solidcraft_geom::Region2 { outer: solidcraft_geom::Loop2::polygon(&[v(50.0, 0.0), v(60.0, 0.0), v(60.0, 10.0)]), holes: vec![] };
+ let b = solidcore_record::Region2 {
+ outer: solidcore_record::Loop2::polygon(&[v(10.0, 0.0), v(20.0, 0.0), v(20.0, 10.0), v(10.0, 10.0)]),
+ holes: vec![],
+ };
+ let c = solidcore_record::Region2 { outer: solidcore_record::Loop2::polygon(&[v(50.0, 0.0), v(60.0, 0.0), v(60.0, 10.0)]), holes: vec![] };
let m = merge_regions(&[a, b, c]);
assert_eq!(m.len(), 2);
let mut areas: Vec<f64> = m.iter().map(|r| r.area()).collect();
@@ -953,7 +956,7 @@ fn links_update_in_place_rebuild_and_break() {
/// end in "face of " with nothing after the "of" (#4929).
#[test]
fn a_source_without_a_body_name_names_its_kind_alone() {
- use solidcraft_geom::Vec3;
+ use solidcore_record::Vec3;
let at = Vec3::ZERO;
for (source, expected) in [
(LinkSource::Edge { body: String::new(), at }, "edge"),
@@ -1017,7 +1020,7 @@ fn long_connected_chain_solves() {
/// cut in two by a line through it (each side gets an exact sub-curve ending on the line).
#[test]
fn exact_profiles_for_high_degree_and_cut_free_form_curves() {
- use solidcraft_geom::Seg2;
+ use solidcore_record::Seg2;
let exact_loop = |p: &Profile| p.region.outer.segs.iter().all(|s| !matches!(s, Seg2::Line { .. }) || s.length() > 1.0);
let closed = |p: &Profile| p.region.outer.joints().all(|(a, b)| a.end().dist(b.start()) < 1e-9);
// Degree 5 over six points, closed by a line.
diff --git a/crates/sketch/src/text.rs b/crates/sketch/src/text.rs
index 247e4a189e..946a0f18f3 100644
--- a/crates/sketch/src/text.rs
+++ b/crates/sketch/src/text.rs
@@ -10,7 +10,9 @@
//! puts them; every other line is set glyph by glyph, as it always was.
use serde::{Deserialize, Serialize};
-use solidcraft_geom::{Ring, Vec2};
+use solidcore_record::Vec2;
+use solidcraft_geom::Ring;
+use solidcraft_geom::prelude::*;
use crate::fonts::{FontData, font_data_styled};
use crate::link::{LinkGeom, LinkKind, LinkSource, MAX_LINK_ENTITIES};
diff --git a/crates/sketch/src/text_style_tests.rs b/crates/sketch/src/text_style_tests.rs
index b44c7ee58d..6a44786c00 100644
--- a/crates/sketch/src/text_style_tests.rs
+++ b/crates/sketch/src/text_style_tests.rs
@@ -1,7 +1,7 @@
//! Text styles: alignment, letter and line spacing, a made-up italic, a bold the font lacks, and
//! text that follows a curve of its sketch; and text measured (`TextMetrics`) by the rule that draws it.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use super::*;
use crate::{CurveKind, Sketch, font_data};
diff --git a/crates/sketch/src/thin.rs b/crates/sketch/src/thin.rs
index 5ca8b85f3e..304966cc20 100644
--- a/crates/sketch/src/thin.rs
+++ b/crates/sketch/src/thin.rs
@@ -12,9 +12,10 @@
//! merged into regions. Walls that cross or meet (a honeycomb, a ring and a cross) come out as
//! one region where they touch.
+use solidcraft_geom::prelude::*;
use std::f64::consts::{PI, TAU};
-use solidcraft_geom::{Loop2, Region2, Seg2, Vec2};
+use solidcore_record::{Loop2, Region2, Seg2, Vec2};
use crate::model::{CurveKind, Result, Sketch, SketchError};
use crate::profiles::{find_profiles, merge_regions};
diff --git a/crates/sketch/src/thin_tests.rs b/crates/sketch/src/thin_tests.rs
index 236a6254a3..5391ee154b 100644
--- a/crates/sketch/src/thin_tests.rs
+++ b/crates/sketch/src/thin_tests.rs
@@ -1,9 +1,10 @@
//! Thin walls against areas worked out by hand: a wall along a chain covers its length times
//! the thickness, less what corners overlap and plus what mitres add.
+use solidcraft_geom::prelude::*;
use std::f64::consts::PI;
-use solidcraft_geom::{Seg2, Vec2};
+use solidcore_record::{Seg2, Vec2};
use crate::thin_wall_regions;
@@ -61,7 +62,7 @@ fn a_straight_wall_takes_its_side_from_the_drawn_direction() {
#[test]
fn a_circle_makes_an_exact_ring() {
- let circle = solidcraft_geom::Loop2::circle(Vec2::new(3.0, 4.0), 10.0).segs;
+ let circle = solidcore_record::Loop2::circle(Vec2::new(3.0, 4.0), 10.0).segs;
let regions = thin_wall_regions(std::slice::from_ref(&circle), 1.0, 1.0).unwrap();
assert_eq!(regions.len(), 1);
assert_eq!(regions[0].holes.len(), 1);
@@ -84,7 +85,7 @@ fn walls_that_cross_or_meet_are_one_region() {
close(regions[0].area(), 4.0 * 10.0 * 2.0 - 4.0);
}
// A ring with a bar across it.
- let mut ring = vec![solidcraft_geom::Loop2::circle(Vec2::ZERO, 10.0).segs];
+ let mut ring = vec![solidcore_record::Loop2::circle(Vec2::ZERO, 10.0).segs];
ring.push(line([-10.0, 0.0], [10.0, 0.0]));
let regions = thin_wall_regions(&ring, 1.0, 1.0).unwrap();
assert_eq!(regions.len(), 1);
diff --git a/crates/sketch/src/virtual_corner_tests.rs b/crates/sketch/src/virtual_corner_tests.rs
index b5357661e0..f1439ad450 100644
--- a/crates/sketch/src/virtual_corner_tests.rs
+++ b/crates/sketch/src/virtual_corner_tests.rs
@@ -1,7 +1,7 @@
#![allow(clippy::unwrap_used, clippy::panic)]
use crate::{Constraint, ConstraintKind, CurveKind, Sketch};
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
fn point(sk: &mut Sketch, x: f64, y: f64) -> usize {
sk.add_point(Vec2::new(x, y), None).unwrap()
diff --git a/crates/sketch/src/wire.rs b/crates/sketch/src/wire.rs
index 69821732b0..c5248b740c 100644
--- a/crates/sketch/src/wire.rs
+++ b/crates/sketch/src/wire.rs
@@ -3,7 +3,8 @@
//! They are reference geometry: drawn and usable as paths, not part of profiles or the solver.
use serde::{Deserialize, Serialize};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_geom::prelude::*;
use crate::link::{Link, LinkGeom, LinkKind, LinkSource};
use crate::model::{Result, Sketch, SketchError, in_range3, radius_in_range};
@@ -73,7 +74,7 @@ pub struct Wire {
/// One exact piece of a 3D sketch curve ([`Wire::exact`]): a record curve on its interval.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct WireCurve {
- pub curve: solidcraft_geom::brep::Curve,
+ pub curve: solidcore_record::brep::Curve,
pub interval: [f64; 2],
}
@@ -81,7 +82,7 @@ impl WireCurve {
/// The piece carried by the rigid motion `point` of points and `vector` of directions (a
/// placement). `None` for an intersection curve, whose surfaces are not carried here.
pub fn mapped(&self, point: &impl Fn(Vec3) -> Vec3, vector: &impl Fn(Vec3) -> Vec3) -> Option<WireCurve> {
- use solidcraft_geom::brep::{Curve, Frame};
+ use solidcore_record::brep::{Curve, Frame};
let a = |q: [f64; 3]| Vec3::new(q[0], q[1], q[2]);
let b = |v: Vec3| [v.x, v.y, v.z];
let p = |q: [f64; 3]| b(point(a(q)));
diff --git a/crates/sketch/tests/analysis_levels.rs b/crates/sketch/tests/analysis_levels.rs
index a65f76f2b5..43dc1d3855 100644
--- a/crates/sketch/tests/analysis_levels.rs
+++ b/crates/sketch/tests/analysis_levels.rs
@@ -1,6 +1,6 @@
//! Reduced diagnostics must preserve placement, rollback, feasibility and exact freedom results.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
use solidcraft_sketch::{Analysis, ConstraintKind, Hold, Sketch, solve_with};
fn compare(sketch: &Sketch, hold: &Hold) {
diff --git a/crates/sketch/tests/cursor_target.rs b/crates/sketch/tests/cursor_target.rs
index 1e15ee33a4..2eb645cedd 100644
--- a/crates/sketch/tests/cursor_target.rs
+++ b/crates/sketch/tests/cursor_target.rs
@@ -1,5 +1,6 @@
//! Analytic cursor oracle plus feasibility checks on every accepted continuation step.
-use solidcraft_geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_geom::prelude::*;
use solidcraft_sketch::{ConstraintKind, Sketch, move_line_towards, move_point_towards, solve};
fn linkage() -> (Sketch, usize, usize) {
diff --git a/crates/smlib/Cargo.toml b/crates/smlib/Cargo.toml
index bbf8616352..9780c386e9 100644
--- a/crates/smlib/Cargo.toml
+++ b/crates/smlib/Cargo.toml
@@ -10,6 +10,7 @@ publish = false
workspace = true
[dependencies]
+solidcore-record = { workspace = true }
log = { workspace = true }
serde_json = { workspace = true }
solidcraft-geom = { workspace = true }
diff --git a/crates/smlib/src/core/blend_tests.rs b/crates/smlib/src/core/blend_tests.rs
index 81707d2afd..f9d80d69ec 100644
--- a/crates/smlib/src/core/blend_tests.rs
+++ b/crates/smlib/src/core/blend_tests.rs
@@ -215,7 +215,7 @@ struct Measured {
kinds: BTreeMap<String, usize>,
}
-fn kinds(rec: &solidcraft_geom::brep::Brep) -> BTreeMap<String, usize> {
+fn kinds(rec: &solidcore_record::brep::Brep) -> BTreeMap<String, usize> {
let mut out = BTreeMap::new();
for f in &rec.faces {
let v = serde_json::to_value(&f.surface).unwrap();
@@ -280,7 +280,7 @@ fn solidcore_case(name: &'static str) -> Got {
let v = volume(&body, 1e-8).unwrap_or_else(|e| panic!("{name}: volume: {e}"));
let n = counts(&body).unwrap();
let (rec, _) = native(&to_arrays(&body).unwrap()).unwrap_or_else(|e| panic!("{name}: record: {e:?}"));
- rec.validate().unwrap_or_else(|e| panic!("{name}: record: {e}"));
+ solidcraft_geom::brep::check::validate(&rec).unwrap_or_else(|e| panic!("{name}: record: {e}"));
Measured { volume: v, counts: n, kinds: kinds(&rec) }
});
judge(name, "solidcore", &c.expect, got)
@@ -557,7 +557,7 @@ fn a_setback_corner_left_open_returns_its_hole() {
assert_eq!(hole.edges.len(), 12);
let flat = to_arrays(&open).unwrap();
let (rec, _) = native(&flat).unwrap();
- rec.validate().unwrap();
+ solidcraft_geom::brep::check::validate(&rec).unwrap();
let ends = &flat.ints[&crate::flat::EDGE_VERTICES];
let end = |h: &crate::HoleEdge, last: bool| ends[2 * h.edge + usize::from(h.forward == last)];
for (k, h) in hole.edges.iter().enumerate() {
@@ -592,7 +592,7 @@ fn a_curvature_round_takes_its_wedges_equal_area_and_mixed_wedges_are_refused()
for (at, alpha) in [(a, 0.75 * PI), (b, 0.5 * PI)] {
let round = blend(&chamfered, Blend::Curvature, &[at], &[r], TOL, &[], &[], Corners::Filled).unwrap();
let (rec, _) = native(&to_arrays(&round).unwrap()).unwrap();
- rec.validate().unwrap();
+ solidcraft_geom::brep::check::validate(&rec).unwrap();
let removed = v0 - volume(&round, 1e-8).unwrap();
assert!(rel(removed, 40.0 * cut(alpha)) < 1e-6, "{removed} vs {}", 40.0 * cut(alpha));
}
@@ -620,7 +620,7 @@ fn a_variable_round_is_the_union_of_its_balls() {
let removed = |radii: &[f64], start: [f64; 3]| {
let r = fillet_variable(&b, TOP_FRONT, TOL, start, 1, &[0.0, 0.0, 1.0, 1.0], radii).unwrap();
let (rec, _) = native(&to_arrays(&r).unwrap()).unwrap();
- rec.validate().unwrap();
+ solidcraft_geom::brep::check::validate(&rec).unwrap();
ABC - volume(&r, 1e-8).unwrap()
};
let constant = removed(&[2.0, 2.0], [0.0, 0.0, 10.0]);
@@ -848,7 +848,7 @@ fn tabbed_plate_rounds_mitred_on_the_arcs_continuation() {
let removed = volume(&plate, 1e-8).unwrap() - volume(&round, 1e-8).unwrap();
assert!(rel(removed, want) < 1e-6, "removed {removed}, expected {want}");
let (rec, _) = native(&to_arrays(&round).unwrap()).unwrap();
- rec.validate().unwrap();
+ solidcraft_geom::brep::check::validate(&rec).unwrap();
assert!(super::is_manifold_solid(&round).unwrap());
assert!(super::check(&round, crate::check::CheckLevel::All).unwrap().is_valid());
}
@@ -857,7 +857,7 @@ fn tabbed_plate_rounds_mitred_on_the_arcs_continuation() {
/// with one blend on its top front edge (y = 0, z = 10), leaves the bottom and back as they were,
/// trims the top, front and both sides, and makes the blend face.
mod history {
- use solidcraft_geom::brep::history::Change;
+ use solidcore_record::brep::history::Change;
use crate::history::Raw;
use crate::{Blend, Brep};
diff --git a/crates/smlib/src/core/boolean_tests.rs b/crates/smlib/src/core/boolean_tests.rs
index 3e0500f341..ddc8115ad1 100644
--- a/crates/smlib/src/core/boolean_tests.rs
+++ b/crates/smlib/src/core/boolean_tests.rs
@@ -125,7 +125,7 @@ struct Measured {
solids: usize,
}
-fn kinds(rec: &solidcraft_geom::brep::Brep) -> BTreeMap<String, usize> {
+fn kinds(rec: &solidcore_record::brep::Brep) -> BTreeMap<String, usize> {
let mut out = BTreeMap::new();
for f in &rec.faces {
let v = serde_json::to_value(&f.surface).unwrap();
@@ -181,7 +181,7 @@ fn solidcore_case(name: &'static str) -> Option<Measured> {
let solids = solid_count(body).unwrap_or_else(|e| panic!("{name}: solid count: {e}"));
assert_eq!(solids, c.solids, "{name}: solids");
let (rec, _) = native(&to_arrays(body).unwrap()).unwrap_or_else(|e| panic!("{name}: record: {e:?}"));
- rec.validate().unwrap_or_else(|e| panic!("{name}: record: {e}"));
+ solidcraft_geom::brep::check::validate(&rec).unwrap_or_else(|e| panic!("{name}: record: {e}"));
Some(Measured { volume: v, counts: n, kinds: kinds(&rec), solids })
})
}
@@ -361,7 +361,7 @@ fn a_ring_and_a_lip_with_walls_nearly_together() {
/// Face and edge tags (`Brep::tagged`) through booleans: each operand tagged, the result's history
/// ([`Raw`]) read back.
mod history {
- use solidcraft_geom::brep::history::Change;
+ use solidcore_record::brep::history::Change;
use crate::history::Raw;
use crate::{BooleanOp, Brep};
diff --git a/crates/smlib/src/core/convert_tests.rs b/crates/smlib/src/core/convert_tests.rs
index 6a473e1a82..847f14392b 100644
--- a/crates/smlib/src/core/convert_tests.rs
+++ b/crates/smlib/src/core/convert_tests.rs
@@ -4,7 +4,7 @@
use std::f64::consts::PI;
-use solidcraft_geom::brep as b;
+use solidcore_record::brep as b;
use super::boolean::boolean;
use super::{Body, from_arrays, make_box, make_cone, make_cylinder, make_sphere, make_torus, to_arrays, volume};
@@ -38,8 +38,8 @@ fn rel(a: f64, b: f64) -> f64 {
/// The record of solidcore's arrays, validated and its geometry checked.
fn record(a: &Arrays) -> b::Brep {
let (rec, _) = native(a).unwrap();
- rec.validate().unwrap();
- rec.check_geometry().unwrap();
+ solidcraft_geom::brep::check::validate(&rec).unwrap();
+ solidcraft_geom::brep::geometry::check(&rec).unwrap();
rec
}
diff --git a/crates/smlib/src/core/history.rs b/crates/smlib/src/core/history.rs
index e11b73b388..ba61e2feee 100644
--- a/crates/smlib/src/core/history.rs
+++ b/crates/smlib/src/core/history.rs
@@ -21,7 +21,7 @@ use solidcore::query::api_queries::edge_closest_point;
use solidcore::topology::face::p4 as face4;
use solidcore::topology::{Brep, EdgeId, VertexId, edge};
use solidcore::{EntityRef, Point3, SolidError};
-use solidcraft_geom::brep::history::Change;
+use solidcore_record::brep::history::Change;
use super::{Body, answer, with_body};
use crate::history::{Raw, RawEdge, RawFace};
diff --git a/crates/smlib/src/core/merge_tests.rs b/crates/smlib/src/core/merge_tests.rs
index 901c51387a..23573197f6 100644
--- a/crates/smlib/src/core/merge_tests.rs
+++ b/crates/smlib/src/core/merge_tests.rs
@@ -150,7 +150,7 @@ struct Measured {
type Got = std::result::Result<Measured, Error>;
-fn kinds(rec: &solidcraft_geom::brep::Brep) -> BTreeMap<String, usize> {
+fn kinds(rec: &solidcore_record::brep::Brep) -> BTreeMap<String, usize> {
let mut out = BTreeMap::new();
for f in &rec.faces {
let v = serde_json::to_value(&f.surface).unwrap();
@@ -192,7 +192,7 @@ fn solidcore_case(name: &str) -> Got {
};
let got = r.map(|(b, closed)| {
let (rec, _) = native(&to_arrays(&b).unwrap()).unwrap_or_else(|e| panic!("{name}: record: {e:?}"));
- rec.validate().unwrap_or_else(|e| panic!("{name}: record: {e}"));
+ solidcraft_geom::brep::check::validate(&rec).unwrap_or_else(|e| panic!("{name}: record: {e}"));
let size = if is_sheet(name) { area(&b, 1e-8) } else { volume(&b, 1e-8) }.unwrap();
Measured { size, counts: counts(&b).unwrap(), closed, bounds: bounds(&b).unwrap(), kinds: kinds(&rec) }
});
diff --git a/crates/smlib/src/core/offset_tests.rs b/crates/smlib/src/core/offset_tests.rs
index 9c448a1ad2..acfe8d0551 100644
--- a/crates/smlib/src/core/offset_tests.rs
+++ b/crates/smlib/src/core/offset_tests.rs
@@ -249,7 +249,7 @@ struct Measured {
kinds: BTreeMap<String, usize>,
}
-fn kinds(rec: &solidcraft_geom::brep::Brep) -> BTreeMap<String, usize> {
+fn kinds(rec: &solidcore_record::brep::Brep) -> BTreeMap<String, usize> {
let mut out = BTreeMap::new();
for f in &rec.faces {
let v = serde_json::to_value(&f.surface).unwrap();
@@ -327,7 +327,7 @@ fn solidcore_case(name: &'static str) -> Got {
let size = if sheet { area(&body, 1e-8) } else { volume(&body, 1e-8) }.unwrap_or_else(|e| panic!("{name}: size: {e}"));
let n = counts(&body).unwrap();
let (rec, _) = native(&to_arrays(&body).unwrap()).unwrap_or_else(|e| panic!("{name}: record: {e:?}"));
- rec.validate().unwrap_or_else(|e| panic!("{name}: record: {e}"));
+ solidcraft_geom::brep::check::validate(&rec).unwrap_or_else(|e| panic!("{name}: record: {e}"));
let bx = bounds(&body).unwrap();
Measured { size, bounds: bx, counts: n, kinds: kinds(&rec) }
});
diff --git a/crates/smlib/src/core/split_tests.rs b/crates/smlib/src/core/split_tests.rs
index 6d0574e045..5a55fca2c9 100644
--- a/crates/smlib/src/core/split_tests.rs
+++ b/crates/smlib/src/core/split_tests.rs
@@ -77,7 +77,7 @@ fn rel(a: f64, b: f64) -> f64 {
fn valid(name: &str, b: &Body) {
let (rec, _) = native(&to_arrays(b).unwrap()).unwrap_or_else(|e| panic!("{name}: record: {e:?}"));
- rec.validate().unwrap_or_else(|e| panic!("{name}: record: {e}"));
+ solidcraft_geom::brep::check::validate(&rec).unwrap_or_else(|e| panic!("{name}: record: {e}"));
}
fn judge(name: &str, who: &str, got: Got) -> Got {
diff --git a/crates/smlib/src/core/sweep_tests.rs b/crates/smlib/src/core/sweep_tests.rs
index 510e5c8851..6e98f8f800 100644
--- a/crates/smlib/src/core/sweep_tests.rs
+++ b/crates/smlib/src/core/sweep_tests.rs
@@ -281,7 +281,7 @@ struct Measured {
kinds: BTreeMap<String, usize>,
}
-fn kinds(rec: &solidcraft_geom::brep::Brep) -> BTreeMap<String, usize> {
+fn kinds(rec: &solidcore_record::brep::Brep) -> BTreeMap<String, usize> {
let mut out = BTreeMap::new();
for f in &rec.faces {
let v = serde_json::to_value(&f.surface).unwrap();
@@ -347,7 +347,7 @@ fn solidcore_case(name: &'static str) -> Got {
let size = if sheet { area(&body, 1e-8) } else { volume(&body, 1e-8) }.unwrap_or_else(|e| panic!("{name}: size: {e}"));
let n = counts(&body).unwrap();
let (rec, _) = native(&to_arrays(&body).unwrap()).unwrap_or_else(|e| panic!("{name}: record: {e:?}"));
- rec.validate().unwrap_or_else(|e| panic!("{name}: record: {e}"));
+ solidcraft_geom::brep::check::validate(&rec).unwrap_or_else(|e| panic!("{name}: record: {e}"));
bounds(&body).unwrap();
Measured { size, counts: n, kinds: kinds(&rec) }
});
diff --git a/crates/smlib/src/core/transform_tests.rs b/crates/smlib/src/core/transform_tests.rs
index c3d60dbad9..ee6c2754fd 100644
--- a/crates/smlib/src/core/transform_tests.rs
+++ b/crates/smlib/src/core/transform_tests.rs
@@ -110,7 +110,7 @@ struct Measured {
type Got = std::result::Result<Measured, Error>;
-fn kinds(rec: &solidcraft_geom::brep::Brep) -> BTreeMap<String, usize> {
+fn kinds(rec: &solidcore_record::brep::Brep) -> BTreeMap<String, usize> {
let mut out = BTreeMap::new();
for f in &rec.faces {
let v = serde_json::to_value(&f.surface).unwrap();
@@ -168,7 +168,7 @@ fn solidcore_case(name: &str) -> Got {
let c = case(name);
let got = transform(&c.shape.core(), &c.matrix).map(|b| {
let (rec, _) = native(&to_arrays(&b).unwrap()).unwrap_or_else(|e| panic!("{name}: record: {e:?}"));
- rec.validate().unwrap_or_else(|e| panic!("{name}: record: {e}"));
+ solidcraft_geom::brep::check::validate(&rec).unwrap_or_else(|e| panic!("{name}: record: {e}"));
Measured { volume: volume(&b, 1e-8).unwrap(), bounds: bounds(&b).unwrap(), counts: counts(&b).unwrap(), kinds: kinds(&rec) }
});
judge(name, "solidcore", got)
diff --git a/crates/smlib/src/core/trim_tests.rs b/crates/smlib/src/core/trim_tests.rs
index 4cdc242675..f3c68de355 100644
--- a/crates/smlib/src/core/trim_tests.rs
+++ b/crates/smlib/src/core/trim_tests.rs
@@ -126,7 +126,7 @@ fn solidcore_case(name: &str) -> Got {
let (c, _) = case(name);
let got = untrim_face(&c.input.core(), c.point, TOL, c.holes, c.outer, c.in_place).map(|b| {
let (rec, _) = native(&to_arrays(&b).unwrap()).unwrap_or_else(|e| panic!("{name}: record: {e:?}"));
- rec.validate().unwrap_or_else(|e| panic!("{name}: record: {e}"));
+ solidcraft_geom::brep::check::validate(&rec).unwrap_or_else(|e| panic!("{name}: record: {e}"));
Measured { area: area(&b, 1e-8).unwrap(), counts: counts(&b).unwrap() }
});
judge(name, "solidcore", got)
@@ -266,7 +266,7 @@ fn extend_solidcore(name: &str) -> Got {
let (sheet, point, distance, how, _) = extend_case(name);
let got = extend_sheet(&sheet.core(), point, TOL, distance, how).map(|b| {
let (rec, _) = native(&to_arrays(&b).unwrap()).unwrap_or_else(|e| panic!("{name}: record: {e:?}"));
- rec.validate().unwrap_or_else(|e| panic!("{name}: record: {e}"));
+ solidcraft_geom::brep::check::validate(&rec).unwrap_or_else(|e| panic!("{name}: record: {e}"));
Measured { area: area(&b, 1e-8).unwrap(), counts: counts(&b).unwrap() }
});
extend_judge(name, "solidcore", got)
diff --git a/crates/smlib/src/export.rs b/crates/smlib/src/export.rs
index a9e59eabaf..473634c967 100644
--- a/crates/smlib/src/export.rs
+++ b/crates/smlib/src/export.rs
@@ -35,12 +35,13 @@
//! `VERTEX_TOLERANCE`), never below a floor of 10⁻⁶ of the body's size (at least 10⁻⁵ mm),
//! which is the body's; from a library without them, SMLib's intersection tolerance (or the
//! floor where larger) for the body, every edge and every vertex.
+use solidcraft_geom::prelude::*;
use std::f64::consts::TAU;
use std::collections::HashMap;
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep as b;
+use solidcore_record::Vec3;
+use solidcore_record::brep as b;
use crate::flat::{self, *};
use crate::history::{Order, Piece};
@@ -375,7 +376,7 @@ fn surfaces(flat: View, n_faces: usize) -> Res<Vec<(b::Surface, Option<b::Surfac
/// `form`, the NURBS the edge runs on over `range`: what [`b::Edge::curve_interval`] reads (an
/// ellipse's radii scale its axes, not the way its angle turns).
fn along(f: b::Frame, form: &b::Curve, range: [f64; 2]) -> Res<b::Frame> {
- let eval = b::eval::CurveEval::new(form).map_err(|e| invalid(format!("circle NURBS form: {e}")))?;
+ let eval = solidcraft_geom::brep::eval::CurveEval::new(form).map_err(|e| invalid(format!("circle NURBS form: {e}")))?;
let [t0, t1] = range;
let (p, q) = (eval.point(t0), eval.point(t0 + 1e-3 * (t1 - t0)));
let (Some(p), Some(q)) = (p, q) else { return Err(invalid("circle NURBS form")) };
@@ -743,7 +744,7 @@ fn native_ordered(arrays: &Arrays) -> Res<(b::Brep, Report, Order)> {
let r = range.get(4 * f..4 * f + 4).ok_or_else(|| invalid("face range"))?;
// A face with a NURBS form is parameterised on it: its range and trims are that NURBS's.
let params = nurbs.as_ref().unwrap_or(&surface);
- let natural = params.natural();
+ let natural = solidcraft_geom::brep::label::surface_natural(params);
let domain = [onto([r[0], r[2]], natural[0]), onto([r[1], r[3]], natural[1])];
// SMLib's own trims are taken where the arrays carry them: B-spline faces, NURBS forms, and
// planes (mapped onto the plane's own (u, v) by the export).
@@ -1265,7 +1266,7 @@ fn canonical(parts: Parts, n_vertices: usize, flat: View, tolerances: &Tolerance
})
.collect::<Res<Vec<_>>>()?;
let brep = b::Brep { version: b::VERSION, tolerance, regions, shells, faces: face_records, edges: edge_records, vertices };
- brep.validate_built().map_err(|e| invalid(format!("the mapped B-rep does not validate: {e}")))?;
+ solidcraft_geom::brep::check::validate_built(&brep).map_err(|e| invalid(format!("the mapped B-rep does not validate: {e}")))?;
let placed = |new: &[Option<u32>]| {
new.iter().map(|i| i.map(|i| i as usize).ok_or_else(|| invalid("an entity outside the canonical walk"))).collect::<Res<Vec<_>>>()
};
@@ -1518,7 +1519,7 @@ fn pcurves<'a>(
let mut loop_uses = Vec::with_capacity(l.len());
for (&(e, forward), given) in l.iter().zip(g) {
let geometry = edge(e).ok_or_else(|| invalid("edge"))?;
- loop_uses.push(b::pcurve::EdgeUse {
+ loop_uses.push(solidcraft_geom::brep::pcurve::EdgeUse {
edge: e,
curve: geometry.curve,
interval: geometry.interval,
@@ -1529,7 +1530,8 @@ fn pcurves<'a>(
}
uses.push(loop_uses);
}
- let mut curves = b::pcurve::pcurves_within(surface, &uses, tolerance, Some(domain)).map_err(|e| invalid(format!("pcurve: {e}")))?;
+ let mut curves =
+ solidcraft_geom::brep::pcurve::pcurves_within(surface, &uses, tolerance, Some(domain)).map_err(|e| invalid(format!("pcurve: {e}")))?;
into_domain(surface, domain, &mut curves);
Ok(curves)
}
@@ -1587,7 +1589,7 @@ fn point2(c: &b::Curve2, t: f64) -> Option<[f64; 2]> {
/// Moves each loop's pcurves by whole periods so the loop's middle is nearest the domain's.
fn into_domain(surface: &b::Surface, domain: [[f64; 2]; 2], curves: &mut [Vec<b::Curve2>]) {
- for (d, natural) in surface.natural().into_iter().enumerate() {
+ for (d, natural) in solidcraft_geom::brep::label::surface_natural(surface).into_iter().enumerate() {
if natural != b::Natural::Periodic {
continue;
}
diff --git a/crates/smlib/src/export/tests.rs b/crates/smlib/src/export/tests.rs
index 22b32609b5..21f283ce06 100644
--- a/crates/smlib/src/export/tests.rs
+++ b/crates/smlib/src/export/tests.rs
@@ -27,8 +27,8 @@ mod native_tests {
let v = b.mass_properties(MEASURE_ACCURACY).unwrap().volume;
assert!((v - exact).abs() < 1e-6 * exact, "{name}: SMLib volume {v}, closed form {exact}");
let (native, report) = b.to_native_report().unwrap_or_else(|e| panic!("{name}: {e}"));
- native.validate().unwrap();
- native.check_geometry().unwrap_or_else(|e| panic!("{name}: {e}"));
+ solidcraft_geom::brep::check::validate(&native).unwrap();
+ solidcraft_geom::brep::geometry::check(&native).unwrap_or_else(|e| panic!("{name}: {e}"));
assert_eq!(report, Report { nurbs_edges: report.nurbs_edges, ..Report::default() }, "{name}: every face agrees");
let [f, e, n] = b.counts().unwrap();
assert_eq!((native.faces.len(), native.edges.len(), native.vertices.len()), (f, e, n), "{name}");
@@ -63,7 +63,7 @@ mod native_tests {
let mids: Vec<[f64; 3]> = [(0.0, 0.0), (a, 0.0), (0.0, a), (a, a)].iter().flat_map(|&(p, q)| [[h, p, q], [p, h, q], [p, q, h]]).collect();
let f = Brep::make_box([0.0; 3], [a; 3]).unwrap().fillet(&mids, 0.1, r).unwrap();
let record = f.to_native().unwrap();
- record.validate().unwrap();
+ solidcraft_geom::brep::check::validate(&record).unwrap();
let corners: Vec<([f64; 3], f64)> = record
.faces
.iter()
@@ -105,10 +105,10 @@ mod native_tests {
assert_eq!((order.faces.len(), order.edges.len()), (record.faces.len(), record.edges.len()), "{name}");
let h = t.history().unwrap().history(std::slice::from_ref(&order), &order).unwrap();
for (i, f) in h.faces.iter().enumerate() {
- assert_eq!(f.origins, vec![solidcraft_geom::brep::history::FaceOrigin::Face { operand: 0, face: i }], "{name}: face {i}");
+ assert_eq!(f.origins, vec![solidcore_record::brep::history::FaceOrigin::Face { operand: 0, face: i }], "{name}: face {i}");
}
for (i, e) in h.edges.iter().enumerate() {
- assert_eq!(e.origins, vec![solidcraft_geom::brep::history::EdgeOrigin::Edge { operand: 0, edge: i }], "{name}: edge {i}");
+ assert_eq!(e.origins, vec![solidcore_record::brep::history::EdgeOrigin::Edge { operand: 0, edge: i }], "{name}: edge {i}");
// The faces it bounds, as the record's uses say.
let mut faces: Vec<usize> = record.edges[i].uses.iter().map(|u| u.face as usize).collect();
faces.sort();
@@ -124,7 +124,7 @@ mod native_tests {
let side = cyl.faces.iter().find(|f| matches!(f.surface, b::Surface::Cylinder { .. })).unwrap();
// The side is on SMLib's NURBS form of the cylinder (its domain is the form's): the whole
// turn, so its domain's two u ends meet, from the base to the top.
- let form = b::eval::SurfaceEval::new(side.parameters()).unwrap();
+ let form = solidcraft_geom::brep::eval::SurfaceEval::new(side.parameters()).unwrap();
let [[u0, u1], [v0, v1]] = side.domain;
for v in [v0, v1] {
let (a, z) = (form.point([u0, v]).unwrap(), form.point([u1, v]).unwrap());
@@ -134,7 +134,7 @@ mod native_tests {
assert!(heights.iter().any(|h| h.abs() < 1e-9) && heights.iter().any(|h| (h - 10.0).abs() < 1e-9), "{heights:?}");
for e in &cyl.edges {
// Evaluated on the curve its interval is on (a circle's NURBS form).
- let eval = b::eval::CurveEval::new(e.parameters()).unwrap();
+ let eval = solidcraft_geom::brep::eval::CurveEval::new(e.parameters()).unwrap();
let [a, z] = e.interval;
// Ends on the edge's vertices.
for (t, v) in [(a, e.vertices[0]), (z, e.vertices[1])] {
@@ -143,7 +143,7 @@ mod native_tests {
assert!((p - Vec3::new(q[0], q[1], q[2])).len() < 1e-9, "{:?} at {t}", e.curve);
}
if let b::Curve::Circle { radius, .. } = e.curve {
- let [a, z] = e.curve_interval().unwrap();
+ let [a, z] = solidcraft_geom::brep::label::edge_curve_interval(e).unwrap();
assert!((radius - 5.0).abs() < 1e-12 && (z - a - TAU).abs() < 1e-9);
}
}
@@ -160,7 +160,7 @@ mod native_tests {
let near = Brep::make_cone([0.0; 3], 4.0, 4.0 - 1e-12, 10.0).unwrap().to_native().unwrap();
assert!(near.faces.iter().any(|f| matches!(f.surface, b::Surface::Cylinder { .. })));
assert!(!near.faces.iter().any(|f| matches!(f.surface, b::Surface::Cone { .. })));
- near.validate().unwrap();
+ solidcraft_geom::brep::check::validate(&near).unwrap();
}
/// A hole tangent to the block's outline from inside: the material touches itself along the
@@ -179,7 +179,7 @@ mod native_tests {
assert_eq!((record.faces.len(), record.edges.len(), record.vertices.len()), (f, e + 1, v));
assert_eq!((record.shells.len(), record.regions.len()), (1, 2));
assert!(record.edges.iter().all(|e| e.uses.len() == 2));
- record.check_geometry().unwrap();
+ solidcraft_geom::brep::geometry::check(&record).unwrap();
let on_line = |e: &b::Edge| {
e.vertices.iter().all(|v| {
let p = record.vertices[*v as usize].point;
@@ -187,7 +187,8 @@ mod native_tests {
})
};
// On the curve the interval is on (a circle's NURBS form).
- let middle = |e: &b::Edge| b::eval::CurveEval::new(e.parameters()).unwrap().point(0.5 * (e.interval[0] + e.interval[1])).unwrap();
+ let middle =
+ |e: &b::Edge| solidcraft_geom::brep::eval::CurveEval::new(e.parameters()).unwrap().point(0.5 * (e.interval[0] + e.interval[1])).unwrap();
let copies: Vec<&b::Edge> = record.edges.iter().filter(|e| on_line(e)).collect();
assert_eq!(copies.len(), 2);
for copy in copies {
@@ -226,7 +227,7 @@ mod native_tests {
let r = block.boolean(&hole, crate::BooleanOp::Subtract).unwrap().unwrap();
let (record, _) = r.to_native_ordered().unwrap();
assert!(record.edges.iter().all(|e| e.uses.len() == 2));
- record.check_geometry().unwrap();
+ solidcraft_geom::brep::geometry::check(&record).unwrap();
let on_line = |e: &b::Edge| {
e.vertices.iter().all(|v| {
let p = record.vertices[*v as usize].point;
@@ -278,7 +279,7 @@ mod native_tests {
assert_eq!(record.regions.len(), 3);
assert!(record.regions.iter().all(|g| !g.void));
assert_eq!(record.regions[0].shells.len(), 2, "the infinite region lists both solids");
- record.check_geometry().unwrap();
+ solidcraft_geom::brep::geometry::check(&record).unwrap();
// V = 180000 - h/6 (A0 + 4 Am + A1), h = 9, Am = 55 x 35.
let want = 180000.0 - 9.0 / 6.0 * (100.0 + 4.0 * 55.0 * 35.0 + 6000.0);
let back = Brep::from_record(&record, true).unwrap();
@@ -326,9 +327,12 @@ mod native_tests {
a
};
let (record, _) = native(&shifted(7e-15)).unwrap();
- record.validate().unwrap();
+ solidcraft_geom::brep::check::validate(&record).unwrap();
assert!(record.edges.iter().any(|x| x.interval[0] == first && x.interval[1] <= last), "an interval on the NURBS's first knot");
- assert!(native(&shifted(1e-3)).map(|(r, _)| r.validate()).map_or(true, |v| v.is_err()), "a real overshoot is not moved");
+ assert!(
+ native(&shifted(1e-3)).map(|(r, _)| solidcraft_geom::brep::check::validate(&r)).map_or(true, |v| v.is_err()),
+ "a real overshoot is not moved"
+ );
}
/// [`outer_area`] as it was: every edge of the body copied into a record for each face.
diff --git a/crates/smlib/src/history.rs b/crates/smlib/src/history.rs
index b13e0a2933..dd9294a911 100644
--- a/crates/smlib/src/history.rs
+++ b/crates/smlib/src/history.rs
@@ -1,4 +1,4 @@
-//! Face and edge history out of SMLib operations, in [`solidcraft_geom::brep::history`]'s terms.
+//! Face and edge history out of SMLib operations, in [`solidcore_record::brep::history`]'s terms.
//!
//! SMLib carries identity through its own edits: every split, merge, copy and coincidence an
//! operation makes passes the attributes of what it changes on to what it makes. So each operand
@@ -12,7 +12,7 @@
use std::collections::BTreeSet;
-use solidcraft_geom::brep::history::{Change, EdgeOrigin, EdgeProv, FaceOrigin, FaceProv, Failed, History, Side};
+use solidcore_record::brep::history::{Change, EdgeOrigin, EdgeProv, FaceOrigin, FaceProv, Failed, History, Side};
use crate::{Brep, Result, core};
diff --git a/crates/smlib/src/history/tests.rs b/crates/smlib/src/history/tests.rs
index 3cb8e0687b..7fd479fe3c 100644
--- a/crates/smlib/src/history/tests.rs
+++ b/crates/smlib/src/history/tests.rs
@@ -1,6 +1,6 @@
use super::*;
use crate::Error;
-use solidcraft_geom::brep::history::{Change, EdgeOrigin, EdgeProv, FaceOrigin, FaceProv, History};
+use solidcore_record::brep::history::{Change, EdgeOrigin, EdgeProv, FaceOrigin, FaceProv, History};
fn face(operand: usize, face: usize) -> FaceOrigin {
FaceOrigin::Face { operand, face }
diff --git a/crates/smlib/src/import.rs b/crates/smlib/src/import.rs
index c3ce8dbb5c..af64c049f1 100644
--- a/crates/smlib/src/import.rs
+++ b/crates/smlib/src/import.rs
@@ -1,4 +1,4 @@
-//! Schema 4 records (`solidcraft_geom::brep::Brep`) into SMLib: the record is laid out as the C
+//! Schema 4 records (`solidcore_record::brep::Brep`) into SMLib: the record is laid out as the C
//! API's flat arrays (`capi/include/smlib.h`, "Flat B-rep arrays"), which solidcore builds into
//! its B-rep ([`crate::core::from_arrays`]).
//!
@@ -14,7 +14,7 @@
use std::collections::{BTreeMap, HashMap, HashSet};
-use solidcraft_geom::brep as b;
+use solidcore_record::brep as b;
use crate::flat;
@@ -83,7 +83,7 @@ fn z_axis(f: &b::Frame) -> [f64; 3] {
/// The record as flat arrays. `trusted`: the record comes from a modeller that keeps SMLib's
/// rules (SMLib then skips its healer); otherwise SMLib heals it on import.
pub fn arrays(brep: &b::Brep, trusted: bool) -> R<Arrays> {
- brep.validate_built().map_err(|e| Unsupported::Invalid(e.0))?;
+ solidcraft_geom::brep::check::validate_built(brep).map_err(|e| Unsupported::Invalid(e.0))?;
let brep = analytic::analytic(brep)?;
laid_out(brep.as_ref(), trusted, true, &HashSet::new())
}
@@ -93,7 +93,7 @@ pub fn arrays(brep: &b::Brep, trusted: bool) -> R<Arrays> {
/// bilinear patch, to compare what SMLib makes of splines with what it makes of its own analytic
/// surfaces. A revolution is still refused (SMLib has no such surface).
pub fn arrays_keeping_splines(brep: &b::Brep, trusted: bool) -> R<Arrays> {
- brep.validate_built().map_err(|e| Unsupported::Invalid(e.0))?;
+ solidcraft_geom::brep::check::validate_built(brep).map_err(|e| Unsupported::Invalid(e.0))?;
laid_out(brep, trusted, false, &HashSet::new())
}
diff --git a/crates/smlib/src/import/analytic.rs b/crates/smlib/src/import/analytic.rs
index 205d61e49a..b996c0331c 100644
--- a/crates/smlib/src/import/analytic.rs
+++ b/crates/smlib/src/import/analytic.rs
@@ -13,11 +13,12 @@
//! stays a revolution, which the import sends as its exact rational B-spline; any other spline
//! stays a spline.
+use solidcraft_geom::prelude::*;
use std::borrow::Cow;
use std::f64::consts::{FRAC_PI_2, TAU};
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep as b;
+use solidcore_record::Vec3;
+use solidcore_record::brep as b;
use solidcraft_geom::brep::eval::{CurveEval, SurfaceEval};
use super::{R, Unsupported};
diff --git a/crates/smlib/src/import/tests.rs b/crates/smlib/src/import/tests.rs
index 8730f29b5f..29092c5a17 100644
--- a/crates/smlib/src/import/tests.rs
+++ b/crates/smlib/src/import/tests.rs
@@ -1,7 +1,8 @@
use super::*;
-use solidcraft_geom::brep::{
+use solidcore_record::brep::{
Brep as Record, Curve, Curve2, Edge, EdgeUseRef, Face, Loop, OrientedEdge, OrientedFace, Region, Shell, Surface, Vertex,
};
+use solidcraft_geom::prelude::*;
/// A closed polyhedron record from its corner points and its faces, each a cycle of corner
/// indices counter-clockwise seen from outside: planar faces, straight edges, canonical order.
@@ -73,7 +74,7 @@ fn polyhedron(corners: &[[f64; 3]], cycles: &[&[usize]]) -> Record {
})
.collect();
Record {
- version: solidcraft_geom::brep::VERSION,
+ version: solidcore_record::brep::VERSION,
tolerance: 1e-6,
regions: vec![Region { shells: vec![0], void: false }, Region { shells: vec![0], void: false }],
shells: vec![Shell::Faces { faces: (0..cycles.len() as u32).map(|face| OrientedFace { face, forward: true }).collect(), wires: vec![] }],
@@ -91,7 +92,7 @@ fn cube(s: f64) -> Record {
#[test]
fn a_cube_record_is_valid_and_maps_to_two_shells() {
let r = cube(10.0);
- r.validate().unwrap();
+ solidcraft_geom::brep::check::validate(&r).unwrap();
let a = arrays(&r, true).unwrap();
// The infinite region (a void in SMLib) and the solid, one shell each, every face once per side.
assert_eq!(a.ints[&flat::REGION_SHELL_COUNT], vec![1, 1]);
@@ -143,7 +144,7 @@ fn a_plane_on_other_axes_goes_as_smlibs_plane() {
}
}
}
- r.validate().unwrap();
+ solidcraft_geom::brep::check::validate(&r).unwrap();
let a = arrays(&r, true).unwrap();
assert_eq!(a.ints[&flat::FACE_SURFACE_TYPE][0], i64::from(flat::SURFACE_PLANE));
let b = crate::Brep::from_record(&r, true).unwrap();
@@ -225,7 +226,7 @@ fn revolutions_become_the_same_surface_as_a_rational_spline() {
#[test]
fn arcs_past_a_turn_come_a_turn_back() {
use std::f64::consts::{FRAC_PI_2, TAU};
- let frame = solidcraft_geom::brep::Frame { origin: [0.0; 3], x_axis: [1.0, 0.0, 0.0], y_axis: [0.0, 1.0, 0.0] };
+ let frame = solidcore_record::brep::Frame { origin: [0.0; 3], x_axis: [1.0, 0.0, 0.0], y_axis: [0.0, 1.0, 0.0] };
let circle = Curve::Circle { frame, radius: 2.0 };
assert_eq!(turned(&circle, [TAU, TAU + FRAC_PI_2]), ([0.0, FRAC_PI_2], -TAU));
assert_eq!(turned(&circle, [-TAU - FRAC_PI_2, -TAU]), ([-FRAC_PI_2, 0.0], TAU));
@@ -242,7 +243,7 @@ fn arcs_past_a_turn_come_a_turn_back() {
#[test]
fn only_a_tube_clear_of_its_axis_is_a_ring_torus() {
let ring = |major: f64| {
- let frame = solidcraft_geom::brep::Frame { origin: [major, 0.0, 0.0], x_axis: [1.0, 0.0, 0.0], y_axis: [0.0, 0.0, 1.0] };
+ let frame = solidcore_record::brep::Frame { origin: [major, 0.0, 0.0], x_axis: [1.0, 0.0, 0.0], y_axis: [0.0, 0.0, 1.0] };
let (profile, _) = solidcraft_geom::brep::form::curve(&Curve::Circle { frame, radius: 1.0 }, [-1.0, 1.0]).unwrap();
let identity = [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]];
let surface =
diff --git a/crates/smlib/src/pcurves.rs b/crates/smlib/src/pcurves.rs
index 19554749d5..ccafeddd54 100644
--- a/crates/smlib/src/pcurves.rs
+++ b/crates/smlib/src/pcurves.rs
@@ -4,10 +4,11 @@
//! every trim it needs (`SmEdgeuse::GetOrCreateUVTrimCurve`, when the body is exported). They are
//! SMLib's, relayed as it holds them on the record's parameters; nothing here fits a curve.
+use solidcraft_geom::prelude::*;
use std::collections::HashSet;
+use solidcore_record::brep::{self as b, Curve2, EdgeUseRef, Loop, OrientedEdge, OrientedFace, Region, Shell, Vertex};
use solidcraft_geom::brep::pcurve::{SURFACE_GAP_MARGIN, TrimFace, Trims};
-use solidcraft_geom::brep::{self as b, Curve2, EdgeUseRef, Loop, OrientedEdge, OrientedFace, Region, Shell, Vertex};
/// [`Trims`] by SMLib.
#[derive(Clone, Copy, Debug, Default)]
diff --git a/crates/smlib/src/ssi.rs b/crates/smlib/src/ssi.rs
index 0f06b24072..99ee643976 100644
--- a/crates/smlib/src/ssi.rs
+++ b/crates/smlib/src/ssi.rs
@@ -6,7 +6,7 @@
//! degrees. Each surface's UV domain is SMLib's natural one ([`Surface::domain`]): (u, v) itself
//! for planes, the parameterisation of SMLib's internal NURBS form for the other analytic kinds.
-use solidcraft_geom::brep as b;
+use solidcore_record::brep as b;
use std::sync::OnceLock;
@@ -204,8 +204,8 @@ impl Surface {
/// record's own parameters: radians for angles), with the record's parameterisation and
/// normal. A spline is taken over its whole knot domain. A cone only as a whole turn, widening
/// along its axis; a revolution not at all ([`Error::Unsupported`]).
- pub fn from_record(surface: &solidcraft_geom::brep::Surface, domain: [[f64; 2]; 2]) -> Result<Surface> {
- use solidcraft_geom::brep::Surface as S;
+ pub fn from_record(surface: &solidcore_record::brep::Surface, domain: [[f64; 2]; 2]) -> Result<Surface> {
+ use solidcore_record::brep::Surface as S;
let [u, v] = domain;
let deg = |r: [f64; 2]| r.map(f64::to_degrees);
let sub = |a: [f64; 3], b: [f64; 3]| [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
@@ -406,7 +406,7 @@ mod tests {
let r = intersect(&plane, &sphere, method, 1e-6).unwrap();
assert!(!r.curves.is_empty(), "{method:?}");
for c in &r.curves {
- let eval = b::eval::CurveEval::new(&c.curve).unwrap();
+ let eval = solidcraft_geom::brep::eval::CurveEval::new(&c.curve).unwrap();
let [t0, t1] = c.interval;
for k in 0..=100 {
let p = eval.point(t0 + (t1 - t0) * f64::from(k) / 100.0).unwrap();
diff --git a/crates/smlib/src/sweeps_tests.rs b/crates/smlib/src/sweeps_tests.rs
index 20b5a7e867..34e3971cd9 100644
--- a/crates/smlib/src/sweeps_tests.rs
+++ b/crates/smlib/src/sweeps_tests.rs
@@ -62,8 +62,8 @@ fn a_horn_torus_comes_out_as_its_nurbs() {
let want = 1.5 * PI * (14.0 + 56.0 / (3.0 * PI)) * PI * 98.0;
assert_close(solid_volume(&b, "horn torus"), want, 1e-6, "horn torus");
let record = b.to_native().unwrap();
- record.validate().unwrap();
- assert!(record.faces.iter().all(|f| !matches!(f.surface, solidcraft_geom::brep::Surface::Torus { .. })), "a torus label on a horn torus");
+ solidcraft_geom::brep::check::validate(&record).unwrap();
+ assert!(record.faces.iter().all(|f| !matches!(f.surface, solidcore_record::brep::Surface::Torus { .. })), "a torus label on a horn torus");
}
#[test]
diff --git a/crates/smlib/src/tests.rs b/crates/smlib/src/tests.rs
index 54e272d8c3..eacd8b5f07 100644
--- a/crates/smlib/src/tests.rs
+++ b/crates/smlib/src/tests.rs
@@ -343,15 +343,15 @@ fn a_failing_solidcore_call_leaves_a_dump_and_names_itself() {
/// ending them 0.1 um short) is held at that tolerance.
#[test]
fn a_pcurve_smlib_ends_within_the_edges_tolerance_is_mapped_onto_our_interval() {
+ use solidcore_record::brep::{Curve, Curve2};
use solidcraft_geom::brep::pcurve::TrimEdge;
- use solidcraft_geom::brep::{Curve, Curve2};
let line = Curve::Line { start: [0.0, 0.0, 0.0], end: [2.0, 0.0, 0.0] };
let edge = TrimEdge { curve: &line, nurbs: None, interval: [0.0, 1.0], vertices: [0, 1], tolerance: 1e-5 };
let theirs = [0.0, 1.0 - 2e-8];
let pc = Curve2::Spline { knots: vec![0.0, 0.0, theirs[1], theirs[1]], points: vec![[0.0, 0.0], [1.0, 0.0]] };
let mapped = crate::pcurves::on_our_interval(pc.clone(), &edge, theirs, edge.tolerance).unwrap();
assert_eq!(mapped.interval(), Some([0.0, 1.0]));
- assert_eq!(mapped.eval(1.0), Some([1.0, 0.0]));
+ assert_eq!(solidcraft_geom::brep::pcurve::eval(&mapped, 1.0), Some([1.0, 0.0]));
// 0.02 mm along the edge is past its 1e-5 mm.
let err = crate::pcurves::on_our_interval(pc, &edge, [0.0, 0.99], edge.tolerance).unwrap_err();
assert!(err.contains("SMLib moved an edge's interval") && err.contains("tolerance"), "{err}");
@@ -359,7 +359,7 @@ fn a_pcurve_smlib_ends_within_the_edges_tolerance_is_mapped_onto_our_interval()
let short = Curve2::Spline { knots: vec![0.0, 0.0, 0.99, 0.99], points: vec![[0.0, 0.0], [1.0, 0.0]] };
let held = crate::pcurves::on_our_interval(short, &edge, [0.0, 0.99], 0.03).unwrap();
assert_eq!(held.interval(), Some([0.0, 1.0]));
- assert_eq!(held.eval(1.0), Some([1.0, 0.0]));
+ assert_eq!(solidcraft_geom::brep::pcurve::eval(&held, 1.0), Some([1.0, 0.0]));
}
/// An edge whose curve runs 2.5 um past its vertex and its face's patch (as Poppy Humanoid's
@@ -369,8 +369,8 @@ fn a_pcurve_smlib_ends_within_the_edges_tolerance_is_mapped_onto_our_interval()
/// own interval, ending at the patch's corner.
#[test]
fn an_edge_a_few_um_past_its_patch_keeps_its_interval() {
+ use solidcore_record::brep::{Curve, Surface};
use solidcraft_geom::brep::pcurve::{TrimEdge, TrimFace, TrimUse, Trims};
- use solidcraft_geom::brep::{Curve, Surface};
// S(u, v) = (10u, 10v, 2v^2), bicubic
let g = [0.0, 1.0 / 3.0, 2.0 / 3.0, 1.0];
let z = [0.0, 0.0, 2.0 / 3.0, 2.0];
@@ -401,6 +401,6 @@ fn an_edge_a_few_um_past_its_patch_keeps_its_interval() {
let pcs = crate::pcurves::SmlibTrims.trims(&face).unwrap();
let pc = &pcs[0][0];
assert_eq!(pc.interval(), Some([0.0, 1.0]));
- let [u, v] = pc.eval(1.0).unwrap();
+ let [u, v] = solidcraft_geom::brep::pcurve::eval(pc, 1.0).unwrap();
assert!((u - 1.0).abs() < 1e-9 && v.abs() < 1e-9, "{u} {v}");
}
diff --git a/crates/smlib/tests/ssi_corpus.rs b/crates/smlib/tests/ssi_corpus.rs
index 577e5e3e2a..90632852a4 100644
--- a/crates/smlib/tests/ssi_corpus.rs
+++ b/crates/smlib/tests/ssi_corpus.rs
@@ -538,7 +538,8 @@ fn runner_output(
b: &solidcraft_smlib::ssi::Surface,
ms: f64,
) -> Outcome {
- use solidcraft_geom::brep::{Curve2, eval::CurveEval};
+ use solidcore_record::brep::Curve2;
+ use solidcraft_geom::brep::eval::CurveEval;
use solidcraft_smlib::ssi::{CurveType, Surface};
let r = match r {
Ok(r) => r,
@@ -551,7 +552,7 @@ fn runner_output(
let on = |c: &Option<Curve2>, s: &Surface| -> (Vec<[f64; 2]>, Vec<V3>) {
let Some(c) = c else { return (Vec::new(), Vec::new()) };
let Some(ivl) = c.interval() else { return (Vec::new(), Vec::new()) };
- params(ivl).filter_map(|t| c.eval(t)).filter_map(|q| s.evaluate(q[0], q[1]).ok().map(|p| (q, p))).unzip()
+ params(ivl).filter_map(|t| solidcraft_geom::brep::pcurve::eval(c, t)).filter_map(|q| s.evaluate(q[0], q[1]).ok().map(|p| (q, p))).unzip()
};
let mut curves = Vec::new();
for c in r.curves {
diff --git a/crates/step/Cargo.toml b/crates/step/Cargo.toml
index 80edcb5da1..3dfc57cdbb 100644
--- a/crates/step/Cargo.toml
+++ b/crates/step/Cargo.toml
@@ -9,5 +9,6 @@ license.workspace = true
workspace = true
[dependencies]
+solidcore-record = { workspace = true }
solidcraft-geom = { workspace = true }
solidcraft-profile = { workspace = true }
diff --git a/crates/step/src/topology.rs b/crates/step/src/topology.rs
index 2c7bba5f42..fa693f7bc7 100644
--- a/crates/step/src/topology.rs
+++ b/crates/step/src/topology.rs
@@ -34,16 +34,17 @@
//! Input is hostile: every reference is checked, nesting and counts are capped, and the work of
//! a whole file is bounded (shared shells count each time a solid uses them).
+use solidcraft_geom::prelude::*;
use std::collections::{HashMap, HashSet};
use std::f64::consts::TAU;
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::eval::{CurveEval, SurfaceEval, face_flux};
-use solidcraft_geom::brep::pcurve::{self, EdgeUse, TrimEdge, TrimFace, TrimUse, Trims};
-use solidcraft_geom::brep::{
+use solidcore_record::Vec3;
+use solidcore_record::brep::{
self, Brep, Curve as BCurve, Curve2, Edge, EdgeUseRef, Face, Frame, Loop, Natural, OrientedEdge, OrientedFace, Region, Shell,
Surface as BSurface, Vertex,
};
+use solidcraft_geom::brep::eval::{CurveEval, SurfaceEval, face_flux};
+use solidcraft_geom::brep::pcurve::{self, EdgeUse, TrimEdge, TrimFace, TrimUse, Trims};
use crate::geom::{BSplineCurve, BSplineSurface, Curve, P3, Placement, dot, scale, sub};
use crate::p21::{Entity, Exchange, Param};
@@ -511,7 +512,7 @@ struct FaceB {
outer: Option<usize>,
/// The face's normal is the surface's natural normal.
forward: bool,
- /// A round face's box on its label (`brep::form::extent`), once measured.
+ /// A round face's box on its label (`solidcraft_geom::brep::form::extent`), once measured.
extent: Option<[[f64; 2]; 2]>,
}
@@ -672,7 +673,7 @@ impl<'b, 'a> Builder<'b, 'a> {
for k in 0..=EDGE_GAP_SAMPLES {
let t = if k == EDGE_GAP_SAMPLES { t1 } else { t0 + (t1 - t0) * (k as f64 / EDGE_GAP_SAMPLES as f64) };
// A point a pcurve or surface lacks is the record check's to name.
- let (Some(q), Some(p)) = (c.eval(t), eval.point(t)) else { continue };
+ let (Some(q), Some(p)) = (solidcraft_geom::brep::pcurve::eval(c, t), eval.point(t)) else { continue };
if let Some(s) = on.point(q) {
gap = gap.max(s.dist(p));
}
@@ -968,7 +969,7 @@ impl<'b, 'a> Builder<'b, 'a> {
let mut frames: Vec<Vec<brep::Frame>> = vec![Vec::new(); self.edges.len()];
let mut tori: Vec<Vec<BSurface>> = vec![Vec::new(); self.edges.len()];
for f in &self.faces {
- let Some(frame) = brep::form::frame_of(&f.surface) else { continue };
+ let Some(frame) = solidcraft_geom::brep::form::frame_of(&f.surface) else { continue };
let torus = matches!(f.surface, BSurface::Torus { .. });
for l in &f.loops {
if let LoopB::Edges(es) = l {
@@ -984,8 +985,8 @@ impl<'b, 'a> Builder<'b, 'a> {
}
}
for ((edge, fr), tr) in self.edges.iter_mut().zip(&frames).zip(&tori) {
- let (label, interval, form) =
- brep::form::edge_on(&edge.curve, edge.interval, fr, tr, self.tol).ok_or_else(|| unsupported("an arc of more than one turn"))?;
+ let (label, interval, form) = solidcraft_geom::brep::form::edge_on(&edge.curve, edge.interval, fr, tr, self.tol)
+ .ok_or_else(|| unsupported("an arc of more than one turn"))?;
(edge.curve, edge.interval, edge.form) = (label, interval, form);
}
// Each face's pcurves; a face whose loops disagree with its same_sense is turned over.
@@ -1263,8 +1264,8 @@ impl<'b, 'a> Builder<'b, 'a> {
out_shells.push(Shell::Faces { faces, wires: Vec::new() });
}
let brep = Brep { version: brep::VERSION, tolerance: self.tol, regions, shells: out_shells, faces, edges, vertices };
- brep.validate().map_err(|e| format!("the record is invalid: {e}"))?;
- brep.check_geometry().map_err(|e| format!("the record's geometry disagrees: {e}"))?;
+ solidcraft_geom::brep::check::validate(&brep).map_err(|e| format!("the record is invalid: {e}"))?;
+ solidcraft_geom::brep::geometry::check(&brep).map_err(|e| format!("the record's geometry disagrees: {e}"))?;
Ok(Solid { item, name, product: None, brep, face_origin, sheet, notes, turned: turned_faces })
}
@@ -1290,7 +1291,7 @@ impl<'b, 'a> Builder<'b, 'a> {
std::iter::once(outer).chain((0..face.loops.len()).filter(|l| *l != outer)).collect()
}
- /// A face's box on its label over its edge loops (`brep::form::extent`); `None` where the
+ /// A face's box on its label over its edge loops (`solidcraft_geom::brep::form::extent`); `None` where the
/// boundary does not project onto it.
fn face_extent(&self, fi: usize) -> R<Option<[[f64; 2]; 2]>> {
let face = self.faces.get(fi).ok_or("face reference")?;
@@ -1304,7 +1305,7 @@ impl<'b, 'a> Builder<'b, 'a> {
}
boundary.push(b);
}
- Ok(brep::form::extent(&face.surface, &boundary))
+ Ok(solidcraft_geom::brep::form::extent(&face.surface, &boundary))
}
/// The pcurves of a face's edge loops (in its edge-loop order), its domain, whether it was
@@ -1329,14 +1330,14 @@ impl<'b, 'a> Builder<'b, 'a> {
let tol = self.tol;
// A cylinder, cone, sphere, torus or revolution on its NURBS form, over the extent of its
// boundary on its label; then every pcurve on the forms.
- let form = match brep::form::frame_of(&label) {
+ let form = match solidcraft_geom::brep::form::frame_of(&label) {
Some(_) => {
let extent = match face.extent {
Some(e) => Some(e),
None => self.face_extent(fi)?,
};
let extent = extent.ok_or_else(|| unsupported("a face whose boundary does not lie on its surface"))?;
- Some(brep::form::surface_within(&label, extent, tol).ok_or_else(|| unsupported("a face of more than one turn"))?)
+ Some(solidcraft_geom::brep::form::surface_within(&label, extent, tol).ok_or_else(|| unsupported("a face of more than one turn"))?)
}
None => None,
};
@@ -1368,7 +1369,7 @@ impl<'b, 'a> Builder<'b, 'a> {
// Each use starts near where the one before it ends, along a bounded direction that
// does not wrap: a loop around a closed spline surface without a seam edge jumps across
// its domain.
- let natural = surface.natural();
+ let natural = solidcraft_geom::brep::label::surface_natural(&surface);
// At a pole (where the surface collapses to a point across a direction, to within the
// tolerance of the vertex the two uses meet at) a loop may jump in that direction: the
// seam's two uses meet there a period apart, and a side collapsed to within the vertex's
@@ -1380,7 +1381,10 @@ impl<'b, 'a> Builder<'b, 'a> {
let mut ends = Vec::with_capacity(l.len());
for (&(_, forward), c) in l.iter().zip(pc) {
let [a, b] = c.interval().ok_or("pcurve interval")?;
- let (s, e) = (c.eval(a).ok_or("pcurve start")?, c.eval(b).ok_or("pcurve end")?);
+ let (s, e) = (
+ solidcraft_geom::brep::pcurve::eval(c, a).ok_or("pcurve start")?,
+ solidcraft_geom::brep::pcurve::eval(c, b).ok_or("pcurve end")?,
+ );
ends.push(if forward { (s, e) } else { (e, s) });
}
for k in 0..ends.len() {
@@ -1533,7 +1537,7 @@ fn uses_of<'e>(edges: &'e [EdgeB], edge_loops: &[Vec<(u32, bool)>], given: Optio
/// A spline surface's parameter box: its knot ranges.
fn natural_box(s: &BSurface) -> Option<[[f64; 2]; 2]> {
- match s.natural() {
+ match solidcraft_geom::brep::label::surface_natural(s) {
[Natural::Range(a, b), Natural::Range(c, d)] if [a, b, c, d].iter().all(|x| x.is_finite()) => Some([[a, b], [c, d]]),
_ => None,
}
@@ -1559,7 +1563,7 @@ fn reverse(uses: &mut [(u32, bool)]) {
}
fn natural_periods(s: &BSurface) -> [bool; 2] {
- s.natural().map(|n| matches!(n, Natural::Periodic))
+ solidcraft_geom::brep::label::surface_natural(s).map(|n| matches!(n, Natural::Periodic))
}
/// The signed area a loop encloses in (u, v) (positive counter-clockwise), or `None` when it
@@ -1571,7 +1575,7 @@ fn loop_area(l: &[(u32, bool)], pcs: &[Curve2], periodic: [bool; 2]) -> Option<f
for k in 0..=16 {
let s = f64::from(k) / 16.0;
let t = if forward { a + (b - a) * s } else { b - (b - a) * s };
- pts.push(c.eval(t)?);
+ pts.push(solidcraft_geom::brep::pcurve::eval(c, t)?);
}
}
let (first, last) = (*pts.first()?, *pts.last()?);
@@ -1608,7 +1612,7 @@ fn face_domain(surface: &BSurface, pcs: &[Vec<Curve2>]) -> R<[[f64; 2]; 2]> {
}
}
}
- let natural = surface.natural();
+ let natural = solidcraft_geom::brep::label::surface_natural(surface);
let mut out = [[0.0; 2]; 2];
for d in 0..2 {
let (a, b) = (lo[d], hi[d]);
diff --git a/crates/step/src/topology/frames.rs b/crates/step/src/topology/frames.rs
index cf87136c76..e9721b9170 100644
--- a/crates/step/src/topology/frames.rs
+++ b/crates/step/src/topology/frames.rs
@@ -10,7 +10,7 @@
//! its form spans the four quarters (or fewer) it covers.
//!
//! A circle edge about the axis of the round faces it bounds is labelled on one of their frames
-//! (`brep::form::edge`), so its form and theirs share one quarter grid and its pcurves are
+//! (`solidcraft_geom::brep::form::edge`), so its form and theirs share one quarter grid and its pcurves are
//! straight lines; the faces joined that way (a cylinder and the coaxial fillet beside it) are
//! turned together, by one angle about their common axis, and keep that. They are turned only
//! when one of them spills and one angle puts every one of them within four quarters (a start
@@ -20,27 +20,28 @@
//!
//! A torus face's tube spills the same way along its tube angle, which STEP counts from the outer
//! equator: its tube start moves to where the face's tube begins, or a turn before where it ends
-//! (`brep::form::tube_turned`), the same surface. Its circles round the tube are labelled from
-//! the tube start (`brep::form::on_tube`), unless one is about another round face's axis (a
+//! (`solidcraft_geom::brep::form::tube_turned`), the same surface. Its circles round the tube are labelled from
+//! the tube start (`solidcraft_geom::brep::form::on_tube`), unless one is about another round face's axis (a
//! pipe's cylinder meeting the tube), which labels it on its own grid: the tube start is then
//! the one of the two that puts the tube's grid on that face's.
+use solidcraft_geom::prelude::*;
use std::f64::consts::TAU;
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::{self, Curve as BCurve};
+use solidcore_record::Vec3;
+use solidcore_record::brep::{self, Curve as BCurve};
use super::{Builder, LoopB, R};
/// A circle edge bounds a face about the circle's own axis: the faces it joins share a grid.
fn about_axis(edge: &BCurve, interval: [f64; 2], frame: &brep::Frame, tol: f64) -> bool {
- matches!(edge, BCurve::Circle { .. }) && brep::form::on_frame(edge, interval, frame, tol).is_some()
+ matches!(edge, BCurve::Circle { .. }) && solidcraft_geom::brep::form::on_frame(edge, interval, frame, tol).is_some()
}
/// The face's quarters about the axis with its frame turned by `angle` (its box shifted to
/// match), or `None` when its form cannot be measured.
fn quarters_turned(surface: &brep::Surface, [u, v]: [[f64; 2]; 2], angle: f64, tol: f64) -> Option<usize> {
- brep::form::turn_quarters(surface, [[u[0] - angle, u[1] - angle], v], tol)
+ solidcraft_geom::brep::form::turn_quarters(surface, [[u[0] - angle, u[1] - angle], v], tol)
}
/// Union-find root of `i`.
@@ -75,7 +76,7 @@ impl Builder<'_, '_> {
/// neither does, where it begins.
fn turn_tubes(&mut self) -> usize {
let tol = self.tol;
- let frames: Vec<Option<brep::Frame>> = self.faces.iter().map(|f| brep::form::frame_of(&f.surface)).collect();
+ let frames: Vec<Option<brep::Frame>> = self.faces.iter().map(|f| solidcraft_geom::brep::form::frame_of(&f.surface)).collect();
// The round faces each edge bounds.
let mut bounding: Vec<Vec<usize>> = vec![Vec::new(); self.edges.len()];
for (fi, f) in self.faces.iter().enumerate() {
@@ -96,7 +97,7 @@ impl Builder<'_, '_> {
for fi in 0..self.faces.len() {
let Some(face) = self.faces.get(fi) else { continue };
let Some(e) = face.extent else { continue };
- if brep::form::tube_quarters(&face.surface, e, tol).is_none_or(|q| q <= 4) {
+ if solidcraft_geom::brep::form::tube_quarters(&face.surface, e, tol).is_none_or(|q| q <= 4) {
continue;
}
// Its tube circles about another round face's axis, with that face's frame.
@@ -113,12 +114,13 @@ impl Builder<'_, '_> {
}
}
let on_grid = |start: f64| {
- brep::form::tube_turned(&face.surface, start)
- .is_some_and(|torus| joined.iter().all(|(c, iv, fr)| brep::form::tube_on_grid(c, *iv, fr, &torus, tol).is_none_or(|on| on)))
+ solidcraft_geom::brep::form::tube_turned(&face.surface, start).is_some_and(|torus| {
+ joined.iter().all(|(c, iv, fr)| solidcraft_geom::brep::form::tube_on_grid(c, *iv, fr, &torus, tol).is_none_or(|on| on))
+ })
};
let (begin, end) = (e[1][0], e[1][1] - TAU);
let start = if !on_grid(begin) && on_grid(end) { end } else { begin };
- let Some(surface) = brep::form::tube_turned(&face.surface, start) else { continue };
+ let Some(surface) = solidcraft_geom::brep::form::tube_turned(&face.surface, start) else { continue };
if let Some(face) = self.faces.get_mut(fi) {
face.surface = surface;
if let Some(e) = face.extent.as_mut() {
@@ -133,7 +135,7 @@ impl Builder<'_, '_> {
/// Measure the round faces' boxes and turn the groups that spill about their axes.
fn turn_about_axes(&mut self) -> R<usize> {
let n = self.faces.len();
- let frames: Vec<Option<brep::Frame>> = self.faces.iter().map(|f| brep::form::frame_of(&f.surface)).collect();
+ let frames: Vec<Option<brep::Frame>> = self.faces.iter().map(|f| solidcraft_geom::brep::form::frame_of(&f.surface)).collect();
for fi in 0..n {
if frames.get(fi).is_some_and(Option::is_some) {
let extent = self.face_extent(fi)?;
@@ -220,7 +222,9 @@ impl Builder<'_, '_> {
}
// A face that cannot be turned, or measured, keeps its group's frames.
if members.len() != g.len()
- || members.iter().any(|(fi, _, e)| e.is_none() || self.faces.get(*fi).and_then(|f| brep::form::turned(&f.surface, 0.0)).is_none())
+ || members
+ .iter()
+ .any(|(fi, _, e)| e.is_none() || self.faces.get(*fi).and_then(|f| solidcraft_geom::brep::form::turned(&f.surface, 0.0)).is_none())
{
continue;
}
@@ -260,7 +264,7 @@ impl Builder<'_, '_> {
};
for (fi, angle) in turns {
let Some(face) = self.faces.get_mut(fi) else { continue };
- let Some(surface) = brep::form::turned(&face.surface, angle) else { continue };
+ let Some(surface) = solidcraft_geom::brep::form::turned(&face.surface, angle) else { continue };
face.surface = surface;
if let Some(e) = face.extent.as_mut() {
e[0] = [e[0][0] - angle, e[0][1] - angle];
diff --git a/crates/step/src/topology/seams.rs b/crates/step/src/topology/seams.rs
index 125f42aadd..cd5a4a482c 100644
--- a/crates/step/src/topology/seams.rs
+++ b/crates/step/src/topology/seams.rs
@@ -15,11 +15,12 @@
//! on a closed surface is all of that surface less a cut of none: its slit is made its seams
//! ([`Builder::complete_slits`]), so the loop bounds the surface's whole (u, v) domain.
+use solidcraft_geom::prelude::*;
use std::f64::consts::{PI, TAU};
-use solidcraft_geom::Vec3;
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Curve as BCurve, Frame, Surface as BSurface, Vertex};
use solidcraft_geom::brep::eval::{CurveEval, SurfaceEval};
-use solidcraft_geom::brep::{Curve as BCurve, Frame, Surface as BSurface, Vertex};
use super::{Builder, EdgeB, LoopB, R, index, unsupported};
@@ -104,7 +105,7 @@ fn axis(s: &BSurface) -> Option<Axis> {
BSurface::PlacedRevolution { profile, origin, axis, matrix, forward: false } if *matrix == IDENTITY => {
let (origin, z) = (Vec3::from(*origin), Vec3::from(*axis));
let c = CurveEval::new(profile).ok()?;
- let solidcraft_geom::brep::Natural::Range(a, b) = profile.natural() else { return None };
+ let solidcore_record::brep::Natural::Range(a, b) = profile.natural() else { return None };
// A profile end on the axis is a pole.
let pole = |t: f64| {
c.point(t).filter(|p| {
@@ -512,7 +513,7 @@ impl Builder<'_, '_> {
// a's angle; each vertex's profile parameter (a pole's from the profile's end).
let qa = eval.project(pa, None, f64::INFINITY).ok_or("a seam vertex off its surface")?;
let qb = eval.project(pb, Some(qa), f64::INFINITY).ok_or("a seam vertex off its surface")?;
- let solidcraft_geom::brep::Natural::Range(lo, hi) = profile.natural() else { return Err("a periodic profile".into()) };
+ let solidcore_record::brep::Natural::Range(lo, hi) = profile.natural() else { return Err("a periodic profile".into()) };
let vb = match ax.poles {
[Some(p), _] if p.dist(pb) <= self.tol => lo,
[_, Some(p)] if p.dist(pb) <= self.tol => hi,
diff --git a/crates/step/src/topology/swept.rs b/crates/step/src/topology/swept.rs
index a31881c2da..c9e447f4a9 100644
--- a/crates/step/src/topology/swept.rs
+++ b/crates/step/src/topology/swept.rs
@@ -14,10 +14,11 @@
//! surfaces' parameters may differ from STEP's (an extrusion's v, a conic's rational
//! parameter); pcurves and domains come from the records, never from STEP's parameters.
+use solidcraft_geom::prelude::*;
use std::f64::consts::{FRAC_PI_2, TAU};
-use solidcraft_geom::Vec3;
-use solidcraft_geom::brep::{Curve as BCurve, Surface as BSurface};
+use solidcore_record::Vec3;
+use solidcore_record::brep::{Curve as BCurve, Surface as BSurface};
use super::{MAX_NESTING, R, frame, map_bspline_curve, unsupported, v3};
use crate::geom::{Axis1, Curve, P3, Placement, Surface};
@@ -608,7 +609,7 @@ fn canonical(s: &Surface, reversed: &mut bool) -> Option<BSurface> {
let step_normal = k.cross(at - o).cross(cy * *radius);
*reversed = step_normal.dot(cx) < 0.0;
Some(BSurface::Torus {
- frame: solidcraft_geom::brep::Frame { origin: p3(foot), x_axis: p3(x), y_axis: p3(k.cross(x)) },
+ frame: solidcore_record::brep::Frame { origin: p3(foot), x_axis: p3(x), y_axis: p3(k.cross(x)) },
major_radius: big,
minor_radius: *radius,
tube_start: 0.0,
diff --git a/crates/step/src/topology_tests.rs b/crates/step/src/topology_tests.rs
index e508edced0..6f810e883b 100644
--- a/crates/step/src/topology_tests.rs
+++ b/crates/step/src/topology_tests.rs
@@ -211,8 +211,8 @@ fn one_solid(ex: &p21::Exchange) -> Solid {
assert!(r.failures.is_empty(), "{:?}", r.failures);
assert_eq!(r.solids.len(), 1);
let s = r.solids.into_iter().next().unwrap();
- s.brep.validate().unwrap();
- s.brep.check_geometry().unwrap();
+ solidcraft_geom::brep::check::validate(&s.brep).unwrap();
+ solidcraft_geom::brep::geometry::check(&s.brep).unwrap();
s
}
@@ -233,7 +233,10 @@ fn sides(b: &Brep) -> Vec<(usize, V, V)> {
let u = &edges[0];
let [t0, t1] = u.pcurve.interval().unwrap();
let m = 0.5 * (t0 + t1);
- let (a, c) = (u.pcurve.eval(m).unwrap(), u.pcurve.eval(m + 1e-4 * (t1 - t0)).unwrap());
+ let (a, c) = (
+ solidcraft_geom::brep::pcurve::eval(&u.pcurve, m).unwrap(),
+ solidcraft_geom::brep::pcurve::eval(&u.pcurve, m + 1e-4 * (t1 - t0)).unwrap(),
+ );
let along = if u.forward { [c[0] - a[0], c[1] - a[1]] } else { [a[0] - c[0], a[1] - c[1]] };
let n = (along[0].hypot(along[1])).max(1e-300);
let left = [-along[1] / n, along[0] / n];
@@ -374,7 +377,7 @@ fn a_cylinder_has_a_seam_used_twice_by_its_side() {
for e in &s.brep.edges {
if matches!(e.curve, BCurve::Circle { .. }) {
// On its NURBS form: a whole turn in angle, its interval in the form's parameter.
- let [a0, a1] = e.curve_interval().unwrap();
+ let [a0, a1] = solidcraft_geom::brep::label::edge_curve_interval(e).unwrap();
assert!(e.nurbs.is_some() && (a1 - a0 - TAU).abs() < 1e-12);
assert_eq!(e.vertices[0], e.vertices[1]);
}
@@ -408,7 +411,7 @@ fn a_ball_bounded_by_its_seam_alone() {
let s = one_solid(&w.file(&[solid]));
assert_eq!(counts(&s.brep), [2, 1, 1, 1, 2]);
let e = &s.brep.edges[0];
- let [a0, a1] = e.curve_interval().unwrap();
+ let [a0, a1] = solidcraft_geom::brep::label::edge_curve_interval(e).unwrap();
assert!((a1 - a0 - PI).abs() < 1e-12, "{:?}", e.interval);
faces_away(&s.brep, 0, |_| [0.0; 3]);
}
@@ -873,8 +876,8 @@ fn step_conformance_parts() {
let r = read_solids(&p21::parse(&std::fs::read_to_string(&path).unwrap()).unwrap());
assert!(r.failures.is_empty() && r.solids.len() == 1, "{name}: {:?}", r.failures);
let b = &r.solids[0].brep;
- b.validate().unwrap();
- b.check_geometry().unwrap();
+ solidcraft_geom::brep::check::validate(b).unwrap();
+ solidcraft_geom::brep::geometry::check(b).unwrap();
assert_eq!(b.regions.len(), 2, "{name}");
}
}
@@ -943,7 +946,7 @@ fn same_surface(data: &str, us: (f64, f64), vs: (f64, f64)) -> BSurface {
.collect();
let ext = swept::Extent { points: grid.iter().map(|&(u, v)| v3(s.point(u, v).unwrap())).collect(), seam: Vec::new() };
let (record, reversed) = swept::map_surface(&s, &ext, DEFAULT_TOLERANCE).unwrap();
- record.natural();
+ solidcraft_geom::brep::label::surface_natural(&record);
let eval = SurfaceEval::new(&record).unwrap();
for &(u, v) in &grid {
let p = v3(s.point(u, v).unwrap());
diff --git a/crates/step/src/write/topology.rs b/crates/step/src/write/topology.rs
index 262e5499c2..eb35749996 100644
--- a/crates/step/src/write/topology.rs
+++ b/crates/step/src/write/topology.rs
@@ -22,9 +22,10 @@
//! the side its first use needs (its same_sense, and its loops run counter-clockwise about that
//! side's normal); a later use of the other side refers to it through an ORIENTED_FACE.
+use solidcraft_geom::prelude::*;
use std::sync::Arc;
-use solidcraft_geom::brep::{Brep, Curve as BCurve, Curve2, Edge, Face, Frame, Loop, Shell, Surface as BSurface};
+use solidcore_record::brep::{Brep, Curve as BCurve, Curve2, Edge, Face, Frame, Loop, Shell, Surface as BSurface};
use super::{GeomWriter, boolean, list, r, s};
use crate::geom::{
@@ -422,7 +423,7 @@ pub fn outer_loop(b: &Brep, face: &Face) -> Option<usize> {
let [t0, t1] = edge_of(b, u.edge).ok()?.interval;
for k in 0..AREA_SAMPLES {
let f = k as f64 / AREA_SAMPLES as f64;
- ring.push(u.pcurve.eval(if u.forward { t0 + (t1 - t0) * f } else { t1 - (t1 - t0) * f })?);
+ ring.push(solidcraft_geom::brep::pcurve::eval(&u.pcurve, if u.forward { t0 + (t1 - t0) * f } else { t1 - (t1 - t0) * f })?);
}
}
(signed_area(&ring) > 0.0).then_some(li)
@@ -618,8 +619,8 @@ fn form_map(analytic: &BSurface, n: &BSurface, domain: [[f64; 2]; 2], map: Map)
let (p, su, sv) = eval.derivs(0.5 * (domain[0][0] + domain[0][1]), 0.5 * (domain[1][0] + domain[1][1]))?;
let normal = su.cross(sv);
let away = |f: &Frame| {
- let o = solidcraft_geom::Vec3::new(f.origin[0], f.origin[1], f.origin[2]);
- let z = solidcraft_geom::Vec3::new(f.x_axis[0], f.x_axis[1], f.x_axis[2]).cross(solidcraft_geom::Vec3::new(
+ let o = solidcore_record::Vec3::new(f.origin[0], f.origin[1], f.origin[2]);
+ let z = solidcore_record::Vec3::new(f.x_axis[0], f.x_axis[1], f.x_axis[2]).cross(solidcore_record::Vec3::new(
f.y_axis[0],
f.y_axis[1],
f.y_axis[2],
diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml
index 17dd817643..294892313f 100644
--- a/crates/ui-egui/Cargo.toml
+++ b/crates/ui-egui/Cargo.toml
@@ -9,6 +9,7 @@ license.workspace = true
workspace = true
[dependencies]
+solidcore-record = { workspace = true }
solidcraft-engine = { workspace = true }
egui = { workspace = true }
egui-wgpu = { workspace = true }
diff --git a/crates/ui-egui/src/agent_chat/context.rs b/crates/ui-egui/src/agent_chat/context.rs
index d93c5a55f8..256a5a32b6 100644
--- a/crates/ui-egui/src/agent_chat/context.rs
+++ b/crates/ui-egui/src/agent_chat/context.rs
@@ -7,7 +7,7 @@
use std::collections::HashMap;
use serde_json::{Value, json};
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_engine::{Sel, Session};
/// The most items one message carries; the rest are counted, not dropped silently.
diff --git a/crates/ui-egui/src/agent_chat/tests.rs b/crates/ui-egui/src/agent_chat/tests.rs
index 0d151563f4..082d01f31a 100644
--- a/crates/ui-egui/src/agent_chat/tests.rs
+++ b/crates/ui-egui/src/agent_chat/tests.rs
@@ -3239,7 +3239,7 @@ fn box_selection(app: &mut SolveApp) -> Vec<solidcraft_engine::Sel> {
app.run("solid.box", json!({"length": 40, "width": 30, "height": 20})).expect("a box");
let face = app.session.execute("model.faces", &json!({"body": "Body1"})).expect("faces")["faces"][0].clone();
let edge = app.session.execute("model.edges", &json!({"body": "Body1"})).expect("edges")["edges"][0].clone();
- let at = |v: &Value| solidcraft_engine::geom::Vec3::new(v[0].as_f64().unwrap_or(0.0), v[1].as_f64().unwrap_or(0.0), v[2].as_f64().unwrap_or(0.0));
+ let at = |v: &Value| solidcore_record::Vec3::new(v[0].as_f64().unwrap_or(0.0), v[1].as_f64().unwrap_or(0.0), v[2].as_f64().unwrap_or(0.0));
vec![
Sel::Face { body: "Body1".into(), index: face["index"].as_u64().unwrap_or(0) as usize, point: at(&face["point"]) },
Sel::Edge { body: "Body1".into(), index: edge["index"].as_u64().unwrap_or(0) as usize, point: at(&edge["mid"]) },
@@ -3317,8 +3317,8 @@ fn a_huge_selection_is_counted_not_dropped_silently() {
assert_eq!((both.items.len(), both.total()), (context::MAX_ITEMS, 200));
// Unknown bodies, faces and features are described by what is known, without panicking.
let odd = [
- Sel::Face { body: "Nope".into(), index: usize::MAX, point: solidcraft_engine::geom::Vec3::new(f64::NAN, f64::INFINITY, 0.0) },
- Sel::Edge { body: "Nope".into(), index: 7, point: solidcraft_engine::geom::Vec3::new(0.0, 0.0, 0.0) },
+ Sel::Face { body: "Nope".into(), index: usize::MAX, point: solidcore_record::Vec3::new(f64::NAN, f64::INFINITY, 0.0) },
+ Sel::Edge { body: "Nope".into(), index: 7, point: solidcore_record::Vec3::new(0.0, 0.0, 0.0) },
Sel::Feature { id: u64::MAX },
Sel::Plane { name: "XY".into() },
Sel::SketchCurve { id: "c1".into(), sketch: None },
@@ -3861,7 +3861,7 @@ fn a_split_wall_clicked_once_is_one_item() {
.and_then(|faces| faces.iter().find(|f| f["cylinder"]["radius"].is_number()).cloned())
.expect("the wall");
let at = &wall["point"];
- let point = solidcraft_engine::geom::Vec3::new(at[0].as_f64().unwrap_or(0.0), at[1].as_f64().unwrap_or(0.0), at[2].as_f64().unwrap_or(0.0));
+ let point = solidcore_record::Vec3::new(at[0].as_f64().unwrap_or(0.0), at[1].as_f64().unwrap_or(0.0), at[2].as_f64().unwrap_or(0.0));
crate::viewport::select(
&mut app,
Some(Sel::Face { body: "Body1".into(), index: wall["index"].as_u64().unwrap_or(0) as usize, point }),
diff --git a/crates/ui-egui/src/agent_cursor.rs b/crates/ui-egui/src/agent_cursor.rs
index b47a48c86b..bf49fe7409 100644
--- a/crates/ui-egui/src/agent_cursor.rs
+++ b/crates/ui-egui/src/agent_cursor.rs
@@ -19,13 +19,14 @@
//! settings on the navigation bar, or `ui.agent_cursor {show, speed, follow_camera}`); a call
//! with `"animate": false` skips it.
+use solidcraft_engine::geom::prelude::*;
use std::collections::VecDeque;
use std::sync::mpsc::Sender;
use egui::{Pos2, Stroke, pos2, vec2};
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
-use solidcraft_engine::geom::{Vec2, Vec3};
+use solidcore_record::{Vec2, Vec3};
use crate::SolveApp;
use crate::control::ControlResponse;
diff --git a/crates/ui-egui/src/blend_arrow_tests.rs b/crates/ui-egui/src/blend_arrow_tests.rs
index fb9821e9dc..d8cb9e1421 100644
--- a/crates/ui-egui/src/blend_arrow_tests.rs
+++ b/crates/ui-egui/src/blend_arrow_tests.rs
@@ -6,8 +6,9 @@ use crate::canvas::{anchor, blend_grow_dir};
use crate::dialogs::Kind;
use crate::scenario::Harness;
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
/// A 40 x 30 x 20 block with a 20 x 30 x 10 step on its left half: the edge along y at x 20,
/// z 20 is inside (concave); the block's right top edge (x 40, z 20) and the step's top right
diff --git a/crates/ui-egui/src/blend_dialog_tests.rs b/crates/ui-egui/src/blend_dialog_tests.rs
index 81bf3e6080..30094344f9 100644
--- a/crates/ui-egui/src/blend_dialog_tests.rs
+++ b/crates/ui-egui/src/blend_dialog_tests.rs
@@ -5,8 +5,8 @@ use crate::dialogs::Kind;
use crate::dialogs_surface::Surf;
use crate::scenario::Harness;
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::doc::{FeatureKind, kernel::Continuity};
-use solidcraft_engine::geom::Vec3;
fn ok(h: &mut Harness) {
h.frames(2);
diff --git a/crates/ui-egui/src/boundary_dialog_tests.rs b/crates/ui-egui/src/boundary_dialog_tests.rs
index 8ce3ad4c47..ae487d3d6e 100644
--- a/crates/ui-egui/src/boundary_dialog_tests.rs
+++ b/crates/ui-egui/src/boundary_dialog_tests.rs
@@ -5,9 +5,9 @@ use crate::dialogs::Kind;
use crate::dialogs_surface::Surf;
use crate::scenario::Harness;
use serde_json::{Map, json};
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::doc::{FeatureKind, Operation, kernel::Continuity};
-use solidcraft_engine::geom::Vec3;
fn ok(h: &mut Harness) {
h.frames(2);
diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rs
index 139797c6d1..3aa8ff79e7 100644
--- a/crates/ui-egui/src/browser.rs
+++ b/crates/ui-egui/src/browser.rs
@@ -7,6 +7,7 @@
//! ([`crate::context_menu`]).
use crate::ui_kit::{Container, Surface};
+use solidcraft_engine::geom::prelude::*;
#[path = "browser_cache.rs"]
mod cache;
@@ -162,7 +163,7 @@ pub struct TreeState {
history_plane: Option<String>,
/// A Section Analysis hidden with its eye in the Analysis folder: its plane (origin,
/// normal), so the eye can bring it back (#822).
- pub hidden_section: Option<(solidcraft_engine::geom::Vec3, solidcraft_engine::geom::Vec3)>,
+ pub hidden_section: Option<(solidcore_record::Vec3, solidcore_record::Vec3)>,
/// What the Section Analysis dialog's OK last made, for Edit to start from.
pub section_dialog: Option<crate::dialogs::SectionDraft>,
/// The Analysis folder hidden with its own eye, and the Section Analysis hidden with its
@@ -247,7 +248,7 @@ pub struct OccMove {
pub translate: [f64; 3],
pub angles: [f64; 3],
/// The occurrence's origin when the move began: what it turns about.
- pub pivot: Option<solidcraft_engine::geom::Vec3>,
+ pub pivot: Option<solidcore_record::Vec3>,
/// The values when the current triad drag began.
drag0: Option<([f64; 3], [f64; 3])>,
}
@@ -1924,7 +1925,7 @@ fn origin_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &mut A
let sel = match icon {
"plane" => Some(Sel::Plane { name: k.into() }),
"axis" => Some(Sel::Axis { name: k.into() }),
- _ => Some(Sel::Vertex { body: String::new(), point: solidcraft_engine::geom::Vec3::ZERO }),
+ _ => Some(Sel::Vertex { body: String::new(), point: solidcore_record::Vec3::ZERO }),
};
let (selected, mark) = lit_row(lit(&thing));
let r = draw_row(
@@ -2299,7 +2300,7 @@ fn pick_from_browser(app: &mut SolveApp, x: Sel) {
return;
}
let hit = match &x {
- Sel::Plane { name } => crate::viewport::Hit::Plane { name: name.clone(), point: solidcraft_engine::geom::Vec3::ZERO },
+ Sel::Plane { name } => crate::viewport::Hit::Plane { name: name.clone(), point: solidcore_record::Vec3::ZERO },
Sel::Axis { name } => crate::viewport::Hit::Axis { name: name.clone() },
Sel::ConstructionPoint { name } => crate::viewport::Hit::ConstructionPoint { name: name.clone() },
// The origin point goes only into a dialog input that takes it.
@@ -3245,7 +3246,7 @@ pub(crate) fn revert_occurrence_dialog(app: &mut SolveApp, m: &OccMove) {
/// The pending move: turned about X, then Y, then Z through the starting origin, then moved.
pub fn apply_occurrence_move(app: &mut SolveApp, m: &OccMove) {
use crate::gizmo;
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
let a = m.angles.map(f64::to_radians);
let r = gizmo::mul(&gizmo::mul(&gizmo::rotation(Vec3::Z, a[2]), &gizmo::rotation(Vec3::Y, a[1])), &gizmo::rotation(Vec3::X, a[0]));
let (axis, angle) = gizmo::axis_angle(&r);
@@ -3264,7 +3265,7 @@ pub fn apply_occurrence_move(app: &mut SolveApp, m: &OccMove) {
/// The shared move triad at the occurrence's origin: arrows and squares move it, rings turn it.
pub(crate) fn occurrence_triad_model(app: &SolveApp) -> Option<crate::gizmo::Triad> {
let movement = app.tree.occurrence_move.as_ref()?;
- let center = movement.pivot? + solidcraft_engine::geom::Vec3::new(movement.translate[0], movement.translate[1], movement.translate[2]);
+ let center = movement.pivot? + solidcore_record::Vec3::new(movement.translate[0], movement.translate[1], movement.translate[2]);
Some(crate::gizmo::Triad { center, translate: true, rotate: true })
}
@@ -3301,7 +3302,7 @@ pub(crate) fn occurrence_triad(app: &mut SolveApp, ui: &mut egui::Ui, painter: &
/// viewport like the sketch being edited draws its own (`crate::dim_view`). A double-click on a
/// value edits it in place without editing the sketch (`crate::dim_view::model_double_click`).
pub fn dims_overlay(app: &SolveApp, ctx: &egui::Context) {
- use solidcraft_engine::geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_engine::sketch::{DimFrame, chain_centres, default_text, dim_frame, dim_layout_reaching, dim_reach};
crate::dim_view::set_model_drawn(Vec::new());
let Some(rect) = app.viewport.rect else { return };
@@ -3422,11 +3423,11 @@ pub fn answer_capture(app: &mut SolveApp, action: &str) -> Result<(), String> {
}
/// Where an occurrence's origin is now (with its pending move).
-pub(crate) fn occurrence_origin(app: &SolveApp, occurrence: u64) -> Option<solidcraft_engine::geom::Vec3> {
+pub(crate) fn occurrence_origin(app: &SolveApp, occurrence: u64) -> Option<solidcore_record::Vec3> {
let o = app.session.doc.occurrences.iter().find(|o| o.id == occurrence)?;
let parent = app.session.doc.component_transform(o.parent);
let own = app.session.pending_moves.get(&occurrence).copied().unwrap_or(o.transform);
- Some(solidcraft_engine::doc::apply_point(&solidcraft_engine::doc::mat_mul(&parent, &own), solidcraft_engine::geom::Vec3::ZERO))
+ Some(solidcraft_engine::doc::apply_point(&solidcraft_engine::doc::mat_mul(&parent, &own), solidcore_record::Vec3::ZERO))
}
/// The names the Bodies folder lists at the top level, for tests.
diff --git a/crates/ui-egui/src/browser/features.rs b/crates/ui-egui/src/browser/features.rs
index 7ddafe0bb2..6e4d88064f 100644
--- a/crates/ui-egui/src/browser/features.rs
+++ b/crates/ui-egui/src/browser/features.rs
@@ -565,7 +565,7 @@ mod tests {
let model_body = state.body(body).unwrap();
let names = solidcraft_engine::doc::naming::face_names(model_body);
let index = names.iter().position(|name| name.starts_with(&format!("F{feature}:"))).unwrap();
- app.session.selection = vec![Sel::Face { body: body.into(), index, point: solidcraft_engine::geom::Vec3::ZERO }];
+ app.session.selection = vec![Sel::Face { body: body.into(), index, point: solidcore_record::Vec3::ZERO }];
let item = crate::context_menu::items(app, &Target::Viewport).into_iter().find(|item| item.id == "ui.findTimeline").unwrap();
assert!(item.enabled);
crate::context_menu::run_item(app, &item, pos2(0.0, 0.0));
@@ -656,7 +656,7 @@ mod tests {
fn browser_find_from_a_body_or_its_face_reveals_the_body() {
let mut h = Harness::new();
h.app.run("solid.box", json!({"length":10,"width":10,"height":10,"body_name":"Plate"})).unwrap();
- for pick in [Sel::Body { name: "Plate".into() }, Sel::Face { body: "Plate".into(), index: 0, point: solidcraft_engine::geom::Vec3::ZERO }] {
+ for pick in [Sel::Body { name: "Plate".into() }, Sel::Face { body: "Plate".into(), index: 0, point: solidcore_record::Vec3::ZERO }] {
h.app.tree.reveal = None;
h.app.session.selection = vec![pick.clone()];
let item = crate::context_menu::items(&h.app, &Target::Viewport).into_iter().find(|item| item.id == "ui.findBrowser").unwrap();
@@ -674,7 +674,7 @@ mod tests {
}
fn face(body: &str) -> Sel {
- Sel::Face { body: body.into(), index: 0, point: solidcraft_engine::geom::Vec3::ZERO }
+ Sel::Face { body: body.into(), index: 0, point: solidcore_record::Vec3::ZERO }
}
#[test]
@@ -803,7 +803,7 @@ mod tests {
let state = h.app.session.world_state().unwrap();
let owner = state.body(&name).unwrap().feature;
assert_ne!(owner, base);
- h.app.session.selection = vec![Sel::Face { body: name, index: 0, point: solidcraft_engine::geom::Vec3::ZERO }];
+ h.app.session.selection = vec![Sel::Face { body: name, index: 0, point: solidcore_record::Vec3::ZERO }];
for id in ["ui.findTimeline", "ui.editFeature"] {
let item = crate::context_menu::items(&h.app, &Target::Viewport).into_iter().find(|item| item.id == id).unwrap();
assert!(!item.enabled || item.params.as_ref().unwrap()["feature"] == json!(owner), "{id}: {item:?}");
diff --git a/crates/ui-egui/src/browser_canvas.rs b/crates/ui-egui/src/browser_canvas.rs
index e8ea1a92f8..20a3963f47 100644
--- a/crates/ui-egui/src/browser_canvas.rs
+++ b/crates/ui-egui/src/browser_canvas.rs
@@ -4,8 +4,9 @@
use egui::{Pos2, Stroke, vec2};
use serde_json::{Value, json};
+use solidcore_record::Vec2;
use solidcraft_engine::doc::canvas::Canvas;
-use solidcraft_engine::geom::Vec2;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::browser::panel_pos;
@@ -170,6 +171,7 @@ fn on_image(c: &Canvas, p: Vec2) -> bool {
#[cfg(test)]
mod tests {
use serde_json::json;
+ use solidcraft_engine::geom::prelude::*;
fn canvas(h: &mut crate::scenario::Harness) -> u64 {
let mut png = b"\x89PNG\r\n\x1a\n\0\0\0\rIHDR".to_vec();
@@ -236,8 +238,8 @@ mod tests {
let plane = h.app.session.doc.canvas_plane(&vals, &c).unwrap();
let ax = c.center.x - 20.0;
let bx = c.center.x + 20.0;
- let sa = proj.to_screen(plane.to_world(solidcraft_engine::geom::Vec2::new(ax, c.center.y))).expect("point A on screen");
- let sb = proj.to_screen(plane.to_world(solidcraft_engine::geom::Vec2::new(bx, c.center.y))).expect("point B on screen");
+ let sa = proj.to_screen(plane.to_world(solidcore_record::Vec2::new(ax, c.center.y))).expect("point A on screen");
+ let sb = proj.to_screen(plane.to_world(solidcore_record::Vec2::new(bx, c.center.y))).expect("point B on screen");
assert!(super::click(&mut h.app, &proj, sa), "first click sets A");
let panel = h.app.tree.canvas_panel.as_ref().unwrap();
assert_eq!(panel.next, 1);
@@ -247,7 +249,7 @@ mod tests {
assert_eq!(panel.next, 0);
assert!((panel.b[0] - bx).abs() < 0.5, "{:?}", panel.b);
let before = panel.a;
- let miss = plane.to_world(solidcraft_engine::geom::Vec2::new(c.center.x + 500.0, c.center.y));
+ let miss = plane.to_world(solidcore_record::Vec2::new(c.center.x + 500.0, c.center.y));
if let Some(sm) = proj.to_screen(miss) {
assert!(!super::click(&mut h.app, &proj, sm));
assert_eq!(h.app.tree.canvas_panel.as_ref().unwrap().a, before);
diff --git a/crates/ui-egui/src/browser_card_tests.rs b/crates/ui-egui/src/browser_card_tests.rs
index 8e540dbd75..bc697ae328 100644
--- a/crates/ui-egui/src/browser_card_tests.rs
+++ b/crates/ui-egui/src/browser_card_tests.rs
@@ -724,8 +724,8 @@ fn collapsed_rail_shares_header_hover_inset_and_expands_from_its_whole_card() {
/// #6907: a mesh body's row has its own icon and tooltip, so it can be told from a solid one.
#[test]
fn mesh_and_solid_body_rows_have_different_icons_and_tooltips() {
+ use solidcore_record::Vec3;
use solidcraft_engine::doc::{Document, FeatureKind, MeshData};
- use solidcraft_engine::geom::Vec3;
let solid = solidcraft_engine::kernel::box_solid(Vec3::ZERO, Vec3::new(10., 10., 10.)).unwrap();
let mesh = solid.mesh(&solidcraft_engine::kernel::MeshTolerance::chord(0.01)).unwrap();
let mut doc = Document::default();
diff --git a/crates/ui-egui/src/browser_model_tests.rs b/crates/ui-egui/src/browser_model_tests.rs
index 6f85e4df36..f60f72ae36 100644
--- a/crates/ui-egui/src/browser_model_tests.rs
+++ b/crates/ui-egui/src/browser_model_tests.rs
@@ -29,7 +29,7 @@ fn pending_and_reverted_moves_replace_cached_transforms() {
h.app.run("occurrence.move", json!({"occurrence":occurrence,"translate":[20,0,0],"capture":false})).unwrap();
let moved = super::model_placement(&mut h.app, &[occurrence]).unwrap();
assert!(!Arc::ptr_eq(&first, &moved));
- assert!((solidcraft_engine::doc::apply_point(&moved.world, solidcraft_engine::geom::Vec3::ZERO).x - 20.0).abs() < 1e-9);
+ assert!((solidcraft_engine::doc::apply_point(&moved.world, solidcore_record::Vec3::ZERO).x - 20.0).abs() < 1e-9);
h.app.run("component.revert_position", json!({"occurrences":[occurrence]})).unwrap();
let reverted = super::model_placement(&mut h.app, &[occurrence]).unwrap();
assert!(!Arc::ptr_eq(&moved, &reverted));
@@ -96,7 +96,7 @@ fn a_face_picked_in_the_viewport_opens_the_browser_to_its_placements_body() {
h.app.tree.collapsed.extend([one.clone(), two.clone(), format!("{two}/bodies")]);
h.frames(2);
assert!(!h.app.tree.order.contains(&format!("b:{second}")), "the body's row is closed away");
- let face = Sel::Face { body: second.clone(), index: 0, point: solidcraft_engine::geom::Vec3::new(55.0, 5.0, 10.0) };
+ let face = Sel::Face { body: second.clone(), index: 0, point: solidcore_record::Vec3::new(55.0, 5.0, 10.0) };
crate::viewport::select(&mut h.app, Some(face), false, false);
assert_eq!(h.app.tree.reveal.as_deref(), Some(second.as_str()));
h.frames(2);
@@ -207,7 +207,7 @@ fn render_browser_swatch_resolves_face_body_component_then_physical_material() {
assert_eq!(swatch(&h).name, "ABS - Red");
h.app.run("appearance.assign", json!({"bodies":["Body1"],"appearance":"ABS - Blue"})).unwrap();
assert_eq!(swatch(&h).name, "ABS - Blue");
- let point = solidcraft_engine::geom::Vec3::new(0.0, 5.0, 5.0);
+ let point = solidcore_record::Vec3::new(0.0, 5.0, 5.0);
h.app.run("appearance.assign", json!({"body":"Body1","faces":[point],"appearance":"ABS - Red"})).unwrap();
let state = crate::open_meshing::session_world(&h.app.session);
let body = state.body("Body1").unwrap();
diff --git a/crates/ui-egui/src/browser_prompts.rs b/crates/ui-egui/src/browser_prompts.rs
index bab9dd2922..75341945d9 100644
--- a/crates/ui-egui/src/browser_prompts.rs
+++ b/crates/ui-egui/src/browser_prompts.rs
@@ -32,7 +32,7 @@ pub(crate) fn occurrence_panel(app: &mut SolveApp, ui: &mut egui::Ui) {
m.pivot = if m.path.is_empty() {
occurrence_origin(app, m.occurrence)
} else {
- app.session.occurrence_placement(&m.path).ok().map(|p| solidcraft_engine::doc::apply_point(&p.world, solidcraft_engine::geom::Vec3::ZERO))
+ app.session.occurrence_placement(&m.path).ok().map(|p| solidcraft_engine::doc::apply_point(&p.world, solidcore_record::Vec3::ZERO))
};
}
let name = app.session.doc.occurrences.iter().find(|o| o.id == m.occurrence).map(|o| o.name.clone()).unwrap_or_default();
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index 407e97dc43..3b2897ded0 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -7,9 +7,11 @@
use crate::ui_kit::{Container, Surface};
use egui::{Color32, Pos2, Stroke, vec2};
+use solidcore_record::{Vec2, Vec3};
use solidcraft_engine::Sel;
use solidcraft_engine::doc::expr::Kind as ValueKind;
-use solidcraft_engine::geom::{Mesh, Vec2, Vec3};
+use solidcraft_engine::geom::Mesh;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::dialogs::{Dialog, Kind};
@@ -39,7 +41,7 @@ pub fn anchor(app: &SolveApp, d: &Dialog) -> Option<(Vec3, Option<Vec3>)> {
.collect();
let regions = solidcraft_engine::sketch::merge_regions(&regions);
let points: Vec<_> = regions.iter().flat_map(|r| r.outer.polyline(1e-2)).collect();
- points.iter().fold(solidcraft_engine::geom::Vec2::default(), |sum, p| sum + *p) * (1.0 / points.len().max(1) as f64)
+ points.iter().fold(solidcore_record::Vec2::default(), |sum, p| sum + *p) * (1.0 / points.len().max(1) as f64)
} else {
p.region.interior_point()
};
@@ -77,7 +79,7 @@ pub fn anchor(app: &SolveApp, d: &Dialog) -> Option<(Vec3, Option<Vec3>)> {
// made, as a body sits at the middle of its box.
Sel::Feature { id } => (crate::viewport::feature_bounds(app, *id)?.center(), None),
Sel::Plane { name } => {
- let pl = solidcraft_engine::geom::Plane::named(name).or_else(|| {
+ let pl = solidcore_record::Plane::named(name).or_else(|| {
solidcraft_engine::view::construction_planes(&app.session).into_iter().find(|(_, n, _)| n == name).map(|(_, _, pl)| pl)
})?;
(pl.origin, Some(pl.normal()))
@@ -87,7 +89,7 @@ pub fn anchor(app: &SolveApp, d: &Dialog) -> Option<(Vec3, Option<Vec3>)> {
Some(match &d.kind {
Kind::Extrude { start, .. } => {
let n = normal?;
- let plane = solidcraft_engine::geom::Plane::from_normal(at, n)?;
+ let plane = solidcore_record::Plane::from_normal(at, n)?;
let from = reference_height(app, d, "From Object", &plane, at).unwrap_or(0.0);
let offset = if start.trim().is_empty() { 0.0 } else { crate::length_input::eval(&app.session.doc, start, ValueKind::Length).ok()? };
(at + n * (from + offset), Some(n))
@@ -189,19 +191,19 @@ fn poly_mid(poly: &[Vec2]) -> Option<(Vec2, Vec2)> {
last
}
-pub(crate) fn profile_plane(app: &SolveApp, sketch: u64) -> Option<solidcraft_engine::geom::Plane> {
+pub(crate) fn profile_plane(app: &SolveApp, sketch: u64) -> Option<solidcore_record::Plane> {
let component = app.session.doc.feature(sketch)?.component;
let state = app.session.model.state();
let plane = state.sketch(sketch)?.plane;
let frame = crate::dialogs::feature_frame(&app.session, component);
- solidcraft_engine::geom::Plane::new(
+ solidcore_record::Plane::new(
solidcraft_engine::doc::apply_point(&frame, plane.origin),
solidcraft_engine::doc::apply_vector(&frame, plane.x),
solidcraft_engine::doc::apply_vector(&frame, plane.y),
)
}
-fn reference_height(app: &SolveApp, d: &Dialog, label: &str, plane: &solidcraft_engine::geom::Plane, centre: Vec3) -> Option<f64> {
+fn reference_height(app: &SolveApp, d: &Dialog, label: &str, plane: &solidcore_record::Plane, centre: Vec3) -> Option<f64> {
let point = crate::dialogs::object_point(&d.inputs, label)?;
let p = point.as_array()?;
let p = Vec3::new(p.first()?.as_f64()?, p.get(1)?.as_f64()?, p.get(2)?.as_f64()?);
@@ -523,7 +525,7 @@ fn offset_plane_quad(proj: &Proj, c: Vec3, n: Vec3, h: f64) -> Option<Vec<Pos2>>
fn draw(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj, d: &mut Dialog, base: Vec3, bs: Pos2, dir: Option<Vec3>) {
let t = Tokens::get();
let to_span = dir.and_then(|n| {
- let plane = solidcraft_engine::geom::Plane::from_normal(base, n)?;
+ let plane = solidcore_record::Plane::from_normal(base, n)?;
reference_height(app, d, "To Object", &plane, base)
});
let all_span = if matches!(d.kind, Kind::Extrude { all: true, .. }) {
@@ -531,7 +533,7 @@ fn draw(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj,
let state = crate::open_meshing::session_world(&app.session);
let plane = match d.inputs.first()?.items.first()? {
Sel::Profile { sketch, .. } => profile_plane(app, *sketch)?,
- _ => solidcraft_engine::geom::Plane::from_normal(base, n)?,
+ _ => solidcore_record::Plane::from_normal(base, n)?,
};
let targets: Vec<String> = d
.extra
@@ -659,7 +661,7 @@ fn draw(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj,
let ang = crate::length_input::eval(&app.session.doc, taper, ValueKind::Angle).ok().filter(|v| v.is_finite()).unwrap_or(0.0);
let before = taper.clone();
let st = crate::open_meshing::session_world(&app.session);
- let regions: Vec<&solidcraft_engine::geom::Region2> = d
+ let regions: Vec<&solidcore_record::Region2> = d
.inputs
.first()
.map(|i| &i.items[..])
@@ -1560,7 +1562,7 @@ pub(crate) fn taper_limits((inward, outward): (f64, f64), height: f64) -> (f64,
/// The smallest inradius of `regions` and of their holes (infinite for none), which
/// [`taper_limits`] turns into angles. A grid search over every side of every loop, so the
/// extrude window keeps it while its profiles stay the same ([`taper_radii_kept`]).
-pub(crate) fn taper_radii(regions: &[&solidcraft_engine::geom::Region2]) -> (f64, f64) {
+pub(crate) fn taper_radii(regions: &[&solidcore_record::Region2]) -> (f64, f64) {
#[cfg(test)]
TAPER_RADII_WORKED_OUT.with(|n| n.set(n.get() + 1));
let inward = regions.iter().map(|r| r.inradius(1e-3)).fold(f64::INFINITY, f64::min);
@@ -1570,10 +1572,7 @@ pub(crate) fn taper_radii(regions: &[&solidcraft_engine::geom::Region2]) -> (f64
/// [`taper_radii`] of `regions`, worked out again only when they differ from the ones `kept`
/// holds: the extrude window draws its taper handle every frame, and only the height changes.
-fn taper_radii_kept(
- kept: &mut Option<(Vec<solidcraft_engine::geom::Region2>, (f64, f64))>,
- regions: &[&solidcraft_engine::geom::Region2],
-) -> (f64, f64) {
+fn taper_radii_kept(kept: &mut Option<(Vec<solidcore_record::Region2>, (f64, f64))>, regions: &[&solidcore_record::Region2]) -> (f64, f64) {
if let Some((was, radii)) = kept
&& was.len() == regions.len()
&& was.iter().zip(regions).all(|(a, b)| a == *b)
@@ -2157,7 +2156,8 @@ mod tests {
#[cfg(test)]
mod taper_limit_tests {
use super::{taper_limits, taper_radii};
- use solidcraft_engine::geom::{Loop2, Region2, Vec2};
+ use solidcore_record::{Loop2, Region2, Vec2};
+ use solidcraft_engine::geom::prelude::*;
/// #1602: a drag stops just short of the taper that closes the profile, either way.
#[test]
diff --git a/crates/ui-egui/src/colour_tokens_tests.rs b/crates/ui-egui/src/colour_tokens_tests.rs
index 3328de3ff1..68aac2bb6e 100644
--- a/crates/ui-egui/src/colour_tokens_tests.rs
+++ b/crates/ui-egui/src/colour_tokens_tests.rs
@@ -71,7 +71,7 @@ fn stroke_colours(shapes: &[egui::epaint::ClippedShape]) -> std::collections::BT
fn every_axis_is_drawn_in_one_set_of_colours() {
use crate::theme::{ColorVision, set_dark, set_vision};
use egui::{Pos2, Rect, vec2};
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
let ctx = crate::fonts::test_context();
let rect = Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0));
let cam = solidcraft_engine::render::Camera::default();
diff --git a/crates/ui-egui/src/context_menu.rs b/crates/ui-egui/src/context_menu.rs
index cd91b2fca4..583cae1b39 100644
--- a/crates/ui-egui/src/context_menu.rs
+++ b/crates/ui-egui/src/context_menu.rs
@@ -15,6 +15,7 @@ use crate::ui_kit::{Container, Surface};
use egui::{Color32, Pos2, Rect, Sense, Vec2, pos2, vec2};
use serde::Serialize;
use serde_json::{Value, json};
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::{Sel, doc::FeatureKind};
use crate::SolveApp;
@@ -1370,7 +1371,7 @@ fn sketch_entity_items(app: &SolveApp) -> Vec<Item> {
}
/// Where on the active sketch's plane the viewport menu was opened (sketch coordinates).
-fn menu_sketch_point(app: &SolveApp, plane: &solidcraft_engine::geom::Plane) -> Option<solidcraft_engine::geom::Vec2> {
+fn menu_sketch_point(app: &SolveApp, plane: &solidcore_record::Plane) -> Option<solidcore_record::Vec2> {
let (at, _) = app.menu.opened?;
let proj = crate::viewport::projection(app, app.viewport.rect?);
let (o, d) = proj.ray(at);
@@ -1825,7 +1826,7 @@ pub fn run_item(app: &mut SolveApp, item: &Item, at: Pos2) {
if let Some(ss) = id_of(&p, "sketch").and_then(|id| st.sketch(id)) {
let to = crate::dialogs::onto_sketch(app.cam.looking_from(ss.plane.normal()), ss);
app.animate_to(to);
- } else if let Some(plane) = p.get("plane").and_then(Value::as_str).and_then(solidcraft_engine::geom::Plane::named) {
+ } else if let Some(plane) = p.get("plane").and_then(Value::as_str).and_then(solidcore_record::Plane::named) {
let mut to = app.cam.looking_from(crate::dialogs::facing(app, plane.normal(), true));
to.target = plane.origin;
app.animate_to(to);
@@ -2823,7 +2824,8 @@ mod tests {
#[test]
fn line_offset_context_menu_breaks_association_and_allows_trim() {
- use solidcraft_engine::{geom::Vec2, sketch::Shape};
+ use solidcore_record::Vec2;
+ use solidcraft_engine::sketch::Shape;
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
@@ -2867,7 +2869,7 @@ mod tests {
/// sketch geometry that Trim then cuts. A line drawn in the sketch is offered no Break Link.
#[test]
fn projected_geometry_context_menu_breaks_its_link_and_allows_trim() {
- use solidcraft_engine::geom::Vec2;
+ use solidcore_record::Vec2;
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
@@ -2969,7 +2971,7 @@ mod tests {
assert!(item.enabled);
let p = item.params.clone().unwrap();
assert_eq!(p["curve"], json!(fit));
- let clicked = solidcraft_engine::geom::Vec2::new(p["at"][0].as_f64().unwrap(), p["at"][1].as_f64().unwrap());
+ let clicked = solidcore_record::Vec2::new(p["at"][0].as_f64().unwrap(), p["at"][1].as_f64().unwrap());
assert!(clicked.dist(at) < 0.5, "the item carries the clicked spot: {clicked:?} for {at:?}");
h.step(&json!({"click":{"handle":"menu:sketch.spline.insert_point"}})).unwrap();
assert_eq!(count(&h, &fit), 5);
diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs
index 7aea70fe49..6208cd199a 100644
--- a/crates/ui-egui/src/control.rs
+++ b/crates/ui-egui/src/control.rs
@@ -41,6 +41,7 @@
//! and replies once the command has run (`"animate": false` skips that one call)
//! - `ui.resize {width, height}`, `app.quit`
+use solidcraft_engine::geom::prelude::*;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::mpsc::Sender;
use std::sync::{Condvar, Mutex, MutexGuard, PoisonError};
@@ -1061,13 +1062,10 @@ fn dispatch(app: &mut SolveApp, ctx: &egui::Context, method: &str, p: &Value) ->
let proj = crate::viewport::projection(app, rect);
let num = |v: &Value, i: usize| v.get(i).and_then(Value::as_f64).unwrap_or(0.0);
let world = if let Some(w) = p.get("world") {
- Some(solidcraft_engine::geom::Vec3::new(num(w, 0), num(w, 1), num(w, 2)))
+ Some(solidcore_record::Vec3::new(num(w, 0), num(w, 1), num(w, 2)))
} else if let Some(s) = p.get("sketch") {
let st = crate::open_meshing::session_world(&app.session);
- app.session
- .active_sketch
- .and_then(|id| st.sketch(id))
- .map(|ss| ss.plane.to_world(solidcraft_engine::geom::Vec2::new(num(s, 0), num(s, 1))))
+ app.session.active_sketch.and_then(|id| st.sketch(id)).map(|ss| ss.plane.to_world(solidcore_record::Vec2::new(num(s, 0), num(s, 1))))
} else if let Some(n) = p.get("plane").and_then(Value::as_str) {
crate::viewport::origin_plane_target(app, &proj, n)
} else if let Some(n) = p.get("axis").and_then(Value::as_str) {
@@ -1077,7 +1075,7 @@ fn dispatch(app: &mut SolveApp, ctx: &egui::Context, method: &str, p: &Value) ->
} else if let Some(n) = p.get("gizmo").and_then(Value::as_str) {
// A handle of the move triad ("x", "xy", "rz", "ball"), moved `by` [x,y,z] mm or
// turned `turn` degrees (rings).
- let by = p.get("by").map(|b| solidcraft_engine::geom::Vec3::new(num(b, 0), num(b, 1), num(b, 2))).unwrap_or_default();
+ let by = p.get("by").map(|b| solidcore_record::Vec3::new(num(b, 0), num(b, 1), num(b, 2))).unwrap_or_default();
crate::gizmo::handle_point(n, by, p.get("turn").and_then(Value::as_f64).unwrap_or(0.0))
} else {
None
@@ -1098,7 +1096,7 @@ fn dispatch(app: &mut SolveApp, ctx: &egui::Context, method: &str, p: &Value) ->
.take(1000)
.map(|v| {
let c = |i: usize| v.get(i).and_then(Value::as_f64).unwrap_or(0.0);
- proj.to_screen(solidcraft_engine::geom::Vec3::new(c(0), c(1), c(2))).map_or(Value::Null, |q| json!([q.x, q.y]))
+ proj.to_screen(solidcore_record::Vec3::new(c(0), c(1), c(2))).map_or(Value::Null, |q| json!([q.x, q.y]))
})
.collect();
ok(json!(pts))
@@ -1118,7 +1116,7 @@ fn dispatch(app: &mut SolveApp, ctx: &egui::Context, method: &str, p: &Value) ->
.take(1000)
.map(|v| {
let c = |i: usize| v.get(i).and_then(Value::as_f64).unwrap_or(0.0);
- let q = solidcraft_engine::geom::Vec2::new(c(0), c(1));
+ let q = solidcore_record::Vec2::new(c(0), c(1));
proj.to_screen(ss.plane.to_world(q)).map_or(Value::Null, |p| json!([p.x, p.y]))
})
.collect();
@@ -2601,8 +2599,7 @@ mod tests {
);
// What is under the pointer is a selection-like item, not the viewport's Debug text.
- h.app.viewport.hover =
- Some(crate::viewport::Hit::Face { body: "Body1".into(), index: 2, point: solidcraft_engine::geom::Vec3::new(1.0, 2.0, 3.0) });
+ h.app.viewport.hover = Some(crate::viewport::Hit::Face { body: "Body1".into(), index: 2, point: solidcore_record::Vec3::new(1.0, 2.0, 3.0) });
let hover = json!({"type": "face", "body": "Body1", "index": 2, "point": [1.0, 2.0, 3.0]});
assert_eq!(h.call("ui.selection", json!({}))["result"]["hover"], hover);
}
diff --git a/crates/ui-egui/src/design_properties.rs b/crates/ui-egui/src/design_properties.rs
index 1cdd5d3ca2..0d432b1d9f 100644
--- a/crates/ui-egui/src/design_properties.rs
+++ b/crates/ui-egui/src/design_properties.rs
@@ -9,13 +9,14 @@
//! about; both are `ui_kit::Window` cards. While the card is open, [`overlay`] marks the centre
//! of mass in the view with the principal axes standing out of it.
+use solidcraft_engine::geom::prelude::*;
use std::sync::Arc;
use egui::{Align2, FontId, Stroke};
use serde_json::{Map, Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::doc::metadata::{DESCRIPTION, Owner, keys};
use solidcraft_engine::doc::progress::Progress;
-use solidcraft_engine::geom::Vec3;
use crate::SolveApp;
use crate::ui_kit;
@@ -465,6 +466,7 @@ pub fn show_object(app: &mut SolveApp, ctx: &egui::Context) {
#[cfg(test)]
mod tests {
use serde_json::json;
+ use solidcraft_engine::geom::prelude::*;
use crate::scenario::Harness;
@@ -566,7 +568,7 @@ mod tests {
/// its centre of mass with three principal axes a third of the box's diagonal long.
#[test]
fn the_measure_panels_properties_button_opens_the_window_with_the_moment_of_inertia() {
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
let mut h = Harness::new();
h.app.run("solid.box", json!({"length": 10, "width": 20, "height": 30, "body_name": "Block"})).unwrap();
h.step(&json!({"start": "component.properties"})).unwrap();
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index d77a0a7eaa..42927c0b1d 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -3,15 +3,17 @@
//! changes the design itself. Things selected before the command starts become its input.
use crate::ui_kit::choice_row;
+use solidcraft_engine::geom::prelude::*;
use std::hash::{Hash, Hasher};
use egui::{RichText, vec2};
use serde_json::{Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::Session;
use solidcraft_engine::doc::expr::Kind as ValueKind;
use solidcraft_engine::doc::{AxisRef, Direction, FeatureKind, FilletStyle, HoleKind, Operation, PatternKind, PlaneRef, ProfileSel, ThinSide};
-use solidcraft_engine::geom::{Aabb3, Vec3};
+use solidcraft_engine::geom::Aabb3;
use crate::SolveApp;
use crate::selection::{
@@ -4045,7 +4047,7 @@ pub(crate) fn set_object_accepting(inputs: &mut Vec<SelInput>, active: &mut usiz
}
/// The plane an extrude's picked profiles lie in: the first pick's sketch plane, or its planar face.
-fn profile_plane(s: &Session, first: &Sel) -> Option<solidcraft_engine::geom::Plane> {
+fn profile_plane(s: &Session, first: &Sel) -> Option<solidcore_record::Plane> {
let st = crate::open_meshing::session_world(s);
match first {
Sel::Profile { sketch, .. } => st.sketch(*sketch).map(|ss| ss.plane),
@@ -4056,7 +4058,7 @@ fn profile_plane(s: &Session, first: &Sel) -> Option<solidcraft_engine::geom::Pl
/// Is a pick an object to extrude to from profiles in `reference` (not one more profile)? A face
/// is unless it is planar and in that plane; a vertex or a place is unless it lies in it.
-fn object_target(s: &Session, reference: &solidcraft_engine::geom::Plane, sel: &Sel) -> bool {
+fn object_target(s: &Session, reference: &solidcore_record::Plane, sel: &Sel) -> bool {
const TOLERANCE: f64 = 1e-6;
match sel {
Sel::Face { body, index, .. } => {
@@ -4277,7 +4279,7 @@ fn flip_toward_viewer(app: &SolveApp, name: &str) -> Option<&'static str> {
/// the sketch, the view turning to it and the extrude all went the wrong way. `None` while the
/// active component sits at the origin (the name says the same) or for a construction plane.
fn shown_origin_plane(app: &SolveApp, name: &str) -> Option<Value> {
- let p = solidcraft_engine::geom::Plane::named(name)?;
+ let p = solidcore_record::Plane::named(name)?;
if app.session.doc.find_feature(name).is_some() || solidcraft_engine::doc::is_identity(&app.session.active_component_frame()) {
return None;
}
@@ -4285,8 +4287,8 @@ fn shown_origin_plane(app: &SolveApp, name: &str) -> Option<Value> {
}
/// The world plane of an origin plane or a construction plane by name, where it is shown.
-pub(crate) fn plane_by_name(s: &Session, name: &str) -> Option<solidcraft_engine::geom::Plane> {
- if let Some(p) = solidcraft_engine::geom::Plane::named(name) {
+pub(crate) fn plane_by_name(s: &Session, name: &str) -> Option<solidcore_record::Plane> {
+ if let Some(p) = solidcore_record::Plane::named(name) {
return Some(p);
}
let st = crate::open_meshing::session_world(s);
@@ -4364,7 +4366,7 @@ pub(crate) fn onto_sketch(mut to: solidcraft_engine::render::Camera, ss: &solidc
return to;
};
let mut b = Aabb3::default();
- for p in [lo, hi, solidcraft_engine::geom::Vec2::new(lo.x, hi.y), solidcraft_engine::geom::Vec2::new(hi.x, lo.y)] {
+ for p in [lo, hi, solidcore_record::Vec2::new(lo.x, hi.y), solidcore_record::Vec2::new(hi.x, lo.y)] {
b.add(ss.plane.to_world(p));
}
let keep = to.distance;
@@ -4583,7 +4585,7 @@ pub fn preview_commands(app: &SolveApp, d: &Dialog) -> Result<Vec<(String, Value
/// A wrapped Emboss edit keeps its profile guide in the saved author occurrence.
/// An invalid saved context must not draw the guide at a different occurrence.
-pub(crate) fn emboss_profile_plane(app: &SolveApp, sketch: u64) -> Result<Option<solidcraft_engine::geom::Plane>, String> {
+pub(crate) fn emboss_profile_plane(app: &SolveApp, sketch: u64) -> Result<Option<solidcore_record::Plane>, String> {
let Some(dialog) = app.dialog.as_ref().filter(|d| matches!(d.kind, Kind::Emboss { .. })) else { return Ok(None) };
let Some((feature, _)) = dialog.editing else { return Ok(None) };
let Some(feature) = app.session.doc.feature(feature) else { return Err("the edited feature is missing".into()) };
@@ -4597,7 +4599,7 @@ pub(crate) fn emboss_profile_plane(app: &SolveApp, sketch: u64) -> Result<Option
let owner = app.session.doc.feature(sketch.feature).map(|feature| feature.component).unwrap_or(0);
let plane = sketch.plane;
let frame = face.sketch_frame(&app.session.doc, feature.component, owner, body).map_err(|error| error.to_string())?;
- solidcraft_engine::geom::Plane::new(
+ solidcore_record::Plane::new(
solidcraft_engine::doc::apply_point(&frame, plane.origin),
solidcraft_engine::doc::apply_vector(&frame, plane.x),
solidcraft_engine::doc::apply_vector(&frame, plane.y),
@@ -4713,7 +4715,7 @@ fn dialog_commands(app: &SolveApp, d: &Dialog) -> Result<Vec<(String, Value)>, S
// Coplanar faces of one body share one sketch and Boolean. Mixed selections
// retain their original order and explicit face-body scope.
let state = crate::open_meshing::session_world(s);
- let mut group: Option<(String, solidcraft_engine::geom::Plane, Vec<Value>)> = None;
+ let mut group: Option<(String, solidcore_record::Plane, Vec<Value>)> = None;
let mut coplanar = true;
for pick in sels(d, 0) {
let Sel::Face { body, index, point } = pick else { continue };
diff --git a/crates/ui-egui/src/dialogs_all_tests.rs b/crates/ui-egui/src/dialogs_all_tests.rs
index d1ca57206d..65ad3876c2 100644
--- a/crates/ui-egui/src/dialogs_all_tests.rs
+++ b/crates/ui-egui/src/dialogs_all_tests.rs
@@ -14,11 +14,11 @@ fn measure_input_fits_external_sketch_geometry() {
assert!(fits(accept, &point));
assert_eq!(d.items(), vec![curve.clone(), point.clone()]);
assert_eq!(
- d.candidate(&h.app.session, &Hit::SketchCurve { sketch: 17, id: "line1".into(), straight: true, point: solidcraft_engine::geom::Vec3::ZERO }),
+ d.candidate(&h.app.session, &Hit::SketchCurve { sketch: 17, id: "line1".into(), straight: true, point: solidcore_record::Vec3::ZERO }),
Some(curve.clone())
);
assert_eq!(
- d.candidate(&h.app.session, &Hit::SketchPoint { sketch: 17, id: "p1".into(), at: solidcraft_engine::geom::Vec2::new(0.0, 0.0) }),
+ d.candidate(&h.app.session, &Hit::SketchPoint { sketch: 17, id: "p1".into(), at: solidcore_record::Vec2::new(0.0, 0.0) }),
Some(point.clone())
);
d.take_box(&h.app.session, vec![curve.clone(), point.clone()], false);
@@ -1145,7 +1145,7 @@ fn extrude_builds_the_one_region_clicked_where_the_face_outline_cuts_a_profile()
let state = h.app.session.world_state().unwrap();
let ss = state.sketch(sketch).unwrap();
assert_eq!(ss.profiles.len(), 3, "the lens, the crescent past the face and the rest of the face");
- let index = ss.profiles.iter().position(|p| p.region.contains(solidcraft_engine::geom::Vec2::new(x, 0.0))).unwrap();
+ let index = ss.profiles.iter().position(|p| p.region.contains(solidcore_record::Vec2::new(x, 0.0))).unwrap();
let area = ss.profiles[index].area;
let mut d = Dialog::for_command(&h.app, "solid.extrude").unwrap();
if let Kind::Extrude { distance, .. } = &mut d.kind {
diff --git a/crates/ui-egui/src/dialogs_appearance.rs b/crates/ui-egui/src/dialogs_appearance.rs
index 7abb3bb59c..74aff4159d 100644
--- a/crates/ui-egui/src/dialogs_appearance.rs
+++ b/crates/ui-egui/src/dialogs_appearance.rs
@@ -592,8 +592,8 @@ fn target_names(targets: &[Sel]) -> String {
#[cfg(test)]
mod tests {
+ use solidcore_record::Vec3;
use solidcraft_engine::Session;
- use solidcraft_engine::geom::Vec3;
use super::*;
use crate::Services;
diff --git a/crates/ui-egui/src/dialogs_assembly.rs b/crates/ui-egui/src/dialogs_assembly.rs
index 7c2b9ff6ae..0afd602df3 100644
--- a/crates/ui-egui/src/dialogs_assembly.rs
+++ b/crates/ui-egui/src/dialogs_assembly.rs
@@ -9,11 +9,13 @@ use crate::fonts::RichTextExt as _;
use crate::ui_kit::{choice_row, expr_row, text_row};
use egui::{Color32, Pos2, RichText, Stroke, vec2};
use serde_json::{Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::Session;
use solidcraft_engine::doc::expr::Kind as ValueKind;
use solidcraft_engine::doc::joints::{JointKind, JointOrigin, Snap};
-use solidcraft_engine::geom::{Aabb3, Mesh, Vec3};
+use solidcraft_engine::geom::prelude::*;
+use solidcraft_engine::geom::{Aabb3, Mesh};
use crate::SolveApp;
use crate::dialogs::{Dialog, Kind, combo, field, form_row};
diff --git a/crates/ui-egui/src/dialogs_cam_tests.rs b/crates/ui-egui/src/dialogs_cam_tests.rs
index 6111a636c2..828a63bf17 100644
--- a/crates/ui-egui/src/dialogs_cam_tests.rs
+++ b/crates/ui-egui/src/dialogs_cam_tests.rs
@@ -1,6 +1,7 @@
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Session;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use super::*;
use crate::Services;
diff --git a/crates/ui-egui/src/dialogs_coupling.rs b/crates/ui-egui/src/dialogs_coupling.rs
index ed66619f65..b222babbcf 100644
--- a/crates/ui-egui/src/dialogs_coupling.rs
+++ b/crates/ui-egui/src/dialogs_coupling.rs
@@ -97,7 +97,7 @@ fn occurrence(s: &Session, body: &str) -> Option<u64> {
s.doc.body_frames(&s.model.state()).into_iter().find(|f| f.0 == body).map(|(_, _, path, _)| path.last().copied().unwrap_or(0))
}
-fn pick(inputs: &[SelInput], i: usize) -> Option<(&str, solidcraft_engine::geom::Vec3)> {
+fn pick(inputs: &[SelInput], i: usize) -> Option<(&str, solidcore_record::Vec3)> {
match inputs.get(i)?.items.first()? {
Sel::Face { body, point, .. } | Sel::Edge { body, point, .. } => Some((body.as_str(), *point)),
_ => None,
diff --git a/crates/ui-egui/src/dialogs_coupling_tests.rs b/crates/ui-egui/src/dialogs_coupling_tests.rs
index a291d00e8c..791c9bbd7f 100644
--- a/crates/ui-egui/src/dialogs_coupling_tests.rs
+++ b/crates/ui-egui/src/dialogs_coupling_tests.rs
@@ -1,6 +1,6 @@
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Session;
-use solidcraft_engine::geom::Vec3;
use super::*;
use crate::Services;
diff --git a/crates/ui-egui/src/dialogs_frame_tests.rs b/crates/ui-egui/src/dialogs_frame_tests.rs
index 6cfdd64df7..b231ffd55a 100644
--- a/crates/ui-egui/src/dialogs_frame_tests.rs
+++ b/crates/ui-egui/src/dialogs_frame_tests.rs
@@ -1,6 +1,7 @@
use crate::test_support::run_all;
use serde_json::json;
use solidcraft_engine::Session;
+use solidcraft_engine::geom::prelude::*;
use super::*;
use crate::Services;
diff --git a/crates/ui-egui/src/dialogs_insert_drawing.rs b/crates/ui-egui/src/dialogs_insert_drawing.rs
index c59f7b5034..d9ce723da4 100644
--- a/crates/ui-egui/src/dialogs_insert_drawing.rs
+++ b/crates/ui-egui/src/dialogs_insert_drawing.rs
@@ -104,7 +104,7 @@ mod tests {
path.to_string_lossy().to_string()
}
- fn lines(h: &Harness) -> Vec<(solidcraft_engine::geom::Vec2, solidcraft_engine::geom::Vec2)> {
+ fn lines(h: &Harness) -> Vec<(solidcore_record::Vec2, solidcore_record::Vec2)> {
let st = h.app.session.world_state().unwrap();
let sk = &st.sketch(h.app.session.active_sketch.unwrap()).unwrap().sketch;
(0..sk.curves.len())
diff --git a/crates/ui-egui/src/dialogs_move.rs b/crates/ui-egui/src/dialogs_move.rs
index 327a6771d4..c38285237f 100644
--- a/crates/ui-egui/src/dialogs_move.rs
+++ b/crates/ui-egui/src/dialogs_move.rs
@@ -7,10 +7,11 @@
use crate::selection::SelectionExt as _;
use crate::ui_kit::{choice_row, expr_row};
use serde_json::{Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::doc::expr::Kind as ValueKind;
use solidcraft_engine::doc::{Mat, apply_point, apply_vector, is_identity, mat_inverse, mat_mul, rigid};
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::dialogs::{Dialog, Kind};
diff --git a/crates/ui-egui/src/dialogs_part_size.rs b/crates/ui-egui/src/dialogs_part_size.rs
index 95c8f159bd..863359613f 100644
--- a/crates/ui-egui/src/dialogs_part_size.rs
+++ b/crates/ui-egui/src/dialogs_part_size.rs
@@ -222,7 +222,8 @@ pub fn commands(app: &SolveApp, k: &Resize) -> Result<Vec<(String, Value)>, Stri
mod tests {
use super::*;
use crate::context_menu::{self, Target};
- use solidcraft_engine::{Session, geom::Vec3};
+ use solidcore_record::Vec3;
+ use solidcraft_engine::Session;
fn part(family: &str, size: &str, length: Option<f64>) -> (SolveApp, u64) {
let mut app = SolveApp::new(Session::default(), crate::Services::default());
diff --git a/crates/ui-egui/src/dialogs_parts.rs b/crates/ui-egui/src/dialogs_parts.rs
index 36e6fd0d1a..9fa4e65368 100644
--- a/crates/ui-egui/src/dialogs_parts.rs
+++ b/crates/ui-egui/src/dialogs_parts.rs
@@ -306,7 +306,7 @@ fn dimension_label(key: &str) -> Option<&'static str> {
#[cfg(test)]
mod tests {
use super::*;
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
fn lib() -> Vec<Family> {
families(&json!({"families": [
diff --git a/crates/ui-egui/src/dialogs_plastic.rs b/crates/ui-egui/src/dialogs_plastic.rs
index d6662a11cb..5baa8438fe 100644
--- a/crates/ui-egui/src/dialogs_plastic.rs
+++ b/crates/ui-egui/src/dialogs_plastic.rs
@@ -4,11 +4,12 @@
use crate::dialogs::put;
use crate::ui_kit::{choice_row, expr_row, hint_row};
use serde_json::{Map, Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::doc::FeatureKind;
use solidcraft_engine::doc::expr::Kind as ValueKind;
use solidcraft_engine::doc::plastic::PlasticRule;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::dialogs::{Kind, combo, face_sel, field, form_row, shown_expr};
diff --git a/crates/ui-egui/src/dialogs_save_mesh.rs b/crates/ui-egui/src/dialogs_save_mesh.rs
index ecdd41e40d..7304127c98 100644
--- a/crates/ui-egui/src/dialogs_save_mesh.rs
+++ b/crates/ui-egui/src/dialogs_save_mesh.rs
@@ -973,7 +973,7 @@ mod tests {
h.settle();
// A click on the face of `body` at `point` in the Print face input; that face's index.
let pick = |h: &mut crate::scenario::Harness, body: &str, point: [f64; 3]| {
- let p = solidcraft_engine::geom::Vec3::new(point[0], point[1], point[2]);
+ let p = solidcore_record::Vec3::new(point[0], point[1], point[2]);
let index = solidcraft_engine::doc::appearance::face_index_at(h.app.session.world_state().unwrap().body(body).unwrap(), p).unwrap();
let d = h.app.dialog.as_mut().unwrap();
d.active = 1;
diff --git a/crates/ui-egui/src/dialogs_sheet.rs b/crates/ui-egui/src/dialogs_sheet.rs
index a2969d9586..d6cac06bb6 100644
--- a/crates/ui-egui/src/dialogs_sheet.rs
+++ b/crates/ui-egui/src/dialogs_sheet.rs
@@ -7,11 +7,12 @@ use crate::dialogs::put;
use crate::ui_kit::{choice_row, expr_row, hint_row};
use egui::{Align2, Color32, FontId, Pos2, Rect, RichText, Stroke, pos2, vec2};
use serde_json::{Map, Value, json};
+use solidcore_record::{Vec2, Vec3};
use solidcraft_engine::Sel;
use solidcraft_engine::doc::expr::Kind as ValueKind;
use solidcraft_engine::doc::sheet::SheetRule;
use solidcraft_engine::doc::{FeatureKind, ProfileSel};
-use solidcraft_engine::geom::{Vec2, Vec3};
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::dialogs::{Dialog, Kind, edge_sel, face_sel, form_row, profile_indices};
diff --git a/crates/ui-egui/src/dialogs_sheet_tests.rs b/crates/ui-egui/src/dialogs_sheet_tests.rs
index a3f94d8b81..c8f83c8640 100644
--- a/crates/ui-egui/src/dialogs_sheet_tests.rs
+++ b/crates/ui-egui/src/dialogs_sheet_tests.rs
@@ -411,7 +411,7 @@ fn rules_dialog_picks_the_corner_relief_shape() {
// The rounds in the base of the tray, and the shape the open dialog shows.
let rounds = |app: &SolveApp| {
let state = app.session.model.state();
- state.sheets.last().map(|s| s.base.outer.segs.iter().filter(|g| matches!(g, solidcraft_engine::geom::Seg2::Arc { .. })).count())
+ state.sheets.last().map(|s| s.base.outer.segs.iter().filter(|g| matches!(g, solidcore_record::Seg2::Arc { .. })).count())
};
let shown = |app: &SolveApp| match app.dialog.as_ref().map(|d| &d.kind) {
Some(Kind::Sheet(Sm::Rules { relief, .. })) => Some(*relief),
@@ -605,7 +605,7 @@ fn flange_dialog_picks_a_corner_relief_of_its_own() {
.state()
.sheets
.last()
- .map(|s| s.base.outer.segs.iter().filter(|g| matches!(g, solidcraft_engine::geom::Seg2::Arc { .. })).count())
+ .map(|s| s.base.outer.segs.iter().filter(|g| matches!(g, solidcore_record::Seg2::Arc { .. })).count())
};
assert_eq!(arcs(&h.app), Some(1), "the round is cut at the one corner the two flanges make");
// Edit Feature shows both again; Rule and an empty size take the feature back to the rule's relief.
diff --git a/crates/ui-egui/src/dialogs_sketch_tests.rs b/crates/ui-egui/src/dialogs_sketch_tests.rs
index fab58f2c2a..19fc84d8f7 100644
--- a/crates/ui-egui/src/dialogs_sketch_tests.rs
+++ b/crates/ui-egui/src/dialogs_sketch_tests.rs
@@ -25,7 +25,7 @@ fn a_context_error_offers_no_create_issue_button_10181() {
h.app.run("solid.box", json!({"length":40,"width":30,"height":20,"body_name":"Body1"})).unwrap();
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.settle();
- h.app.session.selection = vec![Sel::Face { body: "Body1".into(), index: 5, point: solidcraft_engine::geom::Vec3::new(20.0, 15.0, 20.0) }];
+ h.app.session.selection = vec![Sel::Face { body: "Body1".into(), index: 5, point: solidcore_record::Vec3::new(20.0, 15.0, 20.0) }];
h.app.start("sketch.project");
h.frames(4);
assert!(h.app.dialog.as_ref().is_some_and(|d| matches!(d.kind, Kind::SketchProject { .. })), "the Project panel opens for the live sketch");
@@ -249,7 +249,7 @@ fn intersect_dialog_filters_geometry_or_whole_bodies_and_controls_projection_lin
assert_eq!(apply_commands(&h.app, d).unwrap(), vec![("sketch.intersect".into(), json!({"refs":[{"body":"Post"}],"projection_link":false}))]);
// A model edge is cut with the plane too (#10484).
let d = h.app.dialog.as_mut().unwrap();
- d.inputs[0].items = vec![Sel::Edge { body: "Post".into(), index: 0, point: solidcraft_engine::geom::Vec3::new(0.0, 0.0, 10.0) }];
+ d.inputs[0].items = vec![Sel::Edge { body: "Post".into(), index: 0, point: solidcore_record::Vec3::new(0.0, 0.0, 10.0) }];
let cmds = apply_commands(&h.app, h.app.dialog.as_ref().unwrap()).unwrap();
assert_eq!(cmds, vec![("sketch.intersect".into(), json!({"refs":[{"edge":[0.0,0.0,10.0],"body":"Post"}],"projection_link":false}))]);
}
@@ -285,7 +285,7 @@ fn intersect_dialog_takes_a_line_of_another_sketch() {
let link = &sk.sketch.links[0].id;
let at: Vec<_> = sk.sketch.link_points(link).iter().filter_map(|p| sk.sketch.point(*p)).map(|p| sk.plane.to_world(p)).collect();
assert_eq!(at.len(), 1, "{at:?}");
- assert!(at[0].dist(solidcraft_engine::geom::Vec3::new(20.0, 0.0, 0.0)) < 1e-6, "{at:?}");
+ assert!(at[0].dist(solidcore_record::Vec3::new(20.0, 0.0, 0.0)) < 1e-6, "{at:?}");
}
#[test]
diff --git a/crates/ui-egui/src/dialogs_surface.rs b/crates/ui-egui/src/dialogs_surface.rs
index 09c6cd11ce..87c7c28df2 100644
--- a/crates/ui-egui/src/dialogs_surface.rs
+++ b/crates/ui-egui/src/dialogs_surface.rs
@@ -5,10 +5,11 @@
use crate::dialogs::put;
use crate::ui_kit::{choice_row, expr_row, hint_row};
use serde_json::{Map, Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::doc::expr::Kind as ValueKind;
use solidcraft_engine::doc::{AxisRef, Direction, FaceAt, FeatureKind, Mat, PlaneRef, Position, ProfileSel, RuledCorners, RuledMode};
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::kernel::{Construction, Continuity};
use crate::SolveApp;
diff --git a/crates/ui-egui/src/dialogs_sweep.rs b/crates/ui-egui/src/dialogs_sweep.rs
index b18d1a684b..468102c99e 100644
--- a/crates/ui-egui/src/dialogs_sweep.rs
+++ b/crates/ui-egui/src/dialogs_sweep.rs
@@ -5,9 +5,10 @@
use crate::selection::SelectionExt as _;
use crate::ui_kit::{choice_row, expr_row};
use serde_json::{Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::doc::{Expr, Mat, RailFit, SweepOrientation, SweepRail};
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::selection::{AXES, CURVES, EDGES, SelInput};
diff --git a/crates/ui-egui/src/dialogs_thread.rs b/crates/ui-egui/src/dialogs_thread.rs
index 55f05a7811..7895d302d6 100644
--- a/crates/ui-egui/src/dialogs_thread.rs
+++ b/crates/ui-egui/src/dialogs_thread.rs
@@ -723,7 +723,8 @@ mod contribution_tests {
dialogs::{Dialog, Kind, apply_commands},
};
use serde_json::json;
- use solidcraft_engine::{Sel, Session, geom::Vec3};
+ use solidcore_record::Vec3;
+ use solidcraft_engine::{Sel, Session};
fn hole() -> (SolveApp, Dialog) {
let mut app = SolveApp::new(Session::default(), Services::default());
app.run("solid.box", json!({"length":20,"width":20,"height":10,"body_name":"Plate"})).unwrap();
diff --git a/crates/ui-egui/src/dialogs_thread_tests.rs b/crates/ui-egui/src/dialogs_thread_tests.rs
index efda600c8e..4440da3f29 100644
--- a/crates/ui-egui/src/dialogs_thread_tests.rs
+++ b/crates/ui-egui/src/dialogs_thread_tests.rs
@@ -1,5 +1,5 @@
use serde_json::json;
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
use super::*;
use crate::dialogs::{Kind, apply_commands, edge_sel};
diff --git a/crates/ui-egui/src/dialogs_trace.rs b/crates/ui-egui/src/dialogs_trace.rs
index 2ab4f96834..b11790d2ec 100644
--- a/crates/ui-egui/src/dialogs_trace.rs
+++ b/crates/ui-egui/src/dialogs_trace.rs
@@ -5,8 +5,8 @@
use crate::ui_kit::{choice_row, expr_row, text_row};
use egui::{Pos2, Stroke};
use serde_json::{Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::doc::{IDENTITY, Mat, apply_point, mat_inverse, mat_mul};
-use solidcraft_engine::geom::Vec3;
use solidcraft_engine::{Sel, Session};
use super::{Hover, body_of, capital, movable, num, pt, sel_items, snap_of};
diff --git a/crates/ui-egui/src/dim_view.rs b/crates/ui-egui/src/dim_view.rs
index 9a551c866b..b55dd8c6a8 100644
--- a/crates/ui-egui/src/dim_view.rs
+++ b/crates/ui-egui/src/dim_view.rs
@@ -14,13 +14,14 @@
//! `sketch.toggle_driven`, `parameters.change`.
use crate::ui_kit::{Container, Surface};
+use solidcraft_engine::geom::prelude::*;
use std::cell::RefCell;
use std::sync::Arc;
use egui::{FontId, Pos2, Rect, Shape, Stroke, vec2};
use serde_json::json;
+use solidcore_record::Vec2;
use solidcraft_engine::Sel;
-use solidcraft_engine::geom::Vec2;
use solidcraft_engine::sketch::{
ConstraintKind, DimFrame, chain_centres, default_text, default_text_offset, dim_frame, dim_layout_reaching, dim_reach,
};
@@ -1409,7 +1410,7 @@ mod tests {
h.app.run("sketch.dimension", json!({"entities":["l2"],"text_at":[10,20]})).unwrap();
h.call("ui.view", json!({"view":"top"}));
h.app.cam.distance = 90.;
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(10., 10., 0.);
+ h.app.cam.target = solidcore_record::Vec3::new(10., 10., 0.);
h.settle();
let rects = crate::dim_view::text_rects();
assert_eq!(rects.len(), 2, "{rects:?}");
@@ -1430,7 +1431,7 @@ mod tests {
let param = h.app.run("sketch.dimension", json!({"entities":["l1"],"text_at":[10,25]})).unwrap()["param"].as_str().unwrap().to_string();
h.call("ui.view", json!({"view":"top"}));
h.app.cam.distance = 120.;
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(10., 12., 0.);
+ h.app.cam.target = solidcore_record::Vec3::new(10., 12., 0.);
h.settle();
h.app.run("parameters.change", json!({"name":param,"expression":"30"})).unwrap();
h.settle();
diff --git a/crates/ui-egui/src/dimension_create_ui_tests.rs b/crates/ui-egui/src/dimension_create_ui_tests.rs
index 8a75fdd9c4..f551f898a1 100644
--- a/crates/ui-egui/src/dimension_create_ui_tests.rs
+++ b/crates/ui-egui/src/dimension_create_ui_tests.rs
@@ -1,6 +1,7 @@
//! Dimension creation is an editable draft, accepted by the real focused value field.
use crate::scenario::Harness;
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
fn line(end: [f64; 2]) -> Harness {
crate::dim_view::cancel();
@@ -11,7 +12,7 @@ fn line(end: [f64; 2]) -> Harness {
// Leave room around the measured shape while testing the draft itself. Separate Fit
// tests exercise measured dock occlusion without changing the picking projection.
h.app.cam.distance = 80.0;
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(end[0] * 0.5, end[1] * 0.5, 0.0);
+ h.app.cam.target = solidcore_record::Vec3::new(end[0] * 0.5, end[1] * 0.5, 0.0);
h.settle();
h
}
@@ -327,7 +328,7 @@ fn rectangle_side_and_fixed_origin_line_dimensions_preserve_other_constraints()
h.app.run("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[20,10]})).unwrap();
h.call("ui.view", json!({"view":"top"}));
h.app.cam.distance = 80.;
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(10., 5., 0.);
+ h.app.cam.target = solidcore_record::Vec3::new(10., 5., 0.);
h.settle();
let baseline = h.app.session.doc.to_json();
let undo = h.app.session.undo.len();
@@ -346,7 +347,7 @@ fn rectangle_side_and_fixed_origin_line_dimensions_preserve_other_constraints()
#[test]
fn pending_second_nested_plane_uses_world_picks_but_one_local_dimension() {
- use solidcraft_engine::geom::Vec2;
+ use solidcore_record::Vec2;
crate::dim_view::cancel();
let mut h = Harness::new();
let parent = h.app.run("component.create", json!({"name":"Assembly"})).unwrap();
@@ -438,7 +439,7 @@ fn dimension_to_fillet_virtual_sharp_keeps_the_arc_and_fixed_origin() {
let corner = fillet["virtual_corners"][0].as_str().unwrap().to_string();
h.call("ui.view", json!({"view":"top"}));
h.app.cam.distance = 90.;
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(5., 10., 0.);
+ h.app.cam.target = solidcore_record::Vec3::new(5., 10., 0.);
h.settle();
let baseline = h.app.session.doc.to_json();
let undo = h.app.session.undo.len();
@@ -467,7 +468,7 @@ fn draft_annotation_does_not_move_committed_dimension_hitboxes() {
let width = h.app.run("sketch.dimension", json!({"entities":["l3"],"value":20})).unwrap()["param"].as_str().unwrap().to_string();
h.call("ui.view", json!({"view":"top"}));
h.app.cam.distance = 80.;
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(10., 5., 0.);
+ h.app.cam.target = solidcore_record::Vec3::new(10., 5., 0.);
h.settle();
let at = crate::dim_view::text_at(&width).unwrap();
let drawn = crate::dim_view::drawn();
@@ -522,7 +523,7 @@ fn inch_dimension_entry_survives_unit_changes_undo_and_reopen() {
#[test]
fn placing_a_two_point_dimension_picks_horizontal_vertical_or_aligned() {
// What each placement fixes at 10 mm: the X span, the Y span, or the length.
- let spans = |a: solidcraft_engine::geom::Vec2, b: solidcraft_engine::geom::Vec2| [(b.x - a.x).abs(), (b.y - a.y).abs(), a.dist(b)];
+ let spans = |a: solidcore_record::Vec2, b: solidcore_record::Vec2| [(b.x - a.x).abs(), (b.y - a.y).abs(), a.dist(b)];
for (at, measured) in [([6., 25.], 0), ([2., 20.], 0), ([-10., 1.], 1), ([15., 4.], 1), ([10., 4.], 2), ([-6., 22.], 2)] {
let mut h = line([12., 16.]);
place(&mut h, &[[0., 0.], [12., 16.]], at);
@@ -662,7 +663,7 @@ fn sketch_with(setup: &[(&str, serde_json::Value)], centre: [f64; 2]) -> Harness
}
h.call("ui.view", json!({"view":"top"}));
h.app.cam.distance = 80.0;
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(centre[0], centre[1], 0.0);
+ h.app.cam.target = solidcore_record::Vec3::new(centre[0], centre[1], 0.0);
h.settle();
h.step(&json!({"start":"sketch.dimension"})).unwrap();
h
@@ -905,7 +906,7 @@ fn type_first_switching_between_aligned_horizontal_and_vertical_keeps_the_picked
let a = sk.point(sk.resolve_point("l1.start").unwrap()).unwrap();
let b = sk.point(sk.resolve_point("l1.end").unwrap()).unwrap();
assert!(
- a.dist(solidcraft_engine::geom::Vec2::new(0., 0.)) < 1e-6 && b.dist(solidcraft_engine::geom::Vec2::new(end[0], end[1])) < 1e-6,
+ a.dist(solidcore_record::Vec2::new(0., 0.)) < 1e-6 && b.dist(solidcore_record::Vec2::new(end[0], end[1])) < 1e-6,
"{ctx}: the preview moved the points to {a:?} {b:?}"
);
}
@@ -916,7 +917,7 @@ fn type_first_switching_between_aligned_horizontal_and_vertical_keeps_the_picked
let a = sk.point(sk.resolve_point("l1.start").unwrap()).unwrap();
let b = sk.point(sk.resolve_point("l1.end").unwrap()).unwrap();
assert!(
- a.dist(solidcraft_engine::geom::Vec2::new(0., 0.)) < 1e-6 && b.dist(solidcraft_engine::geom::Vec2::new(end[0], end[1])) < 1e-6,
+ a.dist(solidcore_record::Vec2::new(0., 0.)) < 1e-6 && b.dist(solidcore_record::Vec2::new(end[0], end[1])) < 1e-6,
"{picks:?} at {commit_at:?}: {a:?} {b:?}"
);
let new = added(&h, 0);
@@ -977,7 +978,7 @@ fn midpoint_then_edge_creates_a_distance_in_one_undo_step() {
/// The short sketch edge overlaps a face's automatically projected boundary.
fn midpoint_face_sketch() -> Harness {
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
crate::dim_view::cancel();
let mut h = Harness::new();
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
@@ -1228,7 +1229,7 @@ fn shown_dimensions() -> (Harness, u64) {
h.app.session.visibility.shown_dimensions.push(sketch);
h.call("ui.view", json!({"view":"top"}));
h.app.cam.distance = 80.0;
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(10.0, 5.0, 0.0);
+ h.app.cam.target = solidcore_record::Vec3::new(10.0, 5.0, 0.0);
h.settle();
(h, sketch)
}
diff --git a/crates/ui-egui/src/display_lod.rs b/crates/ui-egui/src/display_lod.rs
index 4c1dd014c6..17a2f3f67e 100644
--- a/crates/ui-egui/src/display_lod.rs
+++ b/crates/ui-egui/src/display_lod.rs
@@ -15,13 +15,15 @@
//! drawn triangles (#1064). Display only: the reference mesh the model reads, exports and the
//! B-rep never change.
+use solidcraft_engine::geom::prelude::*;
use std::collections::HashMap;
use std::sync::Arc;
+use solidcore_record::Vec3;
use solidcraft_engine::doc::ModelBody;
use solidcraft_engine::doc::display_quality::{DisplayQuality, MAX_REFINE, refinement_for};
use solidcraft_engine::geom::tess::TessPlan;
-use solidcraft_engine::geom::{Aabb3, Mesh, Vec3};
+use solidcraft_engine::geom::{Aabb3, Mesh};
/// Most triangles all refined bodies may draw together (on top of the rest of the model).
pub(crate) const TRIANGLE_BUDGET: usize = 6_000_000;
diff --git a/crates/ui-egui/src/drag_extrude.rs b/crates/ui-egui/src/drag_extrude.rs
index 7abb1dabcb..6b3d52f8c6 100644
--- a/crates/ui-egui/src/drag_extrude.rs
+++ b/crates/ui-egui/src/drag_extrude.rs
@@ -7,8 +7,9 @@
//! way stays a box selection.
use egui::Pos2;
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::dialogs::{Kind, planar_face};
diff --git a/crates/ui-egui/src/drag_snap.rs b/crates/ui-egui/src/drag_snap.rs
index dc9dac11de..e65fbdc7d7 100644
--- a/crates/ui-egui/src/drag_snap.rs
+++ b/crates/ui-egui/src/drag_snap.rs
@@ -4,11 +4,12 @@
//! a midpoint or a curve adds the matching constraint; lining up adds none. The suppress-snap
//! chord is configurable (default Ctrl/Cmd or Alt/Option; see `prefs::suppress_sketch_snap`).
+use solidcraft_engine::geom::prelude::*;
use std::cell::{Cell, RefCell};
use egui::{Align2, FontId, Stroke};
use serde_json::{Value, json};
-use solidcraft_engine::geom::Vec2;
+use solidcore_record::Vec2;
use solidcraft_engine::sketch::{ConstraintKind, CurveKind, Sketch};
use crate::SolveApp;
diff --git a/crates/ui-egui/src/edit_clipboard.rs b/crates/ui-egui/src/edit_clipboard.rs
index 444517aa72..680d4ea6c8 100644
--- a/crates/ui-egui/src/edit_clipboard.rs
+++ b/crates/ui-egui/src/edit_clipboard.rs
@@ -31,6 +31,7 @@
use egui::Pos2;
use serde_json::{Value, json};
use solidcraft_engine::Sel;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
@@ -590,7 +591,8 @@ pub fn paste_into(app: &mut SolveApp, at: Option<Pos2>, new_copy: bool, into: Op
/// Place the copied design's origin on the pointed solid surface, otherwise its parent's
/// XY plane. With no viewport point or a parallel/behind-camera ray, use the parent origin.
fn paste_placement(app: &SolveApp, at: Option<Pos2>) -> (Vec<u64>, [f64; 3]) {
- use solidcraft_engine::{doc, geom::Vec3};
+ use solidcore_record::Vec3;
+ use solidcraft_engine::doc;
let path = app.session.active_occurrence_path.clone().unwrap_or_else(|| app.session.doc.first_path(app.session.active_component));
let frame = app.session.occurrence_placement(&path).map(|p| p.world).unwrap_or(doc::IDENTITY);
let origin = doc::apply_point(&frame, Vec3::ZERO);
diff --git a/crates/ui-egui/src/edit_clipboard_tests.rs b/crates/ui-egui/src/edit_clipboard_tests.rs
index 0f6f203c7b..e8202c6acb 100644
--- a/crates/ui-egui/src/edit_clipboard_tests.rs
+++ b/crates/ui-egui/src/edit_clipboard_tests.rs
@@ -1,8 +1,9 @@
//! Copy and Paste from the keyboard and the context menu (#1480).
use serde_json::{Value, json};
+use solidcore_record::Vec2;
use solidcraft_engine::Sel;
-use solidcraft_engine::geom::Vec2;
+use solidcraft_engine::geom::prelude::*;
use crate::scenario::Harness;
@@ -368,7 +369,7 @@ fn contribution_occurrence_move_panel_belongs_to_its_document() {
#[test]
fn contribution_linked_paste_uses_the_pointer_and_pending_numeric_move() {
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
let file = ContributionPart::new();
let mut h = crate::scenario::Harness::new();
h.app = contribution_saved_part(&file);
@@ -411,7 +412,8 @@ fn contribution_linked_paste_uses_the_pointer_and_pending_numeric_move() {
#[test]
fn contribution_paste_pointer_uses_parent_coordinates_and_safe_fallbacks() {
- use solidcraft_engine::{doc, geom::Vec3};
+ use solidcore_record::Vec3;
+ use solidcraft_engine::doc;
let mut h = crate::scenario::Harness::new();
let parent = h.app.run("component.create", json!({"name":"Parent","grounded":false})).unwrap();
h.app
diff --git a/crates/ui-egui/src/extrude_auto_to_object_tests.rs b/crates/ui-egui/src/extrude_auto_to_object_tests.rs
index 635e0dfff0..5a637ece45 100644
--- a/crates/ui-egui/src/extrude_auto_to_object_tests.rs
+++ b/crates/ui-egui/src/extrude_auto_to_object_tests.rs
@@ -1,8 +1,8 @@
//! Extrude's automatic To Object: with profiles picked, a pick off their plane is the object to
//! extrude to, and the extent turns to To Object without the Extent Type choice.
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
-use solidcraft_engine::geom::Vec3;
use crate::dialogs::{Dialog, Kind, apply_commands, face_sel};
use crate::scenario::Harness;
diff --git a/crates/ui-egui/src/extrude_preview.rs b/crates/ui-egui/src/extrude_preview.rs
index 481a9f9e05..74aa22bab1 100644
--- a/crates/ui-egui/src/extrude_preview.rs
+++ b/crates/ui-egui/src/extrude_preview.rs
@@ -1,13 +1,11 @@
//! Straight extrusion feedback from existing display triangles, without a scratch design.
+use solidcraft_engine::geom::prelude::*;
use std::collections::HashMap;
use std::sync::Arc;
use serde_json::Value;
-use solidcraft_engine::{
- Sel,
- doc::Document,
- geom::{Aabb3, Seg2, Vec3},
-};
+use solidcore_record::{Seg2, Vec3};
+use solidcraft_engine::{Sel, doc::Document, geom::Aabb3};
use crate::{
SolveApp,
diff --git a/crates/ui-egui/src/file_load.rs b/crates/ui-egui/src/file_load.rs
index 896e4def4b..98f5889a69 100644
--- a/crates/ui-egui/src/file_load.rs
+++ b/crates/ui-egui/src/file_load.rs
@@ -12,6 +12,7 @@
//! linked design being read and its rebuild's progress.
use crate::ui_kit::{Container, Surface};
+use solidcraft_engine::geom::prelude::*;
use std::collections::VecDeque;
use std::sync::{
Arc,
@@ -845,8 +846,9 @@ fn partial_picture(world: &solidcraft_engine::doc::ModelState, stop: &dyn Fn() -
#[cfg(not(target_arch = "wasm32"))]
fn saved_picture(preview: solidcraft_engine::io::DesignPreview) -> Option<egui::ColorImage> {
+ use solidcore_record::Vec3;
use solidcraft_engine::{
- geom::{Aabb3, Mesh, Vec3},
+ geom::{Aabb3, Mesh},
render::{Camera, Rgb, Scene, SceneMesh, StandardView},
};
let mut scene = Scene::default();
@@ -1452,11 +1454,11 @@ mod tests {
fn drawing_insert_and_drop_reuse_the_active_sketch_or_create_xy() {
let mut h = crate::scenario::Harness::new();
let dxf = solidcraft_engine::io::write_dxf(&[
- solidcraft_engine::io::Geom2::Line(solidcraft_engine::geom::Vec2::ZERO, solidcraft_engine::geom::Vec2::new(10.0, 0.0)),
+ solidcraft_engine::io::Geom2::Line(solidcore_record::Vec2::ZERO, solidcore_record::Vec2::new(10.0, 0.0)),
solidcraft_engine::io::Geom2::Arc {
- c: solidcraft_engine::geom::Vec2::ZERO,
- a: solidcraft_engine::geom::Vec2::new(5.0, 0.0),
- b: solidcraft_engine::geom::Vec2::new(0.0, 5.0),
+ c: solidcore_record::Vec2::ZERO,
+ a: solidcore_record::Vec2::new(5.0, 0.0),
+ b: solidcore_record::Vec2::new(0.0, 5.0),
},
]);
let svg = r#"<svg xmlns="http://www.w3.org/2000/svg"><path d="M0 0 L10 0 L10 10"/></svg>"#;
@@ -1478,7 +1480,7 @@ mod tests {
wait(&mut h);
assert_eq!(h.app.session.doc.features.len(), 2, "{:?}", h.app.status);
let id = h.app.session.active_sketch.unwrap();
- assert_eq!(h.app.session.model.state().sketch(id).unwrap().plane, solidcraft_engine::geom::Plane::XY);
+ assert_eq!(h.app.session.model.state().sketch(id).unwrap().plane, solidcore_record::Plane::XY);
assert_eq!(h.app.session.doc.sketch(id).unwrap().curves.len(), 2);
h.app.cam.set_view(solidcraft_engine::render::StandardView::Top);
h.app.fit_view();
diff --git a/crates/ui-egui/src/file_load_ui_tests.rs b/crates/ui-egui/src/file_load_ui_tests.rs
index 7973a20ac3..7b6f5e93cc 100644
--- a/crates/ui-egui/src/file_load_ui_tests.rs
+++ b/crates/ui-egui/src/file_load_ui_tests.rs
@@ -4,6 +4,7 @@
use egui::{Event, PointerButton, Pos2, RawInput, Rect, ViewportCommand, ViewportId, pos2, vec2};
use serde_json::json;
use solidcraft_engine::Session;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
@@ -725,7 +726,7 @@ fn an_opened_design_comes_up_at_the_home_view() {
// The view the design before it was left at: straight down, zoomed right in.
w.app.cam.set_view(StandardView::Top);
w.app.cam.distance = 12.0;
- w.app.cam.target = solidcraft_engine::geom::Vec3::new(50.0, -70.0, 3.0);
+ w.app.cam.target = solidcore_record::Vec3::new(50.0, -70.0, 3.0);
// Opened from the Home screen, which covers the viewport while the design goes in: the
// viewport is not drawn, so the layout a fit would be framed into is the one left over from
// what was there before, which cannot frame anything.
diff --git a/crates/ui-egui/src/file_picker.rs b/crates/ui-egui/src/file_picker.rs
index 3ce98a589f..8faebac430 100644
--- a/crates/ui-egui/src/file_picker.rs
+++ b/crates/ui-egui/src/file_picker.rs
@@ -139,6 +139,7 @@ pub(crate) fn tick(app: &mut SolveApp, ctx: &egui::Context) {
#[cfg(test)]
mod tests {
use super::*;
+ use solidcraft_engine::geom::prelude::*;
use std::cell::{Cell, RefCell};
use std::rc::Rc;
diff --git a/crates/ui-egui/src/fillet_spline_handle_tests.rs b/crates/ui-egui/src/fillet_spline_handle_tests.rs
index 9a0f7eb4ff..29f56f51ae 100644
--- a/crates/ui-egui/src/fillet_spline_handle_tests.rs
+++ b/crates/ui-egui/src/fillet_spline_handle_tests.rs
@@ -1,6 +1,7 @@
use crate::scenario::Harness;
use serde_json::{Value, json};
use solidcraft_engine::doc::{FeatureKind, FilletStyle, kernel};
+use solidcraft_engine::geom::prelude::*;
/// A plate whose top narrows from 20 to 2 mm along 40 mm, against a wall behind its slanted
/// side from z = -15 to 30 (so a blend of its front edges has no cliff to run over and is cut
@@ -46,12 +47,11 @@ fn dragging_a_taper_handle_makes_the_fillet_a_spline() {
let tapered = volume(&h);
open(&mut h);
let (_, taper) = h.app.preview.tapered.first().cloned().expect("the preview's taper");
- let law =
- if taper.start.dist(solidcraft_engine::geom::Vec3::new(0.0, 0.0, 15.0)) < 1e-9 { taper.spline.clone() } else { taper.spline.reversed() };
+ let law = if taper.start.dist(solidcore_record::Vec3::new(0.0, 0.0, 15.0)) < 1e-9 { taper.spline.clone() } else { taper.spline.reversed() };
// A handle per control radius, each that radius into the body from the edge.
- let into = solidcraft_engine::geom::Vec3::new(0.0, 1.0, -1.0) * std::f64::consts::FRAC_1_SQRT_2;
+ let into = solidcore_record::Vec3::new(0.0, 1.0, -1.0) * std::f64::consts::FRAC_1_SQRT_2;
let at = |u: f64, r: f64| {
- let p = solidcraft_engine::geom::Vec3::new(40.0 * u, 0.0, 15.0) + into * r;
+ let p = solidcore_record::Vec3::new(40.0 * u, 0.0, 15.0) + into * r;
json!([p.x, p.y, p.z])
};
let g = law.greville();
@@ -125,7 +125,7 @@ fn dialog_spline(h: &Harness) -> kernel::RadiusSpline {
/// A point `r` into the box from the top edge at y (0 or 30), x = 40 u.
fn into_box(u: f64, y: f64, r: f64) -> Value {
let side = if y == 0.0 { 1.0 } else { -1.0 };
- let p = solidcraft_engine::geom::Vec3::new(40.0 * u, y + side * r * std::f64::consts::FRAC_1_SQRT_2, 20.0 - r * std::f64::consts::FRAC_1_SQRT_2);
+ let p = solidcore_record::Vec3::new(40.0 * u, y + side * r * std::f64::consts::FRAC_1_SQRT_2, 20.0 - r * std::f64::consts::FRAC_1_SQRT_2);
json!({"world": [p.x, p.y, p.z]})
}
diff --git a/crates/ui-egui/src/gizmo.rs b/crates/ui-egui/src/gizmo.rs
index 33e219765d..ce44a309b9 100644
--- a/crates/ui-egui/src/gizmo.rs
+++ b/crates/ui-egui/src/gizmo.rs
@@ -4,10 +4,12 @@
//! round steps at the current zoom, angles to 5°; hold Alt or Ctrl for a free drag), so the caller
//! adds it to the values it had when the drag started.
+use solidcraft_engine::geom::prelude::*;
use std::cell::RefCell;
use egui::{Color32, Pos2, Rect, Sense, Shape, Stroke, vec2};
-use solidcraft_engine::geom::{Ring, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_engine::geom::Ring;
use crate::theme::Tokens;
use crate::viewport::{Proj, projected_polygon};
diff --git a/crates/ui-egui/src/gpu.rs b/crates/ui-egui/src/gpu.rs
index edb5fe718c..4b8f4ab2e3 100644
--- a/crates/ui-egui/src/gpu.rs
+++ b/crates/ui-egui/src/gpu.rs
@@ -723,7 +723,7 @@ mod tests {
app.preferences.ambient_occlusion = false;
app.cpu_meshing = true;
app.cam.distance = 110.0;
- app.cam.target = solidcraft_engine::geom::Vec3::new(20.0, 15.0, 12.5);
+ app.cam.target = solidcore_record::Vec3::new(20.0, 15.0, 12.5);
let window = GpuTarget { format, depth: None, samples: 1, tess: false, oit: false };
let scene = GpuTarget { depth: Some(solidcraft_gpu::depth_format(&device, true)), ..window };
let view = Renderer::with_window_target(&device, scene, window, None);
diff --git a/crates/ui-egui/src/hole_direction_ui_tests.rs b/crates/ui-egui/src/hole_direction_ui_tests.rs
index f58e7c1385..85fd357c39 100644
--- a/crates/ui-egui/src/hole_direction_ui_tests.rs
+++ b/crates/ui-egui/src/hole_direction_ui_tests.rs
@@ -3,8 +3,9 @@
//! round face), and, at sketch points, into the part unless Flip is on.
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::doc::FeatureKind;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::scenario::Harness;
diff --git a/crates/ui-egui/src/hole_place.rs b/crates/ui-egui/src/hole_place.rs
index 2ccf63d01f..3fbb829638 100644
--- a/crates/ui-egui/src/hole_place.rs
+++ b/crates/ui-egui/src/hole_place.rs
@@ -12,14 +12,16 @@
//! centre that drags it across the model (snapping as a pick would) and takes it out when
//! clicked, and a pick elsewhere on a face that already has a hole moves the hole there.
+use solidcraft_engine::geom::prelude::*;
use std::cell::RefCell;
use std::sync::Arc;
use egui::{Pos2, vec2};
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::Session;
use solidcraft_engine::doc::expr::Kind as ValueKind;
-use solidcraft_engine::geom::{Aabb3, Mesh, Vec3};
+use solidcraft_engine::geom::{Aabb3, Mesh};
use crate::SolveApp;
use crate::dialogs::{Dialog, Kind};
@@ -351,7 +353,7 @@ fn marks(app: &SolveApp, painter: &egui::Painter, proj: &Proj) {
#[cfg(test)]
mod tests {
use super::*;
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
/// A square face (two triangles) at z = 5 with a round edge about (2, 3) on it.
fn mesh() -> Mesh {
diff --git a/crates/ui-egui/src/hole_place_ui_tests.rs b/crates/ui-egui/src/hole_place_ui_tests.rs
index d1c2c40fe2..de581d18b4 100644
--- a/crates/ui-egui/src/hole_place_ui_tests.rs
+++ b/crates/ui-egui/src/hole_place_ui_tests.rs
@@ -6,9 +6,10 @@
//! section of it.
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::doc::FeatureKind;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::dialogs::Kind;
use crate::scenario::{Harness, handle_at, rect_of};
diff --git a/crates/ui-egui/src/hole_placement_ui_tests.rs b/crates/ui-egui/src/hole_placement_ui_tests.rs
index 0a7a2118d5..be1020d302 100644
--- a/crates/ui-egui/src/hole_placement_ui_tests.rs
+++ b/crates/ui-egui/src/hole_placement_ui_tests.rs
@@ -6,9 +6,11 @@
//! looks the face up once for every point near the cursor.
use serde_json::{Value, json};
+use solidcore_record::{Vec2, Vec3};
use solidcraft_engine::Sel;
use solidcraft_engine::doc::FeatureKind;
-use solidcraft_engine::geom::{Aabb3, Vec2, Vec3};
+use solidcraft_engine::geom::Aabb3;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::sketch::{CurveKind, LinkKind, SPoint};
use crate::dialogs::Kind;
diff --git a/crates/ui-egui/src/hole_refs.rs b/crates/ui-egui/src/hole_refs.rs
index 86c5aa90fe..74c5e33d8f 100644
--- a/crates/ui-egui/src/hole_refs.rs
+++ b/crates/ui-egui/src/hole_refs.rs
@@ -11,10 +11,11 @@
use egui::{Color32, Pos2, Stroke, vec2};
use serde_json::{Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::doc::HoleReference;
use solidcraft_engine::doc::expr::Kind as ValueKind;
use solidcraft_engine::doc::hole_reference::{ReferenceFrame, on_reference_face, reference_frame};
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::{Sel, Session};
use crate::SolveApp;
diff --git a/crates/ui-egui/src/hole_refs_ui_tests.rs b/crates/ui-egui/src/hole_refs_ui_tests.rs
index 8e14971b00..f598f66266 100644
--- a/crates/ui-egui/src/hole_refs_ui_tests.rs
+++ b/crates/ui-egui/src/hole_refs_ui_tests.rs
@@ -5,9 +5,10 @@
//! A Cylinder standing on a picked face takes reference edges the same way (#6380).
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::doc::FeatureKind;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::dialogs::Kind;
use crate::scenario::Harness;
diff --git a/crates/ui-egui/src/inference.rs b/crates/ui-egui/src/inference.rs
index 7b86a4b685..9ed0a044bc 100644
--- a/crates/ui-egui/src/inference.rs
+++ b/crates/ui-egui/src/inference.rs
@@ -4,11 +4,12 @@
//! the centre of a circle or arc). A dashed guide and a label show it; placing the point adds
//! the matching constraint.
+use solidcraft_engine::geom::prelude::*;
use std::cell::RefCell;
use egui::Stroke;
use serde_json::json;
-use solidcraft_engine::geom::Vec2;
+use solidcore_record::Vec2;
use solidcraft_engine::sketch::{CurveKind, Sketch};
use crate::SolveApp;
@@ -332,7 +333,7 @@ impl Tracking {
/// Where the horizontal through one reference meets the vertical through the other, when
/// that point is within a few pixels of the cursor and is not either reference itself.
- pub(crate) fn meeting(&self, sk: &Sketch, plane: &solidcraft_engine::geom::Plane, proj: &Proj, cursor: egui::Pos2) -> Option<Vec2> {
+ pub(crate) fn meeting(&self, sk: &Sketch, plane: &solidcore_record::Plane, proj: &Proj, cursor: egui::Pos2) -> Option<Vec2> {
let a = self.anchor.as_ref().and_then(|r| Self::point_of(sk, r))?;
let b = self.previous.as_ref().and_then(|r| Self::point_of(sk, r))?;
if a.dist(b) < 1e-6 {
@@ -371,7 +372,7 @@ impl Tracking {
/// Follow the cursor: remember the reference under it and lay out the guides. With
/// `points`, sketch points are references too (a drawing tool waits for a point);
/// without, remembered points are let go.
- fn update(&mut self, sk: &Sketch, plane: &solidcraft_engine::geom::Plane, proj: &Proj, cursor: egui::Pos2, points: bool) {
+ fn update(&mut self, sk: &Sketch, plane: &solidcore_record::Plane, proj: &Proj, cursor: egui::Pos2, points: bool) {
self.guide = None;
self.remembered_guide = None;
if !points {
@@ -504,7 +505,7 @@ mod tests {
#[test]
fn tracking_has_pixel_tolerance_and_only_spans_reference_to_cursor() {
- use solidcraft_engine::geom::Plane;
+ use solidcore_record::Plane;
let mut app = SolveApp::new(Default::default(), Default::default());
app.cam.yaw = 0.0;
app.cam.pitch = std::f64::consts::FRAC_PI_2;
@@ -542,7 +543,7 @@ mod tests {
#[test]
fn end_points_corners_and_free_points_start_guides_only_while_drawing() {
- use solidcraft_engine::geom::Plane;
+ use solidcore_record::Plane;
let mut app = SolveApp::new(Default::default(), Default::default());
app.cam.yaw = 0.0;
app.cam.pitch = std::f64::consts::FRAC_PI_2;
@@ -598,7 +599,7 @@ mod tests {
#[test]
fn two_recent_references_meet_and_a_third_drops_the_oldest() {
- use solidcraft_engine::geom::Plane;
+ use solidcore_record::Plane;
let mut app = SolveApp::new(Default::default(), Default::default());
app.cam.yaw = 0.0;
app.cam.pitch = std::f64::consts::FRAC_PI_2;
diff --git a/crates/ui-egui/src/infinite_line_display_tests.rs b/crates/ui-egui/src/infinite_line_display_tests.rs
index b85f955f61..260fa59c1a 100644
--- a/crates/ui-egui/src/infinite_line_display_tests.rs
+++ b/crates/ui-egui/src/infinite_line_display_tests.rs
@@ -2,6 +2,7 @@
//! and the Sketch Palette's Infinite mode draws one.
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
use crate::scenario::Harness;
use crate::viewport::{Hit, pick, projection};
@@ -44,7 +45,7 @@ fn it_is_picked_far_beyond_its_two_points() {
let rect = h.app.viewport.rect.unwrap();
let proj = projection(&h.app, rect);
let ss_plane = h.app.session.world_state().unwrap().sketch(h.app.session.active_sketch.unwrap()).unwrap().plane;
- let far = proj.to_screen(ss_plane.to_world(solidcraft_engine::geom::Vec2::new(150.0, 0.0))).unwrap();
+ let far = proj.to_screen(ss_plane.to_world(solidcore_record::Vec2::new(150.0, 0.0))).unwrap();
assert!(rect.contains(far));
let hits = pick(&h.app, &proj, far);
assert!(hits.iter().any(|h| matches!(h, Hit::SketchCurve { id, .. } if id == "inf")), "{hits:?}");
diff --git a/crates/ui-egui/src/insert_handles.rs b/crates/ui-egui/src/insert_handles.rs
index ff3e7616f4..a941e6462f 100644
--- a/crates/ui-egui/src/insert_handles.rs
+++ b/crates/ui-egui/src/insert_handles.rs
@@ -4,7 +4,8 @@
//! the window shows.
use egui::{Pos2, Sense, Stroke, Vec2 as Screen, vec2};
-use solidcraft_engine::geom::{Plane, Vec2};
+use solidcore_record::{Plane, Vec2};
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::dialogs::Kind;
diff --git a/crates/ui-egui/src/issue_report.rs b/crates/ui-egui/src/issue_report.rs
index 69344ed8c4..77003a5fba 100644
--- a/crates/ui-egui/src/issue_report.rs
+++ b/crates/ui-egui/src/issue_report.rs
@@ -1749,7 +1749,7 @@ mod tests {
h.app.run("sketch.line", json!({"points":[[0,0],[20,0]]})).unwrap();
h.call("ui.view", json!({"view":"top"}));
h.app.cam.distance = 80.0;
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(10.0, 0.0, 0.0);
+ h.app.cam.target = solidcore_record::Vec3::new(10.0, 0.0, 0.0);
h.settle();
h.step(&json!({"start":"sketch.dimension"})).unwrap();
for point in [[0, 0, 0], [20, 0, 0], [10, 5, 0]] {
diff --git a/crates/ui-egui/src/joint_drag.rs b/crates/ui-egui/src/joint_drag.rs
index f7de2b4988..82e8318f8f 100644
--- a/crates/ui-egui/src/joint_drag.rs
+++ b/crates/ui-egui/src/joint_drag.rs
@@ -4,8 +4,9 @@
use egui::Pos2;
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::doc::{apply_point, joints, mat_inverse};
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::viewport::{Hit, Proj};
@@ -101,8 +102,9 @@ pub fn end(app: &mut SolveApp) {
#[cfg(test)]
mod tests {
use serde_json::{Value, json};
+ use solidcore_record::Vec3;
use solidcraft_engine::doc::{apply_point, joints};
- use solidcraft_engine::geom::Vec3;
+ use solidcraft_engine::geom::prelude::*;
use crate::scenario::Harness;
use crate::test_support::play;
diff --git a/crates/ui-egui/src/joint_handles.rs b/crates/ui-egui/src/joint_handles.rs
index 6c01978475..3d8e581712 100644
--- a/crates/ui-egui/src/joint_handles.rs
+++ b/crates/ui-egui/src/joint_handles.rs
@@ -1,5 +1,7 @@
//! Explicit assembly Move: only the selected part's allowed joint axes are shown. Distances
//! and angles are relative to the current drag, and each drag is one cancellable undo step.
+use solidcore_record::Vec3;
+use solidcraft_engine::geom::prelude::*;
use std::{
collections::{BTreeMap, BTreeSet},
sync::Arc,
@@ -10,7 +12,6 @@ use serde_json::json;
use solidcraft_engine::{
Sel,
doc::{Document, apply_point, joints, mat_inverse, mat_mul},
- geom::Vec3,
};
use crate::{
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 6beed8a9f7..cf021e91c7 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -596,7 +596,7 @@ pub struct SolveApp {
pub edit_in_place: edit_in_place::EditInPlace,
pub(crate) pending_feature_edit: Option<feature_edit::PendingFeatureEdit>,
/// The feature being reopened from a click and where, until its dialog opens (UI state only).
- edit_anchor_hint: Option<(u64, solidcraft_engine::geom::Vec3)>,
+ edit_anchor_hint: Option<(u64, solidcore_record::Vec3)>,
/// The open feature window's check of what its material does (#6901).
pub op_check: op_auto::OpCheck,
/// A command recomputing the history (the marker moved, undo) computing off the window
@@ -2074,7 +2074,7 @@ impl SolveApp {
/// [`Self::edit_feature`] opened from a click at `at` on what the feature made: the dialog's
/// arrow sits by that point (a fillet's or chamfer's edge nearest it).
- pub(crate) fn edit_feature_at(&mut self, id: u64, at: Option<solidcraft_engine::geom::Vec3>) {
+ pub(crate) fn edit_feature_at(&mut self, id: u64, at: Option<solidcore_record::Vec3>) {
use solidcraft_engine::doc::FeatureKind;
// A non-finite point (over the control channel) keeps the first edge.
self.edit_anchor_hint = at.filter(|p| p.is_finite()).map(|p| (id, p));
@@ -2513,7 +2513,7 @@ impl SolveApp {
pub fn fitted(&self, mut cam: Camera) -> Camera {
let b = viewport::view_bounds(self);
if b.is_empty() {
- cam.target = solidcraft_engine::geom::Vec3::ZERO;
+ cam.target = solidcore_record::Vec3::ZERO;
cam.distance = 150.0;
} else {
cam = self.fitted_bounds(cam, &b);
@@ -2551,7 +2551,7 @@ impl SolveApp {
let radius = (bounds.diagonal() * 0.5).max(0.5);
// A cube around the sphere, seen square-on from any axis, projects to the sphere's own
// square, so the layout fit of that cube is the sphere's.
- let offset = solidcraft_engine::geom::Vec3::new(radius, radius, radius);
+ let offset = solidcore_record::Vec3::new(radius, radius, radius);
let sphere = solidcraft_engine::geom::Aabb3 { min: centre - offset, max: centre + offset };
let mut probe = Camera::default();
probe.set_view(StandardView::Front);
diff --git a/crates/ui-egui/src/loft_rails_dialog_tests.rs b/crates/ui-egui/src/loft_rails_dialog_tests.rs
index 9c56c42312..5b3ef259fe 100644
--- a/crates/ui-egui/src/loft_rails_dialog_tests.rs
+++ b/crates/ui-egui/src/loft_rails_dialog_tests.rs
@@ -97,7 +97,7 @@ fn curves_that_share_an_id_are_picked_from_their_own_sketches() {
h.app.run("sketch.arc.three_point", json!({"start": [-10, 0], "end": [-10, -40], "through": [-15, -20], "id": "out"})).unwrap();
h.app.run("sketch.finish", json!({})).unwrap();
let left = h.app.session.doc.find_feature("L").unwrap().id;
- let hit = |sketch: u64, id: &str| Hit::SketchCurve { sketch, id: id.into(), straight: false, point: solidcraft_engine::geom::Vec3::ZERO };
+ let hit = |sketch: u64, id: &str| Hit::SketchCurve { sketch, id: id.into(), straight: false, point: solidcore_record::Vec3::ZERO };
h.step(&json!({"call":"ui.start","params":{"command":"solid.loft"}})).unwrap();
h.frames(3);
let d = h.app.dialog.as_mut().unwrap();
diff --git a/crates/ui-egui/src/look_at_tests.rs b/crates/ui-egui/src/look_at_tests.rs
index 9b493b2750..1f46c23bb1 100644
--- a/crates/ui-egui/src/look_at_tests.rs
+++ b/crates/ui-egui/src/look_at_tests.rs
@@ -2,7 +2,8 @@
//! origin, so a sketch drawn far from the origin (an imported part placed there) stays in view.
use serde_json::json;
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::scenario::Harness;
@@ -88,7 +89,7 @@ fn the_viewport_menu_looks_at_a_plane_under_the_cursor() {
let items = crate::context_menu::items(&h.app, &crate::context_menu::Target::Viewport);
let look = items.iter().find(|i| i.id == "ui.lookAt").cloned().expect("a plane's menu has Look At");
crate::context_menu::run_item(&mut h.app, &look, egui::Pos2::ZERO);
- let normal = solidcraft_engine::geom::Plane::named("XZ").unwrap().normal();
+ let normal = solidcore_record::Plane::named("XZ").unwrap().normal();
assert!((h.app.cam.back().cross(normal)).len() < 1e-6, "facing the plane along its normal: {:?}", h.app.cam.back());
}
diff --git a/crates/ui-egui/src/measurement_ui_tests.rs b/crates/ui-egui/src/measurement_ui_tests.rs
index 1f5a199ec7..cdcaadc853 100644
--- a/crates/ui-egui/src/measurement_ui_tests.rs
+++ b/crates/ui-egui/src/measurement_ui_tests.rs
@@ -3,6 +3,7 @@ use crate::dialogs::Kind;
use crate::scenario::Harness;
use serde_json::{Value, json};
use solidcraft_engine::Sel;
+use solidcraft_engine::geom::prelude::*;
fn result(h: &Harness) -> &Value {
match &h.app.dialog.as_ref().unwrap().kind {
@@ -33,7 +34,7 @@ fn measure_starts_with_selected_vertices_edges_and_faces() {
_ => {
let st = crate::open_meshing::session_world(&h.app.session);
let mesh = st.body("Box").unwrap().mesh();
- let point = solidcraft_engine::geom::Vec3::from(point);
+ let point = solidcore_record::Vec3::from(point);
let index = if kind == "edge" {
mesh.edges.iter().position(|e| e.windows(2).any(|w| point.dist_to_segment(w[0], w[1]) < 1e-6)).unwrap()
} else {
diff --git a/crates/ui-egui/src/menu_tests.rs b/crates/ui-egui/src/menu_tests.rs
index c8264980f9..0049a67204 100644
--- a/crates/ui-egui/src/menu_tests.rs
+++ b/crates/ui-egui/src/menu_tests.rs
@@ -3,8 +3,9 @@
use crate::test_support::sample_app;
use egui::pos2;
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Session;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::context_menu::{self, Item, Target};
use crate::viewport::Hit;
@@ -793,7 +794,7 @@ fn menu_delete_items_use_the_same_path() {
let plate = restored.body(&b).unwrap();
assert_eq!(plate.component, 0);
assert!((solidcraft_engine::kernel::measure(&plate.body).unwrap().volume - original_volume).abs() < 1e-6);
- assert!(plate.mesh().contains(solidcraft_engine::geom::Vec3::new(40.0, 35.0, 12.0)));
+ assert!(plate.mesh().contains(solidcore_record::Vec3::new(40.0, 35.0, 12.0)));
let mut reopened = solidcraft_engine::Session::new(solidcraft_engine::doc::Document::from_json(&app.session.doc.to_json()).unwrap());
reopened.refresh();
let reopened_state = reopened.world_state().unwrap();
@@ -1176,14 +1177,14 @@ fn occurrence_moves_turn_about_their_origin_then_move() {
let occ = app.session.doc.occurrences[0].id;
app.run("occurrence.ground", json!({"occurrence": occ, "grounded": false})).unwrap();
let mut m = crate::browser::OccMove::new(occ);
- m.pivot = Some(solidcraft_engine::geom::Vec3::new(5.0, 0.0, 0.0));
+ m.pivot = Some(solidcore_record::Vec3::new(5.0, 0.0, 0.0));
m.translate = [10.0, 0.0, 0.0];
m.angles = [0.0, 0.0, 90.0];
crate::browser::apply_occurrence_move(&mut app, &m);
let t = *app.session.pending_moves.get(&occ).unwrap();
// The pivot lands 10 mm along X; X turns into Y.
- let p = solidcraft_engine::doc::apply_point(&t, solidcraft_engine::geom::Vec3::new(5.0, 0.0, 0.0));
- let x = solidcraft_engine::doc::apply_vector(&t, solidcraft_engine::geom::Vec3::X);
+ let p = solidcraft_engine::doc::apply_point(&t, solidcore_record::Vec3::new(5.0, 0.0, 0.0));
+ let x = solidcraft_engine::doc::apply_vector(&t, solidcore_record::Vec3::X);
assert!((p.x - 15.0).abs() < 1e-9 && p.y.abs() < 1e-9, "{p:?}");
assert!((x.y - 1.0).abs() < 1e-9, "{x:?}");
// Changing the values again starts from where it was, not from the last move.
@@ -1288,7 +1289,7 @@ fn construction_plane_row_opens_its_menu() {
/// starts the sketch on that plane.
#[test]
fn right_click_on_a_plane_offers_a_sketch_on_it() {
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
let normal = |h: &crate::scenario::Harness| h.app.session.world_state().unwrap().sketches.first().map(|s| s.plane.normal()).unwrap_or_default();
for (plane, axis) in [("XY", Vec3::Z), ("XZ", Vec3::Y), ("YZ", Vec3::X)] {
let mut h = crate::scenario::Harness::new();
@@ -1390,7 +1391,7 @@ fn empty_space_leads_with_create_sketch() {
/// Create Sketch from a right-click on empty space sketches on the next plane clicked (#3032).
#[test]
fn create_sketch_from_empty_space_sketches_on_the_plane_clicked_next() {
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
h.settle();
@@ -1482,7 +1483,8 @@ fn typing_a_new_body_name_and_enter_renames_it() {
#[test]
fn contribution_picked_faces_open_their_own_feature_after_later_modifiers() {
- use solidcraft_engine::{Sel, geom::Vec3};
+ use solidcore_record::Vec3;
+ use solidcraft_engine::Sel;
for expected in [1, 2, 3] {
let mut app = SolveApp::new(Session::default(), Services::default());
app.run("solid.box", json!({"length":40,"width":30,"height":20,"body_name":"Plate"})).unwrap();
@@ -1526,8 +1528,7 @@ fn contribution_picked_faces_open_their_own_feature_after_later_modifiers() {
fn contribution_unresolvable_face_does_not_edit_the_body_creator() {
let mut app = SolveApp::new(Session::default(), Services::default());
app.run("solid.box", json!({"length":10,"width":10,"height":10,"body_name":"Plate"})).unwrap();
- app.session.selection =
- vec![solidcraft_engine::Sel::Face { body: "Plate".into(), index: usize::MAX, point: solidcraft_engine::geom::Vec3::ZERO }];
+ app.session.selection = vec![solidcraft_engine::Sel::Face { body: "Plate".into(), index: usize::MAX, point: solidcore_record::Vec3::ZERO }];
let items = context_menu::items(&app, &Target::Viewport);
assert!(!find(&items, "Edit Feature").enabled);
assert!(!find(&items, "Find in Timeline").enabled);
diff --git a/crates/ui-egui/src/mesh_lod_tests.rs b/crates/ui-egui/src/mesh_lod_tests.rs
index 319ac58515..7af2fb350d 100644
--- a/crates/ui-egui/src/mesh_lod_tests.rs
+++ b/crates/ui-egui/src/mesh_lod_tests.rs
@@ -1,8 +1,9 @@
use super::*;
+use solidcraft_engine::geom::prelude::*;
/// A sphere mesh of about `2 n²` triangles, each corner its own point.
fn sphere(n: u32) -> Arc<Mesh> {
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
let at = |i: u32, j: u32| {
let (t, p) = (std::f64::consts::PI * f64::from(i) / f64::from(n), std::f64::consts::TAU * f64::from(j) / f64::from(2 * n));
let (st, sp, cp) =
diff --git a/crates/ui-egui/src/move_preview.rs b/crates/ui-egui/src/move_preview.rs
index 5a18495af3..b2fd9b5e21 100644
--- a/crates/ui-egui/src/move_preview.rs
+++ b/crates/ui-egui/src/move_preview.rs
@@ -3,11 +3,13 @@
//! the move's transform. The preview from a scratch design evaluated the move and meshed the
//! bodies again for every change, so while the triad was dragged the part trailed the arrow by
//! one evaluation, longer for a larger part.
+use solidcraft_engine::geom::prelude::*;
use std::sync::Arc;
use serde_json::Value;
+use solidcore_record::Vec3;
use solidcraft_engine::doc::{Document, Mat, apply_point, apply_vector, expr::Kind, rigid};
-use solidcraft_engine::geom::{Aabb3, Mesh, Vec3};
+use solidcraft_engine::geom::{Aabb3, Mesh};
use crate::{
SolveApp,
diff --git a/crates/ui-egui/src/navigation.rs b/crates/ui-egui/src/navigation.rs
index 589ebc5988..6456b8fb75 100644
--- a/crates/ui-egui/src/navigation.rs
+++ b/crates/ui-egui/src/navigation.rs
@@ -12,7 +12,8 @@
use egui::{Pos2, Rect, pos2, vec2};
use serde_json::json;
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::render::Camera;
use crate::SolveApp;
@@ -1229,6 +1230,7 @@ fn orbit_camera(app: &mut SolveApp, dx: f64, dy: f64) {
#[cfg(test)]
mod tests {
+ use solidcraft_engine::geom::prelude::*;
fn web_wheel(unit: egui::MouseWheelUnit, delta: egui::Vec2, modifiers: egui::Modifiers) -> egui::Event {
egui::Event::MouseWheel { unit, delta, modifiers, phase: egui::TouchPhase::Move }
}
@@ -2532,6 +2534,7 @@ mod tests {
mod view_key_tests {
use crate::scenario::Harness;
use serde_json::json;
+ use solidcraft_engine::geom::prelude::*;
fn turned(h: &mut Harness, key: serde_json::Value) -> (f64, f64) {
let before = h.app.cam;
diff --git a/crates/ui-egui/src/occurrence_drag.rs b/crates/ui-egui/src/occurrence_drag.rs
index 80d19abb39..3fb73065d4 100644
--- a/crates/ui-egui/src/occurrence_drag.rs
+++ b/crates/ui-egui/src/occurrence_drag.rs
@@ -8,12 +8,13 @@
//! by joints to something fixed go to `joint_drag`; grounded parts and the active component's
//! own bodies are left to the selection box.
+use solidcraft_engine::geom::prelude::*;
use std::sync::Arc;
use egui::Pos2;
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::doc::{Document, apply_point, mat_inverse};
-use solidcraft_engine::geom::Vec3;
use crate::SolveApp;
use crate::viewport::{Hit, Proj};
diff --git a/crates/ui-egui/src/occurrence_drag_tests.rs b/crates/ui-egui/src/occurrence_drag_tests.rs
index f35df26627..9d46654bfd 100644
--- a/crates/ui-egui/src/occurrence_drag_tests.rs
+++ b/crates/ui-egui/src/occurrence_drag_tests.rs
@@ -1,6 +1,7 @@
//! A left-button drag on a free part repositions it (#2804).
use serde_json::{Value, json};
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::scenario::Harness;
diff --git a/crates/ui-egui/src/occurrence_gizmo_tests.rs b/crates/ui-egui/src/occurrence_gizmo_tests.rs
index 1e8a6b9881..82b1a7120a 100644
--- a/crates/ui-egui/src/occurrence_gizmo_tests.rs
+++ b/crates/ui-egui/src/occurrence_gizmo_tests.rs
@@ -4,7 +4,9 @@ use crate::{
scenario::Harness,
};
use serde_json::json;
-use solidcraft_engine::{Sel, doc, geom::Vec3};
+use solidcore_record::Vec3;
+use solidcraft_engine::geom::prelude::*;
+use solidcraft_engine::{Sel, doc};
#[test]
fn occurrence_gizmo_drag_matches_numeric_input_and_preserves_joints_capture_and_undo() {
diff --git a/crates/ui-egui/src/occurrence_ui_tests.rs b/crates/ui-egui/src/occurrence_ui_tests.rs
index 5c0859cc94..260fa243d9 100644
--- a/crates/ui-egui/src/occurrence_ui_tests.rs
+++ b/crates/ui-egui/src/occurrence_ui_tests.rs
@@ -233,20 +233,19 @@ fn occurrence_move_dialog_keeps_other_pending_moves_and_reuses_initial_baseline(
let movement = items.iter().find(|i| i.id == "ui.moveOccurrence").unwrap();
context_menu::run_item(&mut h.app, movement, egui::Pos2::ZERO);
let mut m = h.app.tree.occurrence_move.clone().unwrap();
- m.pivot =
- Some(solidcraft_engine::doc::apply_point(&h.app.session.occurrence_placement(&[second]).unwrap().world, solidcraft_engine::geom::Vec3::ZERO));
+ m.pivot = Some(solidcraft_engine::doc::apply_point(&h.app.session.occurrence_placement(&[second]).unwrap().world, solidcore_record::Vec3::ZERO));
m.translate = [10.0, 0.0, 0.0];
crate::browser::apply_occurrence_move(&mut h.app, &m);
let at = h.app.session.occurrence_placement(&[second]).unwrap();
- assert!((solidcraft_engine::doc::apply_point(&at.world, solidcraft_engine::geom::Vec3::ZERO).x - 65.0).abs() < 1e-8);
+ assert!((solidcraft_engine::doc::apply_point(&at.world, solidcore_record::Vec3::ZERO).x - 65.0).abs() < 1e-8);
m.translate = [3.0, 0.0, 0.0];
crate::browser::apply_occurrence_move(&mut h.app, &m);
let at = h.app.session.occurrence_placement(&[second]).unwrap();
- assert!((solidcraft_engine::doc::apply_point(&at.world, solidcraft_engine::geom::Vec3::ZERO).x - 58.0).abs() < 1e-8);
+ assert!((solidcraft_engine::doc::apply_point(&at.world, solidcore_record::Vec3::ZERO).x - 58.0).abs() < 1e-8);
assert_eq!(h.app.session.pending_moves[&first], first_pending);
crate::browser::revert_occurrence_dialog(&mut h.app, &m);
let restored = h.app.session.occurrence_placement(&[second]).unwrap();
- assert!((solidcraft_engine::doc::apply_point(&restored.world, solidcraft_engine::geom::Vec3::ZERO).x - 55.0).abs() < 1e-8);
+ assert!((solidcraft_engine::doc::apply_point(&restored.world, solidcore_record::Vec3::ZERO).x - 55.0).abs() < 1e-8);
assert_eq!(h.app.session.pending_moves[&first], first_pending);
h.app.run("component.revert_position", json!({"occurrences":[second]})).unwrap();
context_menu::run_item(&mut h.app, movement, egui::Pos2::ZERO);
diff --git a/crates/ui-egui/src/op_auto_tests.rs b/crates/ui-egui/src/op_auto_tests.rs
index 39f058d9c4..879d21f099 100644
--- a/crates/ui-egui/src/op_auto_tests.rs
+++ b/crates/ui-egui/src/op_auto_tests.rs
@@ -3,7 +3,7 @@
use std::time::{Duration, Instant};
use serde_json::json;
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
use super::{CUT, JOIN, NEW};
use crate::dialogs::Kind;
diff --git a/crates/ui-egui/src/pattern_arrow_tests.rs b/crates/ui-egui/src/pattern_arrow_tests.rs
index ab9dc84d30..e5f12c30e3 100644
--- a/crates/ui-egui/src/pattern_arrow_tests.rs
+++ b/crates/ui-egui/src/pattern_arrow_tests.rs
@@ -5,6 +5,7 @@ use crate::dialogs::Kind;
use crate::scenario::{Harness, handle_at};
use crate::sketch_modify_ui::Mod;
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
fn spacings(h: &Harness) -> (String, String) {
match h.app.dialog.as_ref().map(|d| &d.kind) {
@@ -104,8 +105,8 @@ fn a_pattern_of_features_puts_its_arrow_on_the_patterned_feature() {
assert!(matches!(d.inputs.first().and_then(|i| i.items.first()), Some(solidcraft_engine::Sel::Feature { .. })), "{:?}", d.inputs);
// The arrow starts at the middle of the boss and points along X, the pattern's direction.
let (base, dir) = crate::canvas::anchor(&h.app, d).expect("the pattern has an anchor");
- assert!(base.dist(solidcraft_engine::geom::Vec3::new(12.0, 10.0, 8.0)) < 1e-6, "{base:?}");
- assert!(dir.is_some_and(|v| v.dist(solidcraft_engine::geom::Vec3::new(1.0, 0.0, 0.0)) < 1e-9), "{dir:?}");
+ assert!(base.dist(solidcore_record::Vec3::new(12.0, 10.0, 8.0)) < 1e-6, "{base:?}");
+ assert!(dir.is_some_and(|v| v.dist(solidcore_record::Vec3::new(1.0, 0.0, 0.0)) < 1e-9), "{dir:?}");
let Some(tip) = handle_at("arrow") else { panic!("no arrow on a pattern of features") };
let from = h.call("ui.worldToScreen", json!({"points": [[12, 10, 8], [32, 10, 8]]}))["result"].clone();
let at = |i: usize| egui::pos2(from[i][0].as_f64().unwrap() as f32, from[i][1].as_f64().unwrap() as f32);
diff --git a/crates/ui-egui/src/pick_index.rs b/crates/ui-egui/src/pick_index.rs
index 859f97de68..a5007e0ecb 100644
--- a/crates/ui-egui/src/pick_index.rs
+++ b/crates/ui-egui/src/pick_index.rs
@@ -6,11 +6,13 @@
//! modelled thread, #3745), so it is made on a worker thread, and picks scan the mesh until it
//! is there: a scan takes a few milliseconds, the index a frame never waits for.
+use solidcraft_engine::geom::prelude::*;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use egui::{Pos2, vec2};
-use solidcraft_engine::geom::{Mesh, MeshIndex, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_engine::geom::{Mesh, MeshIndex};
use crate::viewport::Proj;
diff --git a/crates/ui-egui/src/pick_index_tests.rs b/crates/ui-egui/src/pick_index_tests.rs
index 91906d812a..5cc74e3bf8 100644
--- a/crates/ui-egui/src/pick_index_tests.rs
+++ b/crates/ui-egui/src/pick_index_tests.rs
@@ -27,7 +27,7 @@ fn indexed_picks_match_the_full_scan() {
app.ui.perspective = perspective;
app.cam.yaw = yaw;
app.cam.pitch = pitch;
- app.cam.target = solidcraft_engine::geom::Vec3::new(20.0, 15.0, 12.0);
+ app.cam.target = solidcore_record::Vec3::new(20.0, 15.0, 12.0);
app.cam.distance = 110.0;
let proj = projection(&app, rect);
for j in 0..48 {
@@ -54,9 +54,9 @@ fn indexed_picks_match_the_full_scan() {
fn indexes_follow_the_model_state() {
let mut app = assembly();
let rect = Rect::from_min_size(pos2(0.0, 0.0), vec2(640.0, 480.0));
- app.cam.target = solidcraft_engine::geom::Vec3::new(20.0, 15.0, 12.0);
+ app.cam.target = solidcore_record::Vec3::new(20.0, 15.0, 12.0);
let proj = projection(&app, rect);
- let centre = proj.to_screen(solidcraft_engine::geom::Vec3::new(20.0, 15.0, 10.0)).unwrap();
+ let centre = proj.to_screen(solidcore_record::Vec3::new(20.0, 15.0, 10.0)).unwrap();
pick(&app, &proj, centre);
assert!(app.viewport.pick_index.len() >= 1);
app.session.execute("solid.box", &json!({"length": 5, "width": 5, "height": 5, "corner": [-20, -20, 0], "operation": "new_body"})).unwrap();
diff --git a/crates/ui-egui/src/place_gizmo.rs b/crates/ui-egui/src/place_gizmo.rs
index d7ad44e736..61a71d99bd 100644
--- a/crates/ui-egui/src/place_gizmo.rs
+++ b/crates/ui-egui/src/place_gizmo.rs
@@ -28,8 +28,9 @@ use egui::{Pos2, vec2};
use look::{
CrossStyle, DIM, DIM_S, MARKER_ACTIVE, MARKER_HOT, RING_ACTIVE, RING_OPEN, RING_PX, RingStyle, angle_label, compass, crosshair, footprint, ring,
};
+use solidcore_record::Vec3;
use solidcraft_engine::doc::expr::Kind as ValueKind;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::dialogs::Dialog;
diff --git a/crates/ui-egui/src/place_gizmo/boss.rs b/crates/ui-egui/src/place_gizmo/boss.rs
index 078d1a99b7..9356307610 100644
--- a/crates/ui-egui/src/place_gizmo/boss.rs
+++ b/crates/ui-egui/src/place_gizmo/boss.rs
@@ -1,7 +1,7 @@
//! Boss: the marker moves the boss across the model and snaps to sketch points, so a screw boss
//! lands on the centre of a circle drawn for it. A boss is round: no ring.
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
use super::{Spec, circle, len};
use crate::SolveApp;
diff --git a/crates/ui-egui/src/place_gizmo/boss_tests.rs b/crates/ui-egui/src/place_gizmo/boss_tests.rs
index c93cb016d9..273ce93997 100644
--- a/crates/ui-egui/src/place_gizmo/boss_tests.rs
+++ b/crates/ui-egui/src/place_gizmo/boss_tests.rs
@@ -2,9 +2,10 @@
//! and moves an existing one from Edit Feature.
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::doc::FeatureKind;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::scenario::Harness;
diff --git a/crates/ui-egui/src/place_gizmo/rest.rs b/crates/ui-egui/src/place_gizmo/rest.rs
index 5a811f1d26..78d29cebe4 100644
--- a/crates/ui-egui/src/place_gizmo/rest.rs
+++ b/crates/ui-egui/src/place_gizmo/rest.rs
@@ -1,7 +1,7 @@
//! Rest: the marker moves the pad, the ring turns a rectangular one in 5° steps, pulled onto the
//! face's compass points when near one (Alt or Ctrl held: free), kept as the command's `along`.
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
use super::{Spec, Turn, angle_of, circle, dir_at, len, pt, pulled, rect, vec3_of};
use crate::SolveApp;
diff --git a/crates/ui-egui/src/place_gizmo/rest_tests.rs b/crates/ui-egui/src/place_gizmo/rest_tests.rs
index 0e036f6520..0c59744761 100644
--- a/crates/ui-egui/src/place_gizmo/rest_tests.rs
+++ b/crates/ui-egui/src/place_gizmo/rest_tests.rs
@@ -2,9 +2,10 @@
//! a sketch point as a click would; the grip turns a rectangular pad, also from Edit Feature.
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::doc::FeatureKind;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::scenario::Harness;
diff --git a/crates/ui-egui/src/place_gizmo/snap_fit.rs b/crates/ui-egui/src/place_gizmo/snap_fit.rs
index 9e3419ba07..5a37e19807 100644
--- a/crates/ui-egui/src/place_gizmo/snap_fit.rs
+++ b/crates/ui-egui/src/place_gizmo/snap_fit.rs
@@ -2,7 +2,7 @@
//! sketch says); the ring's grip points the catch, in the four directions the Catch Direction
//! combo offers for the face, so the ring and the combo always agree.
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
use super::{Spec, Turn, angle_of, len, rect};
use crate::SolveApp;
diff --git a/crates/ui-egui/src/place_gizmo/snap_fit_tests.rs b/crates/ui-egui/src/place_gizmo/snap_fit_tests.rs
index 4dc7de873c..59ae6840d3 100644
--- a/crates/ui-egui/src/place_gizmo/snap_fit_tests.rs
+++ b/crates/ui-egui/src/place_gizmo/snap_fit_tests.rs
@@ -2,9 +2,10 @@
//! point (#3423), the grip points the catch and the Catch Direction combo follows.
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::doc::FeatureKind;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::dialogs::Kind;
use crate::dialogs_plastic::{Pl, hook_dirs};
diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs
index 78dcca61a0..82439bcee9 100644
--- a/crates/ui-egui/src/prefs.rs
+++ b/crates/ui-egui/src/prefs.rs
@@ -1,13 +1,14 @@
//! Grouped preferences composed with the shared UI kit. Changes apply immediately; Cancel
//! restores the opening snapshot, Apply keeps editing, and Defaults affects the current page.
+use solidcraft_engine::geom::prelude::*;
use std::collections::BTreeMap;
use egui::{Modifiers, Pos2};
use serde::{Deserialize, Serialize};
use serde_json::json;
+use solidcore_record::Vec3;
pub use solidcraft_engine::doc::display_units::{format_length, length_number, length_precision, unit_scale};
-use solidcraft_engine::geom::Vec3;
use solidcraft_engine::render::Camera;
/// The key the apps keep the preferences under in eframe's storage.
@@ -9698,9 +9699,9 @@ mod tests {
let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
app.preferences.orbit_around = OrbitAround::Cursor;
- app.cam.target = solidcraft_engine::geom::Vec3::new(5.0, -3.0, 2.0);
+ app.cam.target = solidcore_record::Vec3::new(5.0, -3.0, 2.0);
orbit(&mut app, rect, 40.0, 25.0, Some(corner));
- assert_eq!(app.viewport.orbit_pivot, Some(solidcraft_engine::geom::Vec3::new(5.0, -3.0, 2.0)));
+ assert_eq!(app.viewport.orbit_pivot, Some(solidcore_record::Vec3::new(5.0, -3.0, 2.0)));
}
/// The Y up preference turns the view: the camera's up axis follows it, startup included.
diff --git a/crates/ui-egui/src/preselect_tests.rs b/crates/ui-egui/src/preselect_tests.rs
index 660c834e70..c64f9d29a0 100644
--- a/crates/ui-egui/src/preselect_tests.rs
+++ b/crates/ui-egui/src/preselect_tests.rs
@@ -3,8 +3,9 @@
use crate::test_support::app_with_script as app_with;
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::doc::expr::Kind as ValueKind;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::{Sel, Session};
#[test]
diff --git a/crates/ui-egui/src/preview.rs b/crates/ui-egui/src/preview.rs
index d1f9ea1331..6ee7f0078e 100644
--- a/crates/ui-egui/src/preview.rs
+++ b/crates/ui-egui/src/preview.rs
@@ -11,15 +11,17 @@
//! is all its preview builds: its boolean, which can take seconds (a text joined onto a part),
//! runs once, on OK, and an error it finds shows then, the dialog staying open.
+use solidcraft_engine::geom::prelude::*;
use std::hash::{Hash, Hasher};
use std::sync::Arc;
use std::sync::mpsc::{Receiver, TryRecvError};
use serde_json::Value;
+use solidcore_record::Vec3;
use solidcraft_engine::Session;
use solidcraft_engine::doc::ModelState;
use solidcraft_engine::doc::progress::Progress;
-use solidcraft_engine::geom::{Aabb3, Mesh, Ring, Vec3};
+use solidcraft_engine::geom::{Aabb3, Mesh, Ring};
use solidcraft_engine::kernel::history::Change;
use crate::SolveApp;
diff --git a/crates/ui-egui/src/preview_placement_tests.rs b/crates/ui-egui/src/preview_placement_tests.rs
index 6d0cc98b86..2700abe08c 100644
--- a/crates/ui-egui/src/preview_placement_tests.rs
+++ b/crates/ui-egui/src/preview_placement_tests.rs
@@ -8,9 +8,10 @@
//! the preview draws.
use serde_json::{Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::Session;
use solidcraft_engine::doc::{FeatureKind, PlaneRef};
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
fn run(s: &mut Session, command: &str, params: Value) -> Value {
s.execute(command, &params).unwrap_or_else(|e| panic!("{command} {params}: {e}"))
diff --git a/crates/ui-egui/src/primitive_placement.rs b/crates/ui-egui/src/primitive_placement.rs
index 400d43ce8d..1583ef72a4 100644
--- a/crates/ui-egui/src/primitive_placement.rs
+++ b/crates/ui-egui/src/primitive_placement.rs
@@ -10,9 +10,9 @@
//! feature's stored point goes back unchanged.
use serde_json::{Map, Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::Session;
use solidcraft_engine::doc::expr::Kind as ValueKind;
-use solidcraft_engine::geom::Vec3;
use crate::i18n::tr;
use crate::selection::{EDGES, FACES, ORIGIN, SelInput, VERTICES};
diff --git a/crates/ui-egui/src/primitive_units_tests.rs b/crates/ui-egui/src/primitive_units_tests.rs
index ee7a15e0d2..ea52f69463 100644
--- a/crates/ui-egui/src/primitive_units_tests.rs
+++ b/crates/ui-egui/src/primitive_units_tests.rs
@@ -582,8 +582,8 @@ fn the_cylinder_dialog_takes_its_base_point() {
#[test]
fn a_point_picked_in_the_box_dialog_becomes_its_corner_or_centre() {
+ use solidcore_record::Vec3;
use solidcraft_engine::Sel;
- use solidcraft_engine::geom::Vec3;
let mut h = design("mm");
// The box made here overlaps Base, which the window would join or cut (#6901): this test is
// about where it goes, so the window keeps its New Body.
@@ -701,8 +701,8 @@ fn editing_a_sphere_torus_or_cone_shows_its_placement_and_keeps_it() {
#[test]
fn a_point_picked_in_the_sphere_or_torus_dialog_becomes_its_centre() {
+ use solidcore_record::Vec3;
use solidcraft_engine::Sel;
- use solidcraft_engine::geom::Vec3;
let mut h = design("mm");
h.app.run("solid.box", json!({"length": 40, "width": 30, "height": 20, "body_name": "Base"})).unwrap();
h.frames(2);
diff --git a/crates/ui-egui/src/print_face_ui.rs b/crates/ui-egui/src/print_face_ui.rs
index 63918a1fc5..2c51340f5c 100644
--- a/crates/ui-egui/src/print_face_ui.rs
+++ b/crates/ui-egui/src/print_face_ui.rs
@@ -65,7 +65,7 @@ mod tests {
fn select_face(app: &mut crate::SolveApp, point: [f64; 3]) -> usize {
let world = crate::open_meshing::session_world(&app.session);
let body = world.body("Block").unwrap();
- let p = solidcraft_engine::geom::Vec3::new(point[0], point[1], point[2]);
+ let p = solidcore_record::Vec3::new(point[0], point[1], point[2]);
let index = solidcraft_engine::doc::appearance::face_index_at(body, p).unwrap();
app.session.selection = vec![Sel::Face { body: "Block".into(), index, point: p }];
index
diff --git a/crates/ui-egui/src/quick_measure_tests.rs b/crates/ui-egui/src/quick_measure_tests.rs
index 70874575f8..f4b6729e69 100644
--- a/crates/ui-egui/src/quick_measure_tests.rs
+++ b/crates/ui-egui/src/quick_measure_tests.rs
@@ -2,8 +2,9 @@
//! window thread, shown above History, copied on a click.
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::scenario::Harness;
diff --git a/crates/ui-egui/src/ref_images.rs b/crates/ui-egui/src/ref_images.rs
index f4f3c33e22..dcd56b432c 100644
--- a/crates/ui-egui/src/ref_images.rs
+++ b/crates/ui-egui/src/ref_images.rs
@@ -1,13 +1,14 @@
//! Canvases and decals: the design's reference images. With the GPU viewport they are textured
//! quads in the 3D pass (the model hides them); the CPU viewport draws them over its image.
+use solidcraft_engine::geom::prelude::*;
use std::cell::RefCell;
use std::collections::HashMap;
use std::sync::Arc;
use egui::{Color32, Mesh, Shape, TextureHandle, TextureId, pos2};
+use solidcore_record::Vec2;
use solidcraft_engine::doc::canvas::Canvas;
-use solidcraft_engine::geom::Vec2;
use crate::SolveApp;
use crate::gpu::GpuImage;
diff --git a/crates/ui-egui/src/render_ui/assign.rs b/crates/ui-egui/src/render_ui/assign.rs
index 2c80f0b37e..1de2823998 100644
--- a/crates/ui-egui/src/render_ui/assign.rs
+++ b/crates/ui-egui/src/render_ui/assign.rs
@@ -504,7 +504,7 @@ pub(crate) fn selection_bar(app: &mut SolveApp, ui: &mut egui::Ui, free: egui::R
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] {
- if let Some(p) = proj.to_screen(solidcraft_engine::geom::Vec3::new(x, y, z)).filter(|p| p.is_finite()) {
+ if let Some(p) = proj.to_screen(solidcore_record::Vec3::new(x, y, z)).filter(|p| p.is_finite()) {
screen.extend_with(p);
}
}
diff --git a/crates/ui-egui/src/render_workspace.rs b/crates/ui-egui/src/render_workspace.rs
index 554fa32988..f040f30aa7 100644
--- a/crates/ui-egui/src/render_workspace.rs
+++ b/crates/ui-egui/src/render_workspace.rs
@@ -1,5 +1,6 @@
//! Integrated product preview. Shares the installed device/pipelines, not Design's scene policy.
+use solidcraft_engine::geom::prelude::*;
use std::hash::{Hash, Hasher};
use std::sync::{Arc, Mutex};
diff --git a/crates/ui-egui/src/render_workspace_inspector_tests.rs b/crates/ui-egui/src/render_workspace_inspector_tests.rs
index 6cc3d98333..456372914c 100644
--- a/crates/ui-egui/src/render_workspace_inspector_tests.rs
+++ b/crates/ui-egui/src/render_workspace_inspector_tests.rs
@@ -43,7 +43,7 @@ fn render_workspace_shot_and_scene_widgets_fit_inspector_content_width() {
setups::save(&mut h.app).unwrap();
let name = h.app.render_workspace.view.name.clone();
super::super::shot::choose_aspect(&mut h.app, &name, 0).unwrap();
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(-18.0, 125.5, -18.0);
+ h.app.cam.target = solidcore_record::Vec3::new(-18.0, 125.5, -18.0);
let ctx = crate::fonts::test_context();
let mut textures = std::collections::HashMap::new();
for width in [350.0, 320.0] {
@@ -1838,7 +1838,8 @@ fn browser_shot_remove_keeps_confirmation_and_rejects_stale_actions() {
#[test]
fn appearance_inspector_targets_and_chain_follow_body_face_and_component() {
use super::selection_appearance::{chains, inspected_look, targets};
- use solidcraft_engine::{Sel, geom::Vec3};
+ use solidcore_record::Vec3;
+ use solidcraft_engine::Sel;
let mut h = Harness::new();
h.app.run("component.create", json!({"name":"Part"})).unwrap();
h.app.run("solid.box", json!({"body_name":"Subject","length":20,"width":15,"height":10})).unwrap();
@@ -1977,7 +1978,8 @@ fn appearance_inspector_finish_presets_mixed_set_all_and_clear_use_existing_assi
#[test]
fn appearance_inspector_real_controls_switch_targets_inspect_chain_and_edit_finish() {
- use solidcraft_engine::{Sel, geom::Vec3};
+ use solidcore_record::Vec3;
+ use solidcraft_engine::Sel;
let mut h = fixture();
h.app.run("appearance.assign", json!({"bodies":["Subject"],"appearance":"ABS - Red"})).unwrap();
let face = h.app.run("model.faces", json!({"body":"Subject"})).unwrap()["faces"]
@@ -2303,7 +2305,8 @@ fn appearance_inspector_shared_picker_has_no_outer_hex_editor_and_keeps_mixed_va
#[test]
fn appearance_inspector_component_and_face_overrides_remove_to_material_from_real_controls() {
- use solidcraft_engine::{Sel, geom::Vec3};
+ use solidcore_record::Vec3;
+ use solidcraft_engine::Sel;
let mut h = Harness::new();
h.call("ui.resize", json!({"width":1440,"height":1000}));
h.app.run("component.create", json!({"name":"Part"})).unwrap();
@@ -2516,9 +2519,7 @@ fn appearance_editor_e2_sections_are_ordered_collapsed_and_expand_for_each_metho
assert_eq!(h.app.session.doc.to_json(), before);
assert!(h.app.render_workspace.view.materials.bindings.is_empty(), "opening never installs temporary bindings");
}
- for selection in
- [Sel::Face { body: "Subject".into(), index: 0, point: solidcraft_engine::geom::Vec3::ZERO }, Sel::Body { name: "Subject".into() }]
- {
+ for selection in [Sel::Face { body: "Subject".into(), index: 0, point: solidcore_record::Vec3::ZERO }, Sel::Body { name: "Subject".into() }] {
h.app.session.selection = vec![selection];
{
let selection = super::super::object_selection(&h.app);
diff --git a/crates/ui-egui/src/render_workspace_library.rs b/crates/ui-egui/src/render_workspace_library.rs
index 55c26cd297..6d6bf08a8f 100644
--- a/crates/ui-egui/src/render_workspace_library.rs
+++ b/crates/ui-egui/src/render_workspace_library.rs
@@ -6,7 +6,8 @@ pub(super) mod review;
use super::{ImageMethod, materials, setups};
use crate::{SolveApp, theme::Tokens, ui_kit};
use serde_json::{Value, json};
-use solidcraft_engine::{doc::Document, geom::Vec3};
+use solidcore_record::Vec3;
+use solidcraft_engine::doc::Document;
use std::{
collections::BTreeMap,
sync::{Arc, Weak},
diff --git a/crates/ui-egui/src/render_workspace_light.rs b/crates/ui-egui/src/render_workspace_light.rs
index e72f680065..1d73c79730 100644
--- a/crates/ui-egui/src/render_workspace_light.rs
+++ b/crates/ui-egui/src/render_workspace_light.rs
@@ -3,6 +3,7 @@ use super::{ImageMethod, RenderSelection, cpu, setups, studio};
use crate::{SolveApp, ui_kit};
use serde_json::{Value, json};
use solidcraft_engine::doc::render_settings::{CpuJob, GpuJob, RenderJob, RenderSetup, SkyEnvironment};
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::render::job::{AreaLights, StudioLighting};
use solidcraft_engine::schema::render_lights::{Geometry, Light, Visibility};
@@ -289,9 +290,9 @@ pub(super) fn preview(app: &SolveApp) -> Result<Vec<[f32; 16]>, String> {
emitted_axis, inner_half_angle_radians, outer_half_angle_radians, reference_distance_mm, minimum_distance_mm, ..
} => (emitted_axis, inner_half_angle_radians.cos(), outer_half_angle_radians.cos(), reference_distance_mm.powi(2), minimum_distance_mm),
Geometry::Area { edge_u_mm: [ux, uy, uz], edge_v_mm: [vx, vy, vz], .. } => {
- let normal = solidcraft_engine::geom::Vec3::new(ux, uy, uz).cross(solidcraft_engine::geom::Vec3::new(vx, vy, vz));
+ let normal = solidcore_record::Vec3::new(ux, uy, uz).cross(solidcore_record::Vec3::new(vx, vy, vz));
let area = normal.len();
- let n = solidcraft_engine::render::surface::unit_direction(normal).unwrap_or(-solidcraft_engine::geom::Vec3::Z);
+ let n = solidcraft_engine::render::surface::unit_direction(normal).unwrap_or(-solidcore_record::Vec3::Z);
([n.x, n.y, n.z], 0.0, 0.0, area, 0.001)
}
_ => ([0.0; 3], 0.0, 0.0, 1.0, 0.001),
diff --git a/crates/ui-egui/src/render_workspace_materials.rs b/crates/ui-egui/src/render_workspace_materials.rs
index 576676ac00..d7b11791bd 100644
--- a/crates/ui-egui/src/render_workspace_materials.rs
+++ b/crates/ui-egui/src/render_workspace_materials.rs
@@ -1,5 +1,6 @@
//! Transient body-level optical overrides for the captured GPU image request.
//! The model's appearances, physical material cards and saved setups are not changed.
+use solidcore_record::Vec3;
use std::sync::{Arc, Weak};
use serde::Deserialize;
@@ -9,7 +10,6 @@ use solidcraft_engine::{
Document,
appearance_pack::{self, GlassBoundary, Recipe},
},
- geom::Vec3,
render::{
clear_coat::ClearCoat,
job::textures::{BaseColorMode, PlanarFrame},
diff --git a/crates/ui-egui/src/render_workspace_shot.rs b/crates/ui-egui/src/render_workspace_shot.rs
index 4331f50038..10697806f8 100644
--- a/crates/ui-egui/src/render_workspace_shot.rs
+++ b/crates/ui-egui/src/render_workspace_shot.rs
@@ -321,7 +321,7 @@ fn camera(app: &mut SolveApp, ui: &mut egui::Ui, shot: &str) {
ui_kit::row(ui, app.tr("render.shot_target"), |ui| {
ui_kit::number_fields(ui, &mut target, -1e9..=1e9, 0.1, "");
});
- camera.target = solidcraft_engine::geom::Vec3::new(target[0], target[1], target[2]);
+ camera.target = solidcore_record::Vec3::new(target[0], target[1], target[2]);
for (key, value) in [("camera.shot_yaw", &mut camera.yaw), ("camera.shot_pitch", &mut camera.pitch), ("camera.shot_roll", &mut camera.roll)] {
let mut degrees = value.to_degrees();
if ui_kit::row(ui, app.tr(key), |ui| ui_kit::number_field(ui, &mut degrees, (-1e6f64).to_degrees()..=1e6f64.to_degrees(), 0.5, "°")).changed()
diff --git a/crates/ui-egui/src/render_workspace_tests.rs b/crates/ui-egui/src/render_workspace_tests.rs
index b37941048b..f777cbc5a3 100644
--- a/crates/ui-egui/src/render_workspace_tests.rs
+++ b/crates/ui-egui/src/render_workspace_tests.rs
@@ -1696,7 +1696,7 @@ fn product_gpu_buffers_preserve_opacity_and_never_contain_overlays() {
assert!(gpu.glass.as_chunks::<{ crate::gpu::TRI_SIZE }>().0.iter().all(|v| color(v) == Some([51, 102, 153, 102])));
assert!(gpu.lines.is_empty() && gpu.overlay.is_empty() && gpu.under.is_empty() && gpu.hidden.is_empty() && gpu.ghost.is_empty());
s.selection = vec![solidcraft_engine::Sel::Body { name: "Glass".into() }];
- s.section = Some((solidcraft_engine::geom::Vec3::ZERO, solidcraft_engine::geom::Vec3::X));
+ s.section = Some((solidcore_record::Vec3::ZERO, solidcore_record::Vec3::X));
let after = solidcraft_engine::product_scene::extract(&s).unwrap();
assert_eq!(gpu_scene(&after).unwrap().0, key);
s.execute("appearance.assign", &json!({"bodies":["Glass"],"color":"#336699","opacity":0.0})).unwrap();
@@ -1716,8 +1716,7 @@ fn transmission_uses_legacy_preview_buffers_and_invalidates_the_opaque_cache() {
let (opaque_key, opaque) = gpu_scene(&solidcraft_engine::product_scene::extract(&s).unwrap()).unwrap();
assert!(!opaque.pbr.is_empty());
let mut scene = solidcraft_engine::product_scene::extract(&s).unwrap();
- scene.meshes[0].transmission =
- Some(solidcraft_engine::render::transmission::Transmission::new(solidcraft_engine::geom::Vec3::ZERO, None).unwrap());
+ scene.meshes[0].transmission = Some(solidcraft_engine::render::transmission::Transmission::new(solidcore_record::Vec3::ZERO, None).unwrap());
let (glass_key, glass) = gpu_scene(&scene).unwrap();
assert_ne!(opaque_key, glass_key);
assert!(glass.pbr.is_empty());
@@ -2619,7 +2618,7 @@ fn render_workspace_view_keys_double_middle_click_and_navigators_work() {
// A standard view from the navigator.
h.step(&json!({"click":{"handle":"axis_view:z"}})).unwrap();
h.settle();
- assert!(h.app.cam.back().dot(solidcraft_engine::geom::Vec3::Z) > 0.999, "{style:?}: view from +Z, got {:?}", h.app.cam.back());
+ assert!(h.app.cam.back().dot(solidcore_record::Vec3::Z) > 0.999, "{style:?}: view from +Z, got {:?}", h.app.cam.back());
assert!(h.app.session.selection.is_empty());
}
}
@@ -2731,7 +2730,7 @@ fn gpu_material_recipes_use_exact_linear_absorption_without_changing_saved_appea
assert_eq!(wire["body_name"], "Optics");
assert_eq!(wire["ior"], recipe.dielectric_ior);
let [r, g, b]: [f64; 3] = serde_json::from_value(wire["absorption_per_mm"].clone()).unwrap();
- let medium = solidcraft_engine::render::transmission::Transmission::new(solidcraft_engine::geom::Vec3::new(r, g, b), None).unwrap();
+ let medium = solidcraft_engine::render::transmission::Transmission::new(solidcore_record::Vec3::new(r, g, b), None).unwrap();
let transmitted = medium.attenuation(recipe.reference_path_mm).unwrap();
for (actual, expected) in [transmitted.x, transmitted.y, transmitted.z].into_iter().zip(recipe.transmission_linear_rgb) {
assert!((actual - expected).abs() < 1e-12, "the actual optical consumer must reproduce the recipe's linear transmittance");
@@ -3812,7 +3811,8 @@ fn product_preview_exact_payload_preserves_mixed_surfaces_and_refuses_overflow()
#[cfg(all(not(target_arch = "wasm32"), target_pointer_width = "64"))]
#[test]
fn full_detail_preview_source_can_exceed_legacy_128_mib_without_mesh_reduction() {
- use solidcraft_engine::geom::{Mesh, Vec3};
+ use solidcore_record::Vec3;
+ use solidcraft_engine::geom::Mesh;
use solidcraft_engine::render::{ProductMesh, surface::OpaqueSurface};
// One immutable original triangle repeated in the index list; this tests
// payload admission only. Actual SELENE upload is separate native evidence.
@@ -4523,7 +4523,7 @@ fn assert_product_fits_canvas(app: &SolveApp) {
let (sx, sy, _) = app
.cam
.to_screen(
- solidcraft_engine::geom::Vec3::new(x, y, z),
+ solidcore_record::Vec3::new(x, y, z),
f64::from(layout.viewport.width()),
f64::from(layout.viewport.height()),
bounds.diagonal().max(10.0),
@@ -4801,8 +4801,8 @@ fn render_workspace_click_modifiers_clear_and_browser_share_selection() {
h.settle();
h.app.run("select.filter", json!({"mode":"body"})).unwrap();
let proj = crate::viewport::projection(&h.app, h.app.viewport.rect.unwrap());
- let left = proj.to_screen(solidcraft_engine::geom::Vec3::new(-20.0, 10.0, 20.0)).unwrap();
- let right = proj.to_screen(solidcraft_engine::geom::Vec3::new(40.0, 10.0, 20.0)).unwrap();
+ let left = proj.to_screen(solidcore_record::Vec3::new(-20.0, 10.0, 20.0)).unwrap();
+ let right = proj.to_screen(solidcore_record::Vec3::new(40.0, 10.0, 20.0)).unwrap();
h.step(&json!({"click":[left.x,left.y]})).unwrap();
assert_eq!(h.app.session.selection, [Sel::Body { name: "Left".into() }]);
h.step(&json!({"click":[right.x,right.y],"shift":true})).unwrap();
@@ -4916,7 +4916,7 @@ fn render_workspace_product_pass_draws_only_requested_face_or_body_overlay() {
#[test]
fn render_workspace_pick_projection_matches_orthographic_and_custom_perspective_camera() {
use egui::{Event, Modifiers, PointerButton};
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
for fov in [0.0, 0.6, 1.1] {
let mut app = nav_app(true, "fusion", crate::prefs::OrbitAround::ViewCentre);
app.cam.fov = fov;
@@ -4947,7 +4947,8 @@ fn render_workspace_pick_projection_matches_orthographic_and_custom_perspective_
#[test]
fn render_workspace_component_filter_keeps_nested_repeated_occurrences_distinct() {
use crate::viewport::{Hit, candidate};
- use solidcraft_engine::{Sel, geom::Vec3};
+ use solidcore_record::Vec3;
+ use solidcraft_engine::Sel;
let mut h = Harness::new();
let parent = h.app.run("component.create", json!({"name":"Parent"})).unwrap();
let child = h.app.run("component.create", json!({"name":"Part"})).unwrap();
@@ -6650,7 +6651,7 @@ fn render_assign_gestures_geometry_and_theme_evidence() {
.app
.viewport
.rect
- .and_then(|rect| crate::viewport::projection(&h.app, rect).to_screen(solidcraft_engine::geom::Vec3::new(0.0, 0.0, 28.0)))
+ .and_then(|rect| crate::viewport::projection(&h.app, rect).to_screen(solidcore_record::Vec3::new(0.0, 0.0, 28.0)))
.filter(|_| frame == 1)
.map(|at| vec![egui::Event::PointerMoved(at)])
.unwrap_or_default();
@@ -6842,7 +6843,7 @@ fn render_results_compare_divider_drag_clamps_and_blocks_all_camera_input() {
#[test]
fn render_results_compare_live_projection_matches_image_fit_zoom_and_pan_without_an_oversized_gpu_viewport() {
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
let canvas = egui::Rect::from_min_size(egui::pos2(100.0, 200.0), egui::vec2(800.0, 600.0));
for fov in [0.0, 0.6] {
let camera = Camera { fov, roll: 0.25, ..Default::default() };
@@ -6966,9 +6967,7 @@ fn geometry_refusal_reports_scene_size_limit_and_recovery() {
mesh: Arc::new(Mesh { triangles: vec![[0; 3]; 1 << 20], ..Default::default() }),
color: [128; 3],
opacity: 1.0,
- surface: Some(
- solidcraft_engine::render::surface::OpaqueSurface::new(solidcraft_engine::geom::Vec3::new(0.5, 0.5, 0.5), 0.0, 0.5, 1.5).unwrap(),
- ),
+ surface: Some(solidcraft_engine::render::surface::OpaqueSurface::new(solidcore_record::Vec3::new(0.5, 0.5, 0.5), 0.0, 0.5, 1.5).unwrap()),
transmission: None,
faces: Vec::new(),
}],
@@ -7038,7 +7037,8 @@ fn the_field_of_view_rescales_only_the_design_view() {
/// taller than wide moves the camera back so the sides hold it too.
#[test]
fn fit_aspect_keeps_the_product_inside_a_tall_image() {
- use solidcraft_engine::geom::{Aabb3, Vec3};
+ use solidcore_record::Vec3;
+ use solidcraft_engine::geom::Aabb3;
let bounds = Aabb3 { min: Vec3::new(-30.0, -30.0, -30.0), max: Vec3::new(30.0, 30.0, 30.0) };
let radius = bounds.diagonal();
for fov in [0.0, std::f64::consts::FRAC_PI_4] {
@@ -7063,12 +7063,12 @@ fn fit_aspect_keeps_the_product_inside_a_tall_image() {
}
}
-fn corners(b: &solidcraft_engine::geom::Aabb3) -> Vec<solidcraft_engine::geom::Vec3> {
+fn corners(b: &solidcraft_engine::geom::Aabb3) -> Vec<solidcore_record::Vec3> {
let mut out = Vec::new();
for x in [b.min.x, b.max.x] {
for y in [b.min.y, b.max.y] {
for z in [b.min.z, b.max.z] {
- out.push(solidcraft_engine::geom::Vec3::new(x, y, z));
+ out.push(solidcore_record::Vec3::new(x, y, z));
}
}
}
diff --git a/crates/ui-egui/src/revolve_edit_tests.rs b/crates/ui-egui/src/revolve_edit_tests.rs
index ae1dafdf8f..6a10798355 100644
--- a/crates/ui-egui/src/revolve_edit_tests.rs
+++ b/crates/ui-egui/src/revolve_edit_tests.rs
@@ -1,6 +1,7 @@
use crate::scenario::Harness;
use serde_json::{Value, json};
use solidcraft_engine::doc::{AxisRef, FeatureKind};
+use solidcraft_engine::geom::prelude::*;
fn make(h: Harness, axis: Value) -> Harness {
make_params(h, axis, json!({}))
@@ -61,11 +62,11 @@ fn to_object_noop_preserves_cut_targets_and_untargeted_body() {
assert!((before_a - (2000.0 - removed)).abs() < 0.2, "cut results {:?}: {before_a}", state.bodies.iter().map(|b| &b.name).collect::<Vec<_>>());
let in_cut_stock =
|p| state.bodies.iter().filter(|b| b.name != "B").any(|b| b.body.classify_point(p).unwrap() == solidcraft_engine::kernel::PointClass::Inside);
- assert!(in_cut_stock(solidcraft_engine::geom::Vec3::new(2.0, 2.0, 2.0)));
- assert!(in_cut_stock(solidcraft_engine::geom::Vec3::new(18.0, 2.0, 18.0)));
- assert!(!in_cut_stock(solidcraft_engine::geom::Vec3::new(9.0, 2.0, 9.0)));
+ assert!(in_cut_stock(solidcore_record::Vec3::new(2.0, 2.0, 2.0)));
+ assert!(in_cut_stock(solidcore_record::Vec3::new(18.0, 2.0, 18.0)));
+ assert!(!in_cut_stock(solidcore_record::Vec3::new(9.0, 2.0, 9.0)));
assert_eq!(
- state.body("B").unwrap().body.classify_point(solidcraft_engine::geom::Vec3::new(9.0, 2.0, 9.0)).unwrap(),
+ state.body("B").unwrap().body.classify_point(solidcore_record::Vec3::new(9.0, 2.0, 9.0)).unwrap(),
solidcraft_engine::kernel::PointClass::Inside
);
let before_bounds: Vec<_> = state.bodies.iter().map(|b| (b.name.clone(), b.mesh().bounds())).collect();
@@ -120,7 +121,7 @@ fn second_active_occurrence_noop_preserves_definition_axis_target_and_instances(
h.app.run("component.activate", json!({"component":owner["component"],"occurrence":second,"path":[second]})).unwrap();
let original = serde_json::to_value(&h.app.session.doc.find_feature("Turn").unwrap().kind).unwrap();
let frame = h.app.session.active_component_frame();
- let expected_origin = solidcraft_engine::doc::apply_point(&frame, solidcraft_engine::geom::Vec3::ZERO);
+ let expected_origin = solidcraft_engine::doc::apply_point(&frame, solidcore_record::Vec3::ZERO);
let before: Vec<_> = h.app.session.world_state().unwrap().bodies.iter().map(|b| (b.name.clone(), b.mesh().bounds())).collect();
open(&mut h);
let (origin, _) = crate::canvas::revolve_axis(&h.app, h.app.dialog.as_ref().unwrap()).unwrap();
diff --git a/crates/ui-egui/src/revolve_manipulator_tests.rs b/crates/ui-egui/src/revolve_manipulator_tests.rs
index 65e299e10c..9b064d79af 100644
--- a/crates/ui-egui/src/revolve_manipulator_tests.rs
+++ b/crates/ui-egui/src/revolve_manipulator_tests.rs
@@ -154,7 +154,7 @@ fn selected_second_placement_custom_axis_handle_and_preview_stay_in_its_frame()
let frame = h.app.session.active_component_frame();
let world = |degrees: f64| {
let a = degrees.to_radians();
- let p = solidcraft_engine::doc::apply_point(&frame, solidcraft_engine::geom::Vec3::new(12.5 * a.cos(), 2.5, 12.5 * a.sin()));
+ let p = solidcraft_engine::doc::apply_point(&frame, solidcore_record::Vec3::new(12.5 * a.cos(), 2.5, 12.5 * a.sin()));
json!([p.x, p.y, p.z])
};
let axis = match &h.app.session.doc.find_feature("Turn").unwrap().kind {
@@ -186,7 +186,7 @@ fn curved_to_object_has_surface_feedback_without_an_angular_handle_or_input() {
h.step(&json!({"click":{"handle":"dialog:Type:To Object"}})).unwrap();
let mut dialog = h.app.dialog.take().unwrap();
dialog.active = dialog.inputs.iter().position(|input| input.label == "To Object").unwrap();
- dialog.pick(&h.app.session, solidcraft_engine::Sel::Vertex { body: "Target".into(), point: solidcraft_engine::geom::Vec3::new(0.0, 2.0, 15.0) });
+ dialog.pick(&h.app.session, solidcraft_engine::Sel::Vertex { body: "Target".into(), point: solidcore_record::Vec3::new(0.0, 2.0, 15.0) });
h.app.dialog = Some(dialog);
h.frames(8);
assert!(h.widget("To surface").is_some());
@@ -345,8 +345,8 @@ fn canonical_symmetric_ring_preview_drag_and_reopen_match_material() {
let commands = crate::dialogs::apply_commands(&h.app, h.app.dialog.as_ref().unwrap()).unwrap();
let preview = h.app.session.preview_world(&commands).unwrap();
let body = &preview.after.body("Main").unwrap().body;
- assert_eq!(body.classify_point(solidcraft_engine::geom::Vec3::new(3.0, 5.0, 0.0)).unwrap(), solidcraft_engine::kernel::PointClass::Inside);
- assert_eq!(body.classify_point(solidcraft_engine::geom::Vec3::new(0.0, 5.0, 3.0)).unwrap(), solidcraft_engine::kernel::PointClass::Outside);
+ assert_eq!(body.classify_point(solidcore_record::Vec3::new(3.0, 5.0, 0.0)).unwrap(), solidcraft_engine::kernel::PointClass::Inside);
+ assert_eq!(body.classify_point(solidcore_record::Vec3::new(0.0, 5.0, 3.0)).unwrap(), solidcraft_engine::kernel::PointClass::Outside);
let bounds = preview.after.body("Main").unwrap().mesh().bounds();
assert!((bounds.min.x - 2.0f64.sqrt()).abs() < 0.02 && (bounds.max.x - 4.0).abs() < 0.02, "{bounds:?}");
assert!((bounds.min.z + 2.0 * 2.0f64.sqrt()).abs() < 0.02 && (bounds.max.z - 2.0 * 2.0f64.sqrt()).abs() < 0.02);
@@ -385,12 +385,9 @@ fn reversed_axis_to_object_canvas_sweep_and_preview_follow_the_quarter_target()
let preview = h.app.session.preview_world(&commands).unwrap();
let result = preview.after.body("Main").unwrap();
assert_eq!(result.mesh().bounds(), before);
- assert_eq!(result.body.classify_point(solidcraft_engine::geom::Vec3::new(p, 2.5, p)).unwrap(), solidcraft_engine::kernel::PointClass::Inside);
+ assert_eq!(result.body.classify_point(solidcore_record::Vec3::new(p, 2.5, p)).unwrap(), solidcraft_engine::kernel::PointClass::Inside);
for (x, z) in [(-p, p), (-p, -p), (p, -p)] {
- assert_eq!(
- result.body.classify_point(solidcraft_engine::geom::Vec3::new(x, 2.5, z)).unwrap(),
- solidcraft_engine::kernel::PointClass::Outside
- );
+ assert_eq!(result.body.classify_point(solidcore_record::Vec3::new(x, 2.5, z)).unwrap(), solidcraft_engine::kernel::PointClass::Outside);
}
assert!((kernel::measure(&result.body).unwrap().volume - expected_volume(90.0)).abs() < 0.03);
h.step(&json!({"widget":"OK"})).unwrap();
diff --git a/crates/ui-egui/src/round_pick_tests.rs b/crates/ui-egui/src/round_pick_tests.rs
index 4a17cb0981..47fff4aad6 100644
--- a/crates/ui-egui/src/round_pick_tests.rs
+++ b/crates/ui-egui/src/round_pick_tests.rs
@@ -4,9 +4,10 @@
//! hovering one draws the axis or centre as construction geometry.
use serde_json::{Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::doc::{AxisRef, FeatureKind, PatternKind, PlaneRef};
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::dialogs::Kind;
use crate::scenario::Harness;
diff --git a/crates/ui-egui/src/scale_tests.rs b/crates/ui-egui/src/scale_tests.rs
index eb26d67920..0fc76b1972 100644
--- a/crates/ui-egui/src/scale_tests.rs
+++ b/crates/ui-egui/src/scale_tests.rs
@@ -618,7 +618,7 @@ fn zoomed_view_frame_cost() {
#[test]
#[ignore = "manual highlight measurement"]
fn many_selected_bodies_hover_cost() {
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
let mut h = match std::env::var_os("SOLIDCRAFT_SCALE_DESIGN") {
Some(path) => {
let mut h = Harness::new();
diff --git a/crates/ui-egui/src/scenario.rs b/crates/ui-egui/src/scenario.rs
index 36c7b3b098..874aee74cc 100644
--- a/crates/ui-egui/src/scenario.rs
+++ b/crates/ui-egui/src/scenario.rs
@@ -40,6 +40,7 @@
//!
//! The same files drive the live app over the control channel for screenshots.
+use solidcraft_engine::geom::prelude::*;
use std::cell::RefCell;
use std::path::PathBuf;
use std::rc::Rc;
@@ -435,7 +436,7 @@ impl Harness {
for i in 0..240 {
self.frame();
let now = basis(&self.app.cam);
- let ang = |a: solidcraft_engine::geom::Vec3, b: solidcraft_engine::geom::Vec3| a.dot(b).clamp(-1.0, 1.0).acos().to_degrees();
+ let ang = |a: solidcore_record::Vec3, b: solidcore_record::Vec3| a.dot(b).clamp(-1.0, 1.0).acos().to_degrees();
let d = ang(prev.0, now.0).max(ang(prev.2, now.2));
if d > worst.0 {
worst = (d, i);
diff --git a/crates/ui-egui/src/section_browser_tests.rs b/crates/ui-egui/src/section_browser_tests.rs
index fa9cca193d..a994456b7c 100644
--- a/crates/ui-egui/src/section_browser_tests.rs
+++ b/crates/ui-egui/src/section_browser_tests.rs
@@ -3,6 +3,7 @@
use egui::pos2;
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
use crate::context_menu::{self, Target};
use crate::scenario::Harness;
diff --git a/crates/ui-egui/src/select_other.rs b/crates/ui-egui/src/select_other.rs
index b1ebdec2ad..9a972bc384 100644
--- a/crates/ui-egui/src/select_other.rs
+++ b/crates/ui-egui/src/select_other.rs
@@ -25,6 +25,7 @@ use crate::ui_kit::{Container, Surface};
use egui::{Align2, FontId, Pos2, Rect, Sense, pos2, vec2};
use serde_json::{Value, json};
use solidcraft_engine::Sel;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::sketch::CurveKind;
use std::hash::{Hash, Hasher};
@@ -191,17 +192,17 @@ fn body_of(h: &Hit) -> Option<&str> {
fn hit_depth(
st: &solidcraft_engine::doc::ModelState,
index: &std::collections::HashMap<&str, usize>,
- o: solidcraft_engine::geom::Vec3,
- d: solidcraft_engine::geom::Vec3,
+ o: solidcore_record::Vec3,
+ d: solidcore_record::Vec3,
h: &Hit,
) -> Option<f64> {
- let along = |p: solidcraft_engine::geom::Vec3| Some((p - o).dot(d)).filter(|t| t.is_finite());
+ let along = |p: solidcore_record::Vec3| Some((p - o).dot(d)).filter(|t| t.is_finite());
match h {
Hit::Vertex { point, .. } | Hit::Face { point, .. } => along(*point),
Hit::Edge { body, index: ei, mid, .. } => {
let under = index.get(body.as_str()).and_then(|i| st.bodies.get(*i)).and_then(|b| {
let (m, place) = b.mesh_in_place();
- let at = |p: solidcraft_engine::geom::Vec3| solidcraft_engine::doc::apply_point(&place, p);
+ let at = |p: solidcore_record::Vec3| solidcraft_engine::doc::apply_point(&place, p);
let dd = d.dot(d);
m.edges
.get(*ei)?
diff --git a/crates/ui-egui/src/select_other_tests.rs b/crates/ui-egui/src/select_other_tests.rs
index 531e887420..3fab5009b0 100644
--- a/crates/ui-egui/src/select_other_tests.rs
+++ b/crates/ui-egui/src/select_other_tests.rs
@@ -3,6 +3,7 @@
use serde_json::{Value, json};
use solidcraft_engine::Sel;
+use solidcraft_engine::geom::prelude::*;
use crate::scenario::Harness;
@@ -472,7 +473,7 @@ fn an_edge_is_as_deep_as_its_point_under_the_pointer_not_its_middle() {
h.call("ui.view", json!({"view":"fit"}));
h.settle();
// On the bottom plate's near top edge along Y (x = 15, y from -15 to 15), well off its middle.
- let under = solidcraft_engine::geom::Vec3::new(15.0, 9.0, 2.0);
+ let under = solidcore_record::Vec3::new(15.0, 9.0, 2.0);
let at = h.call("ui.at", json!({"world": [under.x, under.y, under.z]}))["result"].clone();
let pos = egui::pos2(at[0].as_f64().unwrap() as f32, at[1].as_f64().unwrap() as f32);
let proj = crate::viewport::projection(&h.app, h.app.viewport.rect.unwrap());
@@ -483,7 +484,7 @@ fn an_edge_is_as_deep_as_its_point_under_the_pointer_not_its_middle() {
let index = st.bodies.iter().enumerate().map(|(i, b)| (b.name.as_str(), i)).collect();
let t = super::hit_depth(&st, &index, o, d, edge).expect("a depth");
let want = (under - o).dot(d);
- let mid = solidcraft_engine::geom::Vec3::new(15.0, 0.0, 2.0);
+ let mid = solidcore_record::Vec3::new(15.0, 0.0, 2.0);
assert!((t - want).abs() < 0.5, "depth {t}, the point under the pointer {want}, its middle {}", (mid - o).dot(d));
}
diff --git a/crates/ui-egui/src/selection.rs b/crates/ui-egui/src/selection.rs
index 7aa1dccb55..498a07d41e 100644
--- a/crates/ui-egui/src/selection.rs
+++ b/crates/ui-egui/src/selection.rs
@@ -3,8 +3,9 @@
//! selection. The pure parts are unit tested; the viewport uses them.
use egui::{Pos2, Rect};
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
use crate::viewport::Hit;
@@ -43,7 +44,7 @@ pub(crate) fn coincident_operands(selection: &[Sel]) -> Option<serde_json::Value
}
/// The current middle of a finite straight sketch edge.
-pub(crate) fn line_midpoint(sk: &solidcraft_engine::sketch::Sketch, line: usize) -> Option<solidcraft_engine::geom::Vec2> {
+pub(crate) fn line_midpoint(sk: &solidcraft_engine::sketch::Sketch, line: usize) -> Option<solidcore_record::Vec2> {
let curve = sk.curves.get(line)?;
if curve.infinite {
return None;
diff --git a/crates/ui-egui/src/shell_face_sketch_ui_tests.rs b/crates/ui-egui/src/shell_face_sketch_ui_tests.rs
index 8f7877f2fa..015eec1bb3 100644
--- a/crates/ui-egui/src/shell_face_sketch_ui_tests.rs
+++ b/crates/ui-egui/src/shell_face_sketch_ui_tests.rs
@@ -1,5 +1,6 @@
use crate::scenario::Harness;
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::{
Sel,
doc::{FaceAttachmentStatus, FeatureKind, PlaneRef},
diff --git a/crates/ui-egui/src/shell_tests.rs b/crates/ui-egui/src/shell_tests.rs
index 2daf18131a..8efb2e1fa8 100644
--- a/crates/ui-egui/src/shell_tests.rs
+++ b/crates/ui-egui/src/shell_tests.rs
@@ -55,7 +55,7 @@ fn both_modes_keep_their_geometry_and_fit_clear_of_covered_rects() {
assert!(!layout.drawable.intersect(covered).is_positive(), "{layout:?} {covered:?}");
}
let projection = crate::viewport::projection(&h.app, viewport);
- for point in [solidcraft_engine::geom::Vec3::ZERO, solidcraft_engine::geom::Vec3::new(40.0, 30.0, 20.0)] {
+ for point in [solidcore_record::Vec3::ZERO, solidcore_record::Vec3::new(40.0, 30.0, 20.0)] {
assert!(layout.drawable.contains(projection.to_screen(point).unwrap()));
}
h.app.start("solid.extrude");
@@ -108,7 +108,7 @@ fn floating_sketch_palette_and_compass_share_measured_clearance() {
assert!(layout.viewport.expand(1.0).contains_rect(palette), "{palette:?} {layout:?}");
assert!(palette.contains(crate::scenario::handle_at("sketch_palette:look_at").unwrap()));
let proj = crate::viewport::projection(&h.app, layout.viewport);
- for point in [solidcraft_engine::geom::Vec3::ZERO, solidcraft_engine::geom::Vec3::new(20.0, 0.0, 0.0)] {
+ for point in [solidcore_record::Vec3::ZERO, solidcore_record::Vec3::new(20.0, 0.0, 0.0)] {
assert!(layout.drawable.contains(proj.to_screen(point).unwrap()), "{layout:?}");
}
if width > 1000.0 {
diff --git a/crates/ui-egui/src/sketch3d.rs b/crates/ui-egui/src/sketch3d.rs
index 21f2227343..d51e33026c 100644
--- a/crates/ui-egui/src/sketch3d.rs
+++ b/crates/ui-egui/src/sketch3d.rs
@@ -8,11 +8,12 @@
//! Everything runs `sketch.line3d`, `sketch.arc3d`, `sketch.spline3d`, `sketch.point3d`,
//! `sketch.move3d`, `sketch.line` and `sketch.arc.three_point`.
+use solidcraft_engine::geom::prelude::*;
use std::cell::RefCell;
use egui::{Pos2, Rect, Shape, Stroke, vec2};
use serde_json::{Value, json};
-use solidcraft_engine::geom::{Vec2, Vec3};
+use solidcore_record::{Vec2, Vec3};
use crate::SolveApp;
use crate::theme::Tokens;
diff --git a/crates/ui-egui/src/sketch3d_frame_ui_tests.rs b/crates/ui-egui/src/sketch3d_frame_ui_tests.rs
index ee15db7c8a..268526afbf 100644
--- a/crates/ui-egui/src/sketch3d_frame_ui_tests.rs
+++ b/crates/ui-egui/src/sketch3d_frame_ui_tests.rs
@@ -1,7 +1,8 @@
//! Real 3D drawing and triad input in a rotated second component occurrence.
use serde_json::json;
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
+use solidcraft_engine::geom::prelude::*;
#[test]
fn bridge_line_snaps_to_points_on_two_visible_sketch_planes() {
@@ -82,7 +83,7 @@ fn sketch_tools_never_pick_another_sketchs_point() {
);
let (at, id) = crate::viewport::sketch_point_at(&h.app, &proj, pos).unwrap();
assert!(id.is_none(), "sketch_3d={sketch_3d}: snapped to foreign point id {id:?}");
- assert!(at.dist(solidcraft_engine::geom::Vec2::new(10.0, 20.0)) < 0.5, "{at:?}");
+ assert!(at.dist(solidcore_record::Vec2::new(10.0, 20.0)) < 0.5, "{at:?}");
if !sketch_3d {
let before = h.app.session.world_state().unwrap().sketch(other).unwrap().sketch.clone();
// A real 2D line click there creates nothing tied to the other sketch's point.
diff --git a/crates/ui-egui/src/sketch_attachment_ui.rs b/crates/ui-egui/src/sketch_attachment_ui.rs
index fe6a6b842a..316f70e33a 100644
--- a/crates/ui-egui/src/sketch_attachment_ui.rs
+++ b/crates/ui-egui/src/sketch_attachment_ui.rs
@@ -2,10 +2,11 @@
use egui::RichText;
use serde_json::{Value, json};
+use solidcore_record::{Plane, Vec3};
use solidcraft_engine::Sel;
use solidcraft_engine::doc::face_anchor::plane_face_anchor;
use solidcraft_engine::doc::{EmbossFace, FaceAttachmentStatus, FeatureKind, PlaneRef, mat_inverse};
-use solidcraft_engine::geom::{Plane, Vec3};
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::theme::Tokens;
diff --git a/crates/ui-egui/src/sketch_attachment_ui_tests.rs b/crates/ui-egui/src/sketch_attachment_ui_tests.rs
index 19f75d41c0..600c234f72 100644
--- a/crates/ui-egui/src/sketch_attachment_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_attachment_ui_tests.rs
@@ -1,6 +1,7 @@
use crate::scenario::Harness;
use serde_json::{Value, json};
use solidcraft_engine::doc::{FaceAttachmentStatus, FeatureKind, PlaneRef};
+use solidcraft_engine::geom::prelude::*;
fn picked_sketch() -> (Harness, u64) {
let mut h = Harness::new();
@@ -249,9 +250,9 @@ fn actual_nested_second_placement_face_pick_keeps_target_and_author_paths() {
#[test]
fn nested_anchor_saved_fixed_conversion_preserves_rotated_second_author_plane() {
+ use solidcore_record::Plane;
+ use solidcore_record::Vec3;
use solidcraft_engine::doc::{EmbossFace, apply_point, apply_vector};
- use solidcraft_engine::geom::Plane;
- use solidcraft_engine::geom::Vec3;
let mut h = Harness::new();
h.app.session.auto_project = false;
let created = h.app.run("component.create", json!({"name":"Author"})).unwrap();
diff --git a/crates/ui-egui/src/sketch_centre_align_ui_tests.rs b/crates/ui-egui/src/sketch_centre_align_ui_tests.rs
index eee3e56b04..47767935d7 100644
--- a/crates/ui-egui/src/sketch_centre_align_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_centre_align_ui_tests.rs
@@ -4,8 +4,9 @@
//! silently did nothing.
use serde_json::json;
+use solidcore_record::Vec2;
use solidcraft_engine::Sel::{SketchCurve, SketchPoint};
-use solidcraft_engine::geom::Vec2;
+use solidcraft_engine::geom::prelude::*;
use crate::context_menu::{self, Target};
use crate::scenario::Harness;
diff --git a/crates/ui-egui/src/sketch_construction.rs b/crates/ui-egui/src/sketch_construction.rs
index e5d2b6e8ff..d9715bab7e 100644
--- a/crates/ui-egui/src/sketch_construction.rs
+++ b/crates/ui-egui/src/sketch_construction.rs
@@ -2,8 +2,9 @@
use egui::Stroke;
use serde_json::{Value, json};
+use solidcore_record::Vec2;
use solidcraft_engine::cmd::{construction_line_choice, construction_line_mode, construction_line_solutions, construction_segment};
-use solidcraft_engine::geom::Vec2;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::tools::Tool;
diff --git a/crates/ui-egui/src/sketch_construction_tests.rs b/crates/ui-egui/src/sketch_construction_tests.rs
index 8154f61c1c..ff06ec860b 100644
--- a/crates/ui-egui/src/sketch_construction_tests.rs
+++ b/crates/ui-egui/src/sketch_construction_tests.rs
@@ -1,5 +1,6 @@
use crate::scenario::Harness;
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::sketch::CurveKind;
fn sketch() -> Harness {
@@ -74,7 +75,7 @@ fn construction_angle_accepts_inline_value_and_undo_is_one_step() {
dim.locked = true;
dim.value = "30 deg".into();
let mut tool = h.app.tool.take().unwrap();
- super::place_point(&mut h.app, &mut tool, (solidcraft_engine::geom::Vec2::new(15., 15.), None));
+ super::place_point(&mut h.app, &mut tool, (solidcore_record::Vec2::new(15., 15.), None));
let sid = h.app.session.active_sketch.unwrap();
let sk = h.app.session.doc.sketch(sid).unwrap();
let curve = sk.curves.last().unwrap();
@@ -182,9 +183,9 @@ fn a_typed_length_makes_two_clicks_draw_a_dimensioned_segment() {
assert!(!curve.infinite && curve.construction, "{id}: {curve:?}");
let CurveKind::Line { a, b } = curve.kind else { panic!("{id}: a line") };
let (a, b) = (sk.point(a).unwrap(), sk.point(b).unwrap());
- assert!(a.dist(solidcraft_engine::geom::Vec2::new(start[0], start[1])) < 1e-6, "{id}: starts at the snapped point {a:?}");
+ assert!(a.dist(solidcore_record::Vec2::new(start[0], start[1])) < 1e-6, "{id}: starts at the snapped point {a:?}");
assert!((a.dist(b) - 8.0).abs() < 1e-6, "{id}: {a:?} {b:?}");
- let s = solidcraft_engine::geom::Vec2::new(side[0], side[1]);
+ let s = solidcore_record::Vec2::new(side[0], side[1]);
assert!((b - a).dot(s - a) > 0.0, "{id}: runs towards the side clicked");
assert!(sk.constraints.iter().any(|c| matches!(c.kind, solidcraft_engine::sketch::ConstraintKind::Length { .. })), "{id}");
let tool = h.app.tool.as_ref().unwrap();
diff --git a/crates/ui-egui/src/sketch_corner_ui_tests.rs b/crates/ui-egui/src/sketch_corner_ui_tests.rs
index 2c12320418..bb80a21f76 100644
--- a/crates/ui-egui/src/sketch_corner_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_corner_ui_tests.rs
@@ -985,7 +985,7 @@ fn corner_candidates_agree_with_engine_spatial_curve_filter() {
for id in [&line, &spline, &linked, &"side".to_owned()] {
let state = crate::open_meshing::session_world(&h.app.session);
let sk = &state.sketch(sketch).unwrap().sketch;
- let hit = Hit::SketchCurve { sketch, id: id.clone(), straight: true, point: solidcraft_engine::geom::Vec3::ZERO };
+ let hit = Hit::SketchCurve { sketch, id: id.clone(), straight: true, point: solidcore_record::Vec3::ZERO };
let offered = candidate(h.app.dialog.as_ref().unwrap(), &h.app.session, &hit).is_some();
assert_eq!(offered, !sk.is_spatial_corner_curve(id), "{cmd}: {id}");
assert_eq!(offered, id == "side", "{cmd}: {id}");
diff --git a/crates/ui-egui/src/sketch_dims.rs b/crates/ui-egui/src/sketch_dims.rs
index 458a734d68..21e507131d 100644
--- a/crates/ui-egui/src/sketch_dims.rs
+++ b/crates/ui-egui/src/sketch_dims.rs
@@ -8,9 +8,10 @@
use crate::ui_kit::{Container, Surface};
use egui::{Pos2, vec2};
use serde_json::{Value, json};
+use solidcore_record::Vec2;
use solidcraft_engine::doc::Document;
use solidcraft_engine::doc::expr::{Kind as ValueKind, definition};
-use solidcraft_engine::geom::Vec2;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::theme::Tokens;
diff --git a/crates/ui-egui/src/sketch_dims_tests.rs b/crates/ui-egui/src/sketch_dims_tests.rs
index 8259adc595..4f5b7d18c2 100644
--- a/crates/ui-egui/src/sketch_dims_tests.rs
+++ b/crates/ui-egui/src/sketch_dims_tests.rs
@@ -1,6 +1,7 @@
//! Real keyboard input must stay inside the dimensions of the shape being drawn.
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
use super::{BOX, in_view};
use crate::scenario::Harness;
@@ -169,7 +170,7 @@ fn two_point_circle_takes_a_typed_diameter() {
assert!(sk.radius(0).is_some_and(|r| (r - 15.0).abs() < 1e-6), "{:?}", sk.radius(0));
let c = sk.center(0).unwrap();
// From the first point (the origin) toward the cursor at (20, 10).
- let dir = solidcraft_engine::geom::Vec2::new(20.0, 10.0).normalized().unwrap();
+ let dir = solidcore_record::Vec2::new(20.0, 10.0).normalized().unwrap();
assert!((c - dir * 15.0).len() < 1e-6, "{c:?}");
}
@@ -196,7 +197,7 @@ fn an_ellipse_takes_a_typed_major_and_minor_radius() {
let CurveKind::Ellipse { c, m, r } = sk.curves[0].kind.clone() else { panic!("{:?}", sk.curves[0].kind) };
let (c, m) = (sk.point(c).unwrap(), sk.point(m).unwrap());
// From the centre (the origin) toward the cursor at (20, 10).
- let dir = solidcraft_engine::geom::Vec2::new(20.0, 10.0).normalized().unwrap();
+ let dir = solidcore_record::Vec2::new(20.0, 10.0).normalized().unwrap();
assert!(c.len() < 1e-6 && (m - dir * 25.0).len() < 1e-6, "{c:?} {m:?}");
assert!((r - 8.0).abs() < 1e-6, "{r}");
let doc = &h.app.session.doc;
@@ -266,7 +267,7 @@ fn a_typed_rho_shapes_the_conic_whose_apex_is_placed_next() {
.expect("the typed value placed a conic");
assert!((rho - 0.8).abs() < 1e-9, "typed rho reached the command: {rho}");
// The apex lands where the cursor was, within the pixel the cursor was converted through.
- assert!(sketch.point(apex).unwrap().dist(solidcraft_engine::geom::Vec2::new(20.0, 20.0)) < 0.5, "{:?}", sketch.point(apex));
+ assert!(sketch.point(apex).unwrap().dist(solidcore_record::Vec2::new(20.0, 20.0)) < 0.5, "{:?}", sketch.point(apex));
}
/// A rho the command would refuse stays in its box to be corrected, and places nothing.
@@ -433,7 +434,7 @@ fn a_line_end_on_a_spline_snaps_on_it_and_stays_on_it() {
sk.constraints
);
let end = sk.point(b).unwrap();
- let to_segment = |a: solidcraft_engine::geom::Vec2, b: solidcraft_engine::geom::Vec2| {
+ let to_segment = |a: solidcore_record::Vec2, b: solidcore_record::Vec2| {
let ab = b - a;
let t = ((end - a).dot(ab) / ab.len2().max(1e-300)).clamp(0.0, 1.0);
(a + ab * t).dist(end)
@@ -449,7 +450,7 @@ fn a_line_end_on_a_spline_snaps_on_it_and_stays_on_it() {
/// snaps to horizontal or vertical, so the click must place exactly that line, on the circle.
#[test]
fn a_line_end_on_a_circle_within_the_axis_snap_lands_on_the_quadrant_the_preview_shows() {
- use solidcraft_engine::geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_engine::sketch::{ConstraintKind, CurveKind};
let r = 30.0_f64;
for (deg, end, horizontal) in [(-1.5_f64, Vec2::new(r, 0.0), true), (91.8, Vec2::new(0.0, r), false), (178.0, Vec2::new(-r, 0.0), true)] {
@@ -493,7 +494,7 @@ fn a_line_end_on_a_circle_within_the_axis_snap_lands_on_the_quadrant_the_preview
/// Outside the axis snap a line end on a circle stays where the cursor meets the circle.
#[test]
fn a_line_end_on_a_circle_outside_the_axis_snap_stays_at_the_cursor() {
- use solidcraft_engine::geom::Vec2;
+ use solidcore_record::Vec2;
use solidcraft_engine::sketch::CurveKind;
let mut h = Harness::new();
h.app.run("sketch.create", json!({"plane": "XY"})).unwrap();
diff --git a/crates/ui-egui/src/sketch_display.rs b/crates/ui-egui/src/sketch_display.rs
index aae677edd2..3c186af8f1 100644
--- a/crates/ui-egui/src/sketch_display.rs
+++ b/crates/ui-egui/src/sketch_display.rs
@@ -1,10 +1,11 @@
//! Display-only sampling. CAD curves, profiles and constraints are never changed here.
+use solidcraft_engine::geom::prelude::*;
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
use std::sync::Arc;
+use solidcore_record::{Loop2, Plane, Region2, Vec2, Vec3};
use solidcraft_engine::doc::ModelState;
-use solidcraft_engine::geom::{Loop2, Plane, Region2, Vec2, Vec3};
use solidcraft_engine::render::{PixelCurveView, SampledPath, SamplingBudget, SamplingQuality, sample_segment, sample_segment_unclipped};
use solidcraft_engine::sketch::Sketch;
@@ -29,8 +30,8 @@ pub fn pixel_view(proj: &Proj, ppp: f32) -> PixelCurveView {
/// The pieces a curve is drawn and picked from. An infinite line (#1359) reaches across the whole
/// view: through the point of its line nearest the view's centre, far past the view each way
/// (the sampler clips it to the view). Only the display changes: the line keeps its two points.
-fn display_segs(sketch: &Sketch, index: usize, plane: &Plane, proj: &Proj) -> Vec<solidcraft_engine::geom::Seg2> {
- use solidcraft_engine::geom::Seg2;
+fn display_segs(sketch: &Sketch, index: usize, plane: &Plane, proj: &Proj) -> Vec<solidcore_record::Seg2> {
+ use solidcore_record::Seg2;
let segs = sketch.exact_segs(index).unwrap_or_else(|| sketch.segs(index));
if !sketch.curves.get(index).is_some_and(|c| c.infinite) {
return segs;
diff --git a/crates/ui-egui/src/sketch_display_preview_tests.rs b/crates/ui-egui/src/sketch_display_preview_tests.rs
index 1156f1b871..9f6160adc0 100644
--- a/crates/ui-egui/src/sketch_display_preview_tests.rs
+++ b/crates/ui-egui/src/sketch_display_preview_tests.rs
@@ -2,7 +2,8 @@ use super::{Tool, polygon_outline, preview_curve};
use crate::scenario::Harness;
use crate::viewport::Proj;
use serde_json::{Value, json};
-use solidcraft_engine::geom::{Plane, Vec2, Vec3};
+use solidcore_record::{Plane, Vec2, Vec3};
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::render::{Camera, Mat4};
use solidcraft_engine::sketch::Sketch;
@@ -11,7 +12,7 @@ fn tool(command: &str, points: &[[f64; 2]]) -> Tool {
tool.pts = points.iter().map(|p| (Vec2::new(p[0], p[1]), None)).collect();
tool
}
-fn spans(sk: &Sketch) -> Vec<solidcraft_engine::geom::Seg2> {
+fn spans(sk: &Sketch) -> Vec<solidcore_record::Seg2> {
sk.exact_segs(0).unwrap_or_else(|| sk.segs(0))
}
fn projection(scale: f64) -> Proj {
@@ -270,7 +271,7 @@ fn typed_small_slot_width_preview_matches_the_final_click() {
let state = h.app.session.world_state().unwrap();
let committed = &state.sketch(h.app.session.active_sketch.unwrap()).unwrap().sketch;
assert_eq!(committed.curves.len(), 4, "{command}: final click commits the typed width");
- let solidcraft_engine::geom::Seg2::Arc { radius, .. } = committed.segs(1)[0] else { panic!("missing slot cap") };
+ let solidcore_record::Seg2::Arc { radius, .. } = committed.segs(1)[0] else { panic!("missing slot cap") };
assert!((radius - 0.00005).abs() < 1e-10, "{command}: the typed width determines the cap radius");
let mut output = ctx.run_ui(input(), |ui| {
super::paint_preview_curve(committed.clone(), &Plane::XY, ui.painter(), &proj, egui::Stroke::new(1.5, egui::Color32::WHITE), 0);
diff --git a/crates/ui-egui/src/sketch_display_ui_tests.rs b/crates/ui-egui/src/sketch_display_ui_tests.rs
index 268833f7f2..26b03b8432 100644
--- a/crates/ui-egui/src/sketch_display_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_display_ui_tests.rs
@@ -3,7 +3,8 @@ use crate::scenario::Harness;
use crate::sketch_display::{curve_sample, projection_key};
use crate::viewport::{Hit, Proj, pick, projection};
use serde_json::json;
-use solidcraft_engine::geom::{Plane, Vec2, Vec3};
+use solidcore_record::{Plane, Vec2, Vec3};
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::render::{SampledPath, SamplingQuality};
use std::sync::Arc;
@@ -162,10 +163,7 @@ fn pixel_adapter_uses_exact_ellipse_periodic_fit_and_control_spline_spans() {
let state = h.app.session.world_state().unwrap();
let ss = state.sketch(sid).unwrap();
let exact = ss.sketch.exact_segs(0).unwrap();
- assert!(
- exact.iter().all(|s| !matches!(s, solidcraft_engine::geom::Seg2::Line { .. })),
- "freeform display must reach the exact span extractor"
- );
+ assert!(exact.iter().all(|s| !matches!(s, solidcore_record::Seg2::Line { .. })), "freeform display must reach the exact span extractor");
let proj = projection(&h.app, h.app.viewport.rect.unwrap());
let path = curve_sample(&h.app, sid, 0, &ss.plane, &proj);
assert_eq!(path.quality, SamplingQuality::Complete, "{command}");
diff --git a/crates/ui-egui/src/sketch_drag_ui_tests.rs b/crates/ui-egui/src/sketch_drag_ui_tests.rs
index 6e3578c562..e215c93d6a 100644
--- a/crates/ui-egui/src/sketch_drag_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_drag_ui_tests.rs
@@ -2,8 +2,9 @@
//! brings the model up to date in the drag's one undo step, and the grab stays on the geometry.
use serde_json::{Value, json};
+use solidcore_record::Vec2;
use solidcraft_engine::Sel;
-use solidcraft_engine::geom::Vec2;
+use solidcraft_engine::geom::prelude::*;
use crate::scenario::Harness;
use crate::test_support::play;
diff --git a/crates/ui-egui/src/sketch_guidance_ui_tests.rs b/crates/ui-egui/src/sketch_guidance_ui_tests.rs
index fb5b1d6d6f..45404e4763 100644
--- a/crates/ui-egui/src/sketch_guidance_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_guidance_ui_tests.rs
@@ -3,8 +3,9 @@ use crate::scenario::Harness;
use crate::sketch_modify_ui::{Mod, candidate};
use crate::viewport::Hit;
use serde_json::{Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
fn step(h: &mut Harness, value: Value) {
h.step(&value).unwrap();
@@ -163,7 +164,7 @@ fn sketch_modify_inputs_refuse_other_sketches_without_changing_hole_points() {
h.app.start(command);
let d = h.app.dialog.as_ref().unwrap();
assert!(candidate(d, &h.app.session, &Hit::SketchCurve { sketch: 2, id: "l1".into(), straight: true, point: Vec3::ZERO }).is_none());
- assert!(candidate(d, &h.app.session, &Hit::SketchPoint { sketch: 2, id: "p1".into(), at: solidcraft_engine::geom::Vec2::ZERO }).is_none());
+ assert!(candidate(d, &h.app.session, &Hit::SketchPoint { sketch: 2, id: "p1".into(), at: solidcore_record::Vec2::ZERO }).is_none());
if command != "sketch.offset" {
assert!(d.inputs[0].accept & crate::selection::SKETCH_POINTS != 0);
assert_eq!(d.inputs[0].accept & crate::selection::POINTS, 0);
@@ -171,7 +172,7 @@ fn sketch_modify_inputs_refuse_other_sketches_without_changing_hole_points() {
}
let input = crate::selection::SelInput::new("Hole points", crate::selection::POINTS, true);
assert_eq!(
- input.accepts(&Hit::SketchPoint { sketch: 2, id: "p1".into(), at: solidcraft_engine::geom::Vec2::ZERO }, None, |_, _| false),
+ input.accepts(&Hit::SketchPoint { sketch: 2, id: "p1".into(), at: solidcore_record::Vec2::ZERO }, None, |_, _| false),
Some(Sel::SketchPoint { id: "2:p1".into() })
);
h.app.start("sketch.pattern.circular");
@@ -191,7 +192,7 @@ fn sketch_preselected_points_toggle_once_and_empty_shift_box_keeps_reference() {
let d = h.app.dialog.as_mut().unwrap();
assert_eq!(d.inputs[0].items, vec![Sel::SketchPoint { id: point.clone() }]);
d.active = 0;
- let selected = candidate(d, &h.app.session, &Hit::SketchPoint { sketch: 1, id: point, at: solidcraft_engine::geom::Vec2::ZERO }).unwrap();
+ let selected = candidate(d, &h.app.session, &Hit::SketchPoint { sketch: 1, id: point, at: solidcore_record::Vec2::ZERO }).unwrap();
d.pick(&h.app.session, selected);
assert!(d.inputs[0].items.is_empty(), "clicking a preselection removes it instead of duplicating it");
d.active = 1;
@@ -284,7 +285,7 @@ fn tracking_fixture() -> Harness {
#[test]
fn centre_and_midpoint_tracking_is_visual_in_idle_and_drawing_modes() {
- use solidcraft_engine::geom::Vec2;
+ use solidcore_record::Vec2;
let mut h = tracking_fixture();
let before = h.app.session.doc.to_json();
let undo = h.app.session.undo.len();
@@ -311,7 +312,7 @@ fn centre_and_midpoint_tracking_is_visual_in_idle_and_drawing_modes() {
/// midpoint does; idle hovering and the preference turned off keep the old centre/MID-only guides.
#[test]
fn a_corner_starts_a_guide_while_drawing_unless_turned_off() {
- use solidcraft_engine::geom::Vec2;
+ use solidcore_record::Vec2;
let mut h = tracking_fixture();
assert!(h.app.preferences.sketch_tracking_points, "on by default");
let before = h.app.session.doc.to_json();
@@ -340,7 +341,7 @@ fn a_corner_starts_a_guide_while_drawing_unless_turned_off() {
#[test]
fn a_rectangle_snaps_to_an_infinite_line_crossing() {
- use solidcraft_engine::geom::Vec2;
+ use solidcore_record::Vec2;
let mut h = Harness::new();
h.app.preferences.look_at_anim = false;
for (command, params) in [
@@ -365,7 +366,7 @@ fn a_rectangle_snaps_to_an_infinite_line_crossing() {
#[test]
fn two_recent_midpoints_snap_where_their_guides_meet() {
- use solidcraft_engine::geom::Vec2;
+ use solidcore_record::Vec2;
let mut h = tracking_fixture();
// Grid snap at this zoom already rounds a nearby cursor onto the origin. Snap off leaves
// the cursor where it is, so only the remembered crossing can pull it to (0, 0).
@@ -486,7 +487,7 @@ fn point_and_alignments(h: &Harness, at: [f64; 2]) -> Option<(String, Vec<(&'sta
use solidcraft_engine::sketch::ConstraintKind::{HorizontalPoints, VerticalPoints};
let st = crate::open_meshing::session_world(&h.app.session);
let sk = &st.sketch(h.app.session.active_sketch?)?.sketch;
- let at = solidcraft_engine::geom::Vec2::new(at[0], at[1]);
+ let at = solidcore_record::Vec2::new(at[0], at[1]);
let i = sk.points.iter().position(|p| p.pos.dist(at) < 1e-9)?;
let id = |k: usize| sk.points.get(k).map(|p| p.id.clone()).unwrap_or_default();
let tied = sk
@@ -504,7 +505,7 @@ fn point_and_alignments(h: &Harness, at: [f64; 2]) -> Option<(String, Vec<(&'sta
#[test]
fn line_up_takes_the_nearest_point_on_each_axis_on_its_own() {
use crate::sketch_tools::{Lined, line_up};
- use solidcraft_engine::geom::Vec2;
+ use solidcore_record::Vec2;
let points = [(Some("a".to_string()), Vec2::new(0.0, 10.4)), (Some("b".to_string()), Vec2::new(50.3, -30.0)), (None, Vec2::new(5.0, 10.2))];
let (level, plumb) = line_up(&points, Vec2::new(50.0, 10.0), 0.5);
assert_eq!(level, Some(Lined { id: None, at: Vec2::new(5.0, 10.2), horizontal: true }), "the nearer of the two level points");
diff --git a/crates/ui-egui/src/sketch_line_arc.rs b/crates/ui-egui/src/sketch_line_arc.rs
index 5e194efd12..7245a59a33 100644
--- a/crates/ui-egui/src/sketch_line_arc.rs
+++ b/crates/ui-egui/src/sketch_line_arc.rs
@@ -5,7 +5,8 @@
use egui::{Pos2, Stroke};
use serde_json::{Value, json};
-use solidcraft_engine::geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::sketch::Sketch;
use crate::SolveApp;
diff --git a/crates/ui-egui/src/sketch_modify_ui.rs b/crates/ui-egui/src/sketch_modify_ui.rs
index d3a13a981f..8f8a702b01 100644
--- a/crates/ui-egui/src/sketch_modify_ui.rs
+++ b/crates/ui-egui/src/sketch_modify_ui.rs
@@ -28,10 +28,11 @@
use egui::Pos2;
use serde_json::{Map, Value, json};
+use solidcore_record::{Vec2, Vec3};
use solidcraft_engine::Sel;
use solidcraft_engine::doc::Document;
use solidcraft_engine::doc::expr::Kind as ValueKind;
-use solidcraft_engine::geom::{Vec2, Vec3};
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::sketch::{PatternAlignment, VariableUnit};
use crate::SolveApp;
diff --git a/crates/ui-egui/src/sketch_modify_ui_tests.rs b/crates/ui-egui/src/sketch_modify_ui_tests.rs
index 327fe0d23c..3958145db9 100644
--- a/crates/ui-egui/src/sketch_modify_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_modify_ui_tests.rs
@@ -10,6 +10,7 @@
use serde_json::json;
use solidcraft_engine::Sel;
+use solidcraft_engine::geom::prelude::*;
use crate::dialogs::{Kind, apply_commands};
use crate::scenario::Harness;
@@ -662,11 +663,11 @@ fn the_spacing_gets_a_canvas_arrow_along_the_pattern_direction() {
h.app.dialog.as_mut().unwrap().inputs[0].items = vec![Sel::SketchCurve { id, sketch: None }];
let d = h.app.dialog.clone().unwrap();
let (_, dir) = crate::canvas::anchor(&h.app, &d).expect("an anchor on the picked curve");
- assert_eq!(dir, Some(solidcraft_engine::geom::Vec3::X));
+ assert_eq!(dir, Some(solidcore_record::Vec3::X));
h.app.dialog.as_mut().unwrap().inputs[1].items = vec![Sel::Axis { name: "Y".into() }];
let d = h.app.dialog.clone().unwrap();
let (_, dir) = crate::canvas::anchor(&h.app, &d).expect("an anchor on the picked curve");
- assert_eq!(dir, Some(solidcraft_engine::geom::Vec3::Y));
+ assert_eq!(dir, Some(solidcore_record::Vec3::Y));
}
/// Dragging a spacing arrow past its start flips the direction, as typing a negative spacing does
diff --git a/crates/ui-egui/src/sketch_moving_click_tests.rs b/crates/ui-egui/src/sketch_moving_click_tests.rs
index ba5e3919cc..640c564982 100644
--- a/crates/ui-egui/src/sketch_moving_click_tests.rs
+++ b/crates/ui-egui/src/sketch_moving_click_tests.rs
@@ -4,6 +4,7 @@
use crate::scenario::Harness;
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::sketch::CurveKind;
fn harness(command: &str) -> Harness {
@@ -55,7 +56,7 @@ fn clicks_that_move_place_their_points() {
// The points went where the button was let go: the first one is at its spot.
let sid = h.app.session.active_sketch.unwrap();
let sk = h.app.session.model.state().sketch(sid).unwrap().sketch.clone();
- let first = solidcraft_engine::geom::Vec2::new(points[0][0], points[0][1]);
+ let first = solidcore_record::Vec2::new(points[0][0], points[0][1]);
// (A three-point circle keeps only its centre: through all three, its radius is 20.)
let through = sk.curves.iter().any(|c| matches!(c.kind, CurveKind::Circle { r, .. } if (r - 20.0).abs() < 0.5));
assert!(sk.points.iter().any(|p| (p.pos - first).len() < 0.5) || through, "{command}: no point at {first:?}");
@@ -82,7 +83,7 @@ fn a_short_drag_starts_a_rectangle_circle_or_polygon_by_clicks() {
assert_eq!(curves(&h), count, "{command}: {:?}", h.app.status);
let sid = h.app.session.active_sketch.unwrap();
let sk = h.app.session.model.state().sketch(sid).unwrap().sketch.clone();
- let far = solidcraft_engine::geom::Vec2::new(second[0], second[1]);
+ let far = solidcore_record::Vec2::new(second[0], second[1]);
let circle = |c: &solidcraft_engine::sketch::Curve| matches!(c.kind, CurveKind::Circle { r, .. } if (r - far.len()).abs() < 0.5);
let on_shape = sk.points.iter().any(|p| (p.pos - far).len() < 0.5) || sk.curves.iter().any(circle);
assert!(on_shape, "{command}: the second click wasn't where it was let go");
@@ -98,7 +99,7 @@ fn drag(h: &mut Harness, from: [f64; 2], to: [f64; 2]) {
}
/// The lines of the sketch being edited, end to end.
-fn lines(h: &Harness) -> Vec<[solidcraft_engine::geom::Vec2; 2]> {
+fn lines(h: &Harness) -> Vec<[solidcore_record::Vec2; 2]> {
let sid = h.app.session.active_sketch.unwrap();
let sk = h.app.session.model.state().sketch(sid).unwrap().sketch.clone();
(0..sk.curves.len())
@@ -120,7 +121,7 @@ fn a_line_drag_draws_one_line_with_the_preference() {
drag(&mut h, [-20.0, 0.0], [20.0, 10.0]);
let drawn = lines(&h);
assert_eq!(drawn.len(), 1, "one line: {:?}", h.app.status);
- let near = |p: solidcraft_engine::geom::Vec2, q: [f64; 2]| (p - solidcraft_engine::geom::Vec2::new(q[0], q[1])).len() < 0.5;
+ let near = |p: solidcore_record::Vec2, q: [f64; 2]| (p - solidcore_record::Vec2::new(q[0], q[1])).len() < 0.5;
assert!(near(drawn[0][0], [-20.0, 0.0]) && near(drawn[0][1], [20.0, 10.0]), "from the press to the release: {drawn:?}");
let tool = h.app.tool.as_ref().expect("the Line tool stays on");
assert_eq!((tool.cmd, tool.pts.len()), ("sketch.line", 0), "no chain goes on from the line's end");
@@ -160,7 +161,7 @@ fn without_the_preference_a_line_drag_is_a_click_where_it_is_let_go() {
assert!(lines(&h).is_empty());
let tool = h.app.tool.as_ref().unwrap();
assert_eq!(tool.pts.len(), 1);
- assert!((tool.pts[0].0 - solidcraft_engine::geom::Vec2::new(20.0, 10.0)).len() < 0.5, "{:?}", tool.pts);
+ assert!((tool.pts[0].0 - solidcore_record::Vec2::new(20.0, 10.0)).len() < 0.5, "{:?}", tool.pts);
}
/// The preference saves, and the Sketch page's checkbox, Restore Defaults and Cancel treat it as
@@ -245,9 +246,7 @@ fn sketch(h: &Harness) -> solidcraft_engine::sketch::Sketch {
}
/// The arc last drawn: centre, radius and where it starts and ends as drawn.
-fn last_arc(
- sk: &solidcraft_engine::sketch::Sketch,
-) -> (solidcraft_engine::geom::Vec2, f64, solidcraft_engine::geom::Vec2, solidcraft_engine::geom::Vec2) {
+fn last_arc(sk: &solidcraft_engine::sketch::Sketch) -> (solidcore_record::Vec2, f64, solidcore_record::Vec2, solidcore_record::Vec2) {
let (index, curve) = sk.curves.iter().enumerate().rfind(|(_, c)| matches!(c.kind, CurveKind::Arc { .. })).expect("an arc");
let CurveKind::Arc { c, a, b } = curve.kind else { panic!("not an arc: {curve:?}") };
let centre = sk.point(c).unwrap();
@@ -285,9 +284,9 @@ fn a_rest_on_the_last_point_makes_the_next_click_a_tangent_arc_and_back_to_a_lin
assert_eq!(curves(&h), 2, "{:?}", h.app.status);
let sk = sketch(&h);
let (centre, radius, start, end) = last_arc(&sk);
- assert!(centre.dist(solidcraft_engine::geom::Vec2::new(0.0, 10.0)) < 1e-6, "centre {centre:?}");
+ assert!(centre.dist(solidcore_record::Vec2::new(0.0, 10.0)) < 1e-6, "centre {centre:?}");
assert!((radius - 10.0).abs() < 1e-6, "radius {radius}");
- assert!(start.dist(solidcraft_engine::geom::Vec2::ZERO) < 1e-6 && end.dist(solidcraft_engine::geom::Vec2::new(10.0, 10.0)) < 1e-6);
+ assert!(start.dist(solidcore_record::Vec2::ZERO) < 1e-6 && end.dist(solidcore_record::Vec2::new(10.0, 10.0)) < 1e-6);
let (line, arc) = (sk.curves.first().unwrap(), sk.curves.get(1).unwrap());
let shared = sk.resolve_point(&format!("{}.end", line.id)) == sk.resolve_point(&format!("{}.start", arc.id));
assert!(shared, "the arc starts on the line's own end");
@@ -508,10 +507,10 @@ fn arcs_follow_one_another_each_tangent_to_the_last_and_a_pause_after_one_switch
assert_eq!(curves(&h), 3, "{:?}", h.app.status);
let sk = sketch(&h);
let (centre, radius, start, end) = last_arc(&sk);
- assert!(centre.dist(solidcraft_engine::geom::Vec2::new(20.0, 10.0)) < 1e-6, "centre {centre:?}");
+ assert!(centre.dist(solidcore_record::Vec2::new(20.0, 10.0)) < 1e-6, "centre {centre:?}");
assert!((radius - 10.0).abs() < 1e-6, "radius {radius}");
assert!(
- start.dist(solidcraft_engine::geom::Vec2::new(10.0, 10.0)) < 1e-6 && end.dist(solidcraft_engine::geom::Vec2::new(20.0, 20.0)) < 1e-6,
+ start.dist(solidcore_record::Vec2::new(10.0, 10.0)) < 1e-6 && end.dist(solidcore_record::Vec2::new(20.0, 20.0)) < 1e-6,
"from {start:?} to {end:?}"
);
assert!(
diff --git a/crates/ui-egui/src/sketch_shortcut_tests.rs b/crates/ui-egui/src/sketch_shortcut_tests.rs
index 95b7fbb613..dcacb185f3 100644
--- a/crates/ui-egui/src/sketch_shortcut_tests.rs
+++ b/crates/ui-egui/src/sketch_shortcut_tests.rs
@@ -2,12 +2,13 @@ use crate::scenario::Harness;
use serde_json::json;
use solidcraft_engine::Sel;
use solidcraft_engine::doc::{FeatureKind, PlaneRef};
+use solidcraft_engine::geom::prelude::*;
fn tool(h: &Harness) -> Option<&str> {
h.app.tool.as_ref().map(|t| t.cmd)
}
-fn normal(h: &Harness) -> solidcraft_engine::geom::Vec3 {
+fn normal(h: &Harness) -> solidcore_record::Vec3 {
let active = h.app.session.active_sketch;
h.app.session.world_state().unwrap().sketches.iter().find(|s| Some(s.feature) == active).map(|s| s.plane.normal()).unwrap_or_default()
}
diff --git a/crates/ui-egui/src/sketch_side_ui_tests.rs b/crates/ui-egui/src/sketch_side_ui_tests.rs
index cfd029aed2..8106e647df 100644
--- a/crates/ui-egui/src/sketch_side_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_side_ui_tests.rs
@@ -3,8 +3,9 @@
use crate::scenario::Harness;
use serde_json::json;
+use solidcore_record::{Plane, Vec3};
use solidcraft_engine::doc::{FeatureKind, PlaneRef};
-use solidcraft_engine::geom::{Plane, Vec3};
+use solidcraft_engine::geom::prelude::*;
fn sketch_from(yaw: f64, pitch: f64, name: &str) -> (Harness, Vec3, Plane) {
let mut h = Harness::new();
diff --git a/crates/ui-egui/src/sketch_text.rs b/crates/ui-egui/src/sketch_text.rs
index 3b36713860..54cfd8daab 100644
--- a/crates/ui-egui/src/sketch_text.rs
+++ b/crates/ui-egui/src/sketch_text.rs
@@ -2,6 +2,7 @@
//! sketch text's outlines; OK runs `sketch.edit_text`. The canvas follows the fields as they
//! change (live `sketch.edit_text`); the whole edit is one undo step and Cancel puts the text
//! back. The Text tool places a text and opens this dialog on it, so a new text is typed here too.
+use solidcraft_engine::geom::prelude::*;
use std::sync::{Arc, OnceLock};
use serde_json::{Value, json};
@@ -345,7 +346,7 @@ pub(crate) fn open(app: &mut SolveApp, entity: &str) {
/// The Text tool's click: put a placeholder text down at `at` (sketch coordinates) and open
/// Edit Text on it, its text selected so that typing replaces it. Cancel takes it away again;
/// OK keeps it as one undo step.
-pub(crate) fn place(app: &mut SolveApp, at: solidcraft_engine::geom::Vec2, height: f64) {
+pub(crate) fn place(app: &mut SolveApp, at: solidcore_record::Vec2, height: f64) {
let Some(checkpoint) = app.session.execute("edit.checkpoint", &json!({})).ok().and_then(|r| r["checkpoint"].as_u64()) else { return };
let placed = app.run("sketch.text", json!({"text": PLACEHOLDER, "at": [at.x, at.y], "height": height}));
let curve = placed.as_ref().ok().and_then(|v| v["curves"].get(0)?.as_str().map(str::to_owned));
@@ -894,7 +895,7 @@ mod tests {
let sk = h.app.session.doc.sketch(sid).unwrap();
let expected = LinkSource::Text {
text: "O".into(),
- at: solidcraft_engine::geom::Vec2::new(25.0, 12.0),
+ at: solidcore_record::Vec2::new(25.0, 12.0),
height: 20.0,
angle: std::f64::consts::FRAC_PI_2,
font: None,
@@ -1314,7 +1315,7 @@ mod tests {
// A placeholder is down at once, Edit Text is open on it with the text selected, and the tool has ended.
assert!(editing(&h.app));
assert!(h.app.tool.is_none());
- let at = solidcraft_engine::geom::Vec2::new(5.0, 5.0);
+ let at = solidcore_record::Vec2::new(5.0, 5.0);
assert!(matches!(texts(&h).as_slice(), [LinkSource::Text { text, at: a, .. }] if text == PLACEHOLDER && a.dist(at) < 1e-9));
// Typing replaces it, and the canvas follows every key.
h.step(&json!({"text":"Hi"})).unwrap();
@@ -1445,7 +1446,7 @@ mod tests {
};
let whole = area(&h, &text_profiles(&h.app.session, sid, i).unwrap());
// The I's stem, below where the rectangle's top will cross it.
- let stem = solidcraft_engine::geom::Vec2::new(h.app.session.world_state().unwrap().sketch(sid).unwrap().profiles[i].centroid.x, 2.0);
+ let stem = solidcore_record::Vec2::new(h.app.session.world_state().unwrap().sketch(sid).unwrap().profiles[i].centroid.x, 2.0);
h.app.run("sketch.rectangle.two_point", json!({"p0":[-5,-5],"p1":[40,8]})).unwrap();
let state = h.app.session.world_state().unwrap();
let profiles = &state.sketch(sid).unwrap().profiles;
@@ -1454,7 +1455,7 @@ mod tests {
assert_eq!(picked[0], below);
assert!(picked.len() > 2, "the letters are cut in pieces: {picked:?}");
assert!((area(&h, &picked) - whole).abs() < 1e-5 * whole, "{} {whole}", area(&h, &picked));
- let round = solidcraft_engine::sketch::profile_at_point(profiles, solidcraft_engine::geom::Vec2::new(-3.0, -3.0)).unwrap();
+ let round = solidcraft_engine::sketch::profile_at_point(profiles, solidcore_record::Vec2::new(-3.0, -3.0)).unwrap();
assert!(text_profiles(&h.app.session, sid, round).is_none());
}
diff --git a/crates/ui-egui/src/sketch_text_handles.rs b/crates/ui-egui/src/sketch_text_handles.rs
index ba4a138b04..8244ea224e 100644
--- a/crates/ui-egui/src/sketch_text_handles.rs
+++ b/crates/ui-egui/src/sketch_text_handles.rs
@@ -4,11 +4,12 @@
//! `sketch.edit_text` live; the whole gesture is one undo step and Esc cancels it (the drag
//! shares [`crate::viewport::Viewport::text_drag`] with moving a text, so it ends and cancels
//! the same way). A drag from anywhere else inside the frame moves the text ([`grab_inside`]).
+use solidcraft_engine::geom::prelude::*;
use std::cell::RefCell;
use egui::{Align2, CursorIcon, FontId, Painter, Pos2, Rect, Stroke, StrokeKind, vec2};
use serde_json::json;
-use solidcraft_engine::geom::Vec2;
+use solidcore_record::Vec2;
use solidcraft_engine::sketch::{CurveKind, LinkKind, LinkSource};
use crate::SolveApp;
diff --git a/crates/ui-egui/src/sketch_text_move.rs b/crates/ui-egui/src/sketch_text_move.rs
index 608b85f9e4..dc2d0cf52f 100644
--- a/crates/ui-egui/src/sketch_text_move.rs
+++ b/crates/ui-egui/src/sketch_text_move.rs
@@ -96,6 +96,7 @@ pub(crate) fn end_drag(app: &mut SolveApp) {
mod tests {
use super::*;
use crate::scenario::Harness;
+ use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::sketch::LinkSource;
fn setup() -> (Harness, String) {
@@ -126,7 +127,7 @@ mod tests {
assert!(h.app.dialog.is_none());
let sk = h.app.session.doc.sketch(1).unwrap();
let LinkSource::Text { at, angle, text, .. } = &sk.link(&link).unwrap().source else { panic!() };
- assert!(at.dist(solidcraft_engine::geom::Vec2::new(28.4, 2.0)) < 1e-8);
+ assert!(at.dist(solidcore_record::Vec2::new(28.4, 2.0)) < 1e-8);
assert!((*angle - std::f64::consts::FRAC_PI_2).abs() < 1e-12);
assert_eq!(text, "II");
assert_eq!(h.app.session.undo.len(), undo + 1);
diff --git a/crates/ui-egui/src/sketch_tools.rs b/crates/ui-egui/src/sketch_tools.rs
index 1ec114ff5b..937334a0c5 100644
--- a/crates/ui-egui/src/sketch_tools.rs
+++ b/crates/ui-egui/src/sketch_tools.rs
@@ -5,11 +5,12 @@
use crate::icons::markers::glyph_icon;
use crate::icons::markers::glyph_letter;
+use solidcraft_engine::geom::prelude::*;
use std::cell::{Cell, RefCell};
use egui::{Pos2, Stroke};
use serde_json::{Value, json};
-use solidcraft_engine::geom::{Plane, Vec2, Vec3};
+use solidcore_record::{Plane, Vec2, Vec3};
use solidcraft_engine::kernel::Continuity;
use crate::SolveApp;
@@ -507,12 +508,7 @@ pub struct Lined {
/// The points the cursor can line up with: the sketch's visible points on screen (line ends,
/// centres, standalone points, the origin) and the shape's own points so far.
-fn align_targets(
- proj: &Proj,
- sk: &solidcraft_engine::sketch::Sketch,
- plane: &solidcraft_engine::geom::Plane,
- own: &[Vec2],
-) -> Vec<(Option<String>, Vec2)> {
+fn align_targets(proj: &Proj, sk: &solidcraft_engine::sketch::Sketch, plane: &solidcore_record::Plane, own: &[Vec2]) -> Vec<(Option<String>, Vec2)> {
let visible = solidcraft_engine::view::SketchPointVisibility::new(sk);
let on_screen = |p: Vec2| proj.to_screen(plane.to_world(p)).is_some_and(|q| proj.rect.contains(q));
let mut out: Vec<(Option<String>, Vec2)> =
@@ -590,7 +586,7 @@ pub fn refine_snap(
app: &SolveApp,
proj: &Proj,
sk: &solidcraft_engine::sketch::Sketch,
- plane: &solidcraft_engine::geom::Plane,
+ plane: &solidcore_record::Plane,
lp: Vec2,
) -> Option<(Vec2, Option<String>)> {
crate::inference::clear();
diff --git a/crates/ui-egui/src/sketch_transform_ui.rs b/crates/ui-egui/src/sketch_transform_ui.rs
index e7af6b7b94..11cb4e3312 100644
--- a/crates/ui-egui/src/sketch_transform_ui.rs
+++ b/crates/ui-egui/src/sketch_transform_ui.rs
@@ -4,8 +4,9 @@
//! Scale and Angle the window shows, and the entities are drawn where OK would put them.
use egui::{Pos2, Sense, Stroke, Vec2 as Screen, vec2};
+use solidcore_record::{Plane, Vec2};
use solidcraft_engine::Sel;
-use solidcraft_engine::geom::{Plane, Vec2};
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::dialogs::Kind;
diff --git a/crates/ui-egui/src/sketch_trim_drag_ui_tests.rs b/crates/ui-egui/src/sketch_trim_drag_ui_tests.rs
index 6596d87016..7576759e14 100644
--- a/crates/ui-egui/src/sketch_trim_drag_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_trim_drag_ui_tests.rs
@@ -3,7 +3,8 @@
//! the one piece under it.
use serde_json::{Value, json};
-use solidcraft_engine::geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::sketch::Shape;
use crate::scenario::Harness;
diff --git a/crates/ui-egui/src/sketch_typed_intent_tests.rs b/crates/ui-egui/src/sketch_typed_intent_tests.rs
index e141d68dfe..f4f4de8eb3 100644
--- a/crates/ui-egui/src/sketch_typed_intent_tests.rs
+++ b/crates/ui-egui/src/sketch_typed_intent_tests.rs
@@ -1,6 +1,7 @@
//! Keyboard-authored intent must survive stage transitions and later model edits.
use crate::scenario::Harness;
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::sketch::{ConstraintKind, CurveKind};
fn start(command: &str) -> Harness {
@@ -264,7 +265,7 @@ fn the_arc_end_pick_snaps_to_a_point_under_the_value_box() {
h.app.run("sketch.construction", json!({"curves":["l1"]})).unwrap();
h.call("ui.view", json!({"view":"top"}));
h.app.cam.distance = 60.0;
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(0.0, 5.0, 0.0);
+ h.app.cam.target = solidcore_record::Vec3::new(0.0, 5.0, 0.0);
h.settle();
h.step(&json!({"start":command})).unwrap();
for p in picks {
diff --git a/crates/ui-egui/src/smart_extrude.rs b/crates/ui-egui/src/smart_extrude.rs
index e8e9bb4ca1..a1a92b6758 100644
--- a/crates/ui-egui/src/smart_extrude.rs
+++ b/crates/ui-egui/src/smart_extrude.rs
@@ -17,8 +17,9 @@
//! distance changes nothing. Choosing an operation by hand ends the automatic choice for
//! the rest of the extrude.
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
-use solidcraft_engine::geom::Vec3;
+use solidcraft_engine::geom::prelude::*;
/// The extrude window's automatic state.
#[derive(Clone, Debug, Default, PartialEq)]
@@ -33,7 +34,7 @@ pub struct Smart {
pub target: Option<Sel>,
/// The profiles the taper handle's limits were last worked out for, and their radii
/// (`canvas::taper_radii`): too slow to work out every frame on a profile with many holes.
- pub taper_radii: Option<(Vec<solidcraft_engine::geom::Region2>, (f64, f64))>,
+ pub taper_radii: Option<(Vec<solidcore_record::Region2>, (f64, f64))>,
/// Where the extrude starts (its From Object and start offset) when the latch was decided.
pub start: serde_json::Value,
/// The bodies shown when the latch was decided (None: every one), as `shown_scope` gives them.
diff --git a/crates/ui-egui/src/smart_extrude_ui_tests.rs b/crates/ui-egui/src/smart_extrude_ui_tests.rs
index 99b5c23419..0f82b258f1 100644
--- a/crates/ui-egui/src/smart_extrude_ui_tests.rs
+++ b/crates/ui-egui/src/smart_extrude_ui_tests.rs
@@ -3,6 +3,7 @@
use crate::dialogs::{Dialog, Kind};
use crate::scenario::Harness;
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
const JOIN: usize = 1;
const CUT: usize = 2;
@@ -136,7 +137,7 @@ fn a_new_start_object_decides_the_operation_again() {
let b = st.bodies.first().expect("the box");
let bottom =
(0..64).find(|i| b.body.planar_face(*i).is_some_and(|p| p.normal().z < -0.99 && p.origin.z.abs() < 1e-9)).expect("the box's bottom face");
- let face = solidcraft_engine::Sel::Face { body: b.name.clone(), index: bottom, point: solidcraft_engine::geom::Vec3::new(10.0, 10.0, 0.0) };
+ let face = solidcraft_engine::Sel::Face { body: b.name.clone(), index: bottom, point: solidcore_record::Vec3::new(10.0, 10.0, 0.0) };
if let Some(d) = &mut h.app.dialog {
let mut from = crate::selection::SelInput::new("From Object", crate::selection::FACES | crate::selection::VERTICES, false);
from.items.push(face);
@@ -163,7 +164,7 @@ fn press_pull_drags_a_hole_wall() {
h.step(&json!({"call":"ui.view","params":{"view":"home"}})).unwrap();
h.step(&json!({"call":"ui.view","params":{"view":"fit"}})).unwrap();
h.settle();
- let p = solidcraft_engine::geom::Vec3::new(25.0, 15.0, 10.0);
+ let p = solidcore_record::Vec3::new(25.0, 15.0, 10.0);
h.app.session.selection = vec![solidcraft_engine::Sel::Face { body: "Body1".into(), index: wall, point: p }];
h.step(&json!({"start":"solid.press_pull"})).unwrap();
h.frames(2);
diff --git a/crates/ui-egui/src/space_mouse.rs b/crates/ui-egui/src/space_mouse.rs
index 7dd0a9145a..975475a48d 100644
--- a/crates/ui-egui/src/space_mouse.rs
+++ b/crates/ui-egui/src/space_mouse.rs
@@ -689,6 +689,7 @@ mod tests {
use super::*;
use crate::Services;
use solidcraft_engine::Session;
+ use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::render::Camera;
/// The camera math the page applies the motion with (`navigation::device`): `sketch` keeps
diff --git a/crates/ui-egui/src/stand_up.rs b/crates/ui-egui/src/stand_up.rs
index 2369468ef4..08e553162e 100644
--- a/crates/ui-egui/src/stand_up.rs
+++ b/crates/ui-egui/src/stand_up.rs
@@ -17,6 +17,7 @@
//! context menu's "Turn Up Axis" fixes it any time.
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::prefs::StandUpUnknown;
@@ -56,7 +57,7 @@ pub enum Upright {
/// The flat area of `mesh` facing down Z, facing down Y and facing up Y, looking at no more than
/// `budget` triangles.
pub fn flat_areas(mesh: &solidcraft_engine::geom::Mesh, budget: usize) -> [f64; 3] {
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
struct Face {
first: Vec3,
area: f64,
diff --git a/crates/ui-egui/src/sweep_dialog_tests.rs b/crates/ui-egui/src/sweep_dialog_tests.rs
index c94ccd0a6a..752506f778 100644
--- a/crates/ui-egui/src/sweep_dialog_tests.rs
+++ b/crates/ui-egui/src/sweep_dialog_tests.rs
@@ -4,9 +4,9 @@ use crate::dialogs::Kind;
use crate::dialogs_surface::Surf;
use crate::scenario::Harness;
use serde_json::json;
+use solidcore_record::Vec3;
use solidcraft_engine::Sel;
use solidcraft_engine::doc::{FeatureKind, SweepOrientation};
-use solidcraft_engine::geom::Vec3;
/// A square `Q` on XY and a path `P` 40 up the Z axis; the square's sketch id.
fn setup(h: &mut Harness) -> u64 {
diff --git a/crates/ui-egui/src/symmetry_pick_tests.rs b/crates/ui-egui/src/symmetry_pick_tests.rs
index 687375858e..f083e1f994 100644
--- a/crates/ui-egui/src/symmetry_pick_tests.rs
+++ b/crates/ui-egui/src/symmetry_pick_tests.rs
@@ -3,7 +3,8 @@
//! A constraint tool's pick may be a body's edge, a mirrored copy's too (#6348).
use serde_json::json;
-use solidcraft_engine::geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_engine::geom::prelude::*;
use crate::scenario::Harness;
@@ -112,7 +113,7 @@ fn collinear_with_an_edge_of_a_mirrored_body_projects_the_edge() {
h.app.run("solid.mirror", json!({"bodies":["Body1"],"plane":"YZ"})).unwrap();
h.app.run("sketch.create", json!({"plane":{"face":[70,25,20]},"name":"Top"})).unwrap();
h.app.run("sketch.line", json!({"points":[[-100,10],[-100,40]],"ids":["side"]})).unwrap();
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(-60.0, 25.0, 20.0);
+ h.app.cam.target = solidcore_record::Vec3::new(-60.0, 25.0, 20.0);
h.app.cam.distance = 300.0;
h.settle();
let sketch = h.app.session.active_sketch.unwrap();
diff --git a/crates/ui-egui/src/test_boat.rs b/crates/ui-egui/src/test_boat.rs
index 4683f20e9d..508198befc 100644
--- a/crates/ui-egui/src/test_boat.rs
+++ b/crates/ui-egui/src/test_boat.rs
@@ -9,10 +9,11 @@
//! camera takes (`navigation::device_camera`), so calibration, reassigned axes, invert, speed and
//! the zoom direction all show. Pan and zoom are held so the boat never leaves its box.
+use solidcraft_engine::geom::prelude::*;
use std::sync::OnceLock;
use egui::{Pos2, Rect, pos2};
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_engine::render::Camera;
use crate::space_mouse::DeviceMotion;
diff --git a/crates/ui-egui/src/timeline.rs b/crates/ui-egui/src/timeline.rs
index b4897f57ec..5b5b6d9dec 100644
--- a/crates/ui-egui/src/timeline.rs
+++ b/crates/ui-egui/src/timeline.rs
@@ -1522,11 +1522,11 @@ mod tests {
#[test]
fn construction_history_matches_the_tool_that_created_it() {
+ use solidcore_record::Vec3;
use solidcraft_engine::doc::{
FeatureKind, PlaneRef,
construct::{AxisDef, GeoRef, PointDef},
};
- use solidcraft_engine::geom::Vec3;
let point = || GeoRef::Point { p: Vec3::ZERO };
let reference = || Box::new(point());
let mut cases = Vec::new();
@@ -2014,9 +2014,9 @@ mod tests {
let names = solidcraft_engine::doc::naming::face_names(body);
let index = names.iter().position(|name| solidcraft_engine::doc::persistent_name::made_by(name) == Some(hole)).unwrap();
let plate = body.name.clone();
- h.app.viewport.hover = Some(crate::viewport::Hit::Face { body: plate.clone(), index, point: solidcraft_engine::geom::Vec3::ZERO });
+ h.app.viewport.hover = Some(crate::viewport::Hit::Face { body: plate.clone(), index, point: solidcore_record::Vec3::ZERO });
assert_eq!(crate::timeline::hovered_feature(&h.app), Some(hole), "left={left}: hovering the hole's face finds the hole");
- h.app.viewport.hover = Some(crate::viewport::Hit::Vertex { body: plate.clone(), point: solidcraft_engine::geom::Vec3::ZERO });
+ h.app.viewport.hover = Some(crate::viewport::Hit::Vertex { body: plate.clone(), point: solidcore_record::Vec3::ZERO });
assert_eq!(crate::timeline::hovered_feature(&h.app), Some(block), "left={left}: a vertex finds the feature that made its body");
h.app.viewport.hover = None;
diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs
index 97c216c204..0ac655f5d8 100644
--- a/crates/ui-egui/src/toolbar.rs
+++ b/crates/ui-egui/src/toolbar.rs
@@ -4354,7 +4354,7 @@ mod header_report_tests {
h.app.run("sketch.line", json!({"points":[[0,0],[20,0]]})).unwrap();
h.call("ui.view", json!({"view":"top"}));
h.app.cam.distance = 80.0;
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(10.0, 0.0, 0.0);
+ h.app.cam.target = solidcore_record::Vec3::new(10.0, 0.0, 0.0);
h.settle();
h.step(&json!({"start":"sketch.dimension"})).unwrap();
for point in [[0, 0, 0], [20, 0, 0], [10, 5, 0]] {
diff --git a/crates/ui-egui/src/tools.rs b/crates/ui-egui/src/tools.rs
index ca319e6b50..2ad2e9a436 100644
--- a/crates/ui-egui/src/tools.rs
+++ b/crates/ui-egui/src/tools.rs
@@ -3,7 +3,8 @@
use egui::{Pos2, Stroke};
use serde_json::{Value, json};
-use solidcraft_engine::geom::Vec2;
+use solidcore_record::Vec2;
+use solidcraft_engine::geom::prelude::*;
use crate::SolveApp;
use crate::tool_modifiers::{Audit, Scope, ToolModifiers};
@@ -803,7 +804,7 @@ pub(crate) fn projection_preselection(selection: &[solidcraft_engine::Sel]) -> O
/// `x` or `y` when the origin axis `name` is the active sketch's own x or y axis: along it, and
/// through the sketch's origin.
pub(crate) fn sketch_axis_of(app: &SolveApp, name: &str) -> Option<&'static str> {
- use solidcraft_engine::geom::Vec3;
+ use solidcore_record::Vec3;
let dir = match name {
"X" => Vec3::X,
"Y" => Vec3::Y,
@@ -912,7 +913,7 @@ pub fn finish(app: &mut SolveApp) {
/// Rubber-band preview of the shape being drawn.
pub(crate) fn paint_preview_curve(
mut sketch: solidcraft_engine::sketch::Sketch,
- plane: &solidcraft_engine::geom::Plane,
+ plane: &solidcore_record::Plane,
painter: &egui::Painter,
proj: &Proj,
stroke: Stroke,
@@ -931,7 +932,7 @@ pub(crate) fn paint_preview_curve(
crate::scenario::publish_count("tool_preview_curves", sketch.curves.len() as f64);
}
-pub(crate) fn paint_sketch_path(points: &[solidcraft_engine::geom::Vec3], mode: u8, painter: &egui::Painter, proj: &Proj, stroke: Stroke) {
+pub(crate) fn paint_sketch_path(points: &[solidcore_record::Vec3], mode: u8, painter: &egui::Painter, proj: &Proj, stroke: Stroke) {
if mode == 0 {
let screen: Vec<_> = points.iter().filter_map(|point| proj.to_screen(*point)).collect();
if screen.len() >= 2 {
@@ -950,7 +951,7 @@ pub(crate) fn paint_sketch_path(points: &[solidcraft_engine::geom::Vec3], mode:
pub(crate) fn paint_curve(
sketch: &solidcraft_engine::sketch::Sketch,
index: usize,
- plane: &solidcraft_engine::geom::Plane,
+ plane: &solidcore_record::Plane,
painter: &egui::Painter,
proj: &Proj,
stroke: Stroke,
diff --git a/crates/ui-egui/src/value_step_tests.rs b/crates/ui-egui/src/value_step_tests.rs
index d95fa440dd..b8c2592064 100644
--- a/crates/ui-egui/src/value_step_tests.rs
+++ b/crates/ui-egui/src/value_step_tests.rs
@@ -232,7 +232,7 @@ fn edge_flange(on: bool) -> Harness {
for (id, p) in crate::dialogs::apply_commands(&h.app, &d).unwrap() {
h.app.run(&id, p).unwrap();
}
- let edge = crate::dialogs::edge_sel(&h.app.session, solidcraft_engine::geom::Vec3::new(50.0, 0.0, 2.5)).unwrap();
+ let edge = crate::dialogs::edge_sel(&h.app.session, solidcore_record::Vec3::new(50.0, 0.0, 2.5)).unwrap();
h.app.session.selection = vec![edge];
h.step(&json!({"start": "sheet.flange"})).unwrap();
h.frames(6);
diff --git a/crates/ui-egui/src/view_home_tests.rs b/crates/ui-egui/src/view_home_tests.rs
index 2412edef29..cdba4c7c30 100644
--- a/crates/ui-egui/src/view_home_tests.rs
+++ b/crates/ui-egui/src/view_home_tests.rs
@@ -1,7 +1,9 @@
// Home and Fit frame what is shown now, and a middle-button double-click goes Home.
use crate::scenario::Harness;
use serde_json::json;
-use solidcraft_engine::geom::{Aabb3, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_engine::geom::Aabb3;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::render::StandardView;
/// A block drawn at the origin and extruded, then moved 500 mm along X: its sketch stays at the
diff --git a/crates/ui-egui/src/view_pick.rs b/crates/ui-egui/src/view_pick.rs
index 65b940581e..39b4d21658 100644
--- a/crates/ui-egui/src/view_pick.rs
+++ b/crates/ui-egui/src/view_pick.rs
@@ -12,13 +12,15 @@
//! `pixels_per_point`, offset by the viewport rect); `model` pixels are pixels of a
//! `ui.render` of the same size, so an agent can render, look, and pick without a window.
+use solidcraft_engine::geom::prelude::*;
use std::collections::HashMap;
use egui::{Pos2, Rect, pos2, vec2};
use serde_json::{Value, json};
+use solidcore_record::Vec3;
use solidcraft_engine::doc::{apply_point, is_identity};
-use solidcraft_engine::geom::{Mesh, Vec3};
+use solidcraft_engine::geom::Mesh;
use crate::SolveApp;
diff --git a/crates/ui-egui/src/view_pick_tests.rs b/crates/ui-egui/src/view_pick_tests.rs
index 3ca9e37350..f9a8028a9e 100644
--- a/crates/ui-egui/src/view_pick_tests.rs
+++ b/crates/ui-egui/src/view_pick_tests.rs
@@ -3,7 +3,7 @@
use serde_json::json;
-use solidcraft_engine::geom::Vec3;
+use solidcore_record::Vec3;
use solidcraft_engine::render::Camera;
use crate::scenario::Harness;
diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs
index 9878f7ba28..5c24b12c7a 100644
--- a/crates/ui-egui/src/viewport.rs
+++ b/crates/ui-egui/src/viewport.rs
@@ -4,8 +4,9 @@
use crate::ui_kit::{Container, Surface};
use egui::{Align2, Color32, FontId, Pos2, Rect, Sense, Shape, Stroke, pos2, vec2};
use serde_json::json;
+use solidcore_record::{Plane, Vec2, Vec3};
use solidcraft_engine::Sel;
-use solidcraft_engine::geom::{Plane, Vec2, Vec3};
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::render::{Camera, Mat4, Rgb};
use solidcraft_engine::sketch::CurveKind;
use solidcraft_engine::view::{GridFade, GridPlane, colors, grid_ext, grid_lines, grid_plane, grid_step, sketch_lines_with_sampler};
@@ -2932,7 +2933,7 @@ fn feature_parts(app: &SolveApp, id: u64, shown_only: bool) -> Vec<Sel> {
}
/// A point on face `index` of `m`: the middle of its first triangle.
-fn first_triangle_point(m: &solidcraft_engine::geom::Mesh, index: usize) -> Option<solidcraft_engine::geom::Vec3> {
+fn first_triangle_point(m: &solidcraft_engine::geom::Mesh, index: usize) -> Option<solidcore_record::Vec3> {
m.triangles.iter().zip(&m.tri_face).find_map(|(t, f)| (*f as usize == index).then(|| m.tri(t)).flatten().map(|[a, b, c]| (a + b + c) / 3.0))
}
@@ -2988,7 +2989,7 @@ fn current_face(
name: &str,
sample: &solidcraft_engine::kernel::FaceInfo,
tol: f64,
-) -> Option<(usize, solidcraft_engine::geom::Vec3)> {
+) -> Option<(usize, solidcore_record::Vec3)> {
let m = now.mesh();
let names = solidcraft_engine::doc::naming::face_names(now);
if let Some(index) = names.iter().position(|n| n == name) {
@@ -3487,7 +3488,7 @@ pub(crate) fn profile_fill(sc: &mut GpuScene, app: &SolveApp, sketch: u64, index
};
// Lift toward the eye so a profile on a face shows over it.
let lift = app.cam.back() * (app.cam.half_height() * 0.002);
- let w = |q: solidcraft_engine::geom::Vec2| (plane.to_world(q) + lift).to_f32();
+ let w = |q: solidcore_record::Vec2| (plane.to_world(q) + lift).to_f32();
let col = sc.color(c4(fill));
let edge = sc.color(c4(edge));
// In the translucent pass (after the grid and edges) so it covers them.
@@ -5189,7 +5190,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
points_2d(app, &painter, &proj);
if let Some((plane, sketch)) = crate::sketch_attachment_ui::lost_guide(app)
&& let Some((low, high)) = sketch.bounds()
- && let Some(at) = proj.to_screen(plane.to_world(solidcraft_engine::geom::Vec2::new((low.x + high.x) * 0.5, high.y)))
+ && let Some(at) = proj.to_screen(plane.to_world(solidcore_record::Vec2::new((low.x + high.x) * 0.5, high.y)))
{
painter.text(
at - vec2(0.0, 12.0),
@@ -6653,7 +6654,7 @@ impl Conflict {
fn loose_end_markers(
sk: &solidcraft_engine::sketch::Sketch,
ends: &solidcraft_engine::sketch::EndReport,
- plane: &solidcraft_engine::geom::Plane,
+ plane: &solidcore_record::Plane,
painter: &egui::Painter,
proj: &Proj,
t: &Tokens,
diff --git a/crates/ui-egui/src/viewport_appearance_tests.rs b/crates/ui-egui/src/viewport_appearance_tests.rs
index 665355dddd..6b7ccf1165 100644
--- a/crates/ui-egui/src/viewport_appearance_tests.rs
+++ b/crates/ui-egui/src/viewport_appearance_tests.rs
@@ -1,7 +1,8 @@
use super::build_scene;
use crate::{Services, SolveApp};
use serde_json::json;
-use solidcraft_engine::{Session, doc, geom::Vec3, kernel};
+use solidcore_record::Vec3;
+use solidcraft_engine::{Session, doc, kernel};
#[test]
fn a_finished_sketch_on_a_face_draws_a_halo_under_its_own_curves_only() {
@@ -326,7 +327,7 @@ fn bodies_out_of_the_view_are_not_drawn() {
frames.frame(crate::scale_tests::view_frame(&app, SIZE, (1, &slot), (0, &none)));
let both = frames.stats().triangles;
assert_eq!(both, near + far, "both boxes in view");
- app.cam.target = solidcraft_engine::geom::Vec3::new(5.0, 5.0, 5.0);
+ app.cam.target = solidcore_record::Vec3::new(5.0, 5.0, 5.0);
app.cam.distance = 40.0;
frames.frame(crate::scale_tests::view_frame(&app, SIZE, (1, &slot), (0, &none)));
assert_eq!(frames.stats().triangles, near, "the far box is not drawn");
diff --git a/crates/ui-egui/src/viewport_layout.rs b/crates/ui-egui/src/viewport_layout.rs
index b3344f27c5..f5e716cd21 100644
--- a/crates/ui-egui/src/viewport_layout.rs
+++ b/crates/ui-egui/src/viewport_layout.rs
@@ -1,6 +1,8 @@
//! Floating controls reserve drawing space without changing rendering or picking projection.
use egui::{Rect, pos2, vec2};
-use solidcraft_engine::geom::{Aabb3, Vec3};
+use solidcore_record::Vec3;
+use solidcraft_engine::geom::Aabb3;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::render::Camera;
#[derive(Clone, Debug)]
diff --git a/crates/ui-egui/src/viewport_overlays_tests.rs b/crates/ui-egui/src/viewport_overlays_tests.rs
index 341d4b2578..d7b1a46be9 100644
--- a/crates/ui-egui/src/viewport_overlays_tests.rs
+++ b/crates/ui-egui/src/viewport_overlays_tests.rs
@@ -1256,7 +1256,7 @@ fn comb_options_draw_the_combs_shown_again() {
let combs = shown_combs(&h.app);
assert_eq!(combs.len(), 1, "{:?}", h.app.status);
assert_eq!(combs[0].len(), 40);
- let tooth = |c: &[[solidcraft_engine::geom::Vec3; 2]]| c[0][0].dist(c[0][1]);
+ let tooth = |c: &[[solidcore_record::Vec3; 2]]| c[0][0].dist(c[0][1]);
let auto = tooth(&combs[0]);
assert!(auto > 0.0);
let slider = |name: &str| crate::scenario::rect_of(&format!("dialog:slider_track:{name}")).unwrap_or_else(|| panic!("no slider {name}"));
@@ -1300,7 +1300,7 @@ fn combs_shown_together_share_one_scale() {
let ratio = |h: &Harness| {
let combs = shown_combs(&h.app);
assert_eq!(combs.len(), 2, "{:?}", h.app.status);
- let tooth = |c: &[[solidcraft_engine::geom::Vec3; 2]]| c[0][0].dist(c[0][1]);
+ let tooth = |c: &[[solidcore_record::Vec3; 2]]| c[0][0].dist(c[0][1]);
tooth(&combs[0]) / tooth(&combs[1])
};
assert!((ratio(&h) - 2.0).abs() < 1e-9, "{}", ratio(&h));
diff --git a/crates/ui-egui/src/viewport_plane_target_tests.rs b/crates/ui-egui/src/viewport_plane_target_tests.rs
index 1ffe78dabf..818506c253 100644
--- a/crates/ui-egui/src/viewport_plane_target_tests.rs
+++ b/crates/ui-egui/src/viewport_plane_target_tests.rs
@@ -1,5 +1,6 @@
use crate::scenario::Harness;
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
/// `ui.at {"plane": …}` gives a point that a click picks that plane at, even where another
/// origin plane hides the middle of its square (seen from the front right and a little lower
diff --git a/crates/ui-egui/tests/coincident_circles.rs b/crates/ui-egui/tests/coincident_circles.rs
index d7c988ee45..222257de1f 100644
--- a/crates/ui-egui/tests/coincident_circles.rs
+++ b/crates/ui-egui/tests/coincident_circles.rs
@@ -1,4 +1,5 @@
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_ui_egui::scenario::Harness;
/// The Coincident tool takes two circles clicked by their edges and lays the second on the first.
diff --git a/crates/ui-egui/tests/coincident_lines.rs b/crates/ui-egui/tests/coincident_lines.rs
index 8c2cf6aab6..1a13dcee65 100644
--- a/crates/ui-egui/tests/coincident_lines.rs
+++ b/crates/ui-egui/tests/coincident_lines.rs
@@ -3,6 +3,7 @@
mod support;
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::sketch::ConstraintKind;
use solidcraft_ui_egui::scenario::Harness;
diff --git a/crates/ui-egui/tests/constraint_preselection.rs b/crates/ui-egui/tests/constraint_preselection.rs
index 5b8b5eb65e..f96a7e5763 100644
--- a/crates/ui-egui/tests/constraint_preselection.rs
+++ b/crates/ui-egui/tests/constraint_preselection.rs
@@ -3,6 +3,7 @@
mod support;
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::{Sel, sketch::ConstraintKind};
use solidcraft_ui_egui::scenario::Harness;
@@ -202,7 +203,7 @@ fn curvature_polygon_and_fix_consume_clicked_operands_atomically() {
};
h.call("ui.view", json!({"view":"top"}));
h.app.cam.distance = 80.0;
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(30.0, 15.0, 0.0);
+ h.app.cam.target = solidcore_record::Vec3::new(30.0, 15.0, 0.0);
h.settle();
for (i, p) in picks.iter().enumerate() {
h.step(&json!({"click":{"sketch":p},"shift":i>0})).unwrap();
diff --git a/crates/ui-egui/tests/joint_move_render.rs b/crates/ui-egui/tests/joint_move_render.rs
index f298a67c6e..9588156e85 100644
--- a/crates/ui-egui/tests/joint_move_render.rs
+++ b/crates/ui-egui/tests/joint_move_render.rs
@@ -3,7 +3,9 @@
mod raster;
use egui::{ColorImage, Event, PointerButton, Pos2, Rect, TextureId, vec2};
use serde_json::json;
-use solidcraft_engine::{Sel, geom::Vec3};
+use solidcore_record::Vec3;
+use solidcraft_engine::Sel;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_ui_egui::{
scenario::{self, Harness},
theme, viewport,
diff --git a/crates/ui-egui/tests/point_alignment.rs b/crates/ui-egui/tests/point_alignment.rs
index f78fb6654b..d2d46fe497 100644
--- a/crates/ui-egui/tests/point_alignment.rs
+++ b/crates/ui-egui/tests/point_alignment.rs
@@ -4,10 +4,11 @@
mod raster;
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_engine::sketch::ConstraintKind;
use solidcraft_ui_egui::scenario::Harness;
-fn line_midpoint(sk: &solidcraft_engine::sketch::Sketch, id: &str) -> solidcraft_engine::geom::Vec2 {
+fn line_midpoint(sk: &solidcraft_engine::sketch::Sketch, id: &str) -> solidcore_record::Vec2 {
let a = sk.point(sk.resolve_point(&format!("{id}.start")).unwrap()).unwrap();
let b = sk.point(sk.resolve_point(&format!("{id}.end")).unwrap()).unwrap();
(a + b) * 0.5
@@ -325,7 +326,7 @@ fn midpoint_aligns_to_the_fixed_origin_without_straightening_the_line() {
let b = sk.point(sk.resolve_point("l1.end").unwrap()).unwrap();
assert!(((a + b) * 0.5).x.abs() < 1e-6);
assert!((b.x - a.x).abs() > 1. && (b.y - a.y).abs() > 1., "only the midpoint is aligned");
- assert_eq!(sk.point(0).unwrap(), solidcraft_engine::geom::Vec2::ZERO);
+ assert_eq!(sk.point(0).unwrap(), solidcore_record::Vec2::ZERO);
}
}
@@ -480,7 +481,7 @@ fn context_menu_alignment_review_images() {
h.app.run("sketch.point", json!({"point":point,"id":id})).unwrap();
}
h.call("ui.view", json!({"view":"top"}));
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(40.0, 22.0, 0.0);
+ h.app.cam.target = solidcore_record::Vec3::new(40.0, 22.0, 0.0);
h.app.cam.distance = 180.0;
h.app.cam_anim = None;
h.frames(3);
@@ -727,7 +728,7 @@ fn midpoint_selection_review_images() {
h.app.run("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[80,70]})).unwrap();
h.app.run("sketch.rectangle.two_point", json!({"p0":[15,18],"p1":[50,58]})).unwrap();
h.call("ui.view", json!({"view":"top"}));
- h.app.cam.target = solidcraft_engine::geom::Vec3::new(40., 35., 0.);
+ h.app.cam.target = solidcore_record::Vec3::new(40., 35., 0.);
h.app.cam.distance = 180.;
h.app.cam_anim = None;
h.frames(3);
diff --git a/crates/ui-egui/tests/point_constraint_preselection.rs b/crates/ui-egui/tests/point_constraint_preselection.rs
index 331f03fd22..9690d32036 100644
--- a/crates/ui-egui/tests/point_constraint_preselection.rs
+++ b/crates/ui-egui/tests/point_constraint_preselection.rs
@@ -1,5 +1,7 @@
use serde_json::json;
-use solidcraft_engine::{Sel, geom::Vec2, sketch::ConstraintKind};
+use solidcore_record::Vec2;
+use solidcraft_engine::geom::prelude::*;
+use solidcraft_engine::{Sel, sketch::ConstraintKind};
use solidcraft_ui_egui::scenario::Harness;
fn setup() -> Harness {
diff --git a/crates/ui-egui/tests/scenarios.rs b/crates/ui-egui/tests/scenarios.rs
index 2a72fcab6a..c72f2cedeb 100644
--- a/crates/ui-egui/tests/scenarios.rs
+++ b/crates/ui-egui/tests/scenarios.rs
@@ -4,6 +4,7 @@
//! `{"pending": "why"}` step (its test is ignored with that reason). Adding a scenario is adding
//! its file.
+use solidcraft_engine::geom::prelude::*;
use solidcraft_ui_egui::scenario::Harness;
fn run(name: &str) {
@@ -103,7 +104,7 @@ fn dragging_a_conic_after_the_tool_sets_rho_and_its_apex_stays_separately_dragga
.expect("the three clicks created a conic");
assert!((rho - 0.5).abs() < 1e-6, "default rho {rho}");
let apex_before = sk.point(apex_idx).expect("apex point resolves");
- assert!(apex_before.dist(solidcraft_engine::geom::Vec2::new(20.0, 20.0)) < 1e-6);
+ assert!(apex_before.dist(solidcore_record::Vec2::new(20.0, 20.0)) < 1e-6);
// Grabbed on the curve itself, at its default-rho midpoint (20, 10): the chord's midpoint
// is (20, 0), the apex (20, 20), so (20, 14) is 0.7 of the way from one to the other.
diff --git a/crates/ui-egui/tests/stand_up_offer.rs b/crates/ui-egui/tests/stand_up_offer.rs
index b137e1e869..c6fa1cc516 100644
--- a/crates/ui-egui/tests/stand_up_offer.rs
+++ b/crates/ui-egui/tests/stand_up_offer.rs
@@ -5,6 +5,7 @@
//! with `stand_up:stand`, `stand_up:never` and its close (×), `toast:stand_up:close` (also published
//! as `stand_up:dismiss`, the Close button's handle, #7971); Preferences picks the dialog or nothing.
use serde_json::json;
+use solidcraft_engine::geom::prelude::*;
use solidcraft_ui_egui::prefs::StandUpUnknown;
use solidcraft_ui_egui::scenario::Harness;
@@ -177,7 +178,7 @@ fn old_preferences_files_still_load() {
assert!(empty.offer_stand_up);
}
-type V3 = solidcraft_engine::geom::Vec3;
+type V3 = solidcore_record::Vec3;
/// A stood-up SolidWorks file (its component still the active one), a sketch started by
/// `start`, a rectangle far from the part at x 200..220, y 0..10 on it, extruded 15 mm: the
diff --git a/docs/kernel-smlib-history.md b/docs/kernel-smlib-history.md
index 49ca23dd94..1663e49ae8 100644
--- a/docs/kernel-smlib-history.md
+++ b/docs/kernel-smlib-history.md
@@ -16,7 +16,7 @@ The pictures live on the `pr-media-kernel-smlib` branch.
- edges with intervals, and vertices;
- tolerances per body, per edge and per vertex.
-Names follow STEP's B-rep vocabulary. Analytic curves and surfaces are unbounded; their bounds live in the edge interval and the face domain. A validator enforces one **canonical order** of faces, edges and vertices, which persistent names depend on. The history types moved beside it, to `solidcraft_geom::brep::history`. The contract is in docs/native-brep.md and tangency-labs/solidcore#342.
+Names follow STEP's B-rep vocabulary. Analytic curves and surfaces are unbounded; their bounds live in the edge interval and the face domain. A validator enforces one **canonical order** of faces, edges and vertices, which persistent names depend on. The history types moved beside it, to `solidcore_record::brep::history` (solidcore's record crate). The contract is in docs/native-brep.md and tangency-labs/solidcore#342.
truck bodies round-trip through schema 4 exactly, and the model cache stores it. Every corpus design, sample and imported assembly reopens from the cache with bit-identical volumes, areas and face names:
diff --git a/docs/native-brep.md b/docs/native-brep.md
index 1fc7815fb3..b303226186 100644
--- a/docs/native-brep.md
+++ b/docs/native-brep.md
@@ -1,7 +1,8 @@
# Native B-rep, schema 4
-This is SolidCraft's geometry data model in `solidcraft_geom::brep`. It has no
-modelling-backend dependency. It is the body encoding of a design's model cache
+This is SolidCraft's geometry data model in `solidcore_record::brep` (solidcore's
+record crate: geometry as data, no maths). It has no modelling-backend dependency;
+its geometric checks and evaluation are the kernel's (`solidcraft_geom::brep`). It is the body encoding of a design's model cache
([the container format](design-container.md#model-cache)); it is not a STEP
replacement for external interchange. The container reader, binary codec and
kernel adapters are separate layers. The truck adapter writes it exactly: a body
@@ -260,7 +261,7 @@ and one fixture per defect, without a kernel.
## History
The runtime history types (`FaceOrigin`, `Change`, `FaceProv`, `Side`,
-`EdgeOrigin`, `EdgeProv`, `History`) live in `solidcraft_geom::brep::history`, so
+`EdgeOrigin`, `EdgeProv`, `History`) live in `solidcore_record::brep::history`, so
a backend can report history without the kernel crate. Indices are canonical face
and edge indices; operands are numbered by each operation. An operation returns
history beside the B-rep. A backend that cannot report it returns none and never