1 puts "\n#======================================================================"
2 puts "# Check reading empty or small STL files"
3 puts "#======================================================================\n"
5 set minimal_ascii_stl {solid
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
22 readstl res_one_ascii_dos ${imagedir}/${casename}_one_ascii_dos.stl -brep
23 checknbshapes res_one_ascii_dos -face 1
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
32 readstl res_one_ascii_unix ${imagedir}/${casename}_one_ascii_unix.stl -brep
33 checknbshapes res_one_ascii_unix -face 1
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
42 readstl res_one_ascii_noeol ${imagedir}/${casename}_one_ascii_noeol.stl -brep
43 checknbshapes res_one_ascii_noeol -face 1
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"
52 readstl res_zero_ascii_dos ${imagedir}/${casename}_zero_ascii_dos.stl -brep
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"
61 readstl res_zero_ascii_unix ${imagedir}/${casename}_zero_ascii_unix.stl -brep
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]
71 readstl res_one_binary ${imagedir}/${casename}_one_binary.stl -brep
72 checknbshapes res_one_binary -face 1
74 puts "\n#======================================================================"
75 puts "# Binary file with no facets -- will be treated as Ascii and generate e r r o r"
76 puts "#======================================================================"
77 puts "REQUIRED ALL: Error: premature end of file"
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]"
82 readstl res_zero_binary ${imagedir}/${casename}_zero_binary.stl -brep
84 puts "\n#======================================================================"
86 puts "#======================================================================"
87 puts "REQUIRED ALL: Error: premature end of file"
88 set fd [open ${imagedir}/${casename}_empty.stl w]
90 readstl res_empty ${imagedir}/${casename}_empty.stl -brep