Minkowski test code.
[voro++.git] / trunk / scripts / network.pl
blob2e7bf7aaafb3c476a46dd7d2c7707585d7213d6f
1 #!/usr/bin/perl
2 # This script takes a .vol file that has neighbor information created with
3 # the custom output string "%i %q %v %n", and creates a map of the network, by
4 # drawing a line between all particles which are neighbors
6 open A,"@ARGV[0].vol" or die "Can't open input file";
7 open B,">@ARGV[0].net" or die "Can't open output file";
9 $maxn=0;
11 while(<A>) {
12 @A=split;
13 $n=@A[0];
14 $x[$n]=@A[1];
15 $y[$n]=@A[2];
16 $z[$n]=@A[3];
17 $c[$n]=$#A-5;
18 $l[$n][$_-5]=@A[$_] foreach 5..$#A;
19 $maxn=$n if $n>$maxn;
22 foreach $n (1..$maxn) {
23 foreach (0..$c[$n]) {
24 $j=$l[$n][$_];
25 print B "$x[$j] $y[$j] $z[$j]\n$x[$n] $y[$n] $z[$n]\n\n\n" if $j>=$n;