diff options
author | Thomas Kremer <-> | 2022-09-28 06:38:36 +0200 |
---|---|---|
committer | Thomas Kremer <-> | 2022-09-28 06:40:34 +0200 |
commit | 93a592f37d9f5f98ed71588df3143db69d6855dc (patch) | |
tree | 18e2e76dab3e6b7ee3f2952e10c9933b3fb5c385 | |
parent | 1a64cb55abb3c8ffba3d564f00ac274cdffdd99a (diff) |
DXF.pm: fixed lwpolyline->line conversion for closed polylines.
-rw-r--r-- | DXF.pm | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -826,7 +826,7 @@ sub colorize_dxf { # 2*(b*m-a)*l + 2*(b*m-a)*x*(1-c) - 2*x*l - 2*x^2*(1-c) + l^2*m + 2*l*x*m = 0 # -2*(1-c)*x^2 + 2*((b*m-a)*(1-c) + l*(m-1))*x + (2*b*m+l*m-2*a)*l = 0 -# TODO: code 70: open and closed splines and polylines. +# DONE: code 70: open and closed splines and polylines. # dest => source => sub{} my %replacers = ( LWPOLYLINE => { @@ -951,8 +951,18 @@ my %replacers = ( my $node = shift; my @x = @{$node->{attrs}{x}}; my @y = @{$node->{attrs}{y}}; - die "invalid polyline" - unless @x == @y && @x >= 1; + my $flags = $node->{attrs}{int}//0; + my $closed = $flags & 1; + die "invalid lwpolyline" + unless @x == @y; + if (@x == 0) { + warn "empty lwpolyline"; + return (); + } + if ($closed) { + push @x,$x[0]; + push @y,$y[0]; + } my @lines = map lol(LINE => {x => $x[$_], y => $y[$_], x1 => $x[$_+1], y1 => $y[$_+1] }), 0..$#x-1; return @lines; |