出力フォーマットを修正
@@ -15,35 +15,72 @@ | ||
15 | 15 | use strict; |
16 | 16 | use warnings; |
17 | 17 | |
18 | -my $f = 'top'; | |
19 | 18 | my %x; |
20 | 19 | |
21 | -while(<>){ | |
22 | - if(/<ksj:EC01/){ | |
23 | - $f = 'name'; | |
20 | +{ | |
21 | + my $f = 'top'; | |
22 | + | |
23 | + while(<>){ | |
24 | + if(/<ksj:EC01 /){ | |
25 | + $f = 'name'; | |
26 | + } | |
27 | + elsif (/<jps:GM_Surface /){ | |
28 | + $f = 'surface'; | |
29 | + } | |
30 | + elsif (/<jps:GM_OrientableCurve /){ | |
31 | + $f = 'oc'; | |
32 | + } | |
33 | + elsif (/<jps:GM_Curve /){ | |
34 | + $f = 'curve'; | |
35 | + } | |
36 | + elsif (/<jps:GM_Point /){ | |
37 | + $f = 'point'; | |
38 | + } | |
39 | + elsif (m@</ksj:OBJ>@){ | |
40 | + $f = 'bottom'; | |
41 | + } | |
42 | + | |
43 | + $x{$f} .= $_; | |
24 | 44 | } |
25 | - elsif (/<jps:GM_Surface/){ | |
26 | - $f = 'surface'; | |
45 | +} | |
46 | + | |
47 | +my %oc; | |
48 | + | |
49 | +{ | |
50 | + my $id; | |
51 | + my $s; | |
52 | + | |
53 | + for (split /\n/, $x{oc}){ | |
54 | + if(/<jps:GM_OrientableCurve id="_([^\"]*)">/){ | |
55 | + $id = $1; | |
56 | + $s = ''; | |
57 | + } | |
58 | + $s .= $_ . "\n"; | |
59 | + if (m@</jps:GM_OrientableCurve>@){ | |
60 | + $oc{$id} = $s; | |
61 | + } | |
27 | 62 | } |
28 | - elsif (/<jps:GM_OrientableCurve/){ | |
29 | - $f = 'oc'; | |
30 | - } | |
31 | - elsif (/<jps:GM_Curve/){ | |
32 | - $f = 'curve'; | |
33 | - } | |
34 | - elsif (/<jps:GM_Point/){ | |
35 | - $f = 'point'; | |
36 | - } | |
37 | - elsif (m@</ksj:OBJ>@){ | |
38 | - $f = 'bottom'; | |
39 | - } | |
63 | +} | |
40 | 64 | |
41 | - $x{$f} .= $_; | |
42 | -} | |
43 | 65 | print $x{top}; |
44 | 66 | print $x{name}; |
45 | 67 | print $x{surface}; |
46 | -print $x{oc}; | |
47 | -print $x{curve}; | |
68 | + | |
69 | +{ | |
70 | + my $id; | |
71 | + | |
72 | + for (split /\n/, $x{curve}){ | |
73 | + if(/<jps:GM_Curve id="([^\"]*)">/){ | |
74 | + $id = $1; | |
75 | + } | |
76 | + print $_ . "\n"; | |
77 | + if (m@</jps:GM_Curve>@){ | |
78 | + print $oc{$id} . "\n"; | |
79 | + } | |
80 | + } | |
81 | +} | |
82 | + | |
83 | +#print $x{oc}; | |
84 | +#print $x{curve}; | |
48 | 85 | print $x{point}; |
49 | 86 | print $x{bottom}; |