use strict;
use autodie;
+use File::Temp;
+
sub shift_arg () {
die unless @ARGV;
scalar shift @ARGV;
die "no options supported\n";
}
-my $admesh_pipe = '--write-ascii-stl 3<&0 4>&1 >/dev/null /dev/fd/4 /dev/fd/3';
+my $itmp = new File::Temp;
+my $otmp = new File::Temp;
+
+system "cat >$itmp";
+
+my $admesh_stdout = '--write-ascii-stl /dev/fd/3 3>&1 >/dev/null';
-open I, "admesh $admesh_pipe |";
-open O, "| admesh --normal-values $admesh_pipe";
+open I, "admesh $admesh_stdout $itmp |";
our @saved_argv = @ARGV;
while (<I>) {
+ @ARGV = @saved_argv;
if (s/^\s+vertex\s+//) {
my $lhs = $&;
s/\s+$//;
@xyz = map { sprintf "%.18g", $_ } @xyz;
$_ = "$lhs@xyz\n";
}
- print O;
+ print $otmp $_;
}
-<I>,<O> if 0; # suppresses Name "main::I" used only once
-
close I;
-close O;
+<I> if 0; # suppresses Name "main::I" used only once
+
+flush $otmp;
+
+system "admesh --normal-values $admesh_stdout $otmp";