refactor(cad): use direct stack dependencies

This commit is contained in:
Hakan Seven 2026-08-10 15:03:31 +03:00
commit ac8183ec91
36 changed files with 87 additions and 101 deletions

View file

@ -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.
///

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
//! 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<SatDocument> {
let mut document = SatDocument::new();
append(body, &mut document).ok()?;

View file

@ -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));
}

View file

@ -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(),

View file

@ -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<Handle, acadrust::kernel::brep::Body>,
pub solid_models: HashMap<Handle, cadkernel::brep::Body>,
/// GPU render data for raster images (RasterImage entities), keyed by handle.
pub images: HashMap<Handle, ImageModel>,
/// 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)

View file

@ -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,
};

View file

@ -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)]

View file

@ -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;

View file

@ -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<Profile> {
/// A circle as four arcs.
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;
(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<MeshLodSet> {
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<MeshLodSet> {
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)
}

View file

@ -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,
) {

View file

@ -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],
) {