File indexing completed on 2024-04-06 12:28:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 use Data::Dumper;
0019
0020
0021 sub parseLayer {
0022 my $txt = shift;
0023 my ($be, $name) = ($txt =~ ) or die "Can't parse layer block\n" . $txt . "\n";
0024 my ($l) = ($txt =~ ) or die "Can't parse layer block\n" . $txt . "\n";
0025 my ($s) = ($txt =~ );
0026 $s = '' if $be ne "endcap";
0027 return sprintf('%s%s_%d', $name,$s,$l);
0028 }
0029
0030
0031 my %layers;
0032 sub parseNavi {
0033 my $txt = shift;
0034 my $start = parseLayer($txt);
0035 my @outIn = ();
0036 my @inOut = ();
0037 if ($txt =~ ) {
0038 my $list = $1;
0039
0040 foreach (split(/---+/, $list)) { and push @inOut, parseLayer($_); }
0041 }
0042 if ($txt =~ ) {
0043 my $list = $1;
0044
0045 foreach (split(/---+/, $list)) { and push @outIn, parseLayer($_); }
0046 }
0047 $layers{$start} = { 'inOut' => [ @inOut ], 'outIn' => [ @outIn ] };
0048 }
0049
0050
0051 my $text = join('', <>);
0052 while ($text =~ ) {
0053 parseNavi($1);
0054 }
0055
0056
0057
0058
0059 print "digraph G {\n";
0060 foreach my $k (sort(keys(%layers))) {
0061 print "$k\n";
0062 foreach my $l1 ( @{$layers{$k}->{'inOut'}} ) {
0063 my $color = 'red';
0064 if (grep($_ eq $k, @{$layers{$l1}->{'outIn'}})) {
0065 $color = 'darkgreen';
0066 }
0067 print "\t$k -> $l1 [color=$color]\n";
0068 }
0069 foreach my $l2 ( @{$layers{$k}->{'outIn'}} ) {
0070 next if (grep($_ eq $k, @{$layers{$l2}->{'inOut'}})) ;
0071 print "\t$k -> $l2 [color=blue]\n";
0072 }
0073 }
0074 print "}\n";