#!/usr/bin/perl -w

# Update old mesh syntax to new mesh syntax

use File::Copy qw(copy);

while ($ARGV[0]) {

    my $fileNameIn   = shift @ARGV;
    my $fileNameSave = $fileNameIn . ".old";
    my $fileNameOut  = $fileNameIn . ".new";

    copy $fileNameIn, $fileNameSave;

    open( INPUT,   $fileNameIn   )  or die "Can't open $fileNameIn\n";
    open( OUTPUT,">$fileNameOut" )  or die "Can't open $fileNameOut\n";

NEXT:
    while(<INPUT>) {

	$_ =~ s|meshGradient|mesh|;
	$_ =~ s|meshRow|meshrow|;
	$_ =~ s|meshPatch|meshpatch|;
	$_ =~ s|smooth=|type=|;
	$_ =~ s|type="none"||;
	$_ =~ s|smooth8|bicubic|;
	$_ =~ s|smooth7|bicubic|;
	$_ =~ s|smooth6|bicubic|;
	$_ =~ s|smooth5|bicubic|;
	$_ =~ s|smooth4|bicubic|;
	$_ =~ s|smooth3|bicubic|;
	$_ =~ s|smooth2|bicubic|;
	$_ =~ s|smooth1|bicubic|;
	$_ =~ s|smooth|bicubic|;

	print OUTPUT;

    }

    rename $fileNameOut, $fileNameIn;

     
}

