[OpenSCAD] When modules are cached?

nop head nop.head at gmail.com
Fri Nov 1 16:56:50 EDT 2019


What happens if you put render() linear_extrude() in bbox()?

On Fri, 1 Nov 2019 at 20:49, Ronaldo Persiano <rcmpersiano at gmail.com> wrote:

>
> 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.
> _______________________________________________
> OpenSCAD mailing list
> Discuss at lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20191101/e1dc25de/attachment.html>


More information about the Discuss mailing list