165 lines
3.6 KiB
Plaintext
165 lines
3.6 KiB
Plaintext
###
|
|
### Alignment test file. For more information, see:
|
|
###
|
|
### http://www.gnu.org/software/dejagnu/manual/
|
|
###
|
|
|
|
###
|
|
### Useful Globals
|
|
###
|
|
|
|
global ALE
|
|
|
|
###
|
|
### Helper routines
|
|
###
|
|
|
|
proc is_within {x y tolerance} {
|
|
return [expr abs($x - $y) < $tolerance]
|
|
}
|
|
|
|
proc is_translation {t x y tolerance} {
|
|
|
|
set command [lindex $t 0]
|
|
|
|
if [string equal "$command" "P"] {
|
|
|
|
#
|
|
# Projective case
|
|
#
|
|
|
|
set width [lindex $t 1]
|
|
set height [lindex $t 2]
|
|
|
|
set v [expr $x + $width]
|
|
set w [expr $y + $height]
|
|
|
|
return [expr [is_within [lindex $t 3] $x $tolerance] && [is_within [lindex $t 4] $y $tolerance] \
|
|
&& [is_within [lindex $t 5] $x $tolerance] && [is_within [lindex $t 6] $w $tolerance] \
|
|
&& [is_within [lindex $t 7] $v $tolerance] && [is_within [lindex $t 8] $w $tolerance] \
|
|
&& [is_within [lindex $t 9] $v $tolerance] && [is_within [lindex $t 10] $y $tolerance]]
|
|
|
|
} elseif [string equal "$command" "E"] {
|
|
|
|
#
|
|
# Euclidean case
|
|
#
|
|
|
|
return [expr [is_within [lindex $t 3] $x $tolerance] \
|
|
&& [is_within [lindex $t 4] $y $tolerance] \
|
|
&& [is_within [lindex $t 5] 0 $tolerance]]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
###
|
|
### Tests
|
|
###
|
|
|
|
#
|
|
# Transformation Data File Output
|
|
#
|
|
|
|
set test "Transformation Data File Output"
|
|
|
|
set file [svg_open $test 200 100]
|
|
svg_circle $file 50 50 10
|
|
svg_close $file
|
|
|
|
exec $ALE --trans-save [trans_file $test] [ppm_file $test] [out_file $test] 2> /dev/null
|
|
|
|
if [file exists [trans_file $test]] {
|
|
pass "$test (existence)"
|
|
} else {
|
|
fail "$test (existence)"
|
|
}
|
|
|
|
if [string equal "[exec grep ^V [trans_file $test]]" "V 2"] {
|
|
pass "$test (version compatibility)"
|
|
} else {
|
|
fail "$test (version compatibility): [exec grep ^V [trans_file $test]]"
|
|
}
|
|
|
|
#
|
|
# Identical Images
|
|
#
|
|
|
|
set test "Identical Images"
|
|
|
|
set file [svg_open $test 100 100]
|
|
svg_circle $file 50 50 10
|
|
svg_circle $file 60 60 10
|
|
svg_circle $file 70 70 10
|
|
svg_close $file
|
|
|
|
foreach scale {1 1.1 1.25 1.5} {
|
|
foreach type {translation euclidean projective} {
|
|
|
|
set test_identifier "$test.$type.scale.$scale"
|
|
|
|
exec $ALE --$type --scale=$scale --trans-save [trans_file $test_identifier] \
|
|
[ppm_file $test] [ppm_file $test] [out_file $test] 2> /dev/null
|
|
|
|
set transformation [exec grep ^\[EP\] [trans_file $test_identifier] | tail -1]
|
|
set tlist [split $transformation { }]
|
|
|
|
if [is_translation $tlist 0 0 0.125] {
|
|
pass "$test_identifier"
|
|
} else {
|
|
fail "$test_identifier: $tlist"
|
|
}
|
|
}}
|
|
|
|
#
|
|
# Translated Ellipses
|
|
#
|
|
|
|
set test "TranslatedEllipses"
|
|
|
|
set file [svg_open $test-reference 100 100]
|
|
svg_ellipse $file 50 50 30 10
|
|
svg_ellipse $file 80 50 10 30
|
|
svg_ellipse $file 20 50 10 30
|
|
svg_close $file
|
|
|
|
foreach scale {1 1.25 1.5} {
|
|
foreach type {translation euclidean projective} {
|
|
foreach offset {0 1 5 11 18 20 21 22 25 26 27 28 29} {
|
|
|
|
if [expr $offset >= 30] {
|
|
set fail xfail
|
|
set pass xpass
|
|
} else {
|
|
set fail fail
|
|
set pass pass
|
|
}
|
|
|
|
if [string equal "$type" "projective"] {
|
|
set tolerance 1.0
|
|
} else {
|
|
set tolerance 0.125
|
|
}
|
|
|
|
set test_identifier "$test.offset.$offset.$type.scale.$scale"
|
|
|
|
set file [svg_open $test_identifier 100 100]
|
|
svg_ellipse $file 50 [expr 50 + $offset] 30 10
|
|
svg_ellipse $file 80 [expr 50 + $offset] 10 30
|
|
svg_ellipse $file 20 [expr 50 + $offset] 10 30
|
|
svg_close $file
|
|
|
|
exec $ALE --extend --exp-noregister --mc 100 --$type --scale=$scale --trans-save [trans_file $test_identifier] \
|
|
--ui=quiet [ppm_file $test-reference] [ppm_file $test_identifier] \
|
|
[out_file $test_identifier]
|
|
|
|
set transformation [exec grep ^\[EP\] [trans_file $test_identifier] | tail -1]
|
|
set tlist [split $transformation { }]
|
|
|
|
if [is_translation $tlist 0 [expr -$offset * $scale] $tolerance] {
|
|
$pass "$test_identifier"
|
|
} else {
|
|
$fail "$test_identifier: $transformation"
|
|
}
|
|
}}}
|