0026742: Update test cases for using checknbshapes procedure instead of global variables
[occt.git] / tests / boolean / end
1 if { [isdraw result] } {
2    #check if result is valid
3    
4    puts "checkshape"
5    set ch [checkshape result]
6    puts $ch
7    
8    if {[info exists command] && ${command} == "mkvolume"} {
9      set bcheck [bopcheck result]
10      puts $bcheck
11      if {![regexp {This shape seems to be OK.} $bcheck]} {
12        puts "Error: bopcheck failed"
13      }
14    }
15    if { [info exists square] } {
16       set prop "area"
17       set mass $square
18       regexp {Mass +: +([-0-9.+eE]+)} [sprops result] full m      
19    }
20    if { [info exists length] } {
21       set prop "length"
22       set mass $length
23       regexp {Mass +: +([-0-9.+eE]+)} [lprops result] full m      
24
25       puts "checksection"
26       puts [checksection result]
27    }
28
29    #if mass (length or square) is empty in test case then result should be an empty shape.
30    if { [info exists mass] && [string compare "$mass" "empty"] != 0 } {
31       if { $m == 0 } {
32          puts "Error : The $command is not valid. The $prop is 0."
33       }
34       if { $mass > 0 } {
35          puts "The expected $prop is $mass"
36       }
37       #check of change of square is < 1%
38       if { ($mass != 0 && [expr 1.*abs($mass - $m)/$mass] > 0.01) || ($mass == 0 && $m != 0) } {
39          puts "Error : The $prop of the resulting shape is $m"
40       }
41       
42       if { [info exists nbsh_v ] } {
43         set arr_v [explode result v]
44         set nb_v [ llength $arr_v ]
45         if { $nb_v != $nbsh_v } {
46            puts "Error : The resulting shape is WRONG because it must contain $nbsh_v vertexes instead of $nb_v"
47         } else {
48            puts "The resulting shape contains $nb_v vertexes"
49         }
50         
51       }
52
53       if { [info exists nbsh_e ] } {
54         set arr_e [explode result e]
55         set nb_e [ llength $arr_e ]
56         if { $nb_e != $nbsh_e } {
57            puts "Error : The resulting shape is WRONG because it must contain $nbsh_e edges instead of $nb_e"
58         } else {
59            puts "The resulting shape contains $nb_e edges"
60         }
61       }
62    } else {
63       if { [info exists mass] && $m != 0 } {
64          puts "Error : The $command is not valid. The $prop is $m"
65       }
66    }
67
68    smallview
69    if { [info exists m ] } {
70      if { $m > 0 } {
71        donly result
72        if { [info exists nbsh_v ] } {
73          explode result v
74        }
75      } else {
76        donly a b
77      }
78    } else {
79      donly result
80    }
81    fit
82    xwd $imagedir/${test_image}.png
83 } else {
84    puts "Error : The $command cannot be built."
85 }
86
87 # to end a test script
88 puts "TEST COMPLETED"