forked from 1b-agent/opencadstudio-upstream
fix(dwg): preserve hatch context loops
This commit is contained in:
1 parent
3fb49c4d3e
commit
56e09cd3f5
7 files changed
+56
-31
No files matched your search
Generated
+2
-2
@@ -79,7 +79,7 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "acadrust"
|
name = "acadrust"
|
||||||
version = "0.5.4"
|
version = "0.5.4"
|
||||||
source = "git+https://github.com/HakanSeven12/cadcodec.git?rev=f438e7312a98c936c0de1e3404893cf095369a26#f438e7312a98c936c0de1e3404893cf095369a26"
|
source = "git+https://github.com/HakanSeven12/cadcodec.git?rev=f1ef57eddb6ffba91bc529e16b5dc39e2aef975c#f1ef57eddb6ffba91bc529e16b5dc39e2aef975c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash 0.8.12",
|
"ahash 0.8.12",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@@ -885,7 +885,7 @@ 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=922ce39e248f610696ebabf97a76a85ee2e11e20#922ce39e248f610696ebabf97a76a85ee2e11e20"
|
source = "git+https://github.com/HakanSeven12/cadkernel.git?rev=98b273c384a3b9ec706f7e53436dbb9ac7c6ec82#98b273c384a3b9ec706f7e53436dbb9ac7c6ec82"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"acadrust",
|
"acadrust",
|
||||||
"cavalier_contours",
|
"cavalier_contours",
|
||||||
|
|||||||
+2
-2
@@ -31,8 +31,8 @@ glam = { version = "0.33", features = ["bytemuck"] }
|
|||||||
rfd = "0.17"
|
rfd = "0.17"
|
||||||
clap = { version = "4", features = ["derive", "string"] }
|
clap = { version = "4", features = ["derive", "string"] }
|
||||||
env_logger = "0.11"
|
env_logger = "0.11"
|
||||||
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "f438e7312a98c936c0de1e3404893cf095369a26", features = ["serde"] }
|
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "f1ef57eddb6ffba91bc529e16b5dc39e2aef975c", features = ["serde"] }
|
||||||
cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "922ce39e248f610696ebabf97a76a85ee2e11e20", features = ["acis", "offset"] }
|
cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "98b273c384a3b9ec706f7e53436dbb9ac7c6ec82", features = ["acis", "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"] }
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ bincode = "1.3"
|
|||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
|
|
||||||
# Host adapters convert ObjectId to acadrust handles; kernel handles stay local.
|
# Host adapters convert ObjectId to acadrust handles; kernel handles stay local.
|
||||||
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "f438e7312a98c936c0de1e3404893cf095369a26", features = ["serde"], optional = true }
|
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "f1ef57eddb6ffba91bc529e16b5dc39e2aef975c", features = ["serde"], optional = true }
|
||||||
cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "922ce39e248f610696ebabf97a76a85ee2e11e20", features = ["acis", "offset"], optional = true }
|
cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "98b273c384a3b9ec706f7e53436dbb9ac7c6ec82", features = ["acis", "offset"], optional = true }
|
||||||
ocs_plugin_api = { path = "../ocs_plugin_api", optional = true, features = ["host"] }
|
ocs_plugin_api = { path = "../ocs_plugin_api", optional = true, features = ["host"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ serde = { version = "1", features = ["derive"] }
|
|||||||
# 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 = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "f438e7312a98c936c0de1e3404893cf095369a26", optional = true, features = ["serde"] }
|
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "f1ef57eddb6ffba91bc529e16b5dc39e2aef975c", 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 }
|
||||||
@@ -38,7 +38,7 @@ serde_json = "1"
|
|||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
cargo-lock = "11"
|
cargo-lock = "11"
|
||||||
# acadrust is scanned at build time to generate the embedded type registry.
|
# acadrust is scanned at build time to generate the embedded type registry.
|
||||||
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "f438e7312a98c936c0de1e3404893cf095369a26", features = ["serde"] }
|
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "f1ef57eddb6ffba91bc529e16b5dc39e2aef975c", features = ["serde"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
@@ -8,7 +8,7 @@ publish = false
|
|||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "f438e7312a98c936c0de1e3404893cf095369a26", features = ["serde"] }
|
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "f1ef57eddb6ffba91bc529e16b5dc39e2aef975c", features = ["serde"] }
|
||||||
bincode = "1.3"
|
bincode = "1.3"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
console_error_panic_hook = "0.1"
|
console_error_panic_hook = "0.1"
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ crate-type = ["cdylib"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ocs_plugin_api = { path = "../ocs_plugin_api", features = ["host"] }
|
ocs_plugin_api = { path = "../ocs_plugin_api", features = ["host"] }
|
||||||
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "f438e7312a98c936c0de1e3404893cf095369a26", features = ["serde"] }
|
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "f1ef57eddb6ffba91bc529e16b5dc39e2aef975c", features = ["serde"] }
|
||||||
+46
-21
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
use acadrust::entities::{EntityCommon, EntityType};
|
use acadrust::entities::{EntityCommon, EntityType};
|
||||||
use acadrust::objects::{
|
use acadrust::objects::{
|
||||||
Dictionary, DimContext, DimSubtype, EmbeddedMTextContext, HatchScaleContext,
|
Dictionary, DimContext, DimSubtype, EmbeddedMTextContext, HatchLoopContext, HatchScaleContext,
|
||||||
MTextAttributeContext, MTextContext, ObjectContextData, ObjectContextKind, ObjectType,
|
MTextAttributeContext, MTextContext, ObjectContextData, ObjectContextKind, ObjectType,
|
||||||
};
|
};
|
||||||
use acadrust::types::{Vector2, Vector3};
|
use acadrust::types::{Vector2, Vector3};
|
||||||
@@ -289,12 +289,15 @@ fn context_kind_for(
|
|||||||
pattern_lines: hatch.pattern.lines.clone(),
|
pattern_lines: hatch.pattern.lines.clone(),
|
||||||
pattern_scale: hatch.pattern_scale,
|
pattern_scale: hatch.pattern_scale,
|
||||||
pattern_base: Vector3::ZERO,
|
pattern_base: Vector3::ZERO,
|
||||||
loop_types: hatch
|
loops: hatch
|
||||||
.paths
|
.paths
|
||||||
.iter()
|
.iter()
|
||||||
.map(|path| path.flags.bits() as i32)
|
.map(|path| HatchLoopContext {
|
||||||
|
loop_type: path.flags.bits() as i32,
|
||||||
|
supports_context: true,
|
||||||
|
boundary: None,
|
||||||
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
supports_context: true,
|
|
||||||
}),
|
}),
|
||||||
)),
|
)),
|
||||||
_ => None,
|
_ => None,
|
||||||
@@ -435,10 +438,6 @@ pub fn create_annotation_context(
|
|||||||
is_default,
|
is_default,
|
||||||
scale: scale_handle,
|
scale: scale_handle,
|
||||||
kind,
|
kind,
|
||||||
raw_dwg_data: None,
|
|
||||||
raw_dwg_handle_bits: 0,
|
|
||||||
raw_dwg_version: None,
|
|
||||||
raw_dwg_snapshot: None,
|
|
||||||
};
|
};
|
||||||
doc.objects
|
doc.objects
|
||||||
.insert(leaf_h, ObjectType::ObjectContextData(leaf));
|
.insert(leaf_h, ObjectType::ObjectContextData(leaf));
|
||||||
@@ -895,9 +894,43 @@ fn apply_hatch_context(hatch: &mut acadrust::entities::Hatch, context: &HatchSca
|
|||||||
line.base_point.x += context.pattern_base.x;
|
line.base_point.x += context.pattern_base.x;
|
||||||
line.base_point.y += context.pattern_base.y;
|
line.base_point.y += context.pattern_base.y;
|
||||||
}
|
}
|
||||||
for (path, bits) in hatch.paths.iter_mut().zip(&context.loop_types) {
|
let base_paths = std::mem::take(&mut hatch.paths);
|
||||||
path.flags = acadrust::entities::BoundaryPathFlags::from_bits(*bits as u32);
|
hatch.paths = context
|
||||||
}
|
.loops
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(index, loop_data)| {
|
||||||
|
let flags =
|
||||||
|
acadrust::entities::BoundaryPathFlags::from_bits(loop_data.loop_type as u32);
|
||||||
|
let mut path = if loop_data.supports_context {
|
||||||
|
base_paths.get(index).cloned()
|
||||||
|
} else {
|
||||||
|
loop_data.boundary.clone()
|
||||||
|
}
|
||||||
|
.unwrap_or_else(|| acadrust::entities::BoundaryPath::with_flags(flags));
|
||||||
|
path.flags = flags;
|
||||||
|
path
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sync_hatch_loops(loops: &mut Vec<HatchLoopContext>, paths: &[acadrust::entities::BoundaryPath]) {
|
||||||
|
let previous = std::mem::take(loops);
|
||||||
|
*loops = paths
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(index, path)| {
|
||||||
|
let supports_context = previous
|
||||||
|
.get(index)
|
||||||
|
.map(|loop_data| loop_data.supports_context)
|
||||||
|
.unwrap_or(true);
|
||||||
|
HatchLoopContext {
|
||||||
|
loop_type: path.flags.bits() as i32,
|
||||||
|
supports_context,
|
||||||
|
boundary: (!supports_context).then(|| path.clone()),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn entity_for_annotation_context<'a>(
|
pub fn entity_for_annotation_context<'a>(
|
||||||
@@ -1239,11 +1272,7 @@ pub fn sync_annotation_context_from_entity(
|
|||||||
line.base_point.y -= context.pattern_base.y;
|
line.base_point.y -= context.pattern_base.y;
|
||||||
}
|
}
|
||||||
context.pattern_scale = hatch.pattern_scale;
|
context.pattern_scale = hatch.pattern_scale;
|
||||||
context.loop_types = hatch
|
sync_hatch_loops(&mut context.loops, &hatch.paths);
|
||||||
.paths
|
|
||||||
.iter()
|
|
||||||
.map(|path| path.flags.bits() as i32)
|
|
||||||
.collect();
|
|
||||||
}
|
}
|
||||||
(EntityType::Hatch(hatch), ObjectContextKind::HatchView(context)) => {
|
(EntityType::Hatch(hatch), ObjectContextKind::HatchView(context)) => {
|
||||||
context.hatch.pattern_lines.clone_from(&hatch.pattern.lines);
|
context.hatch.pattern_lines.clone_from(&hatch.pattern.lines);
|
||||||
@@ -1252,11 +1281,7 @@ pub fn sync_annotation_context_from_entity(
|
|||||||
line.base_point.y -= context.hatch.pattern_base.y;
|
line.base_point.y -= context.hatch.pattern_base.y;
|
||||||
}
|
}
|
||||||
context.hatch.pattern_scale = hatch.pattern_scale;
|
context.hatch.pattern_scale = hatch.pattern_scale;
|
||||||
context.hatch.loop_types = hatch
|
sync_hatch_loops(&mut context.hatch.loops, &hatch.paths);
|
||||||
.paths
|
|
||||||
.iter()
|
|
||||||
.map(|path| path.flags.bits() as i32)
|
|
||||||
.collect();
|
|
||||||
context.view_normal = hatch.normal;
|
context.view_normal = hatch.normal;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|||||||
Reference in new issue
Block a user