mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-06 12:19:47 +00:00
Merge pull request #169 from adrianVmariano/master
Updates to rounded_prism and new round_corners interface.
This commit is contained in:
commit
b5b8cb0313
6 changed files with 829 additions and 770 deletions
76
beziers.scad
76
beziers.scad
|
@ -1255,49 +1255,41 @@ module bezier_polyhedron(patches=[], splinesteps=16, vnf=EMPTY_VNF, style="defau
|
||||||
// trace_bezier_patches(patches=[patch1, patch2], splinesteps=8, showcps=true);
|
// trace_bezier_patches(patches=[patch1, patch2], splinesteps=8, showcps=true);
|
||||||
module trace_bezier_patches(patches=[], size, splinesteps=16, showcps=true, showdots=false, showpatch=true, convexity=10, style="default")
|
module trace_bezier_patches(patches=[], size, splinesteps=16, showcps=true, showdots=false, showpatch=true, convexity=10, style="default")
|
||||||
{
|
{
|
||||||
assert(is_undef(size)||is_num(size));
|
assert(is_undef(size)||is_num(size));
|
||||||
assert(is_int(splinesteps) && splinesteps>0);
|
assert(is_int(splinesteps) && splinesteps>0);
|
||||||
assert(is_list(patches) && all([for (patch=patches) is_patch(patch)]));
|
assert(is_list(patches) && all([for (patch=patches) is_patch(patch)]));
|
||||||
assert(is_bool(showcps));
|
assert(is_bool(showcps));
|
||||||
assert(is_bool(showdots));
|
assert(is_bool(showdots));
|
||||||
assert(is_bool(showpatch));
|
assert(is_bool(showpatch));
|
||||||
assert(is_int(convexity) && convexity>0);
|
assert(is_int(convexity) && convexity>0);
|
||||||
vnfs = [
|
for (patch = patches) {
|
||||||
for (patch = patches)
|
size = is_num(size)? size :
|
||||||
bezier_patch(patch, splinesteps=splinesteps, style=style)
|
let( bounds = pointlist_bounds(flatten(patch)) )
|
||||||
];
|
max(bounds[1]-bounds[0])*0.01;
|
||||||
if (showcps || showdots) {
|
if (showcps) {
|
||||||
for (patch = patches) {
|
move_copies(flatten(patch)) color("red") sphere(d=size*2);
|
||||||
size = is_num(size)? size :
|
color("cyan") {
|
||||||
let( bounds = pointlist_bounds(flatten(patch)) )
|
if (is_tripatch(patch)) {
|
||||||
max(bounds[1]-bounds[0])*0.01;
|
for (i=[0:1:len(patch)-2], j=[0:1:len(patch[i])-2]) {
|
||||||
if (showcps) {
|
extrude_from_to(patch[i][j], patch[i+1][j]) circle(d=size);
|
||||||
move_copies(flatten(patch)) color("red") sphere(d=size*2);
|
extrude_from_to(patch[i][j], patch[i][j+1]) circle(d=size);
|
||||||
color("cyan") {
|
extrude_from_to(patch[i+1][j], patch[i][j+1]) circle(d=size);
|
||||||
if (is_tripatch(patch)) {
|
}
|
||||||
for (i=[0:1:len(patch)-2], j=[0:1:len(patch[i])-2]) {
|
} else {
|
||||||
extrude_from_to(patch[i][j], patch[i+1][j]) circle(d=size);
|
for (i=[0:1:len(patch)-1], j=[0:1:len(patch[i])-1]) {
|
||||||
extrude_from_to(patch[i][j], patch[i][j+1]) circle(d=size);
|
if (i<len(patch)-1) extrude_from_to(patch[i][j], patch[i+1][j]) circle(d=size);
|
||||||
extrude_from_to(patch[i+1][j], patch[i][j+1]) circle(d=size);
|
if (j<len(patch[i])-1) extrude_from_to(patch[i][j], patch[i][j+1]) circle(d=size);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
for (i=[0:1:len(patch)-1], j=[0:1:len(patch[i])-1]) {
|
}
|
||||||
if (i<len(patch)-1) extrude_from_to(patch[i][j], patch[i+1][j]) circle(d=size);
|
}
|
||||||
if (j<len(patch[i])-1) extrude_from_to(patch[i][j], patch[i][j+1]) circle(d=size);
|
if (showpatch || showdots){
|
||||||
}
|
vnf = bezier_patch(patch, splinesteps=splinesteps, style=style);
|
||||||
}
|
if (showpatch) vnf_polyhedron(vnf, convexity=convexity);
|
||||||
}
|
if (showdots) color("blue") move_copies(vnf[0]) sphere(d=size);
|
||||||
}
|
}
|
||||||
if (showdots){
|
}
|
||||||
color("blue") move_copies(vnfs[i][0]) sphere(d=size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (showpatch) {
|
|
||||||
vnf_polyhedron(vnfs, convexity=convexity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||||
|
|
|
@ -177,7 +177,7 @@ function one_defined(vars, names, required=true) =
|
||||||
let (
|
let (
|
||||||
ok = num_defined(vars)==1 || (!required && num_defined(vars)==0)
|
ok = num_defined(vars)==1 || (!required && num_defined(vars)==0)
|
||||||
)
|
)
|
||||||
assert(ok,str("Must define ",required?"exactly":"at most"," one of ",[for(i=[0:len(vars)]) if (is_def(vars[i])) names[i]]))
|
assert(ok,str("Must define ",required?"exactly":"at most"," one of ",num_defined(vars)==0?names:[for(i=[0:len(vars)]) if (is_def(vars[i])) names[i]]))
|
||||||
first_defined(vars);
|
first_defined(vars);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -527,8 +527,8 @@ module dovetail(gender, length, l, width, w, height, h, angle, slope, taper, bac
|
||||||
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 ? [size,size] :
|
||||||
gender == "male" ? [0,size,0] : [0,0,size];
|
gender == "male" ? [size,0] : [0,size];
|
||||||
|
|
||||||
smallend_half = round_corners(
|
smallend_half = round_corners(
|
||||||
move(
|
move(
|
||||||
|
@ -540,7 +540,7 @@ module dovetail(gender, length, l, width, w, height, h, angle, slope, taper, bac
|
||||||
[width/2 - front_offset + height, 0, 0]
|
[width/2 - front_offset + height, 0, 0]
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
curve=type, size=fullsize, closed=false
|
method=type, cut = fullsize, closed=false
|
||||||
);
|
);
|
||||||
smallend_points = concat(select(smallend_half, 1, -2), [down(extra,p=select(smallend_half, -2))]);
|
smallend_points = concat(select(smallend_half, 1, -2), [down(extra,p=select(smallend_half, -2))]);
|
||||||
offset = is_def(taper) ? -(length+extra) * tan(taper) :
|
offset = is_def(taper) ? -(length+extra) * tan(taper) :
|
||||||
|
|
1503
rounding.scad
1503
rounding.scad
File diff suppressed because it is too large
Load diff
|
@ -151,7 +151,7 @@ include <vnf.scad>
|
||||||
// Example: Vaccum connector example from list-comprehension-demos
|
// Example: Vaccum connector example from list-comprehension-demos
|
||||||
// include <BOSL2/rounding.scad>
|
// include <BOSL2/rounding.scad>
|
||||||
// $fn=32;
|
// $fn=32;
|
||||||
// base = round_corners(square([2,4],center=true), measure="radius", size=0.5);
|
// base = round_corners(square([2,4],center=true), radius=0.5);
|
||||||
// skin([
|
// skin([
|
||||||
// path3d(base,0),
|
// path3d(base,0),
|
||||||
// path3d(base,2),
|
// path3d(base,2),
|
||||||
|
@ -351,7 +351,7 @@ function skin(profiles, slices, refine=1, method="direct", sampling, caps, close
|
||||||
in_list(DUPLICATOR,method_type) ? "segment" : "length"
|
in_list(DUPLICATOR,method_type) ? "segment" : "length"
|
||||||
)
|
)
|
||||||
assert(len(refine)==len(profiles), "refine list is the wrong length")
|
assert(len(refine)==len(profiles), "refine list is the wrong length")
|
||||||
assert(len(slices)==profcount, "slices list is the wrong length")
|
assert(len(slices)==profcount, str("slices list must have length ",profcount))
|
||||||
assert(slicesOK==[],str("slices must be nonnegative integers"))
|
assert(slicesOK==[],str("slices must be nonnegative integers"))
|
||||||
assert(refineOK==[],str("refine must be postive integer"))
|
assert(refineOK==[],str("refine must be postive integer"))
|
||||||
assert(methodok,str("method must be one of ",legal_methods,". Got ",method))
|
assert(methodok,str("method must be one of ",legal_methods,". Got ",method))
|
||||||
|
@ -394,7 +394,7 @@ function skin(profiles, slices, refine=1, method="direct", sampling, caps, close
|
||||||
resampled = [for(i=idx(profiles)) subdivide_path(profiles[i], max_list[i], method=sampling)],
|
resampled = [for(i=idx(profiles)) subdivide_path(profiles[i], max_list[i], method=sampling)],
|
||||||
fixedprof = [for(i=idx(profiles))
|
fixedprof = [for(i=idx(profiles))
|
||||||
i==0 || method[i-1]=="direct" ? resampled[i]
|
i==0 || method[i-1]=="direct" ? resampled[i]
|
||||||
:echo("reindexing") reindex_polygon(resampled[i-1],resampled[i])],
|
: reindex_polygon(resampled[i-1],resampled[i])],
|
||||||
sliced = slice_profiles(fixedprof, slices, closed)
|
sliced = slice_profiles(fixedprof, slices, closed)
|
||||||
)
|
)
|
||||||
!closed ? sliced : concat(sliced,[sliced[0]])
|
!closed ? sliced : concat(sliced,[sliced[0]])
|
||||||
|
@ -415,7 +415,8 @@ function skin(profiles, slices, refine=1, method="direct", sampling, caps, close
|
||||||
)
|
)
|
||||||
each subdivide_and_slice(pair,slices[i], nsamples, method=sampling)]
|
each subdivide_and_slice(pair,slices[i], nsamples, method=sampling)]
|
||||||
)
|
)
|
||||||
_skin_core(full_list,caps=fullcaps);
|
vnf_vertex_array(full_list,cap1=fullcaps[0], col_wrap=true, cap2=fullcaps[1],style="alt");
|
||||||
|
// _skin_core(full_list, caps=fullcaps);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
3
vnf.scad
3
vnf.scad
|
@ -267,17 +267,18 @@ function vnf_vertex_array(
|
||||||
) =
|
) =
|
||||||
assert((!caps)||(caps&&col_wrap))
|
assert((!caps)||(caps&&col_wrap))
|
||||||
assert(in_list(style,["default","alt","quincunx"]))
|
assert(in_list(style,["default","alt","quincunx"]))
|
||||||
|
assert(is_consistent(points), "Non-rectangular or invalid point array")
|
||||||
let(
|
let(
|
||||||
pts = flatten(points),
|
pts = flatten(points),
|
||||||
pcnt = len(pts),
|
pcnt = len(pts),
|
||||||
rows = len(points),
|
rows = len(points),
|
||||||
cols = len(points[0]),
|
cols = len(points[0]),
|
||||||
errchk = [for (row=points) assert(len(row)==cols, "All rows much have the same number of columns.") 0],
|
|
||||||
cap1 = first_defined([cap1,caps,false]),
|
cap1 = first_defined([cap1,caps,false]),
|
||||||
cap2 = first_defined([cap2,caps,false]),
|
cap2 = first_defined([cap2,caps,false]),
|
||||||
colcnt = cols - (col_wrap?0:1),
|
colcnt = cols - (col_wrap?0:1),
|
||||||
rowcnt = rows - (row_wrap?0:1)
|
rowcnt = rows - (row_wrap?0:1)
|
||||||
)
|
)
|
||||||
|
rows<=1 || cols<=1 ? vnf :
|
||||||
vnf_merge([
|
vnf_merge([
|
||||||
vnf, [
|
vnf, [
|
||||||
concat(
|
concat(
|
||||||
|
|
Loading…
Reference in a new issue