fix: preserve bend lines through drawing split — clip, offset, and carry metadata
DrawingSplitter now clips bend lines to each piece's region using Liang-Barsky line clipping and offsets them to the new origin. Bend properties (direction, angle, radius, note text) are preserved through the entire split pipeline instead of being lost during re-import. CadConverterForm applies the same origin offset to bends before passing them to the splitter, and creates FileListItems directly from split results to avoid re-detection overwriting the bend metadata. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,10 @@ namespace OpenNest.IO.Bending
|
||||
@"\\[fHCTQWASpOoLlKk][^;]*;|\\P|[{}]|%%[dDpPcC]",
|
||||
RegexOptions.Compiled);
|
||||
|
||||
private static readonly Regex UnicodeEscapeRegex = new Regex(
|
||||
@"\\U\+([0-9A-Fa-f]{4})",
|
||||
RegexOptions.Compiled);
|
||||
|
||||
public List<Bend> DetectBends(CadDocument document)
|
||||
{
|
||||
var bendLines = FindBendLines(document);
|
||||
@@ -116,8 +120,15 @@ namespace OpenNest.IO.Bending
|
||||
if (string.IsNullOrEmpty(text))
|
||||
return text;
|
||||
|
||||
// Convert \U+XXXX DXF unicode escapes to actual characters
|
||||
var result = UnicodeEscapeRegex.Replace(text, m =>
|
||||
{
|
||||
var codePoint = int.Parse(m.Groups[1].Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
return char.ConvertFromUtf32(codePoint);
|
||||
});
|
||||
|
||||
// Replace known DXF special characters
|
||||
var result = text
|
||||
result = result
|
||||
.Replace("%%d", "°").Replace("%%D", "°")
|
||||
.Replace("%%p", "±").Replace("%%P", "±")
|
||||
.Replace("%%c", "⌀").Replace("%%C", "⌀");
|
||||
|
||||
Reference in New Issue
Block a user