Merge pull request #169 from adrianVmariano/master

Updates to rounded_prism and new round_corners interface.
This commit is contained in:
Revar Desmera 2020-05-21 16:54:51 -07:00 committed by GitHub
commit b5b8cb0313
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 829 additions and 770 deletions

View file

@ -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);
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_int(splinesteps) && splinesteps>0);
assert(is_list(patches) && all([for (patch=patches) is_patch(patch)]));
assert(is_bool(showcps));
assert(is_bool(showdots));
assert(is_bool(showpatch));
assert(is_int(convexity) && convexity>0);
vnfs = [
for (patch = patches)
bezier_patch(patch, splinesteps=splinesteps, style=style)
];
if (showcps || showdots) {
for (patch = patches) {
size = is_num(size)? size :
let( bounds = pointlist_bounds(flatten(patch)) )
max(bounds[1]-bounds[0])*0.01;
if (showcps) {
move_copies(flatten(patch)) color("red") sphere(d=size*2);
color("cyan") {
if (is_tripatch(patch)) {
for (i=[0:1:len(patch)-2], j=[0:1:len(patch[i])-2]) {
extrude_from_to(patch[i][j], patch[i+1][j]) circle(d=size);
extrude_from_to(patch[i][j], patch[i][j+1]) circle(d=size);
extrude_from_to(patch[i+1][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 (showdots){
color("blue") move_copies(vnfs[i][0]) sphere(d=size);
}
}
}
if (showpatch) {
vnf_polyhedron(vnfs, convexity=convexity);
}
assert(is_undef(size)||is_num(size));
assert(is_int(splinesteps) && splinesteps>0);
assert(is_list(patches) && all([for (patch=patches) is_patch(patch)]));
assert(is_bool(showcps));
assert(is_bool(showdots));
assert(is_bool(showpatch));
assert(is_int(convexity) && convexity>0);
for (patch = patches) {
size = is_num(size)? size :
let( bounds = pointlist_bounds(flatten(patch)) )
max(bounds[1]-bounds[0])*0.01;
if (showcps) {
move_copies(flatten(patch)) color("red") sphere(d=size*2);
color("cyan") {
if (is_tripatch(patch)) {
for (i=[0:1:len(patch)-2], j=[0:1:len(patch[i])-2]) {
extrude_from_to(patch[i][j], patch[i+1][j]) circle(d=size);
extrude_from_to(patch[i][j], patch[i][j+1]) circle(d=size);
extrude_from_to(patch[i+1][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);
}
}
}
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View file

@ -177,7 +177,7 @@ function one_defined(vars, names, required=true) =
let (
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);

View file

@ -527,8 +527,8 @@ module dovetail(gender, length, l, width, w, height, h, angle, slope, taper, bac
is_def(radius) && radius>0 ? radius : 0;
type = is_def(chamfer) && chamfer>0 ? "chamfer" : "circle";
fullsize = round ? [0,size,size] :
gender == "male" ? [0,size,0] : [0,0,size];
fullsize = round ? [size,size] :
gender == "male" ? [size,0] : [0,size];
smallend_half = round_corners(
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]
]
),
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))]);
offset = is_def(taper) ? -(length+extra) * tan(taper) :

File diff suppressed because it is too large Load diff

View file

@ -151,7 +151,7 @@ include <vnf.scad>
// Example: Vaccum connector example from list-comprehension-demos
// include <BOSL2/rounding.scad>
// $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([
// path3d(base,0),
// 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"
)
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(refineOK==[],str("refine must be postive integer"))
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)],
fixedprof = [for(i=idx(profiles))
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)
)
!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)]
)
_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);

View file

@ -267,17 +267,18 @@ function vnf_vertex_array(
) =
assert((!caps)||(caps&&col_wrap))
assert(in_list(style,["default","alt","quincunx"]))
assert(is_consistent(points), "Non-rectangular or invalid point array")
let(
pts = flatten(points),
pcnt = len(pts),
rows = len(points),
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]),
cap2 = first_defined([cap2,caps,false]),
colcnt = cols - (col_wrap?0:1),
rowcnt = rows - (row_wrap?0:1)
)
rows<=1 || cols<=1 ? vnf :
vnf_merge([
vnf, [
concat(