DXF/DWG import: hatches follow their island style

Every boundary loop of a hatch went into one even-odd area, which is
right for the normal island style (group 75 = 0) only. With the outer
style (1) the area inside an outermost loop and outside the islands
directly in it is hatched, and islands inside islands are not; with
the ignore style (2) only the outermost loops are, and islands leave no
holes. This applies to solid, gradient and pattern hatches.

A loop counts as inside another when its bounds lie within the other's,
its area is smaller, and most of up to 16 points taken just inside it
lie inside the other loop. Each loop is measured around its own center,
so loops far from the origin, or far from each other, keep their
precision. A hatch whose nesting test would take more than 10,000,000
steps is filled as if every loop were a boundary, with a warning.
This commit is contained in:
dotCooCoo committed 2026-12-04 22:09:32 -08:00
1 parent fc73fd9e2a
commit 3e1fb85fd6
4 files changed
+404 -7

No files matched your search

+93 -3
View File
@@ -3,7 +3,7 @@
use std::collections::BTreeMap;
use kurbo::{BezPath, PathEl};
use kurbo::{BezPath, ParamCurve, ParamCurveDeriv, PathEl, PathSeg, Shape};
use vectorcraft_doc::Justify;
use vectorcraft_geom::{Affine, Point, Vec2};
@@ -21,6 +21,10 @@ const LINE_SPACING: f64 = 5.0 / 3.0;
const MAX_CELLS: i64 = 10_000;
/// The most copies all the array inserts of a file make together.
const MAX_TOTAL_CELLS: i64 = 2_000_000;
/// The most winding steps for island nesting: loops times boundary elements times samples.
const MAX_ISLAND_WORK: usize = if cfg!(test) { 1_000 } else { 10_000_000 };
/// The most segment midpoints sampled just inside each loop for island nesting.
const MAX_ISLAND_SAMPLES: usize = 16;
/// Art farther than this from the origin (drawing units) is damaged data, left out.
const MAX_COORD: f64 = 1e12;
/// How far fit and aligned text may be squeezed or stretched to span their two points: at width
@@ -198,6 +202,7 @@ const PATTERN_HATCH: &str = "pattern hatches without usable pattern lines come i
const DENSE_PATTERN: &str = "pattern hatches of more than 20,000 dashes come in as their boundaries";
const MANY_PATTERNS: &str = "the drawing's pattern hatches have more than 2,000,000 dashes in all: the rest come in as their boundaries";
const MUCH_PATTERN_WORK: &str = "the drawing's pattern hatches take too much work to clip: the rest come in as their boundaries";
const MUCH_ISLAND_WORK: &str = "hatches with too many boundary points to sort into islands are filled as if every loop were a boundary";
const MESH_VERTICES: &str = "polygon meshes and polyface mesh faces whose vertices are missing are left out";
const BIG_ARRAY: &str = "array inserts are limited to 10,000 copies each";
const MANY_ARRAYS: &str = "array inserts are limited to 2,000,000 copies in all";
@@ -400,10 +405,95 @@ impl Converter {
/// A hatch's art; `own`: its color, which a gradient without color records takes.
fn hatch(&mut self, h: &model::Hatch, ocs: Affine, own: Col) -> Option<Geom> {
let mut bp = BezPath::new();
let mut loops = Vec::new();
for l in &h.loops {
let Some(path) = boundary(&l.path) else { break };
bp.extend(path);
loops.push(path);
}
let mut max_depth = match h.style {
1 => Some(1),
2 => Some(0),
_ => None,
};
if max_depth.is_some() {
let elements = loops.iter().fold(0usize, |total, path| total.saturating_add(path.elements().len()));
// Count each loop's samples against every loop, including its own containment checks.
if loops.len().saturating_mul(elements).saturating_mul(MAX_ISLAND_SAMPLES) > MAX_ISLAND_WORK {
self.warn(MUCH_ISLAND_WORK);
max_depth = None;
}
}
let nesting: Vec<_> = if max_depth.is_some() {
loops
.iter()
.map(|path| {
let bounds = path.bounding_box();
// Center each loop independently so distant loops do not erase small geometry.
let center = bounds.center();
let local = transformed(path.clone(), Affine::translate(-center.to_vec2()));
let area = local.area();
// Area divided by perimeter measures thickness independently of the loop's rotation.
let perimeter = local.perimeter(bounds.width().max(bounds.height()) * 1e-3);
let inset = if perimeter > 0.0 { area.abs() / perimeter * 1e-3 * area.signum() } else { 0.0 };
let step = local.segments().count().div_ceil(MAX_ISLAND_SAMPLES).max(1);
let mut samples: Vec<_> = local
.segments()
.step_by(step)
.filter_map(|segment| {
let tangent = match segment {
PathSeg::Line(line) => line.deriv().eval(0.5),
PathSeg::Quad(quad) => quad.deriv().eval(0.5),
PathSeg::Cubic(cubic) => cubic.deriv().eval(0.5),
}
.to_vec2();
let tangent = if tangent.hypot() > 0.0 { tangent } else { segment.end() - segment.start() };
let length = tangent.hypot();
if length == 0.0 {
return None;
}
// Positive area puts the interior to the left of the tangent in y-up coordinates.
Some(segment.eval(0.5) + Vec2::new(-tangent.y, tangent.x) * (inset / length))
})
.take(MAX_ISLAND_SAMPLES)
.filter(|sample| local.winding(*sample) != 0)
.collect();
if samples.is_empty()
&& let Some(PathEl::MoveTo(first)) = local.elements().first()
{
samples.push(*first);
}
(bounds, center, local, area.abs(), samples)
})
.collect()
} else {
Vec::new()
};
let mut bp = BezPath::new();
for (i, path) in loops.iter().enumerate() {
if let Some(limit) = max_depth {
let (bounds, center, _, area, samples) = &nesting[i];
// Require geometric containment and a majority of samples so a shared
// edge or a single vertex on the boundary does not decide nesting.
let depth = nesting
.iter()
.enumerate()
.filter(|(j, _)| {
let (other_bounds, other_center, other, other_area, _) = &nesting[*j];
let offset = *center - *other_center;
*j != i
&& area < other_area
&& bounds.x0 >= other_bounds.x0
&& bounds.y0 >= other_bounds.y0
&& bounds.x1 <= other_bounds.x1
&& bounds.y1 <= other_bounds.y1
&& samples.iter().filter(|p| other.winding(**p + offset) != 0).count() > samples.len() / 2
})
.count();
if depth > limit {
continue;
}
}
bp.extend(path.iter());
}
if bp.elements().is_empty() {
return None;
+308 -1
View File
@@ -4,7 +4,7 @@
use std::sync::Arc;
use kurbo::ParamCurve;
use kurbo::{ParamCurve, Shape};
use vectorcraft_color::{Color, Paint};
use vectorcraft_doc::{Appearance, Document, Justify, LineCap, Node, NodeKind, TextObject, Unit};
use vectorcraft_geom::{Affine, FillRule, Point, Rect, shapes};
@@ -517,6 +517,313 @@ fn pattern_hatch(linetype: &'static str, dashes: &[(i32, &'static str)]) -> Vec<
e
}
#[test]
fn ignore_islands_hatches_fill_and_pattern_through_the_hole() {
let mut e = hatch("1");
*e.iter_mut().find(|p| p.0 == 75).unwrap() = (75, "2");
let r = open(&entities(&e), &points());
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
let [area] = &r.document.layers[0].children().unwrap()[..] else { panic!("one hatch") };
let path = area.path_data().unwrap();
assert_eq!(path.subpaths.len(), 1, "ignore islands leaves only the outer square");
assert!(path.subpaths[0].closed);
assert!(area.appearance.fill().is_some_and(|f| !f.paint.is_none()));
let box_area = bounds(area).area();
assert!((path.to_bezpath().area().abs() - box_area).abs() < box_area * 1e-9, "the whole square is filled");
let mut e = pattern_hatch("CONTINUOUS", &[]);
*e.iter_mut().find(|p| p.0 == 75).unwrap() = (75, "2");
let r = open(&entities(&e), &points());
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
let [lines] = &r.document.layers[0].children().unwrap()[..] else { panic!("one hatch") };
let NodeKind::Compound { children, .. } = &lines.kind else { panic!("{:?}", lines.kind) };
assert_eq!(children.len(), 10, "the ten level lines are not cut by the hole");
let width = bounds(lines).width();
assert!(children.iter().all(|c| (bounds(c).width() - width).abs() < width * 1e-9), "each line spans the square");
}
#[test]
fn hatch_island_styles_select_nested_boundary_levels() {
let mut e = hatch("1");
let count = e.iter().position(|p| p.0 == 91).unwrap();
let end = e.iter().position(|p| p.0 == 75).unwrap();
e[count] = (91, "3");
let mut loops = Vec::new();
// Innermost first so nesting depends on geometry, not boundary order or flags.
for (lo, hi) in [("40", "60"), ("0", "100"), ("20", "80")] {
loops.extend([
(92, "2"),
(72, "0"),
(73, "1"),
(93, "4"),
(10, lo),
(20, lo),
(10, hi),
(20, lo),
(10, hi),
(20, hi),
(10, lo),
(20, hi),
(97, "0"),
]);
}
e.splice(count + 1..end, loops);
for (style, expected) in [("0", 3), ("1", 2), ("2", 1), ("3", 3)] {
*e.iter_mut().find(|p| p.0 == 75).unwrap() = (75, style);
let r = open(&entities(&e), &points());
assert!(r.warnings.is_empty(), "style {style}: {:?}", r.warnings);
let [area] = &r.document.layers[0].children().unwrap()[..] else { panic!("one hatch") };
let count = match &area.kind {
NodeKind::Compound { children, rule } => {
assert_eq!(*rule, FillRule::EvenOdd);
children.len()
}
_ => area.path_data().unwrap().subpaths.len(),
};
assert_eq!(count, expected, "boundary loops for island style {style}");
assert!(area.appearance.fill().is_some_and(|f| !f.paint.is_none()));
}
}
#[test]
fn hatch_ignore_islands_drops_small_island_far_from_origin() {
let mut e = hatch("1");
let start = e.iter().position(|p| p.0 == 92).unwrap();
let end = e.iter().position(|p| p.0 == 75).unwrap();
let mut loops = Vec::new();
for (lo, hi) in [("100000000", "100000001"), ("100000000.2", "100000000.8")] {
loops.extend([(92, "2"), (72, "0"), (73, "1"), (93, "4")]);
for (x, y) in [(lo, lo), (hi, lo), (hi, hi), (lo, hi)] {
loops.extend([(10, x), (20, y)]);
}
loops.push((97, "0"));
}
e.splice(start..end, loops);
*e.iter_mut().find(|p| p.0 == 75).unwrap() = (75, "2");
// Centered, so the art far from the drawing's origin lands on the canvas.
let r = open(&entities(&e), &ImportOptions { center: true, ..points() });
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
let [area] = &r.document.layers[0].children().unwrap()[..] else { panic!("one hatch") };
let path = area.path_data().unwrap();
assert_eq!(path.subpaths.len(), 1, "the small island far from the origin is removed");
}
#[test]
fn hatch_ignore_islands_drops_small_island_with_distant_outer_loop() {
let mut e = hatch("1");
let start = e.iter().position(|p| p.0 == 92).unwrap();
let end = e.iter().position(|p| p.0 == 75).unwrap();
*e.iter_mut().find(|p| p.0 == 91).unwrap() = (91, "3");
let mut loops = Vec::new();
for (lo, hi) in [("0", "1"), ("0.2", "0.8"), ("100000000", "100000001")] {
loops.extend([(92, "2"), (72, "0"), (73, "1"), (93, "4")]);
for (x, y) in [(lo, lo), (hi, lo), (hi, hi), (lo, hi)] {
loops.extend([(10, x), (20, y)]);
}
loops.push((97, "0"));
}
e.splice(start..end, loops);
*e.iter_mut().find(|p| p.0 == 75).unwrap() = (75, "2");
// Fitted to the artboard: the drawing spans more than the canvas holds at 1:1.
let r = open(&entities(&e), &ImportOptions { fit: true, ..points() });
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
let [area] = &r.document.layers[0].children().unwrap()[..] else { panic!("one hatch") };
let NodeKind::Compound { children, .. } = &area.kind else { panic!("both outer boundary loops must remain") };
assert_eq!(children.len(), 2, "the island is removed and both outer squares remain");
}
#[test]
fn hatch_ignore_islands_drops_tiny_island_with_distant_outer_loop() {
let mut e = hatch("1");
let start = e.iter().position(|p| p.0 == 92).unwrap();
let end = e.iter().position(|p| p.0 == 75).unwrap();
*e.iter_mut().find(|p| p.0 == 91).unwrap() = (91, "3");
let mut loops = Vec::new();
for (lo, hi) in [("0", "0.000001"), ("0.0000002", "0.0000008"), ("100000000000", "100000000001")] {
loops.extend([(92, "2"), (72, "0"), (73, "1"), (93, "4")]);
for (x, y) in [(lo, lo), (hi, lo), (hi, hi), (lo, hi)] {
loops.extend([(10, x), (20, y)]);
}
loops.push((97, "0"));
}
e.splice(start..end, loops);
*e.iter_mut().find(|p| p.0 == 75).unwrap() = (75, "2");
// Fitted to the artboard: the drawing spans more than the canvas holds at 1:1.
let r = open(&entities(&e), &ImportOptions { fit: true, ..points() });
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
let [area] = &r.document.layers[0].children().unwrap()[..] else { panic!("one hatch") };
let NodeKind::Compound { children, .. } = &area.kind else { panic!("both outer boundary loops must remain") };
assert_eq!(children.len(), 2, "the tiny island is removed and both outer squares remain");
}
#[test]
fn hatch_ignore_islands_keeps_squares_sharing_an_edge() {
let mut e = hatch("1");
let start = e.iter().position(|p| p.0 == 92).unwrap();
let end = e.iter().position(|p| p.0 == 75).unwrap();
let mut loops = Vec::new();
// The first vertex lies on the second square's left edge.
for vertices in [[("10", "0"), ("10", "10"), ("0", "10"), ("0", "0")], [("10", "0"), ("20", "0"), ("20", "10"), ("10", "10")]] {
loops.extend([(92, "2"), (72, "0"), (73, "1"), (93, "4")]);
for (x, y) in vertices {
loops.extend([(10, x), (20, y)]);
}
loops.push((97, "0"));
}
e.splice(start..end, loops);
*e.iter_mut().find(|p| p.0 == 75).unwrap() = (75, "2");
let r = open(&entities(&e), &points());
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
let [area] = &r.document.layers[0].children().unwrap()[..] else { panic!("one hatch") };
let NodeKind::Compound { children, .. } = &area.kind else { panic!("both boundary loops must remain") };
assert_eq!(children.len(), 2, "adjacent squares are both boundaries");
}
#[test]
fn hatch_ignore_islands_drops_square_touching_outer_boundary_at_a_vertex() {
let mut e = hatch("1");
let start = e.iter().position(|p| p.0 == 92).unwrap();
let end = e.iter().position(|p| p.0 == 75).unwrap();
let mut loops = Vec::new();
// The island's first vertex touches the outer square's right edge, where
// winding is zero. Its other vertices and all segment midpoints are inside.
for vertices in [[("100", "50"), ("75", "75"), ("50", "50"), ("75", "25")], [("0", "0"), ("100", "0"), ("100", "100"), ("0", "100")]] {
loops.extend([(92, "2"), (72, "0"), (73, "1"), (93, "4")]);
for (x, y) in vertices {
loops.extend([(10, x), (20, y)]);
}
loops.push((97, "0"));
}
e.splice(start..end, loops);
*e.iter_mut().find(|p| p.0 == 75).unwrap() = (75, "2");
let r = open(&entities(&e), &points());
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
let [area] = &r.document.layers[0].children().unwrap()[..] else { panic!("one hatch") };
let path = area.path_data().unwrap();
assert_eq!(path.subpaths.len(), 1, "the touching island is removed");
}
#[test]
fn hatch_ignore_islands_drops_square_sharing_two_outer_edges() {
let mut e = hatch("1");
let start = e.iter().position(|p| p.0 == 92).unwrap();
let end = e.iter().position(|p| p.0 == 75).unwrap();
let mut loops = Vec::new();
for vertices in [[("50", "50"), ("100", "50"), ("100", "100"), ("50", "100")], [("0", "0"), ("100", "0"), ("100", "100"), ("0", "100")]] {
loops.extend([(92, "2"), (72, "0"), (73, "1"), (93, "4")]);
for (x, y) in vertices {
loops.extend([(10, x), (20, y)]);
}
loops.push((97, "0"));
}
e.splice(start..end, loops);
*e.iter_mut().find(|p| p.0 == 75).unwrap() = (75, "2");
let r = open(&entities(&e), &points());
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
let [area] = &r.document.layers[0].children().unwrap()[..] else { panic!("one hatch") };
let path = area.path_data().unwrap();
assert_eq!(path.subpaths.len(), 1, "the island sharing two outer edges is removed");
}
#[test]
fn hatch_ignore_islands_drops_thin_island() {
let mut e = hatch("1");
let start = e.iter().position(|p| p.0 == 92).unwrap();
let end = e.iter().position(|p| p.0 == 75).unwrap();
let mut loops = Vec::new();
for vertices in [
[("0", "0"), ("100", "0"), ("100", "0.00001"), ("0", "0.00001")],
[("10", "0.000002"), ("90", "0.000002"), ("90", "0.000008"), ("10", "0.000008")],
] {
loops.extend([(92, "2"), (72, "0"), (73, "1"), (93, "4")]);
for (x, y) in vertices {
loops.extend([(10, x), (20, y)]);
}
loops.push((97, "0"));
}
e.splice(start..end, loops);
*e.iter_mut().find(|p| p.0 == 75).unwrap() = (75, "2");
let r = open(&entities(&e), &points());
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
let [area] = &r.document.layers[0].children().unwrap()[..] else { panic!("one hatch") };
let path = area.path_data().unwrap();
assert_eq!(path.subpaths.len(), 1, "the thin island is removed");
}
#[test]
fn hatch_ignore_islands_drops_rotated_thin_island() {
let mut e = hatch("1");
let start = e.iter().position(|p| p.0 == 92).unwrap();
let end = e.iter().position(|p| p.0 == 75).unwrap();
let mut loops = Vec::new();
// These are the previous test's corners turned 45 degrees about the origin.
for vertices in [
[("0", "0"), ("70.7106781187", "70.7106781187"), ("70.7106710476", "70.7106851897"), ("-0.00000707106781187", "0.00000707106781187")],
[
("7.07106639765", "7.07106922608"),
("63.6396088926", "63.6396117210"),
("63.6396046499", "63.6396159636"),
("7.07106215421", "7.07107346952"),
],
] {
loops.extend([(92, "2"), (72, "0"), (73, "1"), (93, "4")]);
for (x, y) in vertices {
loops.extend([(10, x), (20, y)]);
}
loops.push((97, "0"));
}
e.splice(start..end, loops);
*e.iter_mut().find(|p| p.0 == 75).unwrap() = (75, "2");
let r = open(&entities(&e), &points());
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
let [area] = &r.document.layers[0].children().unwrap()[..] else { panic!("one hatch") };
let path = area.path_data().unwrap();
assert_eq!(path.subpaths.len(), 1, "the rotated thin island is removed");
}
#[test]
fn hatch_island_work_limit_keeps_all_loops_and_warns_only_for_island_styles() {
let mut e = hatch("1");
let count = e.iter().position(|p| p.0 == 91).unwrap();
let hole = e.iter().position(|p| *p == (92, "0")).unwrap();
let end = e.iter().position(|p| p.0 == 75).unwrap();
e[count] = (91, "16");
// Keep the outer square and add 15 inner squares. With at least five path elements
// per square, 16 loops require at least 1,280 steps, over the test-time limit.
// Without the fallback, ignore style removes the inner squares.
let inner = [
(92, "2"),
(72, "0"),
(73, "1"),
(93, "4"),
(10, "20"),
(20, "20"),
(10, "80"),
(20, "20"),
(10, "80"),
(20, "80"),
(10, "20"),
(20, "80"),
(97, "0"),
];
e.splice(hole..end, inner.repeat(15));
for style in ["2", "0"] {
*e.iter_mut().find(|p| p.0 == 75).unwrap() = (75, style);
let r = open(&entities(&e), &points());
let [area] = &r.document.layers[0].children().unwrap()[..] else { panic!("one hatch") };
let count = match &area.kind {
NodeKind::Compound { children, .. } => children.len(),
_ => area.path_data().unwrap().subpaths.len(),
};
assert_eq!(count, 16, "every boundary loop is kept for style {style}");
if style == "2" {
assert_eq!(r.warnings, ["hatches with too many boundary points to sort into islands are filled as if every loop were a boundary"]);
} else {
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
}
}
}
#[test]
fn pattern_hatches_draw_their_lines_inside_the_boundary() {
// A dashed linetype on the hatch: its pattern lines stay solid, as the pattern defines them.
+1 -1
View File
@@ -371,7 +371,7 @@ Gradient meshes in the editing data keep each point's own color where a patch's
| PostScript `.ps` | open, place | yes (the EPS reader reads its first page; `.epsf` files open and place as EPS) | via Print to PostScript | `tests_epsimport.rs` |
| DCS 1.0 / 2.0 | place linked | place linked only (one image of the plates; spot plates as spot swatches; the composite's clipping path; each plate on its own ink in Separations Preview and print separations) | no | `crates/eps/src/dcs/tests.rs`, `crates/engine/src/tests/dcs.rs` |
| SVG / SVGZ | open, place, save | yes | yes (SVG Options, Preserve Editing, symbols, filters, rich text) | strongest format; tests in `crates/svg/tests`; text on a path follows basic shapes as their SVG 2 equivalent paths (#1527); CSS transforms and the `font` shorthand (#1565), percentage lengths in symbols (#1596), Inkscape flowed text as area type (#1568) and Inkscape pages as artboards (#1601) import; an unsupported filter is named in its warning (#1598); an artboard exported on its own (Export As with Use Artboards, Export for Screens, Asset Export) has the artboard's name as `<title>`, Save the document's (#3544); attributes in other applications' XML namespaces (`plotter:pen="2"`) kept on their objects from import to export, as `data-*` attributes are (`crates/svg/tests/it/foreign_attributes.rs`); simple shapes export as `<rect>`, `<circle>`, `<ellipse>`, `<line>`, `<polygon>` and `<polyline>` where they draw the same as the path (#4652, `crates/svg/tests/it/basic_shapes.rs`); the regions of exported masks and filters (opacity masks, inverted masks, knockout groups) cover the art they apply to, and over type keep a region that covers any artwork (#6401, `crates/svg/tests/it/blend_export.rs`); a masked group, or a knockout group's masked group, whose content has a shadow, glow, blur or feather starts with a hidden, unpainted rectangle over the mask's region, so readers that draw a masked group only inside the box of its shapes draw those effects too (`crates/svg/tests/it/blend_export.rs`); SVG Options › Include Variable Data writes the text variables, data sets and bound type objects, and opening the SVG reads them back (`tests::variables::an_svg_with_variable_data_opens_with_its_variables_data_sets_and_bindings`); SVG Options › Units writes `width` and `height` in px (bare numbers, the default), pt, mm, cm or in, the `viewBox` staying in points, for software that reads physical size such as LaserGRBL (#4462, `crates/svg/tests/it/roundtrip.rs`) |
| DXF | open, export | yes | yes (R12–2018) | R13–2018 closed SPLINE flags and control-point closure on import verified (#1299); circular cubic paths export as native CIRCLE/ARC where stroke semantics permit; R12 weighted strokes remain POLYLINE while non-circular curves keep the existing fallback (`crates/cad/src/tests.rs`); [Autodesk group 70](https://help.autodesk.com/cloudhelp/2024/ENU/AutoCAD-DXF/files/GUID-E1F884F8-AA90-4864-A215-3182D47A9C74.htm). DXF 2000–2018 LAYOUT objects write the paper image origin as 148/149 (was a stray 158), the shade plot codes (2004+) and the model type flag, and the plot style placeholder carries no subclass marker (#3085; structure test `r2000_and_later_files_have_the_structure_cad_apps_require`, checked with ezdxf's audit; not yet confirmed in Autodesk Fusion). DXF Options' Preset menu and `document.exportDxf`'s `dxfPreset: "cnc"` set the CNC / CAM options (#5500); VCarve QA remains open. DXF and DWG import draw a pattern hatch as its pattern lines (groups 53, 43–46 and 49) clipped to its boundary and cut into their dashes and dots, and fill a gradient hatch (groups 450–470) with a linear or radial gradient in its colors at its angle; the mapping of each named gradient to a linear or radial one is VectorCraft's own (`pattern_hatches_draw_their_lines_inside_the_boundary`, `gradient_hatches_keep_their_gradient`; [HATCH group codes](https://help.autodesk.com/cloudhelp/2024/ENU/AutoCAD-DXF/files/GUID-C6C71CED-CE0F-4184-82A5-07AD6241F15B.htm)) |
| DXF | open, export | yes | yes (R12–2018) | R13–2018 closed SPLINE flags and control-point closure on import verified (#1299); circular cubic paths export as native CIRCLE/ARC where stroke semantics permit; R12 weighted strokes remain POLYLINE while non-circular curves keep the existing fallback (`crates/cad/src/tests.rs`); [Autodesk group 70](https://help.autodesk.com/cloudhelp/2024/ENU/AutoCAD-DXF/files/GUID-E1F884F8-AA90-4864-A215-3182D47A9C74.htm). DXF 2000–2018 LAYOUT objects write the paper image origin as 148/149 (was a stray 158), the shade plot codes (2004+) and the model type flag, and the plot style placeholder carries no subclass marker (#3085; structure test `r2000_and_later_files_have_the_structure_cad_apps_require`, checked with ezdxf's audit; not yet confirmed in Autodesk Fusion). DXF Options' Preset menu and `document.exportDxf`'s `dxfPreset: "cnc"` set the CNC / CAM options (#5500); VCarve QA remains open. DXF and DWG import draw a pattern hatch as its pattern lines (groups 53, 43–46 and 49) clipped to its boundary and cut into their dashes and dots, and fill a gradient hatch (groups 450–470) with a linear or radial gradient in its colors at its angle; hatches follow their island style (normal, outer, ignore); the mapping of each named gradient to a linear or radial one is VectorCraft's own (`pattern_hatches_draw_their_lines_inside_the_boundary`, `gradient_hatches_keep_their_gradient`; [HATCH group codes](https://help.autodesk.com/cloudhelp/2024/ENU/AutoCAD-DXF/files/GUID-C6C71CED-CE0F-4184-82A5-07AD6241F15B.htm)) |
| HP-GL/2 `.plt`, `.hpgl`, `.hgl`, `.hpg` | — | yes (pen moves, pens and widths, line types and attributes, circles, arcs, wedges and Bézier curves, filled and edged rectangles, wedges and polygons, encoded polylines, scaling and rotation; labels, symbol mode, raster images and hatching aren't drawn) | yes (`.plt`: each visible path once along its line, a pen per color or a pen table, type as outlines, clipping applied, HP-GL or HP-GL/2 with pen colors and encoded polylines; Export As opens HP-GL Options) | recognized by its first instructions after any printer escapes, under its own extensions or one no other format reads; `crates/cad/src/hpgl/tests.rs`, `crates/cad/src/hpgl/write/tests.rs` (plots read back by the reader), `tests_hpgl.rs`, `import_fuzz.rs` |
| DWG | open, export | yes (open and place: craft-dwg converts the drawing to DXF, in a child process on desktop, and the DXF reader reads it with the DXF import options) | no (export DXF instead) | `crates/cad/src/import/tests_dwg.rs`, `crates/engine/src/cmd/fileio/tests_dwgimport.rs` (drawings written as DXF and converted to DWG by craft-dwg's writer); not in the web build |
| EMF / WMF | open, export | yes | yes | an oversized embedded PNG or JPEG is refused from its header, before any pixels are decoded (#1776); a picture cut short by a reader limit, images and pattern brushes that are not read, clips that are not applied and raster operations other than a plain copy come back as warnings; tests in `crates/metafile/src/tests/import.rs` |
+2 -2
View File
@@ -12881,8 +12881,8 @@ artboard under `at`). `center: false` puts the drawing's origin (fitted art: its
artboard's bottom-left corner; `mergeLayers` puts all art on one layer. Each DXF layer holding art becomes a layer
(off and frozen layers hidden, locked ones locked, non-plotting ones non-printing). Lines, polylines (arc segments from
bulges), circles, arcs, ellipses, splines (NURBS, within a millionth of their size), solids and hatches become paths (solid
hatches filled; gradient hatches filled with a linear or radial gradient at their angle, in their two colors or one
color shaded or tinted; pattern hatches as their pattern's lines clipped to the boundary, each cut into its dashes
hatches filled; hatches follow their island style (normal, outer, ignore); gradient hatches filled with a linear or
radial gradient at their angle, in their two colors or one color shaded or tinted; pattern hatches as their pattern's lines clipped to the boundary, each cut into its dashes
and dots and stroked at the lineweight without the linetype; a pattern hatch with no usable pattern lines, with more
than 20,000 dashes, or past the drawing's budget of 2,000,000 dashes or 200,000,000 clipping steps, as its boundary),
text and multiline text point type, named blocks symbols