path = "../gallery/"
map = {"c"=>"cylindrical","o"=>"orthographic","p"=>"orthographic-polar"}

def test(o,g,u)
  if o==1000 && g==5 && u=="1"
    return false
  elsif o==0 && g==5 && u=="sqrt2"
    return false
  elsif o==25 && g==5 && u=="sqrt2"
    return false
  elsif o==50 && g==5 && u=="sqrt2"
    return false
  elsif o==200 && g==5 && u=="sqrt2"
    return false
  elsif o==400 && g==5 && u=="sqrt2"
    return false
  elsif o==1000 && g==5 && u=="sqrt2"
    return false
  elsif g=="inf" && u=="1"
    return false
  end
  return true
end


[0,25,50,100,200,400,1000,4000].each do |i|
  [5,10,100,1000,10000,"inf"].each do |j|
    %w(1 sqrt2).each do |k|
      next unless test(i,j,k)
      %w(vor potvor div hsfc strfunc velpot).each do |v|
        next if j=="inf" && (v=="potvor"||v=="div"||v=="hsfc"||v=="velpot")
        map.keys.each do |l|
          gif = "#{path}#{v}_lon-lat_#{map[l]}_Omega#{i}_G#{j}_U#{k}.gif"
          next if File.exist?(gif)
          p gif
          com = "xvfb-run ruby lonlat-anim.rb #{v} #{i} #{j} #{k} #{l} > /dev/null && convert dcl_*.png #{gif}"
          begin
            system(com)
          ensure
            system("rm -f dcl_*.png")
          end
        end
      end
    end
  end
end
