File: network.pl

package info (click to toggle)
voro%2B%2B 0.4.6%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,372 kB
  • sloc: cpp: 6,384; perl: 232; makefile: 164
file content (27 lines) | stat: -rw-r--r-- 650 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/perl
# This script takes a .vol file that has neighbor information created with
# the custom output string "%i %q %v %n", and creates a map of the network, by
# drawing a line between all particles which are neighbors

open A,"@ARGV[0].vol" or die "Can't open input file";
open B,">@ARGV[0].net" or die "Can't open output file";

$maxn=0;

while(<A>) {
	@A=split;
	$n=@A[0];
	$x[$n]=@A[1];
	$y[$n]=@A[2];
	$z[$n]=@A[3];
	$c[$n]=$#A-5;
	$l[$n][$_-5]=@A[$_] foreach 5..$#A;
	$maxn=$n if $n>$maxn;
}

foreach $n (1..$maxn) {
	foreach (0..$c[$n]) {
		$j=$l[$n][$_];
		print B "$x[$j] $y[$j] $z[$j]\n$x[$n] $y[$n] $z[$n]\n\n\n" if $j>=$n;
	}
}