openscad_soften 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/openscad_soften.gemspec +20 -0
- data/soften/chamfer.scad +15 -0
- data/soften/cube.scad +34 -0
- data/soften/cylinder.scad +37 -0
- data/soften/demo/chamfer-demo.scad +5 -0
- data/soften/demo/cube-demo.scad +5 -0
- data/soften/demo/cylinder-demo.scad +4 -0
- data/soften/demo/fillet-demo.scad +10 -0
- data/soften/demo/hole-demo.scad +4 -0
- data/soften/demo/square-demo.scad +7 -0
- data/soften/fillet.scad +86 -0
- data/soften/hole.scad +53 -0
- data/soften/square.scad +23 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cc236e80666fea49bde70b97225afe914f6a4d1a0c6071ad82366c5961af2732
|
4
|
+
data.tar.gz: 87e3b8303b177cd8cb32679dd7ee554c125ec7311cfc4afca4852d8763cb0361
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d327581765071212010717acf0fa37a18d5c9fb5d9a0a0a4de4fd29488daf0b80063c3899c8454057741c8402f1b187f1f0f0034dfa45cb225e8fcd9632845d5
|
7
|
+
data.tar.gz: 8648c8d01e06e79d5108f5c8ca127288919f4a2bb57c0b0fe25af8cfd988eb3a4592ba9511547cf26c14425dc1c8ad3ed0615858fd54bddda6692e9853598691
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Joe Francis
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "openscad_soften"
|
7
|
+
spec.version = '0.1.0'
|
8
|
+
spec.authors = ["Joe Francis"]
|
9
|
+
spec.email = ["joe@lostapathy.com"]
|
10
|
+
spec.homepage = 'https://github.com/lostapathy/openscad-libs/'
|
11
|
+
|
12
|
+
spec.summary = %q{OpenSCAD modules for generating a collection of shapes and solids that have been softened with rounded edges, chamfers, round overs, or fillets.}
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
|
19
|
+
spec.add_dependency "openscad_util", '~> 0'
|
20
|
+
end
|
data/soften/chamfer.scad
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
include <constants/all.scad>
|
2
|
+
|
3
|
+
module chamfer(length, r, axis=x_axis) {
|
4
|
+
rotates = [[0,90,0],[90,0,0],[0,0,0]];
|
5
|
+
mirrors = [[0,0,1],[0,1,0],[0,0,0]];
|
6
|
+
mirror(mirrors[axis])
|
7
|
+
rotate(rotates[axis]) linear_extrude(length) {
|
8
|
+
chamfer_profile(r);
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
module chamfer_profile(r) {
|
13
|
+
polygon([[-r,0], [-r,epsilon], [epsilon, epsilon], [epsilon, -r],[0,-r]]);
|
14
|
+
}
|
15
|
+
|
data/soften/cube.scad
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
use <layout/layout.scad>
|
2
|
+
use <validation/validate.scad>
|
3
|
+
use <soften/fillet.scad>
|
4
|
+
use <soften/square.scad>
|
5
|
+
include <constants/all.scad>
|
6
|
+
|
7
|
+
module soft_cube(size, r=0, center=false, sidesonly=true) {
|
8
|
+
x_dim = len(size) ? size.x : size;
|
9
|
+
y_dim = len(size) ? size.y : size;
|
10
|
+
z_dim = len(size) ? size.z : size;
|
11
|
+
if(r == 0) {
|
12
|
+
cube(size, center);
|
13
|
+
} else if(sidesonly) {
|
14
|
+
render()
|
15
|
+
translate(center ? [0,0,-z_dim/2] : [x_dim/2, y_dim/2,0])
|
16
|
+
linear_extrude(z_dim)
|
17
|
+
soft_square([x_dim, y_dim], r, center=true);
|
18
|
+
} else {
|
19
|
+
// FIXME: this has different $fn for different corners
|
20
|
+
hull()
|
21
|
+
difference() {
|
22
|
+
soft_cube(size,r=r,center=true);
|
23
|
+
mirror_xyz()
|
24
|
+
translate([-x_dim/2, -y_dim/2, -z_dim/2]) fillet(x_dim, r, x_axis);
|
25
|
+
mirror_xyz()
|
26
|
+
translate([-x_dim/2, -y_dim/2, -z_dim/2]) fillet(y_dim, r, y_axis);
|
27
|
+
|
28
|
+
mirror_xyz() difference() {
|
29
|
+
translate([-x_dim/2, -y_dim/2, -z_dim/2]) cube(r);
|
30
|
+
translate([-x_dim/2+r, -y_dim/2+r, -z_dim/2+r]) sphere(r=r);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
include <constants/all.scad>
|
2
|
+
include <soften/fillet.scad>
|
3
|
+
|
4
|
+
module soft_cylinder(d, r, h,
|
5
|
+
d1, d2, chamfer=0,
|
6
|
+
roundover_r=0, fillet_r=0,
|
7
|
+
fillet_angle=360) {
|
8
|
+
my_d = d ? d : d1;
|
9
|
+
d1 = d1 ? d1 : my_d;
|
10
|
+
d2 = d2 ? d2 : my_d;
|
11
|
+
$fn = fn(my_d/2+fillet_r);
|
12
|
+
hull() difference() {
|
13
|
+
union() {
|
14
|
+
height = fillet_r ? h + epsilon : h;
|
15
|
+
translate([0,0,fillet_r? -epsilon : 0]) cylinder(d1=d1,d2=d2,h=height);
|
16
|
+
}
|
17
|
+
if(chamfer > 0) {
|
18
|
+
rotate_extrude()
|
19
|
+
translate([d/2,h-chamfer])
|
20
|
+
polygon([ [epsilon,epsilon],
|
21
|
+
[-chamfer-epsilon, chamfer+epsilon],
|
22
|
+
[epsilon, chamfer]]);
|
23
|
+
}
|
24
|
+
else if(roundover_r > 0) {
|
25
|
+
rotate_extrude()
|
26
|
+
translate([d/2-roundover_r,h-roundover_r])
|
27
|
+
difference() {
|
28
|
+
square(roundover_r+2*epsilon);
|
29
|
+
circle(r=roundover_r);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
if(fillet_r > 0) {
|
34
|
+
circular_fillet(d=d, r=fillet_r, angle=fillet_angle);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
data/soften/fillet.scad
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
include <constants/all.scad>
|
2
|
+
use <layout/layout.scad>
|
3
|
+
use <soften/hole.scad>
|
4
|
+
use <soften/cylinder.scad>
|
5
|
+
|
6
|
+
function fillet_fn(fn, r) = ceil(min(max(fn, 12), r*6) / 4) * 8;
|
7
|
+
|
8
|
+
module fillet(length, r, axis=x_axis) {
|
9
|
+
$fn = fillet_fn($fn, r);
|
10
|
+
rotates = [[0,90,0],[90,0,0],[0,0,0]];
|
11
|
+
mirrors = [[0,0,1],[0,1,0],[0,0,0]];
|
12
|
+
mirror(mirrors[axis])
|
13
|
+
rotate(rotates[axis])
|
14
|
+
linear_extrude(length)
|
15
|
+
fillet_profile(r, 90);
|
16
|
+
}
|
17
|
+
|
18
|
+
|
19
|
+
module circular_fillet(d,r=5, angle=360,fillet_angle=90) {
|
20
|
+
rotate_extrude(angle=angle)
|
21
|
+
translate([d/2,0])
|
22
|
+
fillet_profile(r,fillet_angle, $fn = fillet_fn($fn, r));
|
23
|
+
}
|
24
|
+
|
25
|
+
module fillet_corner(r=0) {
|
26
|
+
render() intersection() {
|
27
|
+
fillet(r+epsilon, r, x_axis);
|
28
|
+
fillet(r+epsilon,r,y_axis);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
module fillet_profile(r, angle) {
|
33
|
+
$fn = fillet_fn($fn, r);
|
34
|
+
chord = r * sin(angle/2);
|
35
|
+
leg = tan(90-angle/2)*r;
|
36
|
+
rotate(-angle/2)
|
37
|
+
difference() {
|
38
|
+
rotate(angle/2)
|
39
|
+
polygon([
|
40
|
+
[-epsilon, -epsilon],
|
41
|
+
[-epsilon, leg], [0,leg],
|
42
|
+
[sin(angle)*leg, cos(angle)*leg],
|
43
|
+
[sin(angle)*leg, cos(angle)*leg-epsilon]
|
44
|
+
]);
|
45
|
+
translate([0,r/cos(90-angle/2)])
|
46
|
+
circle(r=r);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
module filleted_cube(size, fillet_r=0) {
|
51
|
+
translate([0,0,-epsilon/2])
|
52
|
+
cube(size+[0,0,epsilon], center=true);
|
53
|
+
mirror_y() {
|
54
|
+
translate([-size[0]/2,size[1]/2,-size[2]/2]) fillet(size[0],fillet_r,x_axis);
|
55
|
+
}
|
56
|
+
mirror_x() {
|
57
|
+
translate([size[0]/2,-size[1]/2,-size[2]/2]) fillet(size[1],fillet_r,y_axis);
|
58
|
+
}
|
59
|
+
|
60
|
+
mirror_xy() {
|
61
|
+
translate([size[0]/2, size[1]/2, -size[2]/2]) fillet_corner(fillet_r);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
module inside_fillets(size, fillet_r=0) {
|
66
|
+
$fn = fillet_fn($fn, fillet_r);
|
67
|
+
mirror_y() {
|
68
|
+
translate([-size[0]/2,-size[1]/2,0]) fillet(size[0],fillet_r,x_axis);
|
69
|
+
}
|
70
|
+
mirror_x() {
|
71
|
+
translate([-size[0]/2,-size[1]/2,0]) fillet(size[1],fillet_r,y_axis);
|
72
|
+
}
|
73
|
+
|
74
|
+
// vericals only if h>0?
|
75
|
+
mirror_xy() {
|
76
|
+
translate([-size[0]/2,-size[1]/2,0]) fillet(size[2],fillet_r,z_axis);
|
77
|
+
}
|
78
|
+
|
79
|
+
// FIXME: extract this into some sort of inside_fillet()-type module
|
80
|
+
mirror_xy() {
|
81
|
+
difference() {
|
82
|
+
translate([-size[0]/2,-size[1]/2,0]) cube([fillet_r,fillet_r,fillet_r]);
|
83
|
+
translate([-size[0]/2+fillet_r,-size[1]/2+fillet_r,fillet_r]) sphere(r=fillet_r);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
data/soften/hole.scad
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
use <validation/validate.scad>
|
2
|
+
include <constants/all.scad>
|
3
|
+
|
4
|
+
module hole(h, d, d1, d2, bottom_r=0, top_chamfer=0, top_r=0) {
|
5
|
+
|
6
|
+
function apothem(d, n) = d / 2 / cos (180 / n);
|
7
|
+
|
8
|
+
input_top_d = d1 ? d1 : d;
|
9
|
+
input_bot_d = d2 ? d2 : d;
|
10
|
+
|
11
|
+
n = max(round(input_top_d * 2), 12, $fn);
|
12
|
+
|
13
|
+
bot_d = apothem(input_bot_d, n)*2;
|
14
|
+
top_d = apothem(input_top_d, n)*2;
|
15
|
+
|
16
|
+
$fn = n;
|
17
|
+
height = h + epsilon;
|
18
|
+
d = d ? d : d1;
|
19
|
+
translate([0,0,-h]) hull() difference() {
|
20
|
+
|
21
|
+
cylinder(h = height, d1=bot_d, d2=top_d, $fn = n);
|
22
|
+
if(bottom_r > 0) {
|
23
|
+
validate(bot_d >= 2*bottom_r, "bottom_r must be less than half x-dimension");
|
24
|
+
rotate_extrude($fn=n) translate([d/2-bottom_r, 0]) {
|
25
|
+
difference() {
|
26
|
+
translate([0, -2*epsilon]) square(bottom_r+2*epsilon);
|
27
|
+
translate([0, bottom_r]) circle(r=bottom_r);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
validate(top_chamfer == 0 || top_r == 0, "cannot both chamfer and round top of a hole");
|
34
|
+
if(top_chamfer > 0){
|
35
|
+
translate([0,0,-top_chamfer]) {
|
36
|
+
// FIXME: this hull() is a hack to get around $fn mismatch
|
37
|
+
hull()
|
38
|
+
rotate_extrude()
|
39
|
+
translate([d/2-epsilon,0])
|
40
|
+
polygon([[0,0], [0,top_chamfer+epsilon], [top_chamfer+epsilon, top_chamfer+epsilon]]);
|
41
|
+
}
|
42
|
+
} else if(top_r > 0) {
|
43
|
+
// FIXME: extract profile like we did on circular_fillet
|
44
|
+
translate([0,0,-top_r])
|
45
|
+
rotate_extrude()
|
46
|
+
translate([d/2-epsilon,0])
|
47
|
+
difference() {
|
48
|
+
square(top_r+epsilon);
|
49
|
+
translate([top_r+epsilon,0]) circle(r=top_r);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
data/soften/square.scad
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
use <validation/validate.scad>
|
2
|
+
use <layout/layout.scad>
|
3
|
+
|
4
|
+
module soft_square(size, r=0, center=false) {
|
5
|
+
x_dim = len(size) ? size.x : size;
|
6
|
+
y_dim = len(size) ? size.y : size;
|
7
|
+
|
8
|
+
validate(x_dim >= 2*r, "radius must be less than half x-dimension");
|
9
|
+
|
10
|
+
translate(center ? [0,0] : [x_dim/2, y_dim/2]) {
|
11
|
+
if(r > 0) {
|
12
|
+
hull() {
|
13
|
+
square([x_dim, y_dim-2*r], center=true);
|
14
|
+
square([x_dim-2*r, y_dim], center=true);
|
15
|
+
mirror_xy() {
|
16
|
+
translate([x_dim/2-r, y_dim/2-r]) circle(r=r);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
} else {
|
20
|
+
square([x_dim, y_dim], center=true);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openscad_soften
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joe Francis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: openscad_util
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- joe@lostapathy.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- LICENSE.txt
|
35
|
+
- openscad_soften.gemspec
|
36
|
+
- soften/chamfer.scad
|
37
|
+
- soften/cube.scad
|
38
|
+
- soften/cylinder.scad
|
39
|
+
- soften/demo/chamfer-demo.scad
|
40
|
+
- soften/demo/cube-demo.scad
|
41
|
+
- soften/demo/cylinder-demo.scad
|
42
|
+
- soften/demo/fillet-demo.scad
|
43
|
+
- soften/demo/hole-demo.scad
|
44
|
+
- soften/demo/square-demo.scad
|
45
|
+
- soften/fillet.scad
|
46
|
+
- soften/hole.scad
|
47
|
+
- soften/square.scad
|
48
|
+
homepage: https://github.com/lostapathy/openscad-libs/
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata: {}
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 2.7.3
|
69
|
+
signing_key:
|
70
|
+
specification_version: 4
|
71
|
+
summary: OpenSCAD modules for generating a collection of shapes and solids that have
|
72
|
+
been softened with rounded edges, chamfers, round overs, or fillets.
|
73
|
+
test_files: []
|