#!/usr/bin/perl

#
# usage: ./ctm2dpr.pl <INFILE> <OUTFILE>
#

########################
# Parse the command line

my $infile = "$ARGV[0]";
chomp ( $infile );
my $outfile = "$ARGV[1]";
chomp ( $outfile );

open (INFILE, "$infile") 
    or die "can't open input file";

system("echo '~startCatoms' >> $outfile");

###########################################
# Ignore header info for now, throw it away

my $GUID = 12345678;
my $line = "";
my $atData = "false";

print("RUNNING dprfixer.pl $infile $outfile ...\n");

while ($line=<INFILE>) {
    chomp ( $line );
    @arr = split(/,/, $line);
    $v = @arr[0] * 10;
    $x = @arr[3];
    $y = @arr[1];
    $z = @arr[2];
	
    ###############################
    # Create the objects for dprsim
    
    $GUID += 1;
    $outline = "$GUID,$x,$y,$z,1,1,3";
    
    ###############################
    # Write the objects to the file
    
    system("echo '$outline' >> $outfile");
}

close INFILE;

print("DONE.\n");
