added no_children checks, and attachable to vnf_polyhedron

This commit is contained in:
Adrian Mariano 2020-08-27 19:25:41 -04:00
parent a8522854e4
commit c1782f1113
5 changed files with 18 additions and 4 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

@ -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();
}
}