From ac8183ec919d77d923692862761a64141e1f24a4 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Mon, 10 Aug 2026 15:03:31 +0300 Subject: [PATCH] refactor(cad): use direct stack dependencies --- Cargo.lock | 13 +++++++------ Cargo.toml | 11 +++++++---- crates/ocs_plugin_api/Cargo.toml | 2 +- crates/ocs_web_worker/Cargo.toml | 2 +- src/app/model_ops.rs | 2 +- src/command.rs | 2 +- src/entities/common.rs | 4 ++-- src/entities/curve.rs | 14 +++++++------- src/entities/hatch.rs | 4 ++-- src/entities/lwpolyline.rs | 4 ++-- src/entities/polyline.rs | 2 +- src/entities/solid3d.rs | 2 +- src/entities/spline.rs | 12 ++++++------ src/modules/draw/draw/spline.rs | 2 +- src/modules/draw/inquiry/area.rs | 2 +- src/modules/draw/inquiry/divide.rs | 2 +- src/modules/draw/modify/blend.rs | 4 ++-- src/modules/draw/modify/fillet.rs | 2 +- src/modules/draw/modify/geom.rs | 4 ++-- src/modules/draw/modify/lengthen.rs | 2 +- src/modules/draw/modify/offset.rs | 6 +++--- src/modules/draw/modify/pedit.rs | 4 ++-- src/modules/draw/modify/spline_ops.rs | 4 ++-- src/modules/draw/modify/trim.rs | 6 +++--- src/modules/model/primitive_cmd.rs | 2 +- src/scene/boundary.rs | 2 +- src/scene/convert/acis_export.rs | 28 +++++---------------------- src/scene/convert/acis_kernel.rs | 8 ++++---- src/scene/entity.rs | 2 +- src/scene/mod.rs | 6 +++--- src/scene/model/hatch_model.rs | 2 +- src/scene/model/mesh_model.rs | 2 +- src/scene/model/solid_model.rs | 6 +++--- src/scene/model/sweep_model.rs | 12 ++++++------ src/scene/modify.rs | 4 ++-- src/scene/pipeline/mod.rs | 2 +- 36 files changed, 87 insertions(+), 101 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 18d64428..a91c8e64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,9 +7,11 @@ name = "OpenCADStudio" version = "0.9.4" dependencies = [ "acadifc", + "acadrust", "ashpd", "bincode", "bytemuck", + "cadkernel", "clap", "console_error_panic_hook", "cosmic-text 0.15.0", @@ -70,11 +72,9 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" [[package]] name = "acadifc" version = "0.5.0" -source = "git+https://github.com/OpenAEC-Foundation/acadifc.git?rev=6767b22#6767b22f17ac760f789edb82ec1e32760a8b6cca" +source = "git+https://github.com/OpenAEC-Foundation/acadifc.git?rev=47b5603#47b5603a06303dd9935af041d45c8bc4c37545a6" dependencies = [ - "acadrust", "base64", - "cadkernel", "serde", "serde_json", "sha2 0.10.9", @@ -890,8 +890,9 @@ checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" [[package]] name = "cadkernel" version = "0.1.0" -source = "git+https://github.com/HakanSeven12/cadkernel.git?rev=ba7292c#ba7292c152ef5069b0bcf8c86730db75339fc383" +source = "git+https://github.com/HakanSeven12/cadkernel.git?rev=6b6a995#6b6a99546b1a871007a8e3da73530b3aa4502dea" dependencies = [ + "acadrust", "cavalier_contours", "spade", ] @@ -3747,7 +3748,7 @@ dependencies = [ name = "ocs_plugin_api" version = "0.1.0" dependencies = [ - "acadifc", + "acadrust", "bincode", "getrandom 0.2.17", "interprocess", @@ -3762,7 +3763,7 @@ dependencies = [ name = "ocs_web_worker" version = "0.1.0" dependencies = [ - "acadifc", + "acadrust", "bincode", "console_error_panic_hook", "getrandom 0.3.4", diff --git a/Cargo.toml b/Cargo.toml index 817eb5e9..95d34840 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,10 @@ members = [ "crates/dwg-thumbnailer-win", ] +[features] +default = [] +ifc = ["dep:acadifc"] + [target.'cfg(windows)'.build-dependencies] winresource = "0.1" @@ -27,10 +31,9 @@ glam = { version = "0.33", features = ["bytemuck"] } rfd = "0.17" clap = { version = "4", features = ["derive"] } env_logger = "0.11" -# The CAD stack is reached through acadifc, which re-exports the codec and -# the geometry kernel. Aliased to `acadrust` so existing `use acadrust::…` -# paths keep resolving. -acadrust = { package = "acadifc", git = "https://github.com/OpenAEC-Foundation/acadifc.git", rev = "6767b22", features = ["serde", "offset"] } +acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "7e2fa8c", features = ["serde"] } +cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "6b6a995", features = ["acis", "offset"] } +acadifc = { git = "https://github.com/OpenAEC-Foundation/acadifc.git", rev = "47b5603", optional = true } dwg-thumbnailer = { path = "crates/dwg-thumbnailer" } flate2 = "1" image = { version = "0.25", default-features = false, features = ["png", "jpeg", "bmp", "tiff"] } diff --git a/crates/ocs_plugin_api/Cargo.toml b/crates/ocs_plugin_api/Cargo.toml index 33061ced..16eddf10 100644 --- a/crates/ocs_plugin_api/Cargo.toml +++ b/crates/ocs_plugin_api/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-only" # Pulled in only by the `host` feature, which adds the `acadrust`-typed # `HostApi` runtime surface. The default crate stays dependency-free so engine # crates and external tooling can depend on the manifest/ribbon contract cheaply. -acadrust = { package = "acadifc", git = "https://github.com/OpenAEC-Foundation/acadifc.git", rev = "6767b22", optional = true, features = ["serde"] } +acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "7e2fa8c", optional = true, features = ["serde"] } # Runtime IPC and serialization (host feature only). interprocess = { version = "2", optional = true } diff --git a/crates/ocs_web_worker/Cargo.toml b/crates/ocs_web_worker/Cargo.toml index c11d685f..015a8c4e 100644 --- a/crates/ocs_web_worker/Cargo.toml +++ b/crates/ocs_web_worker/Cargo.toml @@ -8,7 +8,7 @@ publish = false crate-type = ["cdylib"] [dependencies] -acadrust = { package = "acadifc", git = "https://github.com/OpenAEC-Foundation/acadifc.git", rev = "6767b22", features = ["serde"] } +acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "7e2fa8c", features = ["serde"] } bincode = "1.3" console_error_panic_hook = "0.1" getrandom = { version = "0.3", features = ["wasm_js"] } diff --git a/src/app/model_ops.rs b/src/app/model_ops.rs index 7600cc72..c2846a95 100644 --- a/src/app/model_ops.rs +++ b/src/app/model_ops.rs @@ -7,7 +7,7 @@ // cylinder afterwards, and saves as one. use acadrust::entities::Solid3D; -use acadrust::kernel::brep::Body; +use cadkernel::brep::Body; use acadrust::{EntityType, Handle}; use iced::Task; diff --git a/src/command.rs b/src/command.rs index b4bac523..ad5d553d 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1158,7 +1158,7 @@ pub enum CmdResult { /// rendering). Ends the command. CommitSolid { entity: EntityType, - solid: Box, + solid: Box, }, /// Commit an acadrust entity, end the command, and open the in-place text /// editor on it (used by MLEADER to type the annotation after placement). diff --git a/src/entities/common.rs b/src/entities/common.rs index f17bbe8b..3a250f51 100644 --- a/src/entities/common.rs +++ b/src/entities/common.rs @@ -587,7 +587,7 @@ pub fn parse_angle_deg(value: &str) -> Option { /// Re-exported rather than imported at each call site so the twelve modules /// that already reach for `entities::common::BulgeArc` keep working, and so /// there is one obvious place to see that the maths moved out. -pub use acadrust::kernel::geom2d::BulgeArc; +pub use cadkernel::geom2d::BulgeArc; /// Triangulate the solid bands a `wide_fills` returns into the flat WCS f64 /// triangle list `RenderEntity::pick_tris` carries, so a wide polyline is @@ -694,7 +694,7 @@ pub(crate) fn tapered_band_points( if bulge.abs() < 1e-9 { push(p1[0], p1[1], ew0 as f32); } else if let Some(arc) = BulgeArc::from_bulge(p0, p1, bulge) { - let samples = arc.tessellate_angle(acadrust::kernel::tessellation::DEFAULT_ANGLE); + let samples = arc.tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE); let segments = samples.len().saturating_sub(1).max(1); for (index, s) in samples.into_iter().enumerate().skip(1) { let t = index as f64 / segments as f64; diff --git a/src/entities/curve.rs b/src/entities/curve.rs index ec3f877f..a7e0133e 100644 --- a/src/entities/curve.rs +++ b/src/entities/curve.rs @@ -32,11 +32,11 @@ use acadrust::entities::{ Arc as ArcEnt, Circle as CircleEnt, Ellipse as EllipseEnt, LwPolyline as LwPolylineEnt, Polyline2D, Spline as SplineEnt, }; -use acadrust::kernel::geom2d::{ +use cadkernel::geom2d::{ characteristic_points, Arc, Circle, Curve, Ellipse, EllipseArc, Line, Polyline, PolylineVertex, Ray, SnapKind, Transform, XLine, }; -use acadrust::kernel::space::{PlanarCurve, Plane, Vec3}; +use cadkernel::space::{PlanarCurve, Plane, Vec3}; use acadrust::types::Vector3; use acadrust::EntityType; @@ -333,7 +333,7 @@ pub fn entity_curve_xy(entity: &EntityType) -> Option { /// World-space wire points sampled by the kernel's angular policy. pub fn curve_points(curve: &PlanarCurve) -> Vec<[f64; 3]> { - curve.tessellate_angle(acadrust::kernel::tessellation::DEFAULT_ANGLE) + curve.tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE) } /// The snap candidates an entity's curve offers, in the two channels the @@ -705,12 +705,12 @@ mod tests { /// where it happens rather than the next time somebody reaches for it. #[test] fn the_solid_layer_and_the_acis_bridge_are_reachable() { - let solid = acadrust::kernel::brep::make::cuboid([0.0; 3], [1.0; 3]) + let solid = cadkernel::brep::make::cuboid([0.0; 3], [1.0; 3]) .expect("the kernel builds its own primitives"); assert!(solid.validate().is_empty()); assert_eq!(solid.euler_characteristic(), 2); let document = acadrust::entities::acis::types::SatDocument::new(); - let (bodies, loss) = acadrust::acis::lift(&document); + let (bodies, loss) = cadkernel::acis::lift(&document); assert!(bodies.is_empty() && loss.is_empty(), "an empty document lifts to nothing"); } @@ -742,14 +742,14 @@ mod tests { ray.base_point = v3(1.0, 1.0, 0.0); ray.direction = v3(2.0, 0.0, 0.0); let curve = entity_curve(&EntityType::Ray(ray)).unwrap(); - assert_eq!(curve.extent(), acadrust::kernel::geom2d::Extent::Forward); + assert_eq!(curve.extent(), cadkernel::geom2d::Extent::Forward); assert_eq!(curve.point_at(1.0), [3.0, 1.0, 0.0]); let mut line = XLineEnt::default(); line.base_point = v3(0.0, 0.0, 0.0); line.direction = v3(0.0, 3.0, 0.0); let curve = entity_curve(&EntityType::XLine(line)).unwrap(); - assert_eq!(curve.extent(), acadrust::kernel::geom2d::Extent::Infinite); + assert_eq!(curve.extent(), cadkernel::geom2d::Extent::Infinite); assert_eq!(curve.point_at(-1.0), [0.0, -3.0, 0.0]); } } diff --git a/src/entities/hatch.rs b/src/entities/hatch.rs index b53513dd..d0f2201a 100644 --- a/src/entities/hatch.rs +++ b/src/entities/hatch.rs @@ -1,5 +1,5 @@ use acadrust::entities::{BoundaryEdge, Hatch}; -use acadrust::kernel::geom2d::{ +use cadkernel::geom2d::{ Arc as KernelArc, Curve as KernelCurve, Ellipse as KernelEllipse, EllipseArc as KernelEllipseArc, Line as KernelLine, NurbsCurve as KernelNurbs, Parameterization, Polyline as KernelPolyline, PolylineVertex as KernelVertex, @@ -999,7 +999,7 @@ impl FallbackTess for Hatch { continue; }; let local = curve - .tessellate_angle(acadrust::kernel::tessellation::DEFAULT_ANGLE); + .tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE); if local.len() < 2 { continue; } diff --git a/src/entities/lwpolyline.rs b/src/entities/lwpolyline.rs index be0d5664..11fc3488 100644 --- a/src/entities/lwpolyline.rs +++ b/src/entities/lwpolyline.rs @@ -309,7 +309,7 @@ fn to_render(pline: &LwPolyline) -> RenderEntity { radius: arc.radius as f32, }); for s in arc - .tessellate_angle(acadrust::kernel::tessellation::DEFAULT_ANGLE) + .tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE) .into_iter() .skip(1) { @@ -410,7 +410,7 @@ fn to_render(pline: &LwPolyline) -> RenderEntity { crate::entities::common::BulgeArc::from_bulge([ox0, oy0], [ox1, oy1], bulge) { for s in arc - .tessellate_angle(acadrust::kernel::tessellation::DEFAULT_ANGLE) + .tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE) .into_iter() .skip(1) { diff --git a/src/entities/polyline.rs b/src/entities/polyline.rs index 25865140..6e63b558 100644 --- a/src/entities/polyline.rs +++ b/src/entities/polyline.rs @@ -259,7 +259,7 @@ fn tessellate_polyline2d(pl: &Polyline2D) -> RenderEntity { radius: arc.radius as f32, }); for s in arc - .tessellate_angle(acadrust::kernel::tessellation::DEFAULT_ANGLE) + .tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE) .into_iter() .skip(1) { diff --git a/src/entities/solid3d.rs b/src/entities/solid3d.rs index af5c8c2b..022b6207 100644 --- a/src/entities/solid3d.rs +++ b/src/entities/solid3d.rs @@ -6,7 +6,7 @@ // caller translates the mesh vertices to match. use acadrust::entities::{Body, Region, Solid3D, Surface}; -use acadrust::kernel::space::polygon; +use cadkernel::space::polygon; use crate::t; use crate::command::EntityTransform; use crate::entities::common::{center_grip, edit_prop as edit, parse_f64, ro_prop as ro}; diff --git a/src/entities/spline.rs b/src/entities/spline.rs index ac8fa789..b92be0e8 100644 --- a/src/entities/spline.rs +++ b/src/entities/spline.rs @@ -1,6 +1,6 @@ use acadrust::entities::Spline; use crate::t; -use acadrust::kernel::space::NurbsCurve3; +use cadkernel::space::NurbsCurve3; use crate::command::EntityTransform; use crate::entities::common::{edit_prop as edit, parse_f64, ro_prop as ro, square_grip}; @@ -171,7 +171,7 @@ pub(crate) fn measurement_polyline(spl: &Spline) -> Vec<[f64; 3]> { }); match NurbsCurve3::new(degree, controls, spl.knots.clone(), weights) { Some(curve) => { - curve.tessellate_angle(acadrust::kernel::tessellation::DEFAULT_ANGLE) + curve.tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE) } None => spl.control_points.iter().map(|p| [p.x, p.y, p.z]).collect(), } @@ -240,10 +240,10 @@ fn catmull_rom_polyline(pts: &[acadrust::types::Vector3], closed: bool) -> Vec<[ } q }; - let sampled = acadrust::kernel::tessellation::sample_curve3_angle( + let sampled = cadkernel::tessellation::sample_curve3_angle( point_at, tangent_at, - acadrust::kernel::tessellation::DEFAULT_ANGLE, + cadkernel::tessellation::DEFAULT_ANGLE, ); out.extend(sampled.into_iter().skip(usize::from(seg > 0))); } @@ -363,10 +363,10 @@ fn fit_spline_polyline(spl: &Spline) -> Vec<[f64; 3]> { } q }; - let sampled = acadrust::kernel::tessellation::sample_curve3_angle( + let sampled = cadkernel::tessellation::sample_curve3_angle( point_at, tangent_at, - acadrust::kernel::tessellation::DEFAULT_ANGLE, + cadkernel::tessellation::DEFAULT_ANGLE, ); out.extend(sampled.into_iter().skip(usize::from(i > 0))); } diff --git a/src/modules/draw/draw/spline.rs b/src/modules/draw/draw/spline.rs index c26c29fa..e8fe0c7b 100644 --- a/src/modules/draw/draw/spline.rs +++ b/src/modules/draw/draw/spline.rs @@ -11,7 +11,7 @@ use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::scene::model::wire_model::WireModel; use glam::DVec3; -use acadrust::kernel::space::NurbsCurve3; +use cadkernel::space::NurbsCurve3; #[allow(dead_code)] pub fn tool() -> ToolDef { diff --git a/src/modules/draw/inquiry/area.rs b/src/modules/draw/inquiry/area.rs index ab4a6e3c..1301139c 100644 --- a/src/modules/draw/inquiry/area.rs +++ b/src/modules/draw/inquiry/area.rs @@ -1,4 +1,4 @@ -use acadrust::kernel::space::polygon; +use cadkernel::space::polygon; use acadrust::{EntityType, Handle}; use glam::DVec3; diff --git a/src/modules/draw/inquiry/divide.rs b/src/modules/draw/inquiry/divide.rs index 6ce799c8..b8e8acdd 100644 --- a/src/modules/draw/inquiry/divide.rs +++ b/src/modules/draw/inquiry/divide.rs @@ -2,7 +2,7 @@ // MEASURE command — place Point entities at fixed-distance intervals along an entity. use acadrust::entities::Point as PointEnt; -use acadrust::kernel::space::PlanarCurve; +use cadkernel::space::PlanarCurve; use acadrust::types::Vector3; use acadrust::{EntityType, Handle}; use glam::DVec3; diff --git a/src/modules/draw/modify/blend.rs b/src/modules/draw/modify/blend.rs index f4fa0a5f..11830973 100644 --- a/src/modules/draw/modify/blend.rs +++ b/src/modules/draw/modify/blend.rs @@ -6,12 +6,12 @@ //! geometric curvature (G2). use acadrust::entities::{EntityCommon, Spline}; -use acadrust::kernel::space::curve as space_curve; +use cadkernel::space::curve as space_curve; use acadrust::types::Vector3; use acadrust::{EntityType, Handle}; use glam::DVec3; use crate::t; -use acadrust::kernel::space::NurbsCurve3; +use cadkernel::space::NurbsCurve3; use crate::command::{CadCommand, CmdOption, CmdResult}; use crate::entities::common::BulgeArc; diff --git a/src/modules/draw/modify/fillet.rs b/src/modules/draw/modify/fillet.rs index 0d1466c4..04b3e7fb 100644 --- a/src/modules/draw/modify/fillet.rs +++ b/src/modules/draw/modify/fillet.rs @@ -14,7 +14,7 @@ use acadrust::entities::{Arc as ArcEnt, Line as LineEnt, LwPolyline}; // Shared plane geometry, from cadkernel via the local adapters. use super::geom; use super::geom::{arc_points as arc_pts, line_line as ll, normalize_angle as norm_angle}; -use acadrust::kernel::geom2d::{ +use cadkernel::geom2d::{ circle_circle_points as circle_circle_pts, fillet_between_rays, fillets_between, line_circle, Arc as KernelArc, Curve as KernelCurve, Fillet as KernelFillet, Line as KernelLine, Tolerance, diff --git a/src/modules/draw/modify/geom.rs b/src/modules/draw/modify/geom.rs index f4cf3a95..7ea301d1 100644 --- a/src/modules/draw/modify/geom.rs +++ b/src/modules/draw/modify/geom.rs @@ -11,11 +11,11 @@ //! resident render path splits the `f64` into a high/low pair instead. Only a //! caller knows which of the two it is. -use acadrust::kernel::geom2d::{self, Ellipse}; +use cadkernel::geom2d::{self, Ellipse}; /// Re-exported unchanged: these already speak in plain `f64`, so there is no /// call-shape difference for this module to absorb. -pub use acadrust::kernel::geom2d::{arc_parameter, lerp, normalize_angle}; +pub use cadkernel::geom2d::{arc_parameter, lerp, normalize_angle}; /// Preview geometry keeps the density the commands have always used. const SEGMENTS_PER_RADIAN: f64 = geom2d::DEFAULT_SEGMENTS_PER_RADIAN; diff --git a/src/modules/draw/modify/lengthen.rs b/src/modules/draw/modify/lengthen.rs index a8ece805..5c7b21a8 100644 --- a/src/modules/draw/modify/lengthen.rs +++ b/src/modules/draw/modify/lengthen.rs @@ -11,7 +11,7 @@ use crate::modules::draw::modify::spline_ops::{spline_cut, spline_to_nurbs}; use acadrust::entities::{ Arc as ArcEnt, Ellipse as EllipseEnt, Line as LineEnt, LwPolyline, Spline as SplineEnt, }; -use acadrust::kernel::geom2d::{ +use cadkernel::geom2d::{ Curve, Ellipse as KernelEllipse, EllipseArc as KernelEllipseArc, }; use acadrust::types::Vector3; diff --git a/src/modules/draw/modify/offset.rs b/src/modules/draw/modify/offset.rs index 232eb656..218f364b 100644 --- a/src/modules/draw/modify/offset.rs +++ b/src/modules/draw/modify/offset.rs @@ -20,8 +20,8 @@ use acadrust::entities::{ use acadrust::{EntityType, Handle}; // Polyline offsetting, and the angle normalisation that goes with it, come // from the kernel; only the entity conversion stays here. -use acadrust::kernel::geom2d::nurbs::clamped_uniform_knots; -use acadrust::kernel::geom2d::{ +use cadkernel::geom2d::nurbs::clamped_uniform_knots; +use cadkernel::geom2d::{ offset_polyline, Polyline as KernelPolyline, PolylineVertex as KernelVertex, }; use glam::{DVec3, Vec3}; @@ -361,7 +361,7 @@ fn perp_distance(entity: &EntityType, pt: Vec3) -> f64 { // ── Wire preview points ───────────────────────────────────────────────────── /// Preview density, matching the figure the drawn wires use. -const PREVIEW_SEGMENTS_PER_RADIAN: f64 = acadrust::kernel::geom2d::DEFAULT_SEGMENTS_PER_RADIAN; +const PREVIEW_SEGMENTS_PER_RADIAN: f64 = cadkernel::geom2d::DEFAULT_SEGMENTS_PER_RADIAN; /// Preview points for an entity, from its own curve. /// diff --git a/src/modules/draw/modify/pedit.rs b/src/modules/draw/modify/pedit.rs index b5c2703a..c8403f08 100644 --- a/src/modules/draw/modify/pedit.rs +++ b/src/modules/draw/modify/pedit.rs @@ -12,8 +12,8 @@ // straightens every segment. use acadrust::entities::LwVertex; -use acadrust::kernel::geom2d::nurbs::clamped_uniform_knots; -use acadrust::kernel::geom2d::NurbsCurve; +use cadkernel::geom2d::nurbs::clamped_uniform_knots; +use cadkernel::geom2d::NurbsCurve; use acadrust::types::Vector2; use acadrust::{EntityType, Handle}; use glam::{DVec2, DVec3}; diff --git a/src/modules/draw/modify/spline_ops.rs b/src/modules/draw/modify/spline_ops.rs index 184a0fcc..b8adacd8 100644 --- a/src/modules/draw/modify/spline_ops.rs +++ b/src/modules/draw/modify/spline_ops.rs @@ -10,8 +10,8 @@ // fine until it is measured. use acadrust::entities::Spline; -use acadrust::kernel::geom2d::{NurbsCurve, Parameterization}; -use acadrust::kernel::space::Plane; +use cadkernel::geom2d::{NurbsCurve, Parameterization}; +use cadkernel::space::Plane; use acadrust::types::Vector3; use acadrust::Handle; diff --git a/src/modules/draw/modify/trim.rs b/src/modules/draw/modify/trim.rs index cbca3a13..7df1f70b 100644 --- a/src/modules/draw/modify/trim.rs +++ b/src/modules/draw/modify/trim.rs @@ -27,8 +27,8 @@ use acadrust::entities::{ use acadrust::types::Vector3; use acadrust::{EntityType, Handle}; use glam::DVec3; -use acadrust::kernel::geom2d::nurbs::clamped_uniform_knots; -use acadrust::kernel::geom2d::{ +use cadkernel::geom2d::nurbs::clamped_uniform_knots; +use cadkernel::geom2d::{ intersect as kernel_intersect, Arc as KernelArc, Circle as KernelCircle, Curve, Extent as KernelExtent, Ellipse as KernelEllipse, EllipseArc as KernelEllipseArc, Line as KernelLine, @@ -77,7 +77,7 @@ const TRIM_EXTENT: f64 = 1_000_000.0; /// Sampling density for the plan-view point lists the fence and preview /// passes walk. The renderer's own figure, so a preview cut lands where the /// drawn geometry is rather than a chord away from it. -const SAMPLE_SEGMENTS_PER_RADIAN: f64 = acadrust::kernel::geom2d::DEFAULT_SEGMENTS_PER_RADIAN; +const SAMPLE_SEGMENTS_PER_RADIAN: f64 = cadkernel::geom2d::DEFAULT_SEGMENTS_PER_RADIAN; /// If a trim interval endpoint is beyond this threshold it is treated as "infinite". #[derive(Clone)] diff --git a/src/modules/model/primitive_cmd.rs b/src/modules/model/primitive_cmd.rs index e2d0c6d5..a1dee42e 100644 --- a/src/modules/model/primitive_cmd.rs +++ b/src/modules/model/primitive_cmd.rs @@ -11,7 +11,7 @@ use acadrust::entities::Solid3D; use acadrust::{primitives, EntityType}; use glam::DVec3; use crate::t; -use acadrust::kernel::brep::Body; +use cadkernel::brep::Body; use crate::command::{CadCommand, CmdResult, WorkingPlane}; use crate::scene::model::solid_model; diff --git a/src/scene/boundary.rs b/src/scene/boundary.rs index ddf4f0e1..d6b4d4bc 100644 --- a/src/scene/boundary.rs +++ b/src/scene/boundary.rs @@ -1,6 +1,6 @@ use super::*; -use acadrust::kernel::geom2d::{bounded_faces, Line, Tolerance}; +use cadkernel::geom2d::{bounded_faces, Line, Tolerance}; /// How far apart two points may be and still be taken for the same one. /// diff --git a/src/scene/convert/acis_export.rs b/src/scene/convert/acis_export.rs index ffaabcb7..0f522478 100644 --- a/src/scene/convert/acis_export.rs +++ b/src/scene/convert/acis_export.rs @@ -1,30 +1,12 @@ -//! Export a B-rep [`Body`] to an exact ACIS `SatDocument`. +//! Export a kernel [`Body`] to an exact ACIS `SatDocument`. //! -//! A solid built by the Model tab, by EXTRUDE / REVOLVE, or by a boolean -//! carries no ACIS geometry of its own, so other CAD applications drop it on -//! open. Writing the body out as real modeller geometry is what stops that. -//! -//! # Exact, not facetted -//! -//! The kernel keeps analytic surfaces — a cylinder is a `cylinder` record and -//! a sphere a `sphere` — so what lands in the document is the shape itself -//! rather than a triangulation of it. That is the whole reason the Model tab -//! builds bodies at all: a facetted export is a one-way door, and the next -//! application to open the file would have no way back to the circle. -//! -//! The writing is [`acis::append`], which lives with the codec because it has -//! to know both sides. What is left here is the small matter of putting one -//! body into a fresh document. +//! Analytic surfaces remain analytic instead of becoming facets. -use acadrust::acis::append; +use cadkernel::acis::append; use acadrust::entities::acis::SatDocument; -use acadrust::kernel::brep::Body; +use cadkernel::brep::Body; -/// An exact ACIS document holding `body`, or `None` when the kernel has no -/// record form for something in it — a spline curve, at present. -/// -/// Refusing is the point: a document missing a face is one that parses into a -/// different solid, and nothing downstream could tell. +/// Returns `None` when the body contains an unsupported record form. pub fn planar_solid_to_sat(body: &Body) -> Option { let mut document = SatDocument::new(); append(body, &mut document).ok()?; diff --git a/src/scene/convert/acis_kernel.rs b/src/scene/convert/acis_kernel.rs index 2dedcf9c..8a5cfb64 100644 --- a/src/scene/convert/acis_kernel.rs +++ b/src/scene/convert/acis_kernel.rs @@ -8,9 +8,9 @@ //! //! Lift and tessellation failures are reported as an incomplete result. -use acadrust::acis::lift; +use cadkernel::acis::lift; use acadrust::entities::acis::SatDocument; -use acadrust::kernel::brep; +use cadkernel::brep; use crate::scene::convert::solid3d_tess::{body_transform, finalize_mesh}; use crate::scene::model::mesh_model::{CurvedGen, MeshLodSet}; @@ -53,7 +53,7 @@ pub fn tessellate_sat( } else { 1.0 }; - let max_angle = acadrust::kernel::tessellation::DEFAULT_ANGLE / resolution; + let max_angle = cadkernel::tessellation::DEFAULT_ANGLE / resolution; // Positions stay f64 until `finalize_mesh` splits them into the coarse // and fine pair, so a solid at survey coordinates keeps its millimetres. @@ -240,7 +240,7 @@ mod tests { #[test] fn a_round_surface_gets_the_same_sides_whatever_its_size() { - let angle = acadrust::kernel::tessellation::DEFAULT_ANGLE; + let angle = cadkernel::tessellation::DEFAULT_ANGLE; assert!(sides(angle) > 24.0, "{}", sides(angle)); assert!(sides(angle) < 96.0, "{}", sides(angle)); } diff --git a/src/scene/entity.rs b/src/scene/entity.rs index ae1d71c4..634ece4f 100644 --- a/src/scene/entity.rs +++ b/src/scene/entity.rs @@ -1401,7 +1401,7 @@ impl Scene { if let Some(curve) = crate::entities::hatch::edge_curve(edge) { edge_polys.push( curve - .tessellate_angle(acadrust::kernel::tessellation::DEFAULT_ANGLE) + .tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE) .into_iter() .map(|point| to_xy(point[0], point[1])) .collect(), diff --git a/src/scene/mod.rs b/src/scene/mod.rs index ce62bf1e..79c30d22 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -1231,7 +1231,7 @@ fn transform_block_mesh_lod_set( xform.apply_rotation(Vector3::UNIT_Z), ]; out.curved_gens.retain_mut(|generator| { - let transformed = acadrust::kernel::brep::mesh::transform_silhouette_affine( + let transformed = cadkernel::brep::mesh::transform_silhouette_affine( &generator.source, vectors.map(|vector| [vector.x, vector.y, vector.z]), [origin.x, origin.y, origin.z], @@ -1665,7 +1665,7 @@ pub struct Scene { /// here to be combined) and the exact-geometry save path, which writes /// each one back out as ACIS rather than as facets. Not persisted — /// rebuilt only by creating or combining primitives in-session. - pub solid_models: HashMap, + pub solid_models: HashMap, /// GPU render data for raster images (RasterImage entities), keyed by handle. pub images: HashMap, /// The viewport that is currently "entered" (MSPACE mode). @@ -2606,7 +2606,7 @@ impl Scene { /// pipeline under `handle`. The body is in the same offset-relative frame /// the mesh pipeline uses, so the mesh is stored as-is (Model-tab geometry /// is authored at world_offset 0). - pub fn register_solid_model(&mut self, handle: Handle, solid: acadrust::kernel::brep::Body) { + pub fn register_solid_model(&mut self, handle: Handle, solid: cadkernel::brep::Body) { let entity = self.document.get_entity(handle); let color = entity .map(|e| self.render_style(e).0) diff --git a/src/scene/model/hatch_model.rs b/src/scene/model/hatch_model.rs index cc0e4f29..7f9a293d 100644 --- a/src/scene/model/hatch_model.rs +++ b/src/scene/model/hatch_model.rs @@ -6,7 +6,7 @@ use std::sync::Arc; -use acadrust::kernel::geom2d::{ +use cadkernel::geom2d::{ inside_spans, Curve as KernelCurve, Line as KernelLine, Tolerance, XLine as KernelXLine, }; diff --git a/src/scene/model/mesh_model.rs b/src/scene/model/mesh_model.rs index 98024ba9..398a7903 100644 --- a/src/scene/model/mesh_model.rs +++ b/src/scene/model/mesh_model.rs @@ -45,7 +45,7 @@ pub struct MeshModel { /// Kernel-owned source for a view-dependent silhouette. #[derive(Clone, Debug)] pub struct CurvedGen { - pub source: acadrust::kernel::brep::mesh::SilhouetteSource, + pub source: cadkernel::brep::mesh::SilhouetteSource, } #[derive(Clone, Copy, Debug, Default)] diff --git a/src/scene/model/solid_model.rs b/src/scene/model/solid_model.rs index e578df45..60cdd0cf 100644 --- a/src/scene/model/solid_model.rs +++ b/src/scene/model/solid_model.rs @@ -13,7 +13,7 @@ // The resulting `Body` is cached per entity handle on the Scene so the // Design-group boolean tools can run on it. -use acadrust::kernel::brep::{self, Body}; +use cadkernel::brep::{self, Body}; use crate::scene::model::mesh_model::{MeshLodSet, MeshModel}; @@ -24,7 +24,7 @@ fn tessellation(body: &Body) -> brep::mesh::BodyMesh { brep::mesh::tessellate( body, brep::mesh::TessellationTolerance::new( - acadrust::kernel::tessellation::DEFAULT_ANGLE, + cadkernel::tessellation::DEFAULT_ANGLE, TOL, ), ) @@ -346,7 +346,7 @@ pub fn centre(body: &Body) -> Option<[f64; 3]> { /// exists to test with. #[cfg(test)] pub fn volume(body: &Body) -> f64 { - use acadrust::kernel::space::Vec3; + use cadkernel::space::Vec3; let mesh = tessellation(body).mesh; let Some(middle) = centre(body) else { return 0.0; diff --git a/src/scene/model/sweep_model.rs b/src/scene/model/sweep_model.rs index 3ddda186..f79e048c 100644 --- a/src/scene/model/sweep_model.rs +++ b/src/scene/model/sweep_model.rs @@ -12,9 +12,9 @@ // approximated into a surface nobody asked for. That is the kernel's answer // and this module passes it on. -use acadrust::kernel::brep::{self, Body}; -use acadrust::kernel::geom2d::Curve; -use acadrust::kernel::space::{PlanarCurve, Plane}; +use cadkernel::brep::{self, Body}; +use cadkernel::geom2d::Curve; +use cadkernel::space::{PlanarCurve, Plane}; use acadrust::EntityType; use crate::entities::curve::entity_curve; @@ -57,7 +57,7 @@ pub fn profile_of(entity: &EntityType) -> Option { /// A circle as four arcs. fn quarters(centre: [f64; 2], radius: f64) -> Vec { - use acadrust::kernel::geom2d::Arc; + use cadkernel::geom2d::Arc; use std::f64::consts::FRAC_PI_2; (0..4) .map(|quarter| { @@ -112,7 +112,7 @@ use crate::scene::model::mesh_model::{MeshLodSet, MeshModel}; /// SWEEP through the kernel's tolerance-driven mesh API. pub fn swept(profile: &EntityType, path: &EntityType, color: [f32; 4]) -> Option { - let max_angle = acadrust::kernel::tessellation::DEFAULT_ANGLE; + let max_angle = cadkernel::tessellation::DEFAULT_ANGLE; let surface = brep::mesh::sweep_surface( &entity_curve(profile)?, &entity_curve(path)?, @@ -124,7 +124,7 @@ pub fn swept(profile: &EntityType, path: &EntityType, color: [f32; 4]) -> Option /// LOFT through the kernel's tolerance-driven mesh API. pub fn lofted(profiles: &[EntityType], color: [f32; 4]) -> Option { let curves: Vec = profiles.iter().filter_map(entity_curve).collect(); - let max_angle = acadrust::kernel::tessellation::DEFAULT_ANGLE; + let max_angle = cadkernel::tessellation::DEFAULT_ANGLE; mesh_set(brep::mesh::loft_surface(&curves, max_angle)?, color, 1e-9) } diff --git a/src/scene/modify.rs b/src/scene/modify.rs index 5761425b..b784a6bf 100644 --- a/src/scene/modify.rs +++ b/src/scene/modify.rs @@ -698,8 +698,8 @@ impl Scene { translate_split(high, low); } for generator in &mut set.curved_gens { - let placement = acadrust::kernel::brep::Placement::at(delta); - if let Some(source) = acadrust::kernel::brep::mesh::transform_silhouette( + let placement = cadkernel::brep::Placement::at(delta); + if let Some(source) = cadkernel::brep::mesh::transform_silhouette( &generator.source, &placement, ) { diff --git a/src/scene/pipeline/mod.rs b/src/scene/pipeline/mod.rs index 435bd2b7..0a07af59 100644 --- a/src/scene/pipeline/mod.rs +++ b/src/scene/pipeline/mod.rs @@ -2327,7 +2327,7 @@ impl Pipeline { } }; for generator in &set.curved_gens { - for point in acadrust::kernel::brep::mesh::silhouette( + for point in cadkernel::brep::mesh::silhouette( &generator.source, [view.x, view.y, view.z], ) {