1# File : begin 2 3if { [array get Draw_Groups "TOPOLOGY Check commands"] == "" } { 4 pload TOPTEST 5 pload VISUALIZATION 6} 7 8# to prevent loops limit to 16 minutes 9cpulimit 1000 10 11set rel_tol 0 12set max_rel_tol_diff 0 13 14if { [info exists imagedir] == 0 } { 15 set imagedir . 16} 17if { [info exists test_image] == 0 } { 18 set test_image photo 19} 20 21# Procedure to check equality of two reals with tolerance (relative and absolute) 22help checkarea {shape area_expected tol_abs tol_rel} 23proc checkarea {shape area_expected tol_abs tol_rel} { 24 # compute area with half of the relative tolerance 25 # to be used in comparison; 0.001 is added to avoid zero value 26 set prop [uplevel sprops $shape [expr 0.5 * abs($tol_rel) + 0.001]] 27 28 # get the value 29 if { ! [regexp {Mass\s*:\s*([0-9.e+-]+)} $prop res area] } { 30 puts "Error: cannot get area of the shape $shape" 31 return 32 } 33 34 # compare with expected value 35 checkreal "area of $shape" $area $area_expected $tol_abs $tol_rel 36} 37 38# Check if area of triangles is valid 39proc CheckTriArea {shape {eps 0}} { 40 upvar #0 $shape result 41 set area [triarea result $eps] 42 set t_area [lindex $area 0] 43 set g_area [expr abs([lindex $area 1])] 44 puts "area by triangles: $t_area" 45 puts "area by geometry: $g_area" 46 expr ($t_area - $g_area) / $g_area * 100 47} 48 49# Check expected time 50proc checktime {value expected tol_rel message} { 51 set t1 [expr ${value} - ${expected}] 52 set t2 [expr ${expected} * abs (${tol_rel})] 53 54 if { abs (${t1}) <= ${t2} } { 55 puts "OK. ${message}, ${value} seconds, is equal to expected time - ${expected} seconds" 56 } elseif {${t1} > ${t2}} { 57 puts "Error. ${message}, ${value} seconds, is more than expected time - ${expected} seconds" 58 } else { 59 puts "Improvement. ${message}, ${value} seconds, is less than expected time - ${expected} seconds" 60 } 61} 62