-
-
Notifications
You must be signed in to change notification settings - Fork 234
/
dxfb-check
executable file
·156 lines (147 loc) · 4.84 KB
/
dxfb-check
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env bash
# dwg -> dxfb
# dxfb -> dwg2
# teigha dxfb -> dwg (check out_dxfb)
# teigha dwg2 -> dxf (check in_dxf)
v=-v4
case $1 in
-v*)
v="$1"
shift
;;
esac
d="${1:-example_2000}"
b="$(basename "$d" .dwg)"
dir="$(dirname "$d")"
r="$(basename "$dir")"
exitcode=0
DEBUG_CLASSES=
case $dir in
*test/test-data) ;;
*test/test-data/*) b="${b}_${r}" ;;
*td) ;;
*td/*) b="${b}_${r}" ;;
.) ;;
*) b="${b}_${r}" ;;
esac
case $r in
20*) ;;
r9) r=9 ;;
r11) r=12 ;;
r1[0234]) r="${r:1}" ;;
*)
case $b in
*_20*) r="${b:(-4)}" ;;
*_r9) r=9 ;;
*_r11) r=12 ;;
*_r1[0234]) r="${b:(-2)}" ;;
*_R20*) r="${b:(-4)}" ;;
esac
;;
esac
case $r in
9|10|11|12|13|14|2000|2004|2007|2010|2013|2018) ;;
*) make -s -C examples odaversion
r="$(examples/odaversion "$d")"
;;
esac
# first create a dwg log to compare against
./log "-l$b.log.orig" "$v" "$d"
rm "./$b.dxf" "./$b.dwg" 2>/dev/null
if ! ./dxf -b -y "$v" -o "$b.dxfb" "$d"; then
exit 2
fi
if [ -f "$b.dxfb" ]; then
mv "./$b.log" "$b.dwg2dxfb.log"
# teigha can only write from r12-r2018
can_teigha=1
case $(uname) in
Darwin) TeighaFileConverter=/Applications/ODAFileConverter.app/Contents/MacOS/ODAFileConverter ;;
Linux) TeighaFileConverter=/usr/bin/ODAFileConverter ;;
Windows) TeighaFileConverter=ODAFileConverter ;;
esac
baseFileConverter=ODAFileConverter
if [ ! -x "$TeighaFileConverter" ]; then
case $(uname) in
Darwin) TeighaFileConverter=/Applications/TeighaFileConverter.app/Contents/MacOS/TeighaFileConverter ;;
Linux) TeighaFileConverter=/usr/bin/TeighaFileConverter ;;
Windows) TeighaFileConverter=TeighaFileConverter ;;
esac
baseFileConverter=TeighaFileConverter
fi
case $r in
1\.*) can_teigha=0 ;;
2\.*) can_teigha=0 ;;
11) r=12 ;;
esac
test -z "$r" && can_teigha=0
if [ -x "$TeighaFileConverter" ] && [ "$can_teigha" = "1" ]; then
echo timeout 30 "$baseFileConverter" . . "ACAD$r" DWG 0 1 "$b.dxfb"
timeout 30 "$TeighaFileConverter" . . "ACAD$r" DWG 0 1 "$b.dxfb" \
>/dev/null 2>/dev/null
if [ -e "./$b.dwg.err" ]; then
mv "$b.dwg.err" "$b.dxfb2dwg.err"
cat "$b.dxfb2dwg.err"
exitcode=1
fi
else
rm "$b.dxfb2dwg.err" 2>/dev/null
if [ ! -x "$TeighaFileConverter" ]; then
echo "$baseFileConverter not installed"
fi
fi
if ! ./dwg -y "$v" "$b.dxfb"; then
exit 1
fi
fi
if [ -f "$b.dwg" ]; then
if [ -x "$TeighaFileConverter" ] && [ "$can_teigha" = "1" ]; then
echo timeout 30 "$baseFileConverter" . . "ACAD$r" DXF 0 1 "$b.dwg"
timeout 30 "$TeighaFileConverter" . . "ACAD$r" DXF 0 1 "$b.dwg" \
>/dev/null 2>/dev/null
if [ -e "./$b.dxf.err" ]; then
mv "$b.dxf.err" "$b.dxfb.err"
cat "$b.dxfb.err"
exitcode=3
fi
else
rm "$b.dxfb.err" 2>/dev/null
echo "$baseFileConverter not installed"
fi
./log "$v" "$b.dwg"
log1="$b.log.orig"
log2="$b.log"
echo diff -bu "log1" "$log2"
diff -I '^-(objref|found:)' -bu "$log1" "$log2"
test -f "$b.dxfb.err" && cat "$b.dxfb.err"
if false && [ -f "$log1" ] && [ -f "$log2" ]; then
# Really interesting is the Section BLOCKS here. vs BLOCK_HEADER
if grep -q '#define DEBUG_CLASSES' src/config.h; then
DEBUG_CLASSES=1
fi
if [ -z "$DEBUG_CLASSES" ]; then
# we dont write unstable entities yet.
grep -E '^Add entity' "$log1" | grep -E -v 'entity (ARC_DIMENSION|HELIX|SECTIONOBJECT|UNKNOWN_ENT)' >"$log1.tmp"
else
grep -E '^Add entity' "$log1" |
grep -E -v 'entity UNKNOWN_ENT' >"$log1.tmp"
fi
grep -E '^Add entity' "$log2" >"$log2.tmp"
if diff -bu0 "$log1.tmp" "$log2.tmp" >/dev/null 2>/dev/null; then
echo entities roundtrip ok
rm "$log1.tmp" "$log2.tmp" 2>/dev/null
else
c1=$(grep -c entity "$log1.tmp")
c2=$(grep -c entity "$log2.tmp")
if [ "$c1" = "$c2" ]; then
echo entities roundtrip in different order
diff -I '^-(objref|found:)' -bu0 <(perl -lpe's/ \[.\d+\]//' "$log1.tmp" | sort -u) \
<(perl -lpe's/ \[.\d+\]//' "$log2.tmp" | sort -u)
else
echo "$b roundtrip failed, $c1 vs $c2 entities"
diff -I '^-(objref|found:)' -bu0 "$log1.tmp" "$log2.tmp" | grep -v '^@@'
fi
fi
fi
fi
exit $exitcode