mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Added convexity= to skin() and vnf_polyhedron()
This commit is contained in:
parent
3fdc58fded
commit
5ccf1e26bd
4 changed files with 67 additions and 56 deletions
111
joiners.scad
111
joiners.scad
|
@ -512,65 +512,74 @@ module joiner_quad(spacing1=undef, spacing2=undef, xspacing=undef, yspacing=unde
|
||||||
// diff("remove")
|
// diff("remove")
|
||||||
// cuboid([50,30,10])
|
// cuboid([50,30,10])
|
||||||
// position(TOP+BACK) xspread(10,5) dovetail("female", length=10, width=7, height=4, spin=90,$tags="remove",anchor=BOTTOM+RIGHT);
|
// position(TOP+BACK) xspread(10,5) dovetail("female", length=10, width=7, height=4, spin=90,$tags="remove",anchor=BOTTOM+RIGHT);
|
||||||
module dovetail(gender, length, l, width, w, height, h, angle, slope, taper, width2, chamfer, extra=0.01,orient,spin=0,r,radius,round=false,anchor=BOTTOM)
|
module dovetail(gender, length, l, width, w, height, h, angle, slope, taper, width2, chamfer, extra=0.01, r, radius, round=false, anchor=BOTTOM, spin=0, orient)
|
||||||
{
|
{
|
||||||
radius = get_radius(r1=radius,r2=r);
|
radius = get_radius(r1=radius,r2=r);
|
||||||
lcount = num_defined([l,length]);
|
lcount = num_defined([l,length]);
|
||||||
hcount = num_defined([h,height]);
|
hcount = num_defined([h,height]);
|
||||||
wcount = num_defined([w,width]);
|
wcount = num_defined([w,width]);
|
||||||
assert(lcount==1, "Must define exactly one of l and length");
|
assert(lcount==1, "Must define exactly one of l and length");
|
||||||
assert(wcount==1, "Must define exactly one of w and width");
|
assert(wcount==1, "Must define exactly one of w and width");
|
||||||
assert(lcount==1, "Must define exactly one of h and height");
|
assert(hcount==1, "Must define exactly one of h and height");
|
||||||
h = first_defined([h,height]);
|
h = first_defined([h,height]);
|
||||||
w = first_defined([w,width]);
|
w = first_defined([w,width]);
|
||||||
length = first_defined([l,length]);
|
length = first_defined([l,length]);
|
||||||
orient = is_def(orient) ? orient :
|
orient = is_def(orient) ? orient :
|
||||||
gender == "female" ? DOWN : UP;
|
gender == "female" ? DOWN : UP;
|
||||||
count = num_defined([angle,slope]);
|
count = num_defined([angle,slope]);
|
||||||
assert(count<=1, "Do not specify both angle and slope");
|
assert(count<=1, "Do not specify both angle and slope");
|
||||||
count2 = num_defined([taper,width2]);
|
count2 = num_defined([taper,width2]);
|
||||||
assert(count2<=1, "Do not specify both taper and width2");
|
assert(count2<=1, "Do not specify both taper and width2");
|
||||||
count3 = num_defined([chamfer, radius]);
|
count3 = num_defined([chamfer, radius]);
|
||||||
assert(count3<=1 || (radius==0 && chamfer==0), "Do not specify both chamfer and radius");
|
assert(count3<=1 || (radius==0 && chamfer==0), "Do not specify both chamfer and radius");
|
||||||
slope = is_def(slope) ? slope :
|
slope = is_def(slope) ? slope :
|
||||||
is_def(angle) ? 1/tan(angle) : 6;
|
is_def(angle) ? 1/tan(angle) : 6;
|
||||||
width = gender == "male" ? w : w + $slop;
|
width = gender == "male" ? w : w + $slop;
|
||||||
height = h + (gender == "female" ? $slop : 0);
|
height = h + (gender == "female" ? $slop : 0);
|
||||||
|
|
||||||
front_offset = is_def(taper) ? extra * tan(taper) :
|
front_offset = is_def(taper) ? extra * tan(taper) :
|
||||||
is_def(width2) ? extra * (width2-width)/length/2 : 0;
|
is_def(width2) ? extra * (width2-width)/length/2 : 0;
|
||||||
|
|
||||||
size = is_def(chamfer) && chamfer>0 ? chamfer :
|
size = is_def(chamfer) && chamfer>0 ? chamfer :
|
||||||
is_def(radius) && radius>0 ? radius : 0;
|
is_def(radius) && radius>0 ? radius : 0;
|
||||||
type = is_def(chamfer) && chamfer>0 ? "chamfer" : "circle";
|
type = is_def(chamfer) && chamfer>0 ? "chamfer" : "circle";
|
||||||
|
|
||||||
fullsize = round ? [0,size,size] :
|
fullsize = round ? [0,size,size] :
|
||||||
gender == "male" ? [0,size,0] : [0,0,size];
|
gender == "male" ? [0,size,0] : [0,0,size];
|
||||||
|
|
||||||
smallend_half = round_corners(
|
|
||||||
move([-length/2-extra,0,0],
|
|
||||||
p=[[0,0 , height],
|
|
||||||
[0,width/2-front_offset , height],
|
|
||||||
[0,width/2 - height/slope - front_offset, 0 ],
|
|
||||||
[0,width/2 - front_offset + height, 0]
|
|
||||||
]),
|
|
||||||
curve=type, size = fullsize,closed=false);
|
|
||||||
smallend_points = concat(select(smallend_half, 1, -2), [down(extra,p=select(smallend_half, -2))]);
|
|
||||||
offset = is_def(taper) ? (length+extra) * tan(taper) :
|
|
||||||
is_def(width2) ? (width2-width) / 2 : 0;
|
|
||||||
bigend_points = move([length+2*extra,offset,0], p=smallend_points);
|
|
||||||
|
|
||||||
adjustment = gender == "male" ? -0.01 : 0.01; // Adjustment for default overlap in attach()
|
smallend_half = round_corners(
|
||||||
|
move(
|
||||||
|
[-length/2-extra,0,0],
|
||||||
|
p=[
|
||||||
|
[0,0 , height],
|
||||||
|
[0,width/2-front_offset , height],
|
||||||
|
[0,width/2 - height/slope - front_offset, 0 ],
|
||||||
|
[0,width/2 - front_offset + height, 0]
|
||||||
|
]
|
||||||
|
),
|
||||||
|
curve=type, size=fullsize, closed=false
|
||||||
|
);
|
||||||
|
smallend_points = concat(select(smallend_half, 1, -2), [down(extra,p=select(smallend_half, -2))]);
|
||||||
|
offset = is_def(taper) ? (length+extra) * tan(taper) :
|
||||||
|
is_def(width2) ? (width2-width) / 2 : 0;
|
||||||
|
bigend_points = move([length+2*extra,offset,0], p=smallend_points);
|
||||||
|
|
||||||
orient_and_anchor([length, width+2*offset, height],anchor=anchor,orient=orient,spin=spin, chain=true)
|
adjustment = gender == "male" ? -0.01 : 0.01; // Adjustment for default overlap in attach()
|
||||||
down(height/2+adjustment)
|
|
||||||
skin([
|
orient_and_anchor([length, width+2*offset, height],anchor=anchor,orient=orient,spin=spin, chain=true) {
|
||||||
concat(smallend_points, yflip(p=reverse(smallend_points))),
|
down(height/2+adjustment) {
|
||||||
concat(bigend_points, yflip(p=reverse(bigend_points)))]
|
skin(
|
||||||
);
|
[
|
||||||
|
concat(smallend_points, yflip(p=reverse(smallend_points))),
|
||||||
|
concat(bigend_points, yflip(p=reverse(bigend_points)))
|
||||||
|
],
|
||||||
|
convexity=4
|
||||||
|
);
|
||||||
|
}
|
||||||
|
children();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||||
|
|
|
@ -39,6 +39,7 @@ include <vnf.scad>
|
||||||
// closed = If true, the last profile is skinned to the first profile, to allow for making a closed loop. Assumes `caps=false`. Default: false
|
// closed = If true, the last profile is skinned to the first profile, to allow for making a closed loop. Assumes `caps=false`. Default: false
|
||||||
// caps = If true, endcap faces are created. Assumes `closed=false`. Default: true
|
// caps = If true, endcap faces are created. Assumes `closed=false`. Default: true
|
||||||
// method = Specifies the method used to match up vertices between profiles, to create faces. Given as a string, one of `"distance"`, `"angle"`, or `"uniform"`. If given as a list of strings, equal in number to the number of profile transitions, lets you specify the method used for each transition. Default: "uniform"
|
// method = Specifies the method used to match up vertices between profiles, to create faces. Given as a string, one of `"distance"`, `"angle"`, or `"uniform"`. If given as a list of strings, equal in number to the number of profile transitions, lets you specify the method used for each transition. Default: "uniform"
|
||||||
|
// convexity = Max number of times a line could intersect a wall of the shape. (Module use only.) Default: 2.
|
||||||
// Example(FlatSpin):
|
// Example(FlatSpin):
|
||||||
// skin([
|
// skin([
|
||||||
// scale([2,1,1], p=path3d(circle(d=100,$fn=48))),
|
// scale([2,1,1], p=path3d(circle(d=100,$fn=48))),
|
||||||
|
@ -172,8 +173,8 @@ include <vnf.scad>
|
||||||
// move([0,0, 0], p=path3d(circle(d=100,$fn=36))),
|
// move([0,0, 0], p=path3d(circle(d=100,$fn=36))),
|
||||||
// move([0,0,50], p=path3d(circle(d=100,$fn=6)))
|
// move([0,0,50], p=path3d(circle(d=100,$fn=6)))
|
||||||
// ], caps=false);
|
// ], caps=false);
|
||||||
module skin(profiles, closed=false, caps=true, method="uniform") {
|
module skin(profiles, closed=false, caps=true, method="uniform", convexity=2) {
|
||||||
vnf_polyhedron(skin(profiles, caps=caps, closed=closed, method=method));
|
vnf_polyhedron(skin(profiles, caps=caps, closed=closed, method=method), convexity=convexity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,79];
|
BOSL_VERSION = [2,0,80];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
5
vnf.scad
5
vnf.scad
|
@ -301,9 +301,10 @@ function vnf_vertex_array(
|
||||||
// Given a VNF structure, or a list of VNF structures, creates a polyhedron from them.
|
// Given a VNF structure, or a list of VNF structures, creates a polyhedron from them.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// vnf = A VNF structure, or list of VNF structures.
|
// vnf = A VNF structure, or list of VNF structures.
|
||||||
module vnf_polyhedron(vnf) {
|
// convexity = Max number of times a line could intersect a wall of the shape.
|
||||||
|
module vnf_polyhedron(vnf, convexity=2) {
|
||||||
vnf = is_vnf_list(vnf)? vnf_merge(vnf) : vnf;
|
vnf = is_vnf_list(vnf)? vnf_merge(vnf) : vnf;
|
||||||
polyhedron(vnf[0], vnf[1]);
|
polyhedron(vnf[0], vnf[1], convexity=convexity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue