From ac086def56de76150b377a0394ddeca15fb814e2 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Wed, 7 Oct 2026 21:38:17 +0300 Subject: [PATCH] review(#1653): upstream pins, registered expression xdata, table apply refreshes sweeps - Cargo: drop the fork patches; codec 8e93175, kernel 0665fc9, graph 3b91e67 in every manifest and lock. - A swept surface's expression link is written through set_entity_xdata, so OCS_SWEEP_EXPRESSION has its APPID record and the record its handle. - Applying the whole named-parameter table also rebuilds the swept surfaces linked to expressions, not only a single-row edit. - swept_surface_entity keeps its doc comment. - The native-constraint tests find a scope's network through its own dictionary, where it is now stored. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 8 ++++---- Cargo.toml | 15 ++++----------- crates/ocs_plugin_api/Cargo.toml | 4 ++-- crates/ocs_web_worker/Cargo.toml | 2 +- plugins/opencad-python/Cargo.lock | 2 +- src/app/command_driver/parameters.rs | 1 + src/app/command_driver/solid3d.rs | 11 ++++++++--- src/scene/dwg_native_constraints.rs | 10 ++-------- src/scene/model/sweep_command_model.rs | 21 +++++++++++++-------- src/scene/modify.rs | 4 ++-- 10 files changed, 38 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 94a71d2e4..736804900 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4205,7 +4205,7 @@ dependencies = [ [[package]] name = "opencadcodec" version = "0.6.0" -source = "git+https://github.com/ramox81/cadcodec.git?rev=64fe2a6#64fe2a6f8896d674d606ded65f4c9cc4b581ac66" +source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=8e93175#8e9317506f1522bad52920f7398223c1e3538860" dependencies = [ "anyhow", "bitflags 2.13.1", @@ -4228,7 +4228,7 @@ dependencies = [ [[package]] name = "opencadgraph" version = "0.1.0" -source = "git+https://github.com/HakanSeven12/opencadgraph.git?rev=ca3e6a2#ca3e6a20d70210d1422feec536e0c2422bfadfd0" +source = "git+https://github.com/HakanSeven12/opencadgraph.git?rev=3b91e67#3b91e67d7b2b19812f42249b59eb0646fa91e862" dependencies = [ "opencadkernel", "serde_json", @@ -4237,7 +4237,7 @@ dependencies = [ [[package]] name = "opencadkernel" version = "0.1.0" -source = "git+https://github.com/ramox81/cadkernel.git?rev=23138fc#23138fcd3ef251c5624164a2311b8b264e22341e" +source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=0665fc9#0665fc99dd3db6622557bd5773996f319a51ac38" dependencies = [ "cavalier_contours", "opencadcodec", @@ -4248,7 +4248,7 @@ dependencies = [ [[package]] name = "opencadkernel-constraints" version = "0.1.0" -source = "git+https://github.com/ramox81/cadkernel.git?rev=23138fc#23138fcd3ef251c5624164a2311b8b264e22341e" +source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=0665fc9#0665fc99dd3db6622557bd5773996f319a51ac38" dependencies = [ "nalgebra", ] diff --git a/Cargo.toml b/Cargo.toml index 8a6c8aa03..58e54e40d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,10 +34,10 @@ rfd = "0.17" clap = { version = "4", features = ["derive", "string"] } env_logger = "0.11" log = "0.4" -codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "063c106", features = ["serde"] } -kernel = { package = "opencadkernel", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "3f3781a", features = ["acis", "offset"] } -kernel-constraints = { package = "opencadkernel-constraints", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "3f3781a" } -graph = { package = "opencadgraph", git = "https://github.com/HakanSeven12/opencadgraph.git", rev = "ca3e6a2" } +codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "8e93175", features = ["serde"] } +kernel = { package = "opencadkernel", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "0665fc9", features = ["acis", "offset"] } +kernel-constraints = { package = "opencadkernel-constraints", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "0665fc9" } +graph = { package = "opencadgraph", git = "https://github.com/HakanSeven12/opencadgraph.git", rev = "3b91e67" } dwg-thumbnailer = { path = "crates/dwg-thumbnailer" } flate2 = "1" image = { version = "0.25", default-features = false, features = ["png", "jpeg", "bmp", "tiff"] } @@ -181,10 +181,3 @@ harness = false [[test]] name = "integration" path = "tests/integration.rs" - -[patch."https://github.com/HakanSeven12/opencadkernel.git"] -opencadkernel = { git = "https://github.com/ramox81/cadkernel.git", rev = "23138fc" } -opencadkernel-constraints = { git = "https://github.com/ramox81/cadkernel.git", rev = "23138fc" } - -[patch."https://github.com/HakanSeven12/opencadcodec.git"] -opencadcodec = { git = "https://github.com/ramox81/cadcodec.git", rev = "64fe2a6" } diff --git a/crates/ocs_plugin_api/Cargo.toml b/crates/ocs_plugin_api/Cargo.toml index 21b92c87b..fb6e4128d 100644 --- a/crates/ocs_plugin_api/Cargo.toml +++ b/crates/ocs_plugin_api/Cargo.toml @@ -15,7 +15,7 @@ serde_json = { version = "1", optional = true } # Pulled in only by the `host` feature, which adds the `opencadcodec`-typed # `HostApi` runtime surface. The default crate stays dependency-free so engine # crates and external tooling can depend on the manifest/ribbon contract cheaply. -codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "063c106", optional = true, features = ["serde"] } +codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "8e93175", optional = true, features = ["serde"] } # Runtime IPC and serialization (host feature only). interprocess = { version = "2", optional = true } @@ -39,7 +39,7 @@ serde_json = "1" serde = { version = "1", features = ["derive"] } cargo-lock = "11" # opencadcodec is scanned at build time to generate the embedded type registry. -codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "063c106", features = ["serde"] } +codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "8e93175", features = ["serde"] } [dev-dependencies] serde_json = "1" diff --git a/crates/ocs_web_worker/Cargo.toml b/crates/ocs_web_worker/Cargo.toml index 2b406da49..f02c62d3c 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] -codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "063c106", features = ["serde"] } +codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "8e93175", features = ["serde"] } bincode = "1.3" serde = { version = "1", features = ["derive"] } console_error_panic_hook = "0.1" diff --git a/plugins/opencad-python/Cargo.lock b/plugins/opencad-python/Cargo.lock index e85f37e82..9b9cf8566 100644 --- a/plugins/opencad-python/Cargo.lock +++ b/plugins/opencad-python/Cargo.lock @@ -1264,7 +1264,7 @@ dependencies = [ [[package]] name = "opencadcodec" version = "0.6.0" -source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=063c106#063c10671fe7833d562f772159771318c7a0ebb9" +source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=8e93175#8e9317506f1522bad52920f7398223c1e3538860" dependencies = [ "anyhow", "bitflags", diff --git a/src/app/command_driver/parameters.rs b/src/app/command_driver/parameters.rs index 573798723..cab5fc6f7 100644 --- a/src/app/command_driver/parameters.rs +++ b/src/app/command_driver/parameters.rs @@ -417,6 +417,7 @@ impl OpenCADStudio { let pending = self.begin_undo(i, "Apply named parameters", touched.len(), true); self.tabs[i].scene.record_undo_named_parameters_before(); self.tabs[i].scene.named_parameters = table; + self.tabs[i].scene.refresh_expression_sweeps(); self.tabs[i].dirty = true; if !touched.is_empty() { let changes: Vec<(Handle, crate::scene::ChangeKind)> = touched diff --git a/src/app/command_driver/solid3d.rs b/src/app/command_driver/solid3d.rs index 23c2e8814..d9a78dc21 100644 --- a/src/app/command_driver/solid3d.rs +++ b/src/app/command_driver/solid3d.rs @@ -539,9 +539,14 @@ impl OpenCADStudio { continue; } let created = if surface { - let mut entity = sweep_model::swept_surface_entity(&record); - sweep_model::link_sweep_expressions(&mut entity, &expressions); - self.add_surface_model(entity, body) + let created = + self.add_surface_model(sweep_model::swept_surface_entity(&record), body); + sweep_model::link_sweep_expressions( + &mut self.tabs[i].scene.document, + created, + &expressions, + ); + created } else { self.add_solid_model( empty_solid3d(), diff --git a/src/scene/dwg_native_constraints.rs b/src/scene/dwg_native_constraints.rs index 90c8175f2..ce2327f55 100644 --- a/src/scene/dwg_native_constraints.rs +++ b/src/scene/dwg_native_constraints.rs @@ -3189,14 +3189,8 @@ mod tests { } fn native_group_handle(document: &CadDocument, owner: Handle) -> Handle { - let dict = document - .extension_dictionary_handle(owner) - .expect("extension dictionary should exist"); - let Some(ObjectType::Dictionary(dictionary)) = document.objects.get(&dict) else { - panic!("expected owner's extension dictionary object to exist"); - }; - let network_handle = dictionary - .get(NETWORK_DICTIONARY_KEY) + // The scope's network sits under a dictionary of its own. + let network_handle = native_scope_network_handle(document, owner) .expect("ACAD_ASSOCNETWORK entry should exist"); let Some(ObjectType::Associative(AssociativeObject { data: AssociativeData::Network(network), diff --git a/src/scene/model/sweep_command_model.rs b/src/scene/model/sweep_command_model.rs index 7318e7eda..7913e22a6 100644 --- a/src/scene/model/sweep_command_model.rs +++ b/src/scene/model/sweep_command_model.rs @@ -315,22 +315,26 @@ pub fn swept_with_options(profile: &EntityType, path: &EntityType, mode: Extrude kernel::acis::rebuild_sweep_with_mode(&record, mode == ExtrudeMode::Surface).ok() } -/// Preserve native construction parameters alongside the sheet's saved B-rep. /// The application name of the expressions a swept surface stays linked to. pub const SWEEP_EXPRESSION_APP: &str = "OCS_SWEEP_EXPRESSION"; /// Links a swept surface to its scale and twist expressions (kept as the -/// surface's own data, so they are saved with the drawing). -pub fn link_sweep_expressions(entity: &mut EntityType, expressions: &[Option; 2]) { - if expressions.iter().all(Option::is_none) { return; } - let mut record = codec::xdata::ExtendedDataRecord::new(SWEEP_EXPRESSION_APP); +/// surface's own data, under a registered application, so they are saved +/// with the drawing). +pub fn link_sweep_expressions( + document: &mut codec::CadDocument, + handle: codec::Handle, + expressions: &[Option; 2], +) { + if handle.is_null() || expressions.iter().all(Option::is_none) { return; } + let mut values = Vec::new(); for (name, expression) in ["ScaleFactor", "TwistAngle"].iter().zip(expressions) { if let Some(expression) = expression { - record.add_value(codec::xdata::XDataValue::String(name.to_string())); - record.add_value(codec::xdata::XDataValue::String(expression.clone())); + values.push(codec::xdata::XDataValue::String(name.to_string())); + values.push(codec::xdata::XDataValue::String(expression.clone())); } } - entity.common_mut().extended_data.add_record(record); + crate::scene::view::dispatch::set_entity_xdata(document, handle, SWEEP_EXPRESSION_APP, Some(values)); } /// The scale and twist expressions a swept surface is linked to. @@ -382,6 +386,7 @@ pub fn surface_sweep_record(entity: &EntityType) -> Option { }) } +/// Preserve native construction parameters alongside the sheet's saved B-rep. pub fn swept_surface_entity(record: &SolidHistorySweep) -> EntityType { let mut surface = Surface::new(SurfaceKind::Swept); if let Ok(point) = kernel::acis::sweep_history_reference_point(record) { diff --git a/src/scene/modify.rs b/src/scene/modify.rs index 05ec7fd41..2ffb9bea6 100644 --- a/src/scene/modify.rs +++ b/src/scene/modify.rs @@ -1161,9 +1161,9 @@ impl Scene { } } for (handle, expressions) in links { - let Some(entity) = self.document.get_entity_mut(handle) else { continue }; + let Some(entity) = self.document.get_entity(handle) else { continue }; if crate::scene::model::sweep_model::sweep_expressions(entity).is_some() { continue; } - crate::scene::model::sweep_model::link_sweep_expressions(entity, &expressions); + crate::scene::model::sweep_model::link_sweep_expressions(&mut self.document, handle, &expressions); } }