[OpenSCAD] When modules are cached?

Ronaldo Persiano rcmpersiano at gmail.com
Fri Nov 1 16:48:52 EDT 2019


> Even if bbox was cached you are calling projection many times and it is
> the odd one out as it is a very slow CGAL operation but it produces a 2D
> results, so perhaps not cached.
>

I checked that the projection of a cube (like bbox0() is) and  the
intersections have a negligible runtime in this case. The repetitive
computation of bbox0() children() (a 3D object) is what is slowing the run.

A simpler and more dramatic case is the following:

module complexbbx3(p)
  projection()
  intersection(){
    render() children();
    children();
    children();
    children();
    children();
    children();
    children();
    children();
    children();
  }

module bbox0()
  linear_extrude()
  intersection() {
    ext = pow(2,16);
    hull() {
      translate([ ext,    0]) children();
      translate([-ext,    0]) children();
    }
    hull() {
      translate([    0, ext]) children();
      translate([    0,-ext]) children();
    }
  }

complexbbx3([1,1])  bbox0() T();


Here, bbox0() T() is a 3D solid, a cube.  complexbbx3(p) applied on a cube
do just the intersection of 9 equal cubes and project it into a square. The
intersection of 9 equal cubes and the (only one) projection have negligible
runtime compared with the bbox0() operation. What the runtimes show is that
the children of  complexbbx3() are evaluated 9 times. So, its children
geometry (a 3D solid) is not cached.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20191101/3cafa942/attachment.html>


More information about the Discuss mailing list