
CAD::Format::STL - read/write 3D stereolithography files

Reading:
my $stl = CAD::Format::STL->new->load("foo.stl");
# what about the part/multipart?
my @facets = $stl->part->facets;
Writing:
my $stl = CAD::Format::STL->new;
my $part = $stl->add_part("my part");
$part->add_facets(@faces);
$stl->save("foo.stl");
# or $stl->save(binary => "foo.stl");
Streaming read/write:
my $reader = CAD::Format::STL->reader("foo.stl");
my $writer = CAD::Format::STL->writer(binary => "bar.stl");
while(my $part = $reader->next_part) {
my $part_name = $part->name;
$writer->start_solid($part_name);
while(my @data = $part->facet) {
my ($normal, @vertices) = @data;
my @v1 = @{$vertices[0]};
my @v2 = @{$vertices[0]};
my @v3 = @{$vertices[0]};
# that's just for illustration
$writer->facet(\@v1, \@v2, \@v3);
# note the omitted normal
}
$writer->end_solid;
}

my $stl = CAD::Format::STL->new;
Create a new part in the stl.
my $part = $stl->add_part("name");
Optionally, add the faces directly:
my $part = $stl->add_part("name", @faces);
Get the part at $index. Negative indices are valid.
my $part = $stl->part($index);
Throws an error if there is no such part.

Load an STL file (auto-detects binary/ascii)
$stl = $stl->load("filename.stl");
Optionally, explicitly declare binary mode:
$stl = $stl->load(binary => "filename.stl");
The $self object is returned to allow e.g. chaining to new().
The filename may also be a filehandle.
$self->_read_ascii($filehandle);
These functions are currently only used internally.
$self->_read_binary($filehandle);
$stl->save("filename.stl");
$stl->save(binary => "filename.stl");
$self->_write_binary($filehandle);
$self->_write_ascii($filehandle);

Eric Wilhelm @ <ewilhelm at cpan dot org>

If you found this module on CPAN, please report any bugs or feature requests through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
If you pulled this development version from my /svn/, please contact me directly.

Copyright (C) 2007 Eric L. Wilhelm, All Rights Reserved.

Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.