triangular 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +25 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +31 -0
- data/Rakefile +11 -0
- data/examples/example_files/test_cube.stl +58 -0
- data/examples/example_files/y-axis-spacer.stl +310 -0
- data/examples/slice_example.rb +9 -0
- data/lib/triangular.rb +19 -0
- data/lib/triangular/facet.rb +81 -0
- data/lib/triangular/line.rb +38 -0
- data/lib/triangular/point.rb +33 -0
- data/lib/triangular/polyline.rb +24 -0
- data/lib/triangular/solid.rb +45 -0
- data/lib/triangular/vector.rb +4 -0
- data/lib/triangular/version.rb +3 -0
- data/lib/triangular/vertex.rb +44 -0
- data/spec/facet_spec.rb +257 -0
- data/spec/fixtures/test_cube.stl +58 -0
- data/spec/fixtures/y-axis-spacer.stl +310 -0
- data/spec/line_spec.rb +190 -0
- data/spec/point_spec.rb +67 -0
- data/spec/polyline_spec.rb +20 -0
- data/spec/solid_spec.rb +85 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/triangular_spec.rb +22 -0
- data/spec/vertex_spec.rb +44 -0
- data/triangular.gemspec +23 -0
- metadata +104 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
triangular (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.2)
|
10
|
+
rspec (2.5.0)
|
11
|
+
rspec-core (~> 2.5.0)
|
12
|
+
rspec-expectations (~> 2.5.0)
|
13
|
+
rspec-mocks (~> 2.5.0)
|
14
|
+
rspec-core (2.5.1)
|
15
|
+
rspec-expectations (2.5.0)
|
16
|
+
diff-lcs (~> 1.1.2)
|
17
|
+
rspec-mocks (2.5.0)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
bundler (>= 1.0.0)
|
24
|
+
rspec (~> 2)
|
25
|
+
triangular!
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Aaron Gough (http://thingsaaronmade.com/)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
= Triangular
|
2
|
+
|
3
|
+
Triangular is an easy-to-use Ruby library for reading, writing and manipulating Stereolithography (STL) files.
|
4
|
+
|
5
|
+
The main purpose of Triangular is to enable its users to quickly create new software for Rapid Prototyping and Personal Manufacturing applications. Triangular has many of the core functions needed in order to generate toolpaths for 3D printers and CNC Mills/Routers.
|
6
|
+
|
7
|
+
Please note that Triangular requires Ruby 1.9+. Triangular is currently in the Alpha stage of development which means that the API can and will change, and that new features will be added often!
|
8
|
+
|
9
|
+
=== A Quick Example
|
10
|
+
|
11
|
+
# Open and parse an STL file
|
12
|
+
solid = Triangular.parse_file("test.stl")
|
13
|
+
|
14
|
+
# Cut a section slice of the model at a Z height of 1.0
|
15
|
+
slice = solid.slice_at_z(1.0)
|
16
|
+
|
17
|
+
# Create an SVG image of the slice for further manipulation
|
18
|
+
svg = slice.to_svg
|
19
|
+
|
20
|
+
=== Installation
|
21
|
+
|
22
|
+
For ease of use the Triangular is packaged as a RubyGem. Providing you already have Ruby and RubyGems installing Triangular is as easy as entering the following command in a terminal:
|
23
|
+
|
24
|
+
gem install triangular
|
25
|
+
|
26
|
+
=== Author & Credits
|
27
|
+
|
28
|
+
Author:: {Aaron Gough}[mailto:aaron@aarongough.com]
|
29
|
+
|
30
|
+
Copyright (c) 2011 {Aaron Gough}[http://thingsaaronmade.com/] ({thingsaaronmade.com}[http://thingsaaronmade.com/]), released under the MIT license
|
31
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
solid model
|
2
|
+
facet normal -0.0 1.0 -0.0
|
3
|
+
outer loop
|
4
|
+
vertex -10.0 10.0 10.0
|
5
|
+
vertex 10.0 10.0 -10.0
|
6
|
+
vertex -10.0 10.0 -10.0
|
7
|
+
endloop
|
8
|
+
endfacet
|
9
|
+
facet normal -0.0 1.0 -0.0
|
10
|
+
outer loop
|
11
|
+
vertex 10.0 10.0 -10.0
|
12
|
+
vertex -10.0 10.0 10.0
|
13
|
+
vertex 10.0 10.0 10.0
|
14
|
+
endloop
|
15
|
+
endfacet
|
16
|
+
facet normal -1.0 0.0 0.0
|
17
|
+
outer loop
|
18
|
+
vertex -10.0 10.0 10.0
|
19
|
+
vertex -10.0 -10.0 -10.0
|
20
|
+
vertex -10.0 -10.0 10.0
|
21
|
+
endloop
|
22
|
+
endfacet
|
23
|
+
facet normal -1.0 0.0 0.0
|
24
|
+
outer loop
|
25
|
+
vertex -10.0 -10.0 -10.0
|
26
|
+
vertex -10.0 10.0 10.0
|
27
|
+
vertex -10.0 10.0 -10.0
|
28
|
+
endloop
|
29
|
+
endfacet
|
30
|
+
facet normal 1.0 -0.0 -0.0
|
31
|
+
outer loop
|
32
|
+
vertex 10.0 10.0 -10.0
|
33
|
+
vertex 10.0 -10.0 10.0
|
34
|
+
vertex 10.0 -10.0 -10.0
|
35
|
+
endloop
|
36
|
+
endfacet
|
37
|
+
facet normal 1.0 -0.0 -0.0
|
38
|
+
outer loop
|
39
|
+
vertex 10.0 -10.0 10.0
|
40
|
+
vertex 10.0 10.0 -10.0
|
41
|
+
vertex 10.0 10.0 10.0
|
42
|
+
endloop
|
43
|
+
endfacet
|
44
|
+
facet normal 0.0 -1.0 0.0
|
45
|
+
outer loop
|
46
|
+
vertex 10.0 -10.0 10.0
|
47
|
+
vertex -10.0 -10.0 -10.0
|
48
|
+
vertex 10.0 -10.0 -10.0
|
49
|
+
endloop
|
50
|
+
endfacet
|
51
|
+
facet normal 0.0 -1.0 0.0
|
52
|
+
outer loop
|
53
|
+
vertex -10.0 -10.0 -10.0
|
54
|
+
vertex 10.0 -10.0 10.0
|
55
|
+
vertex -10.0 -10.0 10.0
|
56
|
+
endloop
|
57
|
+
endfacet
|
58
|
+
endsolid model
|
@@ -0,0 +1,310 @@
|
|
1
|
+
solid y-axis-spacer
|
2
|
+
facet normal 0.0 0.0 -1.0
|
3
|
+
outer loop
|
4
|
+
vertex 16.5 0.0 -0.75
|
5
|
+
vertex 0.0 -9.5 -0.75
|
6
|
+
vertex 0.0 0.0 -0.75
|
7
|
+
endloop
|
8
|
+
endfacet
|
9
|
+
facet normal 0.0 0.0 -1.0
|
10
|
+
outer loop
|
11
|
+
vertex 0.0 -9.5 -0.75
|
12
|
+
vertex 16.5 0.0 -0.75
|
13
|
+
vertex 16.5 -9.5 -0.75
|
14
|
+
endloop
|
15
|
+
endfacet
|
16
|
+
facet normal -0.0 -1.0 -0.0
|
17
|
+
outer loop
|
18
|
+
vertex 16.5 -9.5 0.0
|
19
|
+
vertex 0.0 -9.5 -0.75
|
20
|
+
vertex 16.5 -9.5 -0.75
|
21
|
+
endloop
|
22
|
+
endfacet
|
23
|
+
facet normal -0.0 -1.0 -0.0
|
24
|
+
outer loop
|
25
|
+
vertex 0.0 -9.5 -0.75
|
26
|
+
vertex 16.5 -9.5 0.0
|
27
|
+
vertex 0.0 -9.5 0.0
|
28
|
+
endloop
|
29
|
+
endfacet
|
30
|
+
facet normal -0.0 1.0 0.0
|
31
|
+
outer loop
|
32
|
+
vertex 0.0 0.0 0.0
|
33
|
+
vertex 16.5 0.0 -0.75
|
34
|
+
vertex 0.0 0.0 -0.75
|
35
|
+
endloop
|
36
|
+
endfacet
|
37
|
+
facet normal -0.0 1.0 0.0
|
38
|
+
outer loop
|
39
|
+
vertex 16.5 0.0 -0.75
|
40
|
+
vertex 0.0 0.0 0.0
|
41
|
+
vertex 16.5 0.0 0.0
|
42
|
+
endloop
|
43
|
+
endfacet
|
44
|
+
facet normal -1.0 0.0 0.0
|
45
|
+
outer loop
|
46
|
+
vertex 0.0 -2.13 0.0
|
47
|
+
vertex 0.0 -7.37 -0.13
|
48
|
+
vertex 0.0 -7.37 0.0
|
49
|
+
endloop
|
50
|
+
endfacet
|
51
|
+
facet normal -1.0 0.0 0.0
|
52
|
+
outer loop
|
53
|
+
vertex 0.0 0.0 0.0
|
54
|
+
vertex 0.0 -1.87 -0.13
|
55
|
+
vertex 0.0 -1.87 0.0
|
56
|
+
endloop
|
57
|
+
endfacet
|
58
|
+
facet normal -1.0 0.0 0.0
|
59
|
+
outer loop
|
60
|
+
vertex 0.0 -7.63 0.0
|
61
|
+
vertex 0.0 -9.5 -0.75
|
62
|
+
vertex 0.0 -9.5 0.0
|
63
|
+
endloop
|
64
|
+
endfacet
|
65
|
+
facet normal -1.0 0.0 0.0
|
66
|
+
outer loop
|
67
|
+
vertex 0.0 -9.5 -0.75
|
68
|
+
vertex 0.0 -7.63 0.0
|
69
|
+
vertex 0.0 -7.63 -0.13
|
70
|
+
endloop
|
71
|
+
endfacet
|
72
|
+
facet normal -1.0 0.0 0.0
|
73
|
+
outer loop
|
74
|
+
vertex 0.0 -9.5 -0.75
|
75
|
+
vertex 0.0 -7.63 -0.13
|
76
|
+
vertex 0.0 0.0 -0.75
|
77
|
+
endloop
|
78
|
+
endfacet
|
79
|
+
facet normal -1.0 0.0 0.0
|
80
|
+
outer loop
|
81
|
+
vertex 0.0 0.0 -0.75
|
82
|
+
vertex 0.0 -7.63 -0.13
|
83
|
+
vertex 0.0 -7.37 -0.13
|
84
|
+
endloop
|
85
|
+
endfacet
|
86
|
+
facet normal -1.0 0.0 0.0
|
87
|
+
outer loop
|
88
|
+
vertex 0.0 0.0 -0.75
|
89
|
+
vertex 0.0 -7.37 -0.13
|
90
|
+
vertex 0.0 -2.13 -0.13
|
91
|
+
endloop
|
92
|
+
endfacet
|
93
|
+
facet normal -1.0 0.0 0.0
|
94
|
+
outer loop
|
95
|
+
vertex 0.0 -2.13 -0.13
|
96
|
+
vertex 0.0 -7.37 -0.13
|
97
|
+
vertex 0.0 -2.13 0.0
|
98
|
+
endloop
|
99
|
+
endfacet
|
100
|
+
facet normal -1.0 0.0 0.0
|
101
|
+
outer loop
|
102
|
+
vertex 0.0 0.0 -0.75
|
103
|
+
vertex 0.0 -2.13 -0.13
|
104
|
+
vertex 0.0 -1.87 -0.13
|
105
|
+
endloop
|
106
|
+
endfacet
|
107
|
+
facet normal -1.0 0.0 0.0
|
108
|
+
outer loop
|
109
|
+
vertex 0.0 0.0 -0.75
|
110
|
+
vertex 0.0 -1.87 -0.13
|
111
|
+
vertex 0.0 0.0 0.0
|
112
|
+
endloop
|
113
|
+
endfacet
|
114
|
+
facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
|
115
|
+
outer loop
|
116
|
+
vertex 16.5 0.0 -0.75
|
117
|
+
vertex 16.5 -9.5 0.0
|
118
|
+
vertex 16.5 -9.5 -0.75
|
119
|
+
endloop
|
120
|
+
endfacet
|
121
|
+
facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
|
122
|
+
outer loop
|
123
|
+
vertex 16.5 -9.5 0.0
|
124
|
+
vertex 16.5 0.0 -0.75
|
125
|
+
vertex 16.5 -7.63 -0.13
|
126
|
+
endloop
|
127
|
+
endfacet
|
128
|
+
facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
|
129
|
+
outer loop
|
130
|
+
vertex 16.5 -7.63 -0.13
|
131
|
+
vertex 16.5 0.0 -0.75
|
132
|
+
vertex 16.5 -7.37 -0.13
|
133
|
+
endloop
|
134
|
+
endfacet
|
135
|
+
facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
|
136
|
+
outer loop
|
137
|
+
vertex 16.5 -7.37 -0.13
|
138
|
+
vertex 16.5 0.0 -0.75
|
139
|
+
vertex 16.5 -7.37 0.0
|
140
|
+
endloop
|
141
|
+
endfacet
|
142
|
+
facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
|
143
|
+
outer loop
|
144
|
+
vertex 16.5 -7.37 0.0
|
145
|
+
vertex 16.5 0.0 -0.75
|
146
|
+
vertex 16.5 -2.13 -0.13
|
147
|
+
endloop
|
148
|
+
endfacet
|
149
|
+
facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
|
150
|
+
outer loop
|
151
|
+
vertex 16.5 -2.13 -0.13
|
152
|
+
vertex 16.5 0.0 -0.75
|
153
|
+
vertex 16.5 -1.87 -0.13
|
154
|
+
endloop
|
155
|
+
endfacet
|
156
|
+
facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
|
157
|
+
outer loop
|
158
|
+
vertex 16.5 -1.87 -0.13
|
159
|
+
vertex 16.5 0.0 -0.75
|
160
|
+
vertex 16.5 -1.87 0.0
|
161
|
+
endloop
|
162
|
+
endfacet
|
163
|
+
facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
|
164
|
+
outer loop
|
165
|
+
vertex 16.5 -1.87 0.0
|
166
|
+
vertex 16.5 0.0 -0.75
|
167
|
+
vertex 16.5 0.0 0.0
|
168
|
+
endloop
|
169
|
+
endfacet
|
170
|
+
facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
|
171
|
+
outer loop
|
172
|
+
vertex 16.5 -2.13 0.0
|
173
|
+
vertex 16.5 -7.37 0.0
|
174
|
+
vertex 16.5 -2.13 -0.13
|
175
|
+
endloop
|
176
|
+
endfacet
|
177
|
+
facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
|
178
|
+
outer loop
|
179
|
+
vertex 16.5 -7.63 0.0
|
180
|
+
vertex 16.5 -9.5 0.0
|
181
|
+
vertex 16.5 -7.63 -0.13
|
182
|
+
endloop
|
183
|
+
endfacet
|
184
|
+
facet normal -0.0 -0.0 1.0
|
185
|
+
outer loop
|
186
|
+
vertex 16.5 -1.87 0.0
|
187
|
+
vertex 0.0 0.0 0.0
|
188
|
+
vertex 0.0 -1.87 0.0
|
189
|
+
endloop
|
190
|
+
endfacet
|
191
|
+
facet normal -0.0 -0.0 1.0
|
192
|
+
outer loop
|
193
|
+
vertex 0.0 0.0 0.0
|
194
|
+
vertex 16.5 -1.87 0.0
|
195
|
+
vertex 16.5 0.0 0.0
|
196
|
+
endloop
|
197
|
+
endfacet
|
198
|
+
facet normal -0.0 -0.0 1.0
|
199
|
+
outer loop
|
200
|
+
vertex 16.5 -9.5 0.0
|
201
|
+
vertex 0.0 -7.63 0.0
|
202
|
+
vertex 0.0 -9.5 0.0
|
203
|
+
endloop
|
204
|
+
endfacet
|
205
|
+
facet normal -0.0 -0.0 1.0
|
206
|
+
outer loop
|
207
|
+
vertex 0.0 -7.63 0.0
|
208
|
+
vertex 16.5 -9.5 0.0
|
209
|
+
vertex 16.5 -7.63 0.0
|
210
|
+
endloop
|
211
|
+
endfacet
|
212
|
+
facet normal -0.0 -0.0 1.0
|
213
|
+
outer loop
|
214
|
+
vertex 16.5 -7.37 0.0
|
215
|
+
vertex 0.0 -2.13 0.0
|
216
|
+
vertex 0.0 -7.37 0.0
|
217
|
+
endloop
|
218
|
+
endfacet
|
219
|
+
facet normal -0.0 -0.0 1.0
|
220
|
+
outer loop
|
221
|
+
vertex 0.0 -2.13 0.0
|
222
|
+
vertex 16.5 -7.37 0.0
|
223
|
+
vertex 16.5 -2.13 0.0
|
224
|
+
endloop
|
225
|
+
endfacet
|
226
|
+
facet normal 0.0 0.0 -1.0
|
227
|
+
outer loop
|
228
|
+
vertex 16.5 -7.37 -0.13
|
229
|
+
vertex 0.0 -7.63 -0.13
|
230
|
+
vertex 0.0 -7.37 -0.13
|
231
|
+
endloop
|
232
|
+
endfacet
|
233
|
+
facet normal 0.0 0.0 -1.0
|
234
|
+
outer loop
|
235
|
+
vertex 0.0 -7.63 -0.13
|
236
|
+
vertex 16.5 -7.37 -0.13
|
237
|
+
vertex 16.5 -7.63 -0.13
|
238
|
+
endloop
|
239
|
+
endfacet
|
240
|
+
facet normal -0.0 1.0 0.0
|
241
|
+
outer loop
|
242
|
+
vertex 0.0 -7.37 0.0
|
243
|
+
vertex 16.5 -7.37 -0.13
|
244
|
+
vertex 0.0 -7.37 -0.13
|
245
|
+
endloop
|
246
|
+
endfacet
|
247
|
+
facet normal -0.0 1.0 0.0
|
248
|
+
outer loop
|
249
|
+
vertex 16.5 -7.37 -0.13
|
250
|
+
vertex 0.0 -7.37 0.0
|
251
|
+
vertex 16.5 -7.37 0.0
|
252
|
+
endloop
|
253
|
+
endfacet
|
254
|
+
facet normal -0.0 -1.0 -0.0
|
255
|
+
outer loop
|
256
|
+
vertex 16.5 -7.63 0.0
|
257
|
+
vertex 0.0 -7.63 -0.13
|
258
|
+
vertex 16.5 -7.63 -0.13
|
259
|
+
endloop
|
260
|
+
endfacet
|
261
|
+
facet normal -0.0 -1.0 -0.0
|
262
|
+
outer loop
|
263
|
+
vertex 0.0 -7.63 -0.13
|
264
|
+
vertex 16.5 -7.63 0.0
|
265
|
+
vertex 0.0 -7.63 0.0
|
266
|
+
endloop
|
267
|
+
endfacet
|
268
|
+
facet normal 0.0 0.0 -1.0
|
269
|
+
outer loop
|
270
|
+
vertex 16.5 -1.87 -0.13
|
271
|
+
vertex 0.0 -2.13 -0.13
|
272
|
+
vertex 0.0 -1.87 -0.13
|
273
|
+
endloop
|
274
|
+
endfacet
|
275
|
+
facet normal 0.0 0.0 -1.0
|
276
|
+
outer loop
|
277
|
+
vertex 0.0 -2.13 -0.13
|
278
|
+
vertex 16.5 -1.87 -0.13
|
279
|
+
vertex 16.5 -2.13 -0.13
|
280
|
+
endloop
|
281
|
+
endfacet
|
282
|
+
facet normal -0.0 1.0 0.0
|
283
|
+
outer loop
|
284
|
+
vertex 0.0 -1.87 0.0
|
285
|
+
vertex 16.5 -1.87 -0.13
|
286
|
+
vertex 0.0 -1.87 -0.13
|
287
|
+
endloop
|
288
|
+
endfacet
|
289
|
+
facet normal -0.0 1.0 0.0
|
290
|
+
outer loop
|
291
|
+
vertex 16.5 -1.87 -0.13
|
292
|
+
vertex 0.0 -1.87 0.0
|
293
|
+
vertex 16.5 -1.87 0.0
|
294
|
+
endloop
|
295
|
+
endfacet
|
296
|
+
facet normal -0.0 -1.0 -0.0
|
297
|
+
outer loop
|
298
|
+
vertex 16.5 -2.13 0.0
|
299
|
+
vertex 0.0 -2.13 -0.13
|
300
|
+
vertex 16.5 -2.13 -0.13
|
301
|
+
endloop
|
302
|
+
endfacet
|
303
|
+
facet normal -0.0 -1.0 -0.0
|
304
|
+
outer loop
|
305
|
+
vertex 0.0 -2.13 -0.13
|
306
|
+
vertex 16.5 -2.13 0.0
|
307
|
+
vertex 0.0 -2.13 0.0
|
308
|
+
endloop
|
309
|
+
endfacet
|
310
|
+
endsolid y-axis-spacer
|