File: RubyImageFilterTestTemplate.rb.in

package info (click to toggle)
simpleitk 1.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 75,056 kB
  • sloc: cpp: 25,403; python: 3,060; sh: 1,131; ansic: 369; java: 260; cs: 215; makefile: 51; ruby: 47; tcl: 22
file content (152 lines) | stat: -rw-r--r-- 4,423 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#==========================================================================
#
#   Copyright Insight Software Consortium
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#          http://www.apache.org/licenses/LICENSE-2.0.txt
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
#==========================================================================*/

#
# WARNING: DO NOT EDIT THIS FILE!
# THIS FILE IS AUTOMATICALLY GENERATED BY THE SIMPLEITK BUILD PROCESS.
# Please look at RubyImageFilterTestTemplate.rb.in to make changes.
#


# This is Ruby code to test ${name}
require 'simpleitk'

inputs = 1
$(if number_of_inputs then
    OUT=[[inputs = ${number_of_inputs}]]
  end)

if ARGV.length < inputs + 2 then
    puts( "Usage: ${name} tag <input(s)> output" )
    exit( 1 )
end

tag = ARGV[0];

reader = Simpleitk::ImageFileReader.new
writer = Simpleitk::ImageFileWriter.new
filter = Simpleitk::${name}.new

$(if #tests == 0 then
    OUT=[[
puts( "No tests defined!" );
exit( 1 );
    ]]
  end)

$(foreach tests
if tag == "${tag}" then
  $(when settings
$(foreach settings
$(if parameter == "SeedList" and ruby_value then
    OUT=[[  filter.clear_seeds()
    $(for i=1,#ruby_value do OUT=OUT .. "\
    v = Simpleitk::VectorUInt32.new\
    for i in ".. ruby_value[i] .." do v << i end\
    filter.add_seed(v)" end)]]
elseif parameter == "SeedList"then
    OUT=[[  filter.clear_seeds()
    $(for i=1,#value do OUT=OUT .. "\
    v = Simpleitk::VectorUInt32.new\
    for i in ".. value[i] .." do v << i end\
    filter.add_seed(v)" end)]]
elseif parameter == "TrialPoints" and ruby_value then
    OUT=[[  filter.clear_trial_points()
    $(for i=1,#ruby_value do OUT=OUT .. "\
    v = Simpleitk::VectorUInt32.new\
    for i in ".. ruby_value[i] .." do v << i end\
    filter.add_trial_point(v)" end)]]
elseif parameter == "TrialPoints"then
    OUT=[[  filter.clear_trial_points()
    $(for i=1,#value do OUT=OUT .. "\
    v = Simpleitk::VectorUInt32.new\
    for i in ".. value[i] .." do v << i end\
    filter.add_trial_point(v)" end)]]
elseif dim_vec and dim_vec == 1 then 

   if type == "bool" then
     OUT="v = Simpleitk::VectorBool.new"
   elseif type == "uint8_t" then
     OUT="v = Simpleitk::VectorUInt8.new"
   elseif type == "int" then
     OUT="v = Simpleitk::VectorInt32.new"
   elseif type == "double" then
     OUT="v = Simpleitk::VectorDouble.new"
   else
     OUT="v = Simpleitk::VectorUInt32.new"
   end

OUT=OUT..[[

  for i in ]]
if ruby_value then
  OUT='${ruby_value}'
else
  OUT=OUT..'[ '
  for i=1,#value-1 do
    OUT=OUT..value[i]..", "
  end
  OUT=OUT..value[#value]..' ]'
end
OUT=OUT..[[do v << i end
  filter.set_${parameter:gsub ( "([a-z])([A-Z])", "%1_%2" ):lower()}(v)]]
else
OUT=[[
    filter.set_${parameter:gsub ( "([a-z])([A-Z])", "%1_%2" ):lower()}( $(if ruby_value then OUT='${ruby_value}' else OUT='${value}' end) ) ]]
end)
)
)
  inputs = Array.new

  for i in 1..ARGV.length-2
    puts "reading.."+ARGV[i]
    inputs.push( Simpleitk::read_image( ARGV[i] ) )
  end
$(if inputA_cast then

-- the first char of the string needs to be converted to upper case
OUT=[[
  caster = Simpleitk::CastImageFilter.new
  caster.set_output_pixel_type( Simpleitk::${inputA_cast:gsub("^%l", inputA_cast.upper ) })
  inputs[0] = caster.execute( inputs[0] ) ]]
end)
$(if inputB_cast then

-- the first char of the string needs to be converted to upper case
OUT=[[
  caster = Simpleitk::CastImageFilter.new
  caster.set_output_pixel_type( Simpleitk::${inputB_cast:gsub("^%l", inputB_cast.upper ) })
  inputs[1] = caster.execute( inputs[1] ) ]]
end)

  output = filter.execute( *inputs )

$(if not no_return_image then
OUT=[[
  labelIDs = [ Simpleitk::SitkLabelUInt8, Simpleitk::SitkLabelUInt16, Simpleitk::SitkLabelUInt32, Simpleitk::SitkLabelUInt64 ]
  if labelIDs.include?(output.get_pixel_id()) then
    caster = Simpleitk::LabelMapToLabelImageFilter.new
    output = caster.execute( output )
  end
  writer.set_file_name( ARGV[ARGV.length-1] )
  writer.execute( output )
]]
end)
end
)