Martin Isenburg wrote:
> Hello John.
>
> this funcitonality is not in
http://pointzip.org yet. When I did the
> programming of pointzip.exe I assumed that each PTS / PTX file
> contains just one unstructured (PTS) / gridded (PTX) point cloud. But
> as both PTS and PTX are simple ASCII formats it should be easy to
> write some perl / python / ... script that can find the places where
> they can be segmented into multiple files. With so many scripting
> enthusiasts in this forum I am sure there is someone who either has
> such a script already or can write one in a few minutes. Some more
> info on the PTS / PTX formats and pointzip.exe is here:
That's a challenge if I ever saw one. :-)
Try this perl script,
ptx-split.pl
It assumes that each segment starts with the same ype of startup block
of 10 lines, I tested it by concatenating a few of the samples you
pointed us at and ran it like this:
ptx-split.pl samples.ptx ptx
This generated ptx_000.ptx, ptx_001.ptx etc.
#!perl -w
#
ptx-split.pl, written by Terje Mathisen
use strict;
my $ifile = shift;
my $oprefix = shift;
die("Usage:
ptx-split.pl <input_filename> <output_prefix>\n") unless
(defined($oprefix) && open(I, $ifile));
my ($part, $lines, $ofile) = (0,1e38);
while (<I>) {
chomp;
my @f = split;
if (scalar(@f) == 1 && $lines >= 10) { # Start of new PTX segment
close(O) if ($lines < 1e38);
my $ofile = sprintf(">%s_%03d.ptx", $oprefix, $part++);
open(O, $ofile) || die("Could not write to $ofile\n");
$lines = 0;
}
printf(O "%s\n", $_) || die("Error writing output\n");
$lines++;
}
close(O) if ($lines < 1e38);
--
- <
Terje.M...@tmsw.no>
"almost all programming can be viewed as an exercise in caching"