refactor(cad): use direct stack dependencies
This commit is contained in:
parent
3b4fbabdba
commit
ac8183ec91
36 changed files with 87 additions and 101 deletions
13
Cargo.lock
generated
13
Cargo.lock
generated
|
|
@ -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",
|
||||
|
|
|
|||
11
Cargo.toml
11
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"] }
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -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"] }
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1158,7 +1158,7 @@ pub enum CmdResult {
|
|||
/// rendering). Ends the command.
|
||||
CommitSolid {
|
||||
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
|
||||
/// editor on it (used by MLEADER to type the annotation after placement).
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/// 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;
|
||||
|
|
|
|||
|
|
@ -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<Curve> {
|
|||
|
||||
/// 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]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use acadrust::kernel::space::polygon;
|
||||
use cadkernel::space::polygon;
|
||||
use acadrust::{EntityType, Handle};
|
||||
use glam::DVec3;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -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()?;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue