From 2551f199399afeb41ef1b097b75c4d6406199584 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Mon, 9 Mar 2020 18:35:14 -0700 Subject: [PATCH] Added EMPTY_VNF --- beziers.scad | 8 ++++---- version.scad | 2 +- vnf.scad | 15 +++++++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/beziers.scad b/beziers.scad index bfddbeb..491bd3f 100644 --- a/beziers.scad +++ b/beziers.scad @@ -808,7 +808,7 @@ function is_patch(x) = is_tripatch(x) || is_rectpatch(x); // ) // ]; // vnf_polyhedron(concat(edges,corners,faces)); -function bezier_patch(patch, splinesteps=16, vnf=[[],[]]) = +function bezier_patch(patch, splinesteps=16, vnf=EMPTY_VNF) = assert(is_num(splinesteps)||is_list(splinesteps)) is_tripatch(patch)? _bezier_triangle(patch, splinesteps=splinesteps, vnf=vnf) : let( @@ -831,7 +831,7 @@ function bezier_patch(patch, splinesteps=16, vnf=[[],[]]) = function _tri_count(n) = (n*(1+n))/2; -function _bezier_triangle(tri, splinesteps=16, vnf=[[],[]]) = +function _bezier_triangle(tri, splinesteps=16, vnf=EMPTY_VNF) = assert(is_num(splinesteps)) let( pts = [ @@ -923,7 +923,7 @@ function patch_reverse(patch) = [for (row=patch) reverse(row)]; // ]; // vnf = bezier_surface(patches=[patch1, patch2], splinesteps=16); // polyhedron(points=vnf[0], faces=vnf[1]); -function bezier_surface(patches=[], splinesteps=16, vnf=[[],[]], i=0) = +function bezier_surface(patches=[], splinesteps=16, vnf=EMPTY_VNF, i=0) = let( vnf = (i >= len(patches))? vnf : bezier_patch(patches[i], splinesteps=splinesteps, vnf=vnf) @@ -958,7 +958,7 @@ function bezier_surface(patches=[], splinesteps=16, vnf=[[],[]], i=0) = // [[18,82,0], [33,100, 0], [ 67,100, 0], [ 82, 82,0]], // ]; // bezier_polyhedron([patch1, patch2], splinesteps=8); -module bezier_polyhedron(patches=[], splinesteps=16, vnf=[[],[]]) +module bezier_polyhedron(patches=[], splinesteps=16, vnf=EMPTY_VNF) { vnf_polyhedron( bezier_surface(patches=patches, splinesteps=splinesteps, vnf=vnf) diff --git a/version.scad b/version.scad index c8ecab2..c36cb13 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,172]; +BOSL_VERSION = [2,0,174]; // Section: BOSL Library Version Functions diff --git a/vnf.scad b/vnf.scad index 2ec6dfa..6f217ee 100644 --- a/vnf.scad +++ b/vnf.scad @@ -20,6 +20,9 @@ include // merge the various VNFs to get the completed polyhedron vertex list and faces. +EMPTY_VNF = [[],[]]; // The standard empty VNF with no vertices or faces. + + // Function: is_vnf() // Description: Returns true if the given value looks passingly like a VNF structure. function is_vnf(x) = is_list(x) && len(x)==2 && is_list(x[0]) && is_list(x[1]) && (x[0]==[] || is_vector(x[0][0])) && (x[1]==[] || is_vector(x[1][0])); @@ -56,7 +59,7 @@ function vnf_faces(vnf) = vnf[1]; // vnf2 = vnf_get_vertex(vnf1, p=[3,2,1]); // Returns: [1, [[[3,5,8],[3,2,1]],[]]] // vnf3 = vnf_get_vertex(vnf2, p=[3,5,8]); // Returns: [0, [[[3,5,8],[3,2,1]],[]]] // vnf4 = vnf_get_vertex(vnf3, p=[[1,3,2],[3,2,1]]); // Returns: [[1,2], [[[3,5,8],[3,2,1],[1,3,2]],[]]] -function vnf_get_vertex(vnf=[[],[]], p) = +function vnf_get_vertex(vnf=EMPTY_VNF, p) = is_path(p)? _vnf_get_vertices(vnf, p) : assert(is_vnf(vnf)) assert(is_vector(p)) @@ -73,7 +76,7 @@ function vnf_get_vertex(vnf=[[],[]], p) = // Internal use only -function _vnf_get_vertices(vnf=[[],[]], pts, _i=0, _idxs=[]) = +function _vnf_get_vertices(vnf=EMPTY_VNF, pts, _i=0, _idxs=[]) = _i>=len(pts)? [_idxs, vnf] : let( vvnf = vnf_get_vertex(vnf, pts[_i]) @@ -90,7 +93,7 @@ function _vnf_get_vertices(vnf=[[],[]], pts, _i=0, _idxs=[]) = // Arguments: // vnf = The VNF structure to add a face to. // pts = The vertex points for the face. -function vnf_add_face(vnf=[[],[]], pts) = +function vnf_add_face(vnf=EMPTY_VNF, pts) = assert(is_vnf(vnf)) assert(is_path(pts)) let( @@ -114,7 +117,7 @@ function vnf_add_face(vnf=[[],[]], pts) = // Arguments: // vnf = The VNF structure to add a face to. // faces = The list of faces, where each face is given as a list of vertex points. -function vnf_add_faces(vnf=[[],[]], faces, _i=0) = +function vnf_add_faces(vnf=EMPTY_VNF, faces, _i=0) = (assert(is_vnf(vnf)) assert(is_list(faces)) _i>=len(faces))? vnf : vnf_add_faces(vnf_add_face(vnf, faces[_i]), faces, _i=_i+1); @@ -124,7 +127,7 @@ function vnf_add_faces(vnf=[[],[]], faces, _i=0) = // vnf = vnf_merge([VNF, VNF, VNF, ...]); // Description: // Given a list of VNF structures, merges them all into a single VNF structure. -function vnf_merge(vnfs=[],_i=0,_acc=[[],[]]) = +function vnf_merge(vnfs=[],_i=0,_acc=EMPTY_VNF) = (assert(is_vnf_list(vnfs)) _i>=len(vnfs))? _acc : vnf_merge( vnfs, _i=_i+1, @@ -224,7 +227,7 @@ function vnf_vertex_array( row_wrap=false, reverse=false, style="default", - vnf=[[],[]] + vnf=EMPTY_VNF ) = assert((!caps)||(caps&&col_wrap)) assert(in_list(style,["default","alt","quincunx"]))