From f4a8138b37be3ddafdc14434b7724b344158c3c8 Mon Sep 17 00:00:00 2001 From: RonaldoCMP Date: Tue, 18 Aug 2020 11:01:42 +0100 Subject: [PATCH] Revert "Merge remote-tracking branch 'upstream/revarbat_dev'" This reverts commit ee80b1d08f2e26b2350e2cf9512e4729ad680a73, reversing changes made to 2b12659d009019c340e183f052d148e679797ecc. --- attachments.scad | 48 ++++++++++++++++------------------- rounding.scad | 2 +- shapes.scad | 4 +-- skin.scad | 65 +++++++++++------------------------------------- version.scad | 2 +- 5 files changed, 41 insertions(+), 80 deletions(-) diff --git a/attachments.scad b/attachments.scad index c2c969e..6004e29 100644 --- a/attachments.scad +++ b/attachments.scad @@ -458,9 +458,10 @@ function find_anchor(anchor, geom) = eps = 1/2048, points = vnf[0], faces = vnf[1], - rpts = apply(rot(from=anchor, to=RIGHT) * move(point3d(-cp)), points), + rpts = rot(from=anchor, to=RIGHT, p=move(point3d(-cp), p=points)), hits = [ - for (face = faces) let( + for (i = idx(faces)) let( + face = faces[i], verts = select(rpts, face) ) if ( max(subindex(verts,0)) >= -eps && @@ -469,40 +470,35 @@ function find_anchor(anchor, geom) = min(subindex(verts,1)) <= eps && min(subindex(verts,2)) <= eps ) let( - poly = select(points, face), - pt = polygon_line_intersection(poly, [cp,cp+anchor], bounded=[true,false], eps=eps) - ) if (!is_undef(pt)) let( - plane = plane_from_polygon(poly), - n = unit(plane_normal(plane)) - ) - [norm(pt-cp), n, pt] + pt = polygon_line_intersection( + select(points, face), + [CENTER,anchor], eps=eps + ) + ) if (!is_undef(pt)) [norm(pt), i, pt] ] ) assert(len(hits)>0, "Anchor vector does not intersect with the shape. Attachment failed.") let( furthest = max_index(subindex(hits,0)), + pos = point3d(cp) + hits[furthest][2], dist = hits[furthest][0], - pos = hits[furthest][2], - hitnorms = [for (hit = hits) if (approx(hit[0],dist,eps=eps)) hit[1]], - unorms = len(hitnorms) > 7 - ? unique([for (nn = hitnorms) quant(nn,1e-9)]) - : [ - for (i = idx(hitnorms)) let( - nn = hitnorms[i], - isdup = [ - for (j = [i+1:1:len(hitnorms)-1]) - if (approx(nn, hitnorms[j])) 1 - ] != [] - ) if (!isdup) nn - ], - n = unit(sum(unorms)), - oang = approx(point2d(n), [0,0])? 0 : atan2(n.y, n.x) + 90 + nfaces = [for (hit = hits) if(approx(hit[0],dist,eps=eps)) hit[1]], + n = unit( + sum([ + for (i = nfaces) let( + faceverts = select(points, faces[i]), + faceplane = plane_from_points(faceverts), + nrm = plane_normal(faceplane) + ) nrm + ]) / len(nfaces), + UP + ) ) [anchor, pos, n, oang] ) : type == "vnf_extent"? ( //vnf let( vnf=geom[1], - rpts = apply(rot(from=anchor, to=RIGHT) * move(point3d(-cp)), vnf[0]), + rpts = rot(from=anchor, to=RIGHT, p=move(point3d(-cp), p=vnf[0])), maxx = max(subindex(rpts,0)), idxs = [for (i = idx(rpts)) if (approx(rpts[i].x, maxx)) i], mm = pointlist_bounds(select(rpts,idxs)), @@ -853,7 +849,7 @@ module attachable( // Module: position() // Usage: -// position(from) ... +// position(from, [overlap]) ... // Description: // Attaches children to a parent object at an anchor point. // Arguments: diff --git a/rounding.scad b/rounding.scad index 94b8143..2dc2ea4 100644 --- a/rounding.scad +++ b/rounding.scad @@ -1962,4 +1962,4 @@ module bent_cutout_mask(r, thickness, path, convexity=10) } -// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap \ No newline at end of file +// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/shapes.scad b/shapes.scad index d612b0a..cb6d4e5 100644 --- a/shapes.scad +++ b/shapes.scad @@ -102,8 +102,8 @@ module cuboid( if (edges == EDGES_ALL && trimcorners) { if (chamfer<0) { cube(size, center=true) { - attach(TOP,overlap=0) prismoid([size.x,size.y], [size.x-2*chamfer,size.y-2*chamfer], h=-chamfer, anchor=TOP); - attach(BOT,overlap=0) prismoid([size.x,size.y], [size.x-2*chamfer,size.y-2*chamfer], h=-chamfer, anchor=TOP); + attach(TOP) prismoid([size.x,size.y], [size.x-2*chamfer,size.y-2*chamfer], h=-chamfer, anchor=TOP); + attach(BOT) prismoid([size.x,size.y], [size.x-2*chamfer,size.y-2*chamfer], h=-chamfer, anchor=TOP); } } else { isize = [for (v = size) max(0.001, v-2*chamfer)]; diff --git a/skin.scad b/skin.scad index 87ae8d4..30d8a17 100644 --- a/skin.scad +++ b/skin.scad @@ -16,8 +16,7 @@ include // Function&Module: skin() // Usage: As module: -// skin(profiles, [slices], [refine], [method], [sampling], [caps], [closed], [z], [convexity], -// [anchor],[cp],[spin],[orient],[extent]); +// skin(profiles, [slices], [refine], [method], [sampling], [caps], [closed], [z]); // Usage: As function: // vnf = skin(profiles, [slices], [refine], [method], [sampling], [caps], [closed], [z]); // Description: @@ -118,12 +117,6 @@ include // caps = true to create endcap faces when closed is false. Can be a length 2 boolean array. Default is true if closed is false. // method = method for connecting profiles, one of "distance", "tangent", "direct" or "reindex". Default: "direct". // z = array of height values for each profile if the profiles are 2d -// convexity = convexity setting for use with polyhedron. (module only) Default: 10 -// anchor = Translate so anchor point is at the origin. (module only) Default: "origin" -// spin = Rotate this many degrees around Z axis after anchor. (module only) Default: 0 -// orient = Vector to rotate top towards after spin (module only) -// extent = use extent method for computing anchors. (module only) Default: false -// cp = set centerpoint for anchor computation. (module only) Default: object centroid // Example: // skin([octagon(4), circle($fn=70,r=2)], z=[0,3], slices=10); // Example: Rotating the pentagon place the zero index at different locations, giving a twist @@ -322,15 +315,11 @@ include // stroke(zrot(30, p=yscale(0.5, p=circle(d=120))),width=10,closed=true); // } // } -module skin(profiles, slices, refine=1, method="direct", sampling, caps, closed=false, z, convexity=10, - anchor="origin",cp,spin=0, orient=UP, extent=false) + + +module skin(profiles, slices, refine=1, method="direct", sampling, caps, closed=false, z, convexity=10) { - vnf = skin(profiles, slices, refine, method, sampling, caps, closed, z); - attachable(anchor=anchor, spin=spin, orient=orient, vnf=vnf, extent=extent, cp=is_def(cp) ? cp : vnf_centroid(vnf)) - { - vnf_polyhedron(vnf,convexity=convexity); - children(); - } + vnf_polyhedron(skin(profiles, slices, refine, method, sampling, caps, closed, z), convexity=convexity); } @@ -814,12 +803,6 @@ function associate_vertices(polygons, split, curpoly=0) = // transformations = list of 4x4 matrices to apply // closed = set to true to form a closed (torus) model. Default: false // caps = true to create endcap faces when closed is false. Can be a singe boolean to specify endcaps at both ends, or a length 2 boolean array. Default is true if closed is false. -// convexity = convexity setting for use with polyhedron. (module only) Default: 10 -// anchor = Translate so anchor point is at the origin. (module only) Default: "origin" -// spin = Rotate this many degrees around Z axis after anchor. (module only) Default: 0 -// orient = Vector to rotate top towards after spin (module only) -// extent = use extent method for computing anchors. (module only) Default: false -// cp = set centerpoint for anchor computation. (module only) Default: object centroid // Example: This is the "sweep-drop" example from list-comprehension-demos. // function drop(t) = 100 * 0.5 * (1 - cos(180 * t)) * sin(180 * t) + 1; // function path(t) = [0, 0, 80 + 80 * cos(180 * t)]; @@ -856,16 +839,9 @@ function sweep(shape, transformations, closed=false, caps) = assert(!closed || !caps, "Cannot make closed shape with caps") _skin_core([for(i=[0:len(transformations)-(closed?0:1)]) apply(transformations[i%len(transformations)],path3d(shape))],caps=fullcaps); -module sweep(shape, transformations, closed=false, caps, convexity=10, - anchor="origin",cp,spin=0, orient=UP, extent=false) -{ - vnf = sweep(shape, transformations, closed, caps); - attachable(anchor=anchor, spin=spin, orient=orient, vnf=vnf, extent=extent, cp=is_def(cp) ? cp : vnf_centroid(vnf)) - { - vnf_polyhedron(vnf,convexity=convexity); - children(); - } -} +module sweep(shape, transformations, closed=false, caps, convexity=10) { + vnf_polyhedron(sweep(shape, transformations, closed, caps), convexity=convexity); +} // Function&Module: path_sweep() @@ -930,13 +906,8 @@ module sweep(shape, transformations, closed=false, caps, convexity=10, // tangent = a list of tangent vectors in case you need more accuracy (particularly at the end points of your curve) // relaxed = set to true with the "manual" method to relax the orthogonality requirement of cross sections to the path tangent. Default: false // caps = Can be a boolean or vector of two booleans. Set to false to disable caps at the two ends. Default: true -// transforms = set to true to return transforms instead of a VNF. These transforms can be manipulated and passed to sweep(). Default: false. // convexity = convexity parameter for polyhedron(). Only accepted by the module version. Default: 10 -// anchor = Translate so anchor point is at the origin. (module only) Default: "origin" -// spin = Rotate this many degrees around Z axis after anchor. (module only) Default: 0 -// orient = Vector to rotate top towards after spin (module only) -// extent = use extent method for computing anchors. (module only) Default: false -// cp = set centerpoint for anchor computation. (module only) Default: object centroid +// transforms = set to true to return transforms instead of a VNF. These transforms can be manipulated and passed to sweep(). Default: false. // // Example(2D): We'll use this shape in several examples // ushape = [[-10, 0],[-10, 10],[ -7, 10],[ -7, 2],[ 7, 2],[ 7, 7],[ 10, 7],[ 10, 0]]; @@ -1150,19 +1121,13 @@ module sweep(shape, transformations, closed=false, caps, convexity=10, // outside = [for(i=[0:len(trans)-1]) trans[i]*scale(lerp(1,1.5,i/(len(trans)-1)))]; // inside = [for(i=[len(trans)-1:-1:0]) trans[i]*scale(lerp(1.1,1.4,i/(len(trans)-1)))]; // sweep(shape, concat(outside,inside),closed=true); -module path_sweep(shape, path, method="incremental", normal, closed=false, twist=0, twist_by_length=true, - symmetry=1, last_normal, tangent, relaxed=false, caps, convexity=10, - anchor="origin",cp,spin=0, orient=UP, extent=false) -{ - vnf = path_sweep(shape, path, method, normal, closed, twist, twist_by_length, - symmetry, last_normal, tangent, relaxed, caps); - attachable(anchor=anchor, spin=spin, orient=orient, vnf=vnf, extent=extent, cp=is_def(cp) ? cp : vnf_centroid(vnf)) - { - vnf_polyhedron(vnf,convexity=convexity); - children(); - } -} +module path_sweep(shape, path, method="incremental", normal, closed=false, twist=0, twist_by_length=true, + symmetry=1, last_normal, tangent, relaxed=false, caps, convexity=10) +{ + vnf_polyhedron(path_sweep(shape, path, method, normal, closed, twist, twist_by_length, + symmetry, last_normal, tangent, relaxed, caps), convexity=convexity); +} function path_sweep(shape, path, method="incremental", normal, closed=false, twist=0, twist_by_length=true, symmetry=1, last_normal, tangent, relaxed=false, caps, transforms=false) = diff --git a/version.scad b/version.scad index 1420f58..e6ba60b 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,405]; +BOSL_VERSION = [2,0,402]; // Section: BOSL Library Version Functions