Merge branch 'master' of github.com:revarbat/BOSL2 into revarbat_dev

This commit is contained in:
Garth Minette 2020-08-28 19:19:04 -07:00
commit 5d2c45bba0
7 changed files with 18 additions and 14 deletions

View File

@ -353,6 +353,7 @@ function segs(r) =
// Arguments:
// $children = number of children the module has.
module no_children(count) {
assert($children==0, "Module no_children() does not support child modules");
assert(count==0, str("Module ",parent_module(1),"() does not support child modules"));
}
@ -377,6 +378,7 @@ function _valstr(x) =
// expected = The value that was expected.
// info = Extra info to print out to make the error clearer.
module assert_approx(got, expected, info) {
no_children($children);
if (!approx(got, expected)) {
echo();
echo(str("EXPECT: ", _valstr(expected)));
@ -404,6 +406,7 @@ module assert_approx(got, expected, info) {
// expected = The value that was expected.
// info = Extra info to print out to make the error clearer.
module assert_equal(got, expected, info) {
no_children($children);
if (got != expected || (is_nan(got) && is_nan(expected))) {
echo();
echo(str("EXPECT: ", _valstr(expected)));

View File

@ -652,7 +652,7 @@ function regular_polyhedron_info(
let(
entry = (
name == "trapezohedron"? (
trapezohedron(faces=faces, side=side, longside=longside, h=h, r=r)
_trapezohedron(faces=faces, side=side, longside=longside, h=h, r=r)
) : (
_polyhedra_[!is_undef(index)?
indexlist[index] :
@ -671,7 +671,7 @@ function regular_polyhedron_info(
) / entry[edgelen]
),
face_triangles = hull(entry[vertices]),
faces_normals_vertices = stellate_faces(
faces_normals_vertices = _stellate_faces(
entry[edgelen], stellate, entry[vertices],
entry[facevertices]==[3]?
[face_triangles, [for(face=face_triangles) _facenormal(entry[vertices],face)]] :
@ -713,11 +713,7 @@ function regular_polyhedron_info(
assert(false, str("Unknown info type '",info,"' requested"));
/// hull solution fails due to roundoff
/// either cross product or just rotate to
///
function stellate_faces(scalefactor,stellate,vertices,faces_normals) =
function _stellate_faces(scalefactor,stellate,vertices,faces_normals) =
(stellate == false || stellate == 0)? concat(faces_normals,[vertices]) :
let(
faces = [for(face=faces_normals[0]) select(face,hull(select(vertices,face)))],
@ -730,8 +726,8 @@ function stellate_faces(scalefactor,stellate,vertices,faces_normals) =
) [newfaces, normals, allpts];
function trapezohedron(faces, r, side, longside, h, d) =
assert(faces%2==0, "Number of faces must be even")
function _trapezohedron(faces, r, side, longside, h, d) =
assert(faces%2==0, "Must set 'faces' to an even number for trapezohedron")
let(
r = get_radius(r=r, d=d, dflt=1),
N = faces/2,

View File

@ -701,7 +701,9 @@ function str_format(fmt, vals, use_nbsp=false) =
// echofmt("{:-10s}{:.3f}", ["plecostamus",27.43982]); // ECHO: "plecostamus27.440"
// echofmt("{:-10.9s}{:.3f}", ["plecostamus",27.43982]); // ECHO: "plecostam 27.440"
function echofmt(fmt, vals, use_nbsp=false) = echo(str_format(fmt,vals,use_nbsp));
module echofmt(fmt, vals, use_nbsp=false) echo(str_format(fmt,vals,use_nbsp));
module echofmt(fmt, vals, use_nbsp=false) {
no_children($children);
echo(str_format(fmt,vals,use_nbsp));
}
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@ -101,6 +101,7 @@ function struct_echo(struct,name="") =
undef;
module struct_echo(struct,name="") {
no_children($children);
dummy = struct_echo(struct,name);
}

View File

@ -232,7 +232,7 @@ module test_rot() {
assert_equal(rot(a,p=pts2d), pts2d, info=str("rot(",a,",p=...), 2D"));
assert_equal(rot(a,p=pts3d), pts3d, info=str("rot(",a,",p=...), 3D"));
}
assert_equal(rot(90), [[0,-1,0,0],[1,0,0,0],[0,0,1,0],[0,0,0,1]])
assert_equal(rot(90), [[0,-1,0,0],[1,0,0,0],[0,0,1,0],[0,0,0,1]]);
for (a=angs) {
assert_equal(rot(a), affine3d_zrot(a), info=str("Z angle (only) = ",a));
assert_equal(rot([a,0,0]), affine3d_xrot(a), info=str("X angle = ",a));

View File

@ -8,7 +8,7 @@
//////////////////////////////////////////////////////////////////////
BOSL_VERSION = [2,0,414];
BOSL_VERSION = [2,0,415];
// Section: BOSL Library Version Functions
@ -49,6 +49,7 @@ function bosl_version_str() = version_to_str(BOSL_VERSION);
// Description:
// Given a version as a list, number, or string, asserts that the currently installed BOSL library is at least the given version.
module bosl_required(target) {
no_children($children);
assert(
version_cmp(bosl_version(), target) >= 0,
str(

View File

@ -348,7 +348,8 @@ function vnf_vertex_array(
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
module vnf_polyhedron(vnf, convexity=2, extent=true, cp=[0,0,0], anchor="origin", spin=0, orient=UP) {
vnf = is_vnf_list(vnf)? vnf_merge(vnf) : vnf;
attachable(anchor,spin,orient, vnf=vnf, cp=cp, extent=extent) {
cp = is_def(cp) ? cp : vnf_centroid(vnf);
attachable(anchor,spin,orient, vnf=vnf, extent=extent, cp=cp) {
polyhedron(vnf[0], vnf[1], convexity=convexity);
children();
}