aboutsummaryrefslogtreecommitdiff
path: root/src/misc/select.plane
blob: 062f12dd1ea28d38857fa020cbf92487e2a357ba (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl -w
use strict;
my $true  = 1;
my $false = 0;

########################################

my $usage_msg = <<'EOF';
Usage:
	select.plane	[ xy | xz | yz ]

This script reads an AHFinderDirect horizon-shape data file from
standard input, with file format
	dpx	dpy	radius		x	y	z
selects the subset of the data which lies in the specified plane,
and writes that to standard output.
EOF

########################################

if (scalar(@ARGV) != 1)
	{ die $usage_msg; }

my $xy_plane_flag = $false;
my $xz_plane_flag = $false;
my $yz_plane_flag = $false;
if    ($ARGV[0] eq 'xy') { $xy_plane_flag = $true; }
elsif ($ARGV[0] eq 'xz') { $xz_plane_flag = $true; }
elsif ($ARGV[0] eq 'yz') { $yz_plane_flag = $true; }
else	{ die $usage_msg; }


	while (my $line = <STDIN>)
	{
	chomp($line);

	# echo blank or comment lines
	if (($line =~ /^$/) || ($line =~ /^#/))
		{
		print $line, "\n";
		next;					# *** LOOP CONTROL ***
		}

	my ($dpx,$dpy,$radius,$x,$y,$z) = split(/\s+/, $line);

	if (    ($xy_plane_flag && (abs($z) <= 1.0e-10))
	     || ($xz_plane_flag && (abs($y) <= 1.0e-10))
	     || ($yz_plane_flag && (abs($x) <= 1.0e-10))    )
		{ print $line, "\n"; }
	}