Merge pull request #249 from adrianVmariano/master

some child handling
This commit is contained in:
Revar Desmera 2020-08-27 23:50:45 -07:00 committed by GitHub
commit 1d6d63748d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 5 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

@ -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

@ -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

@ -341,9 +341,16 @@ function vnf_vertex_array(
// Arguments:
// vnf = A VNF structure, or list of VNF structures.
// convexity = Max number of times a line could intersect a wall of the shape.
module vnf_polyhedron(vnf, convexity=2) {
module vnf_polyhedron(vnf,
convexity=10,anchor="origin",cp,
spin=0, orient=UP, extent=false
)
{
vnf = is_vnf_list(vnf)? vnf_merge(vnf) : vnf;
polyhedron(vnf[0], vnf[1], convexity=convexity);
attachable(anchor=anchor, spin=spin, orient=orient, vnf=vnf, extent=extent, cp=is_def(cp) ? cp : vnf_centroid(vnf)){
polyhedron(vnf[0], vnf[1], convexity=convexity);
children();
}
}