0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / tests / bugs / step / bug30694
1 puts "================"
2 puts "0030694: Data Exchange - support non-standard GB2312-encoded STEP files"
3 puts ""
4 puts "Test case:"
5 puts "1) Creates a temporary STEP file-template using WriteStep."
6 puts "2) Reads generated template and replaces @tmp_name@ entity in it with Simplified Chinese characters using Tcl."
7 puts "3) Generates 2 STEP files in UTF-8 and GB2312 encodings (converted by Tcl)."
8 puts "4) Reads generated files using StepRead and validates entity name."
9 puts "================"
10 puts ""
11
12 proc fileToString { thePath } {
13   set aFile [open "$thePath" r]
14   set aText [read $aFile [file size "$thePath"]]
15   close $aFile
16   return $aText
17 }
18
19 proc fileFromString { thePath theContent theCodePage } {
20   set aFile [open "$thePath" w]
21   fconfigure $aFile -translation lf -encoding "$theCodePage"
22   puts $aFile $theContent
23   close $aFile
24 }
25
26 pload XDE OCAF MODELING VISUALIZATION
27 set aTmpNameTmpl "@tmp_name@"
28 set aTmpFileTmpl "${imagedir}/${casename}-tmp.stp"
29 set aTmpFileUtf8 "${imagedir}/${casename}-tmp-utf8.stp"
30 set aTmpFileGb   "${imagedir}/${casename}-tmp-gb.stp"
31 # 国标
32 set aName [encoding convertfrom unicode "\xFD\x56\x07\x68"]
33 box b 1 2 3
34 Close A T U G -silent
35 XNewDoc   T
36 XAddShape T b 0
37 XSetColor T b 1 0 0
38 SetName   T 0:1:1:1 "$aTmpNameTmpl"
39 GetName   T 0:1:1:1
40 WriteStep T "$aTmpFileTmpl"
41
42 regsub -all -- $aTmpNameTmpl [fileToString "$aTmpFileTmpl"] "$aName" aContent
43 fileFromString "$aTmpFileUtf8" "$aContent" "utf-8"
44 fileFromString "$aTmpFileGb"   "$aContent" "gb2312"
45
46 param read.step.codepage UTF8
47 ReadStep U "$aTmpFileUtf8"
48 ReadStep A "$aTmpFileGb"
49 param read.step.codepage GB
50 ReadStep G "$aTmpFileGb"
51
52 if { [GetName U 0:1:1:1] != "$aName" } { puts "Error: unable to read UTF-8  STEP" }
53 if { [GetName G 0:1:1:1] != "$aName" } { puts "Error: unable to read gb2312 STEP" }
54 if { [GetName A 0:1:1:1] == "$aName" } { puts "Error: broken test case" }