Fri Nov 1 15:43:34 EDT 2019

```I think it needs an answer from one of the developers but my guess is that
2D objects are not cached at all. They live in a world of their own with 64
bit fixed point numbers. Most 2D operations are blindingly fast compared to
the very slow 3D CGAL stuff, so it would normally not give much speed
increase to cache them.

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

> Thank you, Michael, for expending your time on that. I have not gotten any
> crash with version 2019.01-RC4. I guess it will depend on the
> available memory to display the CSG tree.
>
> As we say in Portuguese,I have shot what I saw and hit what I haven't.
> Besides, the code I have presented was a failed attempt to illustrate with
> a small code the problem I am having in my original code. Here is a better
> illustration although not as simple.
>
> I have devised the following code to find the bounding box of a 2D object:
>
> module bbox()
>   intersection() {
>     ext = pow(2,16);
>     hull() {
>       translate([ ext,    0]) children();
>       translate([-ext,    0]) children();
>     }
>     hull() {
>       translate([    0, ext]) children();
>       translate([    0,-ext]) children();
>     }
>   }
>
>
> It returns the bounding box (a rectangle) of 2D objects with points away
> from the origin less than pow(2,15) (or something like that).
>
> It is rather efficient even with complex 2D geometries:
>
> n = 270;
>
> text = S(n);
> font = "Palatino Linotype:style=Italic";
>
> // just a complex 2D model
> module T() resize([100,0])
> text(text,font=font,valign="center",halign="center");
>
> // creates a string with n capital S
> function S(n,s="") = n<=0? s: S(n-1,str(s,"S"));
>
> T();
>
> bbx() T();
>
>
> But things get a bit convoluted when bbx() is called many times even over
> the same object:
>
> module complexbbx(p)
>   intersection(){
>     render() bbox() children();
>     bbox() children();
>     bbox() children();
>     bbox() children();
>     bbox() children();
>     bbox() children();
>     bbox() children();
>     bbox() children();
>     bbox() children();
>   }
>
>   complexbbx([1,1]) T();
>
>
> This last code requires 18 sec on my machine while a simple call to bbx()
> T() requires 2 sec.
>
> In the next code,  bbox() children() is called just once but the
> intersection of 9 squares is still done:
>
> module complexbbx2(p)
>   intersection(){
>     render() bbox() children();
>     square([100,10],center=true);
>     square([100,10],center=true);
>     square([100,10],center=true);
>     square([100,10],center=true);
>     square([100,10],center=true);
>     square([100,10],center=true);
>     square([100,10],center=true);
>     square([100,10],center=true);
>   }
>
>
> Now,  complexbbx2([1,1]) T()  requires only 2 sec to run which shows 9
> rectangle intersection is negligible when compared to bbox(). It also shows
> that the bbox() children() in  complexbbx() is not being cached but instead
> computed again and again.
>
> So, the question in this   thread subject remains unanswered. Is there any
> way I could enforce that bbox() children() in  complexbbx() be cached?
> _______________________________________________