1
#==========================================================================
3
# Copyright Insight Software Consortium
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
# you may not use this file except in compliance with the License.
7
# You may obtain a copy of the License at
9
# http://www.apache.org/licenses/LICENSE-2.0.txt
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
17
#==========================================================================*/
20
# WARNING: DO NOT EDIT THIS FILE!
21
# THIS FILE IS AUTOMATICALLY GENERATED BY THE SIMPLEITK BUILD PROCESS.
22
# Please look at RubyImageFilterTestTemplate.rb.in to make changes.
26
# This is Ruby code to test ${name}
30
$(if number_of_inputs then
31
OUT=[[inputs = ${number_of_inputs}]]
34
if ARGV.length < inputs + 2 then
35
puts( "Usage: ${name} tag <input(s)> output" )
41
reader = Simpleitk::ImageFileReader.new
42
writer = Simpleitk::ImageFileWriter.new
43
filter = Simpleitk::${name}.new
47
puts( "No tests defined!" );
53
if tag == "${tag}" then
56
$(if parameter == "SeedList" and ruby_value then
57
OUT=[[ filter.clear_seeds()
58
$(for i=1,#ruby_value do OUT=OUT .. "\
59
v = Simpleitk::VectorUInt32.new\
60
for i in ".. ruby_value[i] .." do v << i end\
61
filter.add_seed(v)" end)]]
62
elseif parameter == "SeedList"then
63
OUT=[[ filter.clear_seeds()
64
$(for i=1,#value do OUT=OUT .. "\
65
v = Simpleitk::VectorUInt32.new\
66
for i in ".. value[i] .." do v << i end\
67
filter.add_seed(v)" end)]]
68
elseif parameter == "TrialPoints" and ruby_value then
69
OUT=[[ filter.clear_trial_points()
70
$(for i=1,#ruby_value do OUT=OUT .. "\
71
v = Simpleitk::VectorUInt32.new\
72
for i in ".. ruby_value[i] .." do v << i end\
73
filter.add_trial_point(v)" end)]]
74
elseif parameter == "TrialPoints"then
75
OUT=[[ filter.clear_trial_points()
76
$(for i=1,#value do OUT=OUT .. "\
77
v = Simpleitk::VectorUInt32.new\
78
for i in ".. value[i] .." do v << i end\
79
filter.add_trial_point(v)" end)]]
80
elseif dim_vec and dim_vec == 1 then
82
if type == "bool" then
83
OUT="v = Simpleitk::VectorBool.new"
84
elseif type == "uint8_t" then
85
OUT="v = Simpleitk::VectorUInt8.new"
86
elseif type == "int" then
87
OUT="v = Simpleitk::VectorInt32.new"
88
elseif type == "double" then
89
OUT="v = Simpleitk::VectorDouble.new"
91
OUT="v = Simpleitk::VectorUInt32.new"
102
OUT=OUT..value[i]..", "
104
OUT=OUT..value[#value]..' ]'
106
OUT=OUT..[[do v << i end
107
filter.set_${parameter:gsub ( "([a-z])([A-Z])", "%1_%2" ):lower()}(v)]]
110
filter.set_${parameter:gsub ( "([a-z])([A-Z])", "%1_%2" ):lower()}( $(if ruby_value then OUT='${ruby_value}' else OUT='${value}' end) ) ]]
116
for i in 1..ARGV.length-2
117
puts "reading.."+ARGV[i]
118
inputs.push( Simpleitk::read_image( ARGV[i] ) )
120
$(if inputA_cast then
122
-- the first char of the string needs to be converted to upper case
124
caster = Simpleitk::CastImageFilter.new
125
caster.set_output_pixel_type( Simpleitk::${inputA_cast:gsub("^%l", inputA_cast.upper ) })
126
inputs[0] = caster.execute( inputs[0] ) ]]
128
$(if inputB_cast then
130
-- the first char of the string needs to be converted to upper case
132
caster = Simpleitk::CastImageFilter.new
133
caster.set_output_pixel_type( Simpleitk::${inputB_cast:gsub("^%l", inputB_cast.upper ) })
134
inputs[1] = caster.execute( inputs[1] ) ]]
137
output = filter.execute( *inputs )
139
$(if not no_return_image then
141
labelIDs = [ Simpleitk::SitkLabelUInt8, Simpleitk::SitkLabelUInt16, Simpleitk::SitkLabelUInt32, Simpleitk::SitkLabelUInt64 ]
142
if labelIDs.include?(output.get_pixel_id()) then
143
caster = Simpleitk::LabelMapToLabelImageFilter.new
144
output = caster.execute( output )
146
writer.set_file_name( ARGV[ARGV.length-1] )
147
writer.execute( output )