22e70738 |
1 | puts "\n#======================================================================" |
2 | puts "# Check reading empty or small STL files" |
3 | puts "#======================================================================\n" |
4 | |
5 | set minimal_ascii_stl {solid |
6 | facet normal 0 0 1 |
7 | outer loop |
8 | vertex 0 0 0 |
9 | vertex 1 0 0 |
10 | vertex 0 1 0 |
11 | endloop |
12 | endfacet |
13 | endsolid} |
14 | |
15 | puts "\n#======================================================================" |
16 | puts "# Ascii file with single facet, CRLF" |
17 | puts "#======================================================================" |
18 | set fd [open ${imagedir}/${casename}_one_ascii_dos.stl w] |
19 | fconfigure $fd -translation crlf |
20 | puts $fd $minimal_ascii_stl |
21 | close $fd |
4c4420df |
22 | readstl res_one_ascii_dos ${imagedir}/${casename}_one_ascii_dos.stl -brep |
22e70738 |
23 | checknbshapes res_one_ascii_dos -face 1 |
24 | |
25 | puts "\n#======================================================================" |
26 | puts "# Ascii file with single facet, LF" |
27 | puts "#======================================================================" |
28 | set fd [open ${imagedir}/${casename}_one_ascii_unix.stl w] |
29 | fconfigure $fd -translation lf |
30 | puts $fd $minimal_ascii_stl |
31 | close $fd |
4c4420df |
32 | readstl res_one_ascii_unix ${imagedir}/${casename}_one_ascii_unix.stl -brep |
22e70738 |
33 | checknbshapes res_one_ascii_unix -face 1 |
34 | |
35 | puts "\n#======================================================================" |
36 | puts "# Ascii file with single facet, LF, no EOL at the last line" |
37 | puts "#======================================================================" |
38 | set fd [open ${imagedir}/${casename}_one_ascii_noeol.stl w] |
39 | fconfigure $fd -translation lf |
40 | puts -nonewline $fd $minimal_ascii_stl |
41 | close $fd |
4c4420df |
42 | readstl res_one_ascii_noeol ${imagedir}/${casename}_one_ascii_noeol.stl -brep |
22e70738 |
43 | checknbshapes res_one_ascii_noeol -face 1 |
44 | |
45 | puts "\n#======================================================================" |
46 | puts "# Ascii file with no facets, CRLF" |
47 | puts "#======================================================================" |
48 | set fd [open ${imagedir}/${casename}_zero_ascii_dos.stl w] |
49 | fconfigure $fd -translation crlf |
50 | puts $fd "solid \nendsolid" |
51 | close $fd |
4c4420df |
52 | readstl res_zero_ascii_dos ${imagedir}/${casename}_zero_ascii_dos.stl -brep |
22e70738 |
53 | |
54 | puts "\n#======================================================================" |
55 | puts "# Ascii file with no facets, LF" |
56 | puts "#======================================================================" |
57 | set fd [open ${imagedir}/${casename}_zero_ascii_unix.stl w] |
58 | fconfigure $fd -translation lf |
59 | puts $fd "solid \nendsolid" |
60 | close $fd |
4c4420df |
61 | readstl res_zero_ascii_unix ${imagedir}/${casename}_zero_ascii_unix.stl -brep |
22e70738 |
62 | |
63 | puts "\n#======================================================================" |
64 | puts "# Binary file with single facet" |
65 | puts "#======================================================================" |
66 | set fd [open ${imagedir}/${casename}_one_binary.stl w] |
67 | fconfigure $fd -translation binary |
68 | puts -nonewline $fd "stl [string repeat { } 76]" |
69 | puts -nonewline $fd [binary format if3f3f3f3t 1 {0 0 1} {0 0 0} {1 0 0} {0 1 0} 0] |
70 | close $fd |
4c4420df |
71 | readstl res_one_binary ${imagedir}/${casename}_one_binary.stl -brep |
22e70738 |
72 | checknbshapes res_one_binary -face 1 |
73 | |
74 | puts "\n#======================================================================" |
75 | puts "# Binary file with no facets -- will be treated as Ascii and generate e r r o r" |
76 | puts "#======================================================================" |
51ee6a7d |
77 | puts "REQUIRED ALL: Error: premature end of file" |
22e70738 |
78 | set fd [open ${imagedir}/${casename}_zero_binary.stl w] |
79 | fconfigure $fd -translation binary |
80 | puts -nonewline $fd "stl [string repeat { } 76][binary format i 0]" |
81 | close $fd |
4c4420df |
82 | readstl res_zero_binary ${imagedir}/${casename}_zero_binary.stl -brep |
22e70738 |
83 | |
84 | puts "\n#======================================================================" |
85 | puts "# Empty file" |
86 | puts "#======================================================================" |
51ee6a7d |
87 | puts "REQUIRED ALL: Error: premature end of file" |
22e70738 |
88 | set fd [open ${imagedir}/${casename}_empty.stl w] |
89 | close $fd |
4c4420df |
90 | readstl res_empty ${imagedir}/${casename}_empty.stl -brep |
22e70738 |
91 | |