1CAD::Format::STL(3) User Contributed Perl Documentation CAD::Format::STL(3)
2
3
4
6 CAD::Format::STL - read/write 3D stereolithography files
7
9 Reading:
10
11 my $stl = CAD::Format::STL->new->load("foo.stl");
12 # what about the part/multipart?
13 my @facets = $stl->part->facets;
14
15 Writing:
16
17 my $stl = CAD::Format::STL->new;
18 my $part = $stl->add_part("my part");
19 $part->add_facets(@faces);
20 $stl->save("foo.stl");
21 # or $stl->save(binary => "foo.stl");
22
23 Streaming read/write:
24
25 my $reader = CAD::Format::STL->reader("foo.stl");
26 my $writer = CAD::Format::STL->writer(binary => "bar.stl");
27 while(my $part = $reader->next_part) {
28 my $part_name = $part->name;
29 $writer->start_solid($part_name);
30 while(my @data = $part->facet) {
31 my ($normal, @vertices) = @data;
32 my @v1 = @{$vertices[0]};
33 my @v2 = @{$vertices[0]};
34 my @v3 = @{$vertices[0]};
35 # that's just for illustration
36 $writer->facet(\@v1, \@v2, \@v3);
37 # note the omitted normal
38 }
39 $writer->end_solid;
40 }
41
43 This module provides object-oriented methods to read and write the STL
44 (Stereo Lithography) file format in both binary and ASCII forms. The
45 STL format is a simple set of 3D triangles.
46
48 new
49 my $stl = CAD::Format::STL->new;
50
51 add_part
52 Create a new part in the stl.
53
54 my $part = $stl->add_part("name");
55
56 Optionally, add the faces directly:
57
58 my $part = $stl->add_part("name", @faces);
59
60 part
61 Get the part at $index. Negative indices are valid.
62
63 my $part = $stl->part($index);
64
65 Throws an error if there is no such part.
66
68 load
69 Load an STL file (auto-detects binary/ascii)
70
71 $stl = $stl->load("filename.stl");
72
73 Optionally, explicitly declare binary mode:
74
75 $stl = $stl->load(binary => "filename.stl");
76
77 The $self object is returned to allow e.g. chaining to "new()".
78
79 The filename may also be a filehandle.
80
81 _read_ascii
82 $self->_read_ascii($filehandle);
83
84 get_<something>
85 These functions are currently only used internally.
86
87 get_triangle
88 get_ulong
89 get_float32
90 get_short
91
92 _read_binary
93 $self->_read_binary($filehandle);
94
95 save
96 $stl->save("filename.stl");
97
98 $stl->save(binary => "filename.stl");
99
100 _write_binary
101 $self->_write_binary($filehandle);
102
103 _write_ascii
104 $self->_write_ascii($filehandle);
105
107 Eric Wilhelm @ <ewilhelm at cpan dot org>
108
109 http://scratchcomputing.com/
110
112 If you found this module on CPAN, please report any bugs or feature
113 requests through the web interface at <http://rt.cpan.org>. I will be
114 notified, and then you'll automatically be notified of progress on your
115 bug as I make changes.
116
117 If you pulled this development version from my /svn/, please contact me
118 directly.
119
121 Copyright (C) 2007 Eric L. Wilhelm, All Rights Reserved.
122
124 Absolutely, positively NO WARRANTY, neither express or implied, is
125 offered with this software. You use this software at your own risk.
126 In case of loss, no person or entity owes you anything whatsoever. You
127 have been warned.
128
130 This program is free software; you can redistribute it and/or modify it
131 under the same terms as Perl itself.
132
133
134
135perl v5.32.1 2021-01-26 CAD::Format::STL(3)