refactor(cad): use direct stack dependencies

This commit is contained in:
Hakan Seven committed 2026-08-10 15:03:31 +03:00
1 parent 3b4fbabdba
commit ac8183ec91
36 files changed
+87 -101

No files matched your search

Generated
+7 -6
View File
@@ -7,9 +7,11 @@ name = "OpenCADStudio"
version = "0.9.4" version = "0.9.4"
dependencies = [ dependencies = [
"acadifc", "acadifc",
"acadrust",
"ashpd", "ashpd",
"bincode", "bincode",
"bytemuck", "bytemuck",
"cadkernel",
"clap", "clap",
"console_error_panic_hook", "console_error_panic_hook",
"cosmic-text 0.15.0", "cosmic-text 0.15.0",
@@ -70,11 +72,9 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618"
[[package]] [[package]]
name = "acadifc" name = "acadifc"
version = "0.5.0" 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 = [ dependencies = [
"acadrust",
"base64", "base64",
"cadkernel",
"serde", "serde",
"serde_json", "serde_json",
"sha2 0.10.9", "sha2 0.10.9",
@@ -890,8 +890,9 @@ checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
[[package]] [[package]]
name = "cadkernel" name = "cadkernel"
version = "0.1.0" 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 = [ dependencies = [
"acadrust",
"cavalier_contours", "cavalier_contours",
"spade", "spade",
] ]
@@ -3747,7 +3748,7 @@ dependencies = [
name = "ocs_plugin_api" name = "ocs_plugin_api"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"acadifc", "acadrust",
"bincode", "bincode",
"getrandom 0.2.17", "getrandom 0.2.17",
"interprocess", "interprocess",
@@ -3762,7 +3763,7 @@ dependencies = [
name = "ocs_web_worker" name = "ocs_web_worker"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"acadifc", "acadrust",
"bincode", "bincode",
"console_error_panic_hook", "console_error_panic_hook",
"getrandom 0.3.4", "getrandom 0.3.4",
+7 -4
View File
@@ -12,6 +12,10 @@ members = [
"crates/dwg-thumbnailer-win", "crates/dwg-thumbnailer-win",
] ]
[features]
default = []
ifc = ["dep:acadifc"]
[target.'cfg(windows)'.build-dependencies] [target.'cfg(windows)'.build-dependencies]
winresource = "0.1" winresource = "0.1"
@@ -27,10 +31,9 @@ glam = { version = "0.33", features = ["bytemuck"] }
rfd = "0.17" rfd = "0.17"
clap = { version = "4", features = ["derive"] } clap = { version = "4", features = ["derive"] }
env_logger = "0.11" env_logger = "0.11"
# The CAD stack is reached through acadifc, which re-exports the codec and acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "7e2fa8c", features = ["serde"] }
# the geometry kernel. Aliased to `acadrust` so existing `use acadrust::…` cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "6b6a995", features = ["acis", "offset"] }
# paths keep resolving. acadifc = { git = "https://github.com/OpenAEC-Foundation/acadifc.git", rev = "47b5603", optional = true }
acadrust = { package = "acadifc", git = "https://github.com/OpenAEC-Foundation/acadifc.git", rev = "6767b22", features = ["serde", "offset"] }
dwg-thumbnailer = { path = "crates/dwg-thumbnailer" } dwg-thumbnailer = { path = "crates/dwg-thumbnailer" }
flate2 = "1" flate2 = "1"
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "bmp", "tiff"] } image = { version = "0.25", default-features = false, features = ["png", "jpeg", "bmp", "tiff"] }
+1 -1
View File
@@ -9,7 +9,7 @@ license = "GPL-3.0-only"
# Pulled in only by the `host` feature, which adds the `acadrust`-typed # Pulled in only by the `host` feature, which adds the `acadrust`-typed
# `HostApi` runtime surface. The default crate stays dependency-free so engine # `HostApi` runtime surface. The default crate stays dependency-free so engine
# crates and external tooling can depend on the manifest/ribbon contract cheaply. # 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). # Runtime IPC and serialization (host feature only).
interprocess = { version = "2", optional = true } interprocess = { version = "2", optional = true }
+1 -1
View File
@@ -8,7 +8,7 @@ publish = false
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [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" bincode = "1.3"
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
getrandom = { version = "0.3", features = ["wasm_js"] } getrandom = { version = "0.3", features = ["wasm_js"] }
+1 -1
View File
@@ -7,7 +7,7 @@
// cylinder afterwards, and saves as one. // cylinder afterwards, and saves as one.
use acadrust::entities::Solid3D; use acadrust::entities::Solid3D;
use acadrust::kernel::brep::Body; use cadkernel::brep::Body;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use iced::Task; use iced::Task;
+1 -1
View File
@@ -1158,7 +1158,7 @@ pub enum CmdResult {
/// rendering). Ends the command. /// rendering). Ends the command.
CommitSolid { CommitSolid {
entity: EntityType, entity: EntityType,
solid: Box<acadrust::kernel::brep::Body>, solid: Box<cadkernel::brep::Body>,
}, },
/// Commit an acadrust entity, end the command, and open the in-place text /// 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). /// editor on it (used by MLEADER to type the annotation after placement).
+2 -2
View File
@@ -587,7 +587,7 @@ pub fn parse_angle_deg(value: &str) -> Option<f64> {
/// Re-exported rather than imported at each call site so the twelve modules /// Re-exported rather than imported at each call site so the twelve modules
/// that already reach for `entities::common::BulgeArc` keep working, and so /// that already reach for `entities::common::BulgeArc` keep working, and so
/// there is one obvious place to see that the maths moved out. /// 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 /// Triangulate the solid bands a `wide_fills` returns into the flat WCS f64
/// triangle list `RenderEntity::pick_tris` carries, so a wide polyline is /// 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 { if bulge.abs() < 1e-9 {
push(p1[0], p1[1], ew0 as f32); push(p1[0], p1[1], ew0 as f32);
} else if let Some(arc) = BulgeArc::from_bulge(p0, p1, bulge) { } 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); let segments = samples.len().saturating_sub(1).max(1);
for (index, s) in samples.into_iter().enumerate().skip(1) { for (index, s) in samples.into_iter().enumerate().skip(1) {
let t = index as f64 / segments as f64; let t = index as f64 / segments as f64;
+7 -7
View File
@@ -32,11 +32,11 @@ use acadrust::entities::{
Arc as ArcEnt, Circle as CircleEnt, Ellipse as EllipseEnt, LwPolyline as LwPolylineEnt, Arc as ArcEnt, Circle as CircleEnt, Ellipse as EllipseEnt, LwPolyline as LwPolylineEnt,
Polyline2D, Spline as SplineEnt, Polyline2D, Spline as SplineEnt,
}; };
use acadrust::kernel::geom2d::{ use cadkernel::geom2d::{
characteristic_points, Arc, Circle, Curve, Ellipse, EllipseArc, Line, Polyline, PolylineVertex, characteristic_points, Arc, Circle, Curve, Ellipse, EllipseArc, Line, Polyline, PolylineVertex,
Ray, SnapKind, Transform, XLine, Ray, SnapKind, Transform, XLine,
}; };
use acadrust::kernel::space::{PlanarCurve, Plane, Vec3}; use cadkernel::space::{PlanarCurve, Plane, Vec3};
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
@@ -333,7 +333,7 @@ pub fn entity_curve_xy(entity: &EntityType) -> Option<Curve> {
/// World-space wire points sampled by the kernel's angular policy. /// World-space wire points sampled by the kernel's angular policy.
pub fn curve_points(curve: &PlanarCurve) -> Vec<[f64; 3]> { 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 /// 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. /// where it happens rather than the next time somebody reaches for it.
#[test] #[test]
fn the_solid_layer_and_the_acis_bridge_are_reachable() { 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"); .expect("the kernel builds its own primitives");
assert!(solid.validate().is_empty()); assert!(solid.validate().is_empty());
assert_eq!(solid.euler_characteristic(), 2); assert_eq!(solid.euler_characteristic(), 2);
let document = acadrust::entities::acis::types::SatDocument::new(); 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"); 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.base_point = v3(1.0, 1.0, 0.0);
ray.direction = v3(2.0, 0.0, 0.0); ray.direction = v3(2.0, 0.0, 0.0);
let curve = entity_curve(&EntityType::Ray(ray)).unwrap(); 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]); assert_eq!(curve.point_at(1.0), [3.0, 1.0, 0.0]);
let mut line = XLineEnt::default(); let mut line = XLineEnt::default();
line.base_point = v3(0.0, 0.0, 0.0); line.base_point = v3(0.0, 0.0, 0.0);
line.direction = v3(0.0, 3.0, 0.0); line.direction = v3(0.0, 3.0, 0.0);
let curve = entity_curve(&EntityType::XLine(line)).unwrap(); 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]); assert_eq!(curve.point_at(-1.0), [0.0, -3.0, 0.0]);
} }
} }
+2 -2
View File
@@ -1,5 +1,5 @@
use acadrust::entities::{BoundaryEdge, Hatch}; use acadrust::entities::{BoundaryEdge, Hatch};
use acadrust::kernel::geom2d::{ use cadkernel::geom2d::{
Arc as KernelArc, Curve as KernelCurve, Ellipse as KernelEllipse, Arc as KernelArc, Curve as KernelCurve, Ellipse as KernelEllipse,
EllipseArc as KernelEllipseArc, Line as KernelLine, NurbsCurve as KernelNurbs, EllipseArc as KernelEllipseArc, Line as KernelLine, NurbsCurve as KernelNurbs,
Parameterization, Polyline as KernelPolyline, PolylineVertex as KernelVertex, Parameterization, Polyline as KernelPolyline, PolylineVertex as KernelVertex,
@@ -999,7 +999,7 @@ impl FallbackTess for Hatch {
continue; continue;
}; };
let local = curve let local = curve
.tessellate_angle(acadrust::kernel::tessellation::DEFAULT_ANGLE); .tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE);
if local.len() < 2 { if local.len() < 2 {
continue; continue;
} }
+2 -2
View File
@@ -309,7 +309,7 @@ fn to_render(pline: &LwPolyline) -> RenderEntity {
radius: arc.radius as f32, radius: arc.radius as f32,
}); });
for s in arc for s in arc
.tessellate_angle(acadrust::kernel::tessellation::DEFAULT_ANGLE) .tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE)
.into_iter() .into_iter()
.skip(1) .skip(1)
{ {
@@ -410,7 +410,7 @@ fn to_render(pline: &LwPolyline) -> RenderEntity {
crate::entities::common::BulgeArc::from_bulge([ox0, oy0], [ox1, oy1], bulge) crate::entities::common::BulgeArc::from_bulge([ox0, oy0], [ox1, oy1], bulge)
{ {
for s in arc for s in arc
.tessellate_angle(acadrust::kernel::tessellation::DEFAULT_ANGLE) .tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE)
.into_iter() .into_iter()
.skip(1) .skip(1)
{ {
+1 -1
View File
@@ -259,7 +259,7 @@ fn tessellate_polyline2d(pl: &Polyline2D) -> RenderEntity {
radius: arc.radius as f32, radius: arc.radius as f32,
}); });
for s in arc for s in arc
.tessellate_angle(acadrust::kernel::tessellation::DEFAULT_ANGLE) .tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE)
.into_iter() .into_iter()
.skip(1) .skip(1)
{ {
+1 -1
View File
@@ -6,7 +6,7 @@
// caller translates the mesh vertices to match. // caller translates the mesh vertices to match.
use acadrust::entities::{Body, Region, Solid3D, Surface}; use acadrust::entities::{Body, Region, Solid3D, Surface};
use acadrust::kernel::space::polygon; use cadkernel::space::polygon;
use crate::t; use crate::t;
use crate::command::EntityTransform; use crate::command::EntityTransform;
use crate::entities::common::{center_grip, edit_prop as edit, parse_f64, ro_prop as ro}; use crate::entities::common::{center_grip, edit_prop as edit, parse_f64, ro_prop as ro};
+6 -6
View File
@@ -1,6 +1,6 @@
use acadrust::entities::Spline; use acadrust::entities::Spline;
use crate::t; use crate::t;
use acadrust::kernel::space::NurbsCurve3; use cadkernel::space::NurbsCurve3;
use crate::command::EntityTransform; use crate::command::EntityTransform;
use crate::entities::common::{edit_prop as edit, parse_f64, ro_prop as ro, square_grip}; 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) { match NurbsCurve3::new(degree, controls, spl.knots.clone(), weights) {
Some(curve) => { 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(), 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 q
}; };
let sampled = acadrust::kernel::tessellation::sample_curve3_angle( let sampled = cadkernel::tessellation::sample_curve3_angle(
point_at, point_at,
tangent_at, tangent_at,
acadrust::kernel::tessellation::DEFAULT_ANGLE, cadkernel::tessellation::DEFAULT_ANGLE,
); );
out.extend(sampled.into_iter().skip(usize::from(seg > 0))); out.extend(sampled.into_iter().skip(usize::from(seg > 0)));
} }
@@ -363,10 +363,10 @@ fn fit_spline_polyline(spl: &Spline) -> Vec<[f64; 3]> {
} }
q q
}; };
let sampled = acadrust::kernel::tessellation::sample_curve3_angle( let sampled = cadkernel::tessellation::sample_curve3_angle(
point_at, point_at,
tangent_at, tangent_at,
acadrust::kernel::tessellation::DEFAULT_ANGLE, cadkernel::tessellation::DEFAULT_ANGLE,
); );
out.extend(sampled.into_iter().skip(usize::from(i > 0))); out.extend(sampled.into_iter().skip(usize::from(i > 0)));
} }
+1 -1
View File
@@ -11,7 +11,7 @@ use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
use glam::DVec3; use glam::DVec3;
use acadrust::kernel::space::NurbsCurve3; use cadkernel::space::NurbsCurve3;
#[allow(dead_code)] #[allow(dead_code)]
pub fn tool() -> ToolDef { pub fn tool() -> ToolDef {
+1 -1
View File
@@ -1,4 +1,4 @@
use acadrust::kernel::space::polygon; use cadkernel::space::polygon;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::DVec3; use glam::DVec3;
+1 -1
View File
@@ -2,7 +2,7 @@
// MEASURE command — place Point entities at fixed-distance intervals along an entity. // MEASURE command — place Point entities at fixed-distance intervals along an entity.
use acadrust::entities::Point as PointEnt; use acadrust::entities::Point as PointEnt;
use acadrust::kernel::space::PlanarCurve; use cadkernel::space::PlanarCurve;
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::DVec3; use glam::DVec3;
+2 -2
View File
@@ -6,12 +6,12 @@
//! geometric curvature (G2). //! geometric curvature (G2).
use acadrust::entities::{EntityCommon, Spline}; 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::types::Vector3;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::DVec3; use glam::DVec3;
use crate::t; use crate::t;
use acadrust::kernel::space::NurbsCurve3; use cadkernel::space::NurbsCurve3;
use crate::command::{CadCommand, CmdOption, CmdResult}; use crate::command::{CadCommand, CmdOption, CmdResult};
use crate::entities::common::BulgeArc; use crate::entities::common::BulgeArc;
+1 -1
View File
@@ -14,7 +14,7 @@ use acadrust::entities::{Arc as ArcEnt, Line as LineEnt, LwPolyline};
// Shared plane geometry, from cadkernel via the local adapters. // Shared plane geometry, from cadkernel via the local adapters.
use super::geom; use super::geom;
use super::geom::{arc_points as arc_pts, line_line as ll, normalize_angle as norm_angle}; 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, circle_circle_points as circle_circle_pts, fillet_between_rays, fillets_between, line_circle,
Arc as KernelArc, Curve as KernelCurve, Fillet as KernelFillet, Arc as KernelArc, Curve as KernelCurve, Fillet as KernelFillet,
Line as KernelLine, Tolerance, Line as KernelLine, Tolerance,
+2 -2
View File
@@ -11,11 +11,11 @@
//! resident render path splits the `f64` into a high/low pair instead. Only a //! resident render path splits the `f64` into a high/low pair instead. Only a
//! caller knows which of the two it is. //! 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 /// Re-exported unchanged: these already speak in plain `f64`, so there is no
/// call-shape difference for this module to absorb. /// 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. /// Preview geometry keeps the density the commands have always used.
const SEGMENTS_PER_RADIAN: f64 = geom2d::DEFAULT_SEGMENTS_PER_RADIAN; const SEGMENTS_PER_RADIAN: f64 = geom2d::DEFAULT_SEGMENTS_PER_RADIAN;
+1 -1
View File
@@ -11,7 +11,7 @@ use crate::modules::draw::modify::spline_ops::{spline_cut, spline_to_nurbs};
use acadrust::entities::{ use acadrust::entities::{
Arc as ArcEnt, Ellipse as EllipseEnt, Line as LineEnt, LwPolyline, Spline as SplineEnt, 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, Curve, Ellipse as KernelEllipse, EllipseArc as KernelEllipseArc,
}; };
use acadrust::types::Vector3; use acadrust::types::Vector3;
+3 -3
View File
@@ -20,8 +20,8 @@ use acadrust::entities::{
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
// Polyline offsetting, and the angle normalisation that goes with it, come // Polyline offsetting, and the angle normalisation that goes with it, come
// from the kernel; only the entity conversion stays here. // from the kernel; only the entity conversion stays here.
use acadrust::kernel::geom2d::nurbs::clamped_uniform_knots; use cadkernel::geom2d::nurbs::clamped_uniform_knots;
use acadrust::kernel::geom2d::{ use cadkernel::geom2d::{
offset_polyline, Polyline as KernelPolyline, PolylineVertex as KernelVertex, offset_polyline, Polyline as KernelPolyline, PolylineVertex as KernelVertex,
}; };
use glam::{DVec3, Vec3}; use glam::{DVec3, Vec3};
@@ -361,7 +361,7 @@ fn perp_distance(entity: &EntityType, pt: Vec3) -> f64 {
// ── Wire preview points ───────────────────────────────────────────────────── // ── Wire preview points ─────────────────────────────────────────────────────
/// Preview density, matching the figure the drawn wires use. /// 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. /// Preview points for an entity, from its own curve.
/// ///
+2 -2
View File
@@ -12,8 +12,8 @@
// straightens every segment. // straightens every segment.
use acadrust::entities::LwVertex; use acadrust::entities::LwVertex;
use acadrust::kernel::geom2d::nurbs::clamped_uniform_knots; use cadkernel::geom2d::nurbs::clamped_uniform_knots;
use acadrust::kernel::geom2d::NurbsCurve; use cadkernel::geom2d::NurbsCurve;
use acadrust::types::Vector2; use acadrust::types::Vector2;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::{DVec2, DVec3}; use glam::{DVec2, DVec3};
+2 -2
View File
@@ -10,8 +10,8 @@
// fine until it is measured. // fine until it is measured.
use acadrust::entities::Spline; use acadrust::entities::Spline;
use acadrust::kernel::geom2d::{NurbsCurve, Parameterization}; use cadkernel::geom2d::{NurbsCurve, Parameterization};
use acadrust::kernel::space::Plane; use cadkernel::space::Plane;
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::Handle; use acadrust::Handle;
+3 -3
View File
@@ -27,8 +27,8 @@ use acadrust::entities::{
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::DVec3; use glam::DVec3;
use acadrust::kernel::geom2d::nurbs::clamped_uniform_knots; use cadkernel::geom2d::nurbs::clamped_uniform_knots;
use acadrust::kernel::geom2d::{ use cadkernel::geom2d::{
intersect as kernel_intersect, Arc as KernelArc, Circle as KernelCircle, Curve, intersect as kernel_intersect, Arc as KernelArc, Circle as KernelCircle, Curve,
Extent as KernelExtent, Extent as KernelExtent,
Ellipse as KernelEllipse, EllipseArc as KernelEllipseArc, Line as KernelLine, 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 /// 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 /// passes walk. The renderer's own figure, so a preview cut lands where the
/// drawn geometry is rather than a chord away from it. /// 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". /// If a trim interval endpoint is beyond this threshold it is treated as "infinite".
#[derive(Clone)] #[derive(Clone)]
+1 -1
View File
@@ -11,7 +11,7 @@ use acadrust::entities::Solid3D;
use acadrust::{primitives, EntityType}; use acadrust::{primitives, EntityType};
use glam::DVec3; use glam::DVec3;
use crate::t; use crate::t;
use acadrust::kernel::brep::Body; use cadkernel::brep::Body;
use crate::command::{CadCommand, CmdResult, WorkingPlane}; use crate::command::{CadCommand, CmdResult, WorkingPlane};
use crate::scene::model::solid_model; use crate::scene::model::solid_model;
+1 -1
View File
@@ -1,6 +1,6 @@
use super::*; 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. /// How far apart two points may be and still be taken for the same one.
/// ///
+5 -23
View File
@@ -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 //! Analytic surfaces remain analytic instead of becoming facets.
//! 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.
use acadrust::acis::append; use cadkernel::acis::append;
use acadrust::entities::acis::SatDocument; 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 /// Returns `None` when the body contains an unsupported record form.
/// 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.
pub fn planar_solid_to_sat(body: &Body) -> Option<SatDocument> { pub fn planar_solid_to_sat(body: &Body) -> Option<SatDocument> {
let mut document = SatDocument::new(); let mut document = SatDocument::new();
append(body, &mut document).ok()?; append(body, &mut document).ok()?;
+4 -4
View File
@@ -8,9 +8,9 @@
//! //!
//! Lift and tessellation failures are reported as an incomplete result. //! 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::entities::acis::SatDocument;
use acadrust::kernel::brep; use cadkernel::brep;
use crate::scene::convert::solid3d_tess::{body_transform, finalize_mesh}; use crate::scene::convert::solid3d_tess::{body_transform, finalize_mesh};
use crate::scene::model::mesh_model::{CurvedGen, MeshLodSet}; use crate::scene::model::mesh_model::{CurvedGen, MeshLodSet};
@@ -53,7 +53,7 @@ pub fn tessellate_sat(
} else { } else {
1.0 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 // Positions stay f64 until `finalize_mesh` splits them into the coarse
// and fine pair, so a solid at survey coordinates keeps its millimetres. // and fine pair, so a solid at survey coordinates keeps its millimetres.
@@ -240,7 +240,7 @@ mod tests {
#[test] #[test]
fn a_round_surface_gets_the_same_sides_whatever_its_size() { 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) > 24.0, "{}", sides(angle));
assert!(sides(angle) < 96.0, "{}", sides(angle)); assert!(sides(angle) < 96.0, "{}", sides(angle));
} }
+1 -1
View File
@@ -1401,7 +1401,7 @@ impl Scene {
if let Some(curve) = crate::entities::hatch::edge_curve(edge) { if let Some(curve) = crate::entities::hatch::edge_curve(edge) {
edge_polys.push( edge_polys.push(
curve curve
.tessellate_angle(acadrust::kernel::tessellation::DEFAULT_ANGLE) .tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE)
.into_iter() .into_iter()
.map(|point| to_xy(point[0], point[1])) .map(|point| to_xy(point[0], point[1]))
.collect(), .collect(),
+3 -3
View File
@@ -1231,7 +1231,7 @@ fn transform_block_mesh_lod_set(
xform.apply_rotation(Vector3::UNIT_Z), xform.apply_rotation(Vector3::UNIT_Z),
]; ];
out.curved_gens.retain_mut(|generator| { 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, &generator.source,
vectors.map(|vector| [vector.x, vector.y, vector.z]), vectors.map(|vector| [vector.x, vector.y, vector.z]),
[origin.x, origin.y, origin.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 /// here to be combined) and the exact-geometry save path, which writes
/// each one back out as ACIS rather than as facets. Not persisted — /// each one back out as ACIS rather than as facets. Not persisted —
/// rebuilt only by creating or combining primitives in-session. /// rebuilt only by creating or combining primitives in-session.
pub solid_models: HashMap<Handle, acadrust::kernel::brep::Body>, pub solid_models: HashMap<Handle, cadkernel::brep::Body>,
/// GPU render data for raster images (RasterImage entities), keyed by handle. /// GPU render data for raster images (RasterImage entities), keyed by handle.
pub images: HashMap<Handle, ImageModel>, pub images: HashMap<Handle, ImageModel>,
/// The viewport that is currently "entered" (MSPACE mode). /// 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 /// 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 /// the mesh pipeline uses, so the mesh is stored as-is (Model-tab geometry
/// is authored at world_offset 0). /// 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 entity = self.document.get_entity(handle);
let color = entity let color = entity
.map(|e| self.render_style(e).0) .map(|e| self.render_style(e).0)
+1 -1
View File
@@ -6,7 +6,7 @@
use std::sync::Arc; use std::sync::Arc;
use acadrust::kernel::geom2d::{ use cadkernel::geom2d::{
inside_spans, Curve as KernelCurve, Line as KernelLine, Tolerance, XLine as KernelXLine, inside_spans, Curve as KernelCurve, Line as KernelLine, Tolerance, XLine as KernelXLine,
}; };
+1 -1
View File
@@ -45,7 +45,7 @@ pub struct MeshModel {
/// Kernel-owned source for a view-dependent silhouette. /// Kernel-owned source for a view-dependent silhouette.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct CurvedGen { pub struct CurvedGen {
pub source: acadrust::kernel::brep::mesh::SilhouetteSource, pub source: cadkernel::brep::mesh::SilhouetteSource,
} }
#[derive(Clone, Copy, Debug, Default)] #[derive(Clone, Copy, Debug, Default)]
+3 -3
View File
@@ -13,7 +13,7 @@
// The resulting `Body` is cached per entity handle on the Scene so the // The resulting `Body` is cached per entity handle on the Scene so the
// Design-group boolean tools can run on it. // 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}; use crate::scene::model::mesh_model::{MeshLodSet, MeshModel};
@@ -24,7 +24,7 @@ fn tessellation(body: &Body) -> brep::mesh::BodyMesh {
brep::mesh::tessellate( brep::mesh::tessellate(
body, body,
brep::mesh::TessellationTolerance::new( brep::mesh::TessellationTolerance::new(
acadrust::kernel::tessellation::DEFAULT_ANGLE, cadkernel::tessellation::DEFAULT_ANGLE,
TOL, TOL,
), ),
) )
@@ -346,7 +346,7 @@ pub fn centre(body: &Body) -> Option<[f64; 3]> {
/// exists to test with. /// exists to test with.
#[cfg(test)] #[cfg(test)]
pub fn volume(body: &Body) -> f64 { pub fn volume(body: &Body) -> f64 {
use acadrust::kernel::space::Vec3; use cadkernel::space::Vec3;
let mesh = tessellation(body).mesh; let mesh = tessellation(body).mesh;
let Some(middle) = centre(body) else { let Some(middle) = centre(body) else {
return 0.0; return 0.0;
+6 -6
View File
@@ -12,9 +12,9 @@
// approximated into a surface nobody asked for. That is the kernel's answer // approximated into a surface nobody asked for. That is the kernel's answer
// and this module passes it on. // and this module passes it on.
use acadrust::kernel::brep::{self, Body}; use cadkernel::brep::{self, Body};
use acadrust::kernel::geom2d::Curve; use cadkernel::geom2d::Curve;
use acadrust::kernel::space::{PlanarCurve, Plane}; use cadkernel::space::{PlanarCurve, Plane};
use acadrust::EntityType; use acadrust::EntityType;
use crate::entities::curve::entity_curve; use crate::entities::curve::entity_curve;
@@ -57,7 +57,7 @@ pub fn profile_of(entity: &EntityType) -> Option<Profile> {
/// A circle as four arcs. /// A circle as four arcs.
fn quarters(centre: [f64; 2], radius: f64) -> Vec<Curve> { fn quarters(centre: [f64; 2], radius: f64) -> Vec<Curve> {
use acadrust::kernel::geom2d::Arc; use cadkernel::geom2d::Arc;
use std::f64::consts::FRAC_PI_2; use std::f64::consts::FRAC_PI_2;
(0..4) (0..4)
.map(|quarter| { .map(|quarter| {
@@ -112,7 +112,7 @@ use crate::scene::model::mesh_model::{MeshLodSet, MeshModel};
/// SWEEP through the kernel's tolerance-driven mesh API. /// SWEEP through the kernel's tolerance-driven mesh API.
pub fn swept(profile: &EntityType, path: &EntityType, color: [f32; 4]) -> Option<MeshLodSet> { pub fn swept(profile: &EntityType, path: &EntityType, color: [f32; 4]) -> Option<MeshLodSet> {
let max_angle = acadrust::kernel::tessellation::DEFAULT_ANGLE; let max_angle = cadkernel::tessellation::DEFAULT_ANGLE;
let surface = brep::mesh::sweep_surface( let surface = brep::mesh::sweep_surface(
&entity_curve(profile)?, &entity_curve(profile)?,
&entity_curve(path)?, &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. /// LOFT through the kernel's tolerance-driven mesh API.
pub fn lofted(profiles: &[EntityType], color: [f32; 4]) -> Option<MeshLodSet> { pub fn lofted(profiles: &[EntityType], color: [f32; 4]) -> Option<MeshLodSet> {
let curves: Vec<PlanarCurve> = profiles.iter().filter_map(entity_curve).collect(); let curves: Vec<PlanarCurve> = 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) mesh_set(brep::mesh::loft_surface(&curves, max_angle)?, color, 1e-9)
} }
+2 -2
View File
@@ -698,8 +698,8 @@ impl Scene {
translate_split(high, low); translate_split(high, low);
} }
for generator in &mut set.curved_gens { for generator in &mut set.curved_gens {
let placement = acadrust::kernel::brep::Placement::at(delta); let placement = cadkernel::brep::Placement::at(delta);
if let Some(source) = acadrust::kernel::brep::mesh::transform_silhouette( if let Some(source) = cadkernel::brep::mesh::transform_silhouette(
&generator.source, &generator.source,
&placement, &placement,
) { ) {
+1 -1
View File
@@ -2327,7 +2327,7 @@ impl Pipeline {
} }
}; };
for generator in &set.curved_gens { for generator in &set.curved_gens {
for point in acadrust::kernel::brep::mesh::silhouette( for point in cadkernel::brep::mesh::silhouette(
&generator.source, &generator.source,
[view.x, view.y, view.z], [view.x, view.y, view.z],
) { ) {