stlgen 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/Rakefile +6 -0
- data/examples/cube.rb +5 -0
- data/examples/cube.stl +86 -0
- data/lib/stlgen.rb +5 -0
- data/lib/stlgen/ascii_templates/cube.erb +86 -0
- data/lib/stlgen/stl/base.rb +9 -0
- data/lib/stlgen/stl/cube.rb +21 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/stlgen/stl/cube_spec.rb +12 -0
- data/spec/support/cube-ascii.stl +86 -0
- data/stlgen.gemspec +21 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 38bd513e13da77ebb03c82f015ff45fd3fa67345
|
4
|
+
data.tar.gz: a37cbb6d1b29a95694a4b2ad0a5265f8b50e3710
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0fe0bc6fbd85a5e1c1201819d386f2a8b7e8594179e728a4efbe8cd1e7d076dad89ab06e6b1f5221e26e48f96392977f8e883c4a01332e633bbb83b0e9027c3e
|
7
|
+
data.tar.gz: b2ff2ea84ba199f08dfbe95e331c632f127cd3ecc132960810fbc5ef1b13b7bb9b53aadafffc30a208e6bf5a8898561cbbc0ffb0f28d2ed5467c8cd44c0807dc
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Naoto Kaneko
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# STLgen
|
2
|
+
|
3
|
+
STL generator.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```sh
|
8
|
+
$ gem install stlgen
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```rb
|
14
|
+
require "stlgen"
|
15
|
+
|
16
|
+
stl = STLgen::STL::Cube.new(width: 1, length: 1, height: 1)
|
17
|
+
data = stl.generate
|
18
|
+
File.write("cube.stl", data)
|
19
|
+
```
|
20
|
+
|
21
|
+
This code generates [examples/cube.stl](https://github.com/naoty/stlgen/blob/master/examples/cube.stl).
|
data/Rakefile
ADDED
data/examples/cube.rb
ADDED
data/examples/cube.stl
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
solid Cube generated by STLgen
|
2
|
+
facet normal 0 0 1
|
3
|
+
outer loop
|
4
|
+
vertex 0 0 1
|
5
|
+
vertex 1 0 1
|
6
|
+
vertex 0 1 1
|
7
|
+
endloop
|
8
|
+
endfacet
|
9
|
+
facet normal 0 0 1
|
10
|
+
outer loop
|
11
|
+
vertex 1 1 1
|
12
|
+
vertex 0 1 1
|
13
|
+
vertex 1 0 1
|
14
|
+
endloop
|
15
|
+
endfacet
|
16
|
+
facet normal 1 0 0
|
17
|
+
outer loop
|
18
|
+
vertex 1 0 1
|
19
|
+
vertex 1 0 0
|
20
|
+
vertex 1 1 1
|
21
|
+
endloop
|
22
|
+
endfacet
|
23
|
+
facet normal 1 0 0
|
24
|
+
outer loop
|
25
|
+
vertex 1 1 0
|
26
|
+
vertex 1 1 1
|
27
|
+
vertex 1 0 0
|
28
|
+
endloop
|
29
|
+
endfacet
|
30
|
+
facet normal 0 0 -1
|
31
|
+
outer loop
|
32
|
+
vertex 1 0 0
|
33
|
+
vertex 0 0 0
|
34
|
+
vertex 1 1 0
|
35
|
+
endloop
|
36
|
+
endfacet
|
37
|
+
facet normal 0 0 -1
|
38
|
+
outer loop
|
39
|
+
vertex 0 1 0
|
40
|
+
vertex 1 1 0
|
41
|
+
vertex 0 0 0
|
42
|
+
endloop
|
43
|
+
endfacet
|
44
|
+
facet normal -1 0 0
|
45
|
+
outer loop
|
46
|
+
vertex 0 0 0
|
47
|
+
vertex 0 0 1
|
48
|
+
vertex 0 1 0
|
49
|
+
endloop
|
50
|
+
endfacet
|
51
|
+
facet normal -1 0 0
|
52
|
+
outer loop
|
53
|
+
vertex 0 1 1
|
54
|
+
vertex 0 1 0
|
55
|
+
vertex 0 0 1
|
56
|
+
endloop
|
57
|
+
endfacet
|
58
|
+
facet normal 0 1 0
|
59
|
+
outer loop
|
60
|
+
vertex 0 1 1
|
61
|
+
vertex 1 1 1
|
62
|
+
vertex 0 1 0
|
63
|
+
endloop
|
64
|
+
endfacet
|
65
|
+
facet normal 0 1 0
|
66
|
+
outer loop
|
67
|
+
vertex 1 1 0
|
68
|
+
vertex 0 1 0
|
69
|
+
vertex 1 1 1
|
70
|
+
endloop
|
71
|
+
endfacet
|
72
|
+
facet normal 0 -1 0
|
73
|
+
outer loop
|
74
|
+
vertex 1 0 1
|
75
|
+
vertex 0 0 1
|
76
|
+
vertex 1 0 0
|
77
|
+
endloop
|
78
|
+
endfacet
|
79
|
+
facet normal 0 -1 0
|
80
|
+
outer loop
|
81
|
+
vertex 0 0 0
|
82
|
+
vertex 1 0 0
|
83
|
+
vertex 0 0 1
|
84
|
+
endloop
|
85
|
+
endfacet
|
86
|
+
endsolid
|
data/lib/stlgen.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
solid <%= @text %>
|
2
|
+
facet normal 0 0 1
|
3
|
+
outer loop
|
4
|
+
vertex 0 0 <%= @length %>
|
5
|
+
vertex <%= @width %> 0 <%= @length %>
|
6
|
+
vertex 0 <%= @height %> <%= @length %>
|
7
|
+
endloop
|
8
|
+
endfacet
|
9
|
+
facet normal 0 0 1
|
10
|
+
outer loop
|
11
|
+
vertex <%= @width %> <%= @height %> <%= @length %>
|
12
|
+
vertex 0 <%= @height %> <%= @length %>
|
13
|
+
vertex <%= @width %> 0 <%= @length %>
|
14
|
+
endloop
|
15
|
+
endfacet
|
16
|
+
facet normal 1 0 0
|
17
|
+
outer loop
|
18
|
+
vertex <%= @width %> 0 <%= @length %>
|
19
|
+
vertex <%= @width %> 0 0
|
20
|
+
vertex <%= @width %> <%= @height %> <%= @length %>
|
21
|
+
endloop
|
22
|
+
endfacet
|
23
|
+
facet normal 1 0 0
|
24
|
+
outer loop
|
25
|
+
vertex <%= @width %> <%= @height %> 0
|
26
|
+
vertex <%= @width %> <%= @height %> <%= @length %>
|
27
|
+
vertex <%= @width %> 0 0
|
28
|
+
endloop
|
29
|
+
endfacet
|
30
|
+
facet normal 0 0 -1
|
31
|
+
outer loop
|
32
|
+
vertex <%= @width %> 0 0
|
33
|
+
vertex 0 0 0
|
34
|
+
vertex <%= @width %> <%= @height %> 0
|
35
|
+
endloop
|
36
|
+
endfacet
|
37
|
+
facet normal 0 0 -1
|
38
|
+
outer loop
|
39
|
+
vertex 0 <%= @height %> 0
|
40
|
+
vertex <%= @width %> <%= @height %> 0
|
41
|
+
vertex 0 0 0
|
42
|
+
endloop
|
43
|
+
endfacet
|
44
|
+
facet normal -1 0 0
|
45
|
+
outer loop
|
46
|
+
vertex 0 0 0
|
47
|
+
vertex 0 0 <%= @length %>
|
48
|
+
vertex 0 <%= @height %> 0
|
49
|
+
endloop
|
50
|
+
endfacet
|
51
|
+
facet normal -1 0 0
|
52
|
+
outer loop
|
53
|
+
vertex 0 <%= @height %> <%= @length %>
|
54
|
+
vertex 0 <%= @height %> 0
|
55
|
+
vertex 0 0 <%= @length %>
|
56
|
+
endloop
|
57
|
+
endfacet
|
58
|
+
facet normal 0 1 0
|
59
|
+
outer loop
|
60
|
+
vertex 0 <%= @height %> <%= @length %>
|
61
|
+
vertex <%= @width %> <%= @height %> <%= @length %>
|
62
|
+
vertex 0 <%= @height %> 0
|
63
|
+
endloop
|
64
|
+
endfacet
|
65
|
+
facet normal 0 1 0
|
66
|
+
outer loop
|
67
|
+
vertex <%= @width %> <%= @height %> 0
|
68
|
+
vertex 0 <%= @height %> 0
|
69
|
+
vertex <%= @width %> <%= @height %> <%= @length %>
|
70
|
+
endloop
|
71
|
+
endfacet
|
72
|
+
facet normal 0 -1 0
|
73
|
+
outer loop
|
74
|
+
vertex <%= @width %> 0 <%= @length %>
|
75
|
+
vertex 0 0 <%= @length %>
|
76
|
+
vertex <%= @width %> 0 0
|
77
|
+
endloop
|
78
|
+
endfacet
|
79
|
+
facet normal 0 -1 0
|
80
|
+
outer loop
|
81
|
+
vertex 0 0 0
|
82
|
+
vertex <%= @width %> 0 0
|
83
|
+
vertex 0 0 <%= @length %>
|
84
|
+
endloop
|
85
|
+
endfacet
|
86
|
+
endsolid
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "erb"
|
3
|
+
|
4
|
+
module STLgen
|
5
|
+
module STL
|
6
|
+
class Cube < Base
|
7
|
+
def initialize(attrs = {})
|
8
|
+
@width = attrs[:width] || 1
|
9
|
+
@length = attrs[:length] || 1
|
10
|
+
@height = attrs[:height] || 1
|
11
|
+
super(attrs)
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate
|
15
|
+
template_path = Pathname.new("lib/stlgen/ascii_templates/cube.erb")
|
16
|
+
template = ERB.new(template_path.read)
|
17
|
+
template.result(binding)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require File.expand_path("../lib/stlgen", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
5
|
+
config.run_all_when_everything_filtered = true
|
6
|
+
config.filter_run :focus
|
7
|
+
config.order = "random"
|
8
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe STLgen::STL::Cube do
|
4
|
+
describe "#generate" do
|
5
|
+
it "generates 10x10x10 cube with ASCII format" do
|
6
|
+
sample = Pathname.new("spec/support/cube-ascii.stl")
|
7
|
+
cube = STLgen::STL::Cube.new(width: 1, length: 1, height: 1)
|
8
|
+
data = cube.generate
|
9
|
+
expect(data).to eq sample.read
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
solid Cube generated by STLgen
|
2
|
+
facet normal 0 0 1
|
3
|
+
outer loop
|
4
|
+
vertex 0 0 1
|
5
|
+
vertex 1 0 1
|
6
|
+
vertex 0 1 1
|
7
|
+
endloop
|
8
|
+
endfacet
|
9
|
+
facet normal 0 0 1
|
10
|
+
outer loop
|
11
|
+
vertex 1 1 1
|
12
|
+
vertex 0 1 1
|
13
|
+
vertex 1 0 1
|
14
|
+
endloop
|
15
|
+
endfacet
|
16
|
+
facet normal 1 0 0
|
17
|
+
outer loop
|
18
|
+
vertex 1 0 1
|
19
|
+
vertex 1 0 0
|
20
|
+
vertex 1 1 1
|
21
|
+
endloop
|
22
|
+
endfacet
|
23
|
+
facet normal 1 0 0
|
24
|
+
outer loop
|
25
|
+
vertex 1 1 0
|
26
|
+
vertex 1 1 1
|
27
|
+
vertex 1 0 0
|
28
|
+
endloop
|
29
|
+
endfacet
|
30
|
+
facet normal 0 0 -1
|
31
|
+
outer loop
|
32
|
+
vertex 1 0 0
|
33
|
+
vertex 0 0 0
|
34
|
+
vertex 1 1 0
|
35
|
+
endloop
|
36
|
+
endfacet
|
37
|
+
facet normal 0 0 -1
|
38
|
+
outer loop
|
39
|
+
vertex 0 1 0
|
40
|
+
vertex 1 1 0
|
41
|
+
vertex 0 0 0
|
42
|
+
endloop
|
43
|
+
endfacet
|
44
|
+
facet normal -1 0 0
|
45
|
+
outer loop
|
46
|
+
vertex 0 0 0
|
47
|
+
vertex 0 0 1
|
48
|
+
vertex 0 1 0
|
49
|
+
endloop
|
50
|
+
endfacet
|
51
|
+
facet normal -1 0 0
|
52
|
+
outer loop
|
53
|
+
vertex 0 1 1
|
54
|
+
vertex 0 1 0
|
55
|
+
vertex 0 0 1
|
56
|
+
endloop
|
57
|
+
endfacet
|
58
|
+
facet normal 0 1 0
|
59
|
+
outer loop
|
60
|
+
vertex 0 1 1
|
61
|
+
vertex 1 1 1
|
62
|
+
vertex 0 1 0
|
63
|
+
endloop
|
64
|
+
endfacet
|
65
|
+
facet normal 0 1 0
|
66
|
+
outer loop
|
67
|
+
vertex 1 1 0
|
68
|
+
vertex 0 1 0
|
69
|
+
vertex 1 1 1
|
70
|
+
endloop
|
71
|
+
endfacet
|
72
|
+
facet normal 0 -1 0
|
73
|
+
outer loop
|
74
|
+
vertex 1 0 1
|
75
|
+
vertex 0 0 1
|
76
|
+
vertex 1 0 0
|
77
|
+
endloop
|
78
|
+
endfacet
|
79
|
+
facet normal 0 -1 0
|
80
|
+
outer loop
|
81
|
+
vertex 0 0 0
|
82
|
+
vertex 1 0 0
|
83
|
+
vertex 0 0 1
|
84
|
+
endloop
|
85
|
+
endfacet
|
86
|
+
endsolid
|
data/stlgen.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "stlgen"
|
6
|
+
spec.version = "0.0.1"
|
7
|
+
spec.authors = ["Naoto Kaneko"]
|
8
|
+
spec.email = ["naoty.k@gmail.com"]
|
9
|
+
spec.summary = %q{STL generator.}
|
10
|
+
spec.homepage = "https://github.com/naoty/stlgen"
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split($/)
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
19
|
+
spec.add_development_dependency "rake"
|
20
|
+
spec.add_development_dependency "rspec"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stlgen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Naoto Kaneko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- naoty.k@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- examples/cube.rb
|
69
|
+
- examples/cube.stl
|
70
|
+
- lib/stlgen.rb
|
71
|
+
- lib/stlgen/ascii_templates/cube.erb
|
72
|
+
- lib/stlgen/stl/base.rb
|
73
|
+
- lib/stlgen/stl/cube.rb
|
74
|
+
- spec/spec_helper.rb
|
75
|
+
- spec/stlgen/stl/cube_spec.rb
|
76
|
+
- spec/support/cube-ascii.stl
|
77
|
+
- stlgen.gemspec
|
78
|
+
homepage: https://github.com/naoty/stlgen
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.2.0
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: STL generator.
|
102
|
+
test_files:
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
- spec/stlgen/stl/cube_spec.rb
|
105
|
+
- spec/support/cube-ascii.stl
|