Render and F6

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Render and F6

nophead
Does render() do anything in F6 if F5 has not been run first, or the cache is cleared?

This simple test appears to show it doesn't

$fn = 32;

render() difference() {
    sphere();
    cube();
}

I ask because a user of NopSCADlib added a conditional render that skips in F5. I.e. render_if(!$preview). Does that make it a NOP?


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Render and F6

MichaelAtOz
Administrator
AFAIK render() always renders, the render processing [F6 or render()] will
look at the child objects, and
if in cache, unchanged, will not re-render them. Hence if not in cache will.
Likewise F5 will render children, during which it won't re-render if in
cache, unchanged.

Guessing at the render_if() code.

If it is;

module render_if(bool)
  if (bool)
    render() children();

Then with bool=false it is a F5 NOP but will F6/render the children .

If it has

  else
    children()

Then both F5/preview & F6/render will process appropriately (OpenGl or
CGAL).

If that is not it, you need to clarify or post code.



-----
OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: Render and F6

MichaelAtOz
Administrator
Clarification

MichaelAtOz wrote
> Likewise F5,
*
> with render()
*
> , will render children, during which it won't re-render if in
> cache, unchanged.





-----
OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: Render and F6

nophead
The code is here: https://github.com/nophead/NopSCADlib/blob/master/utils/core/global.scad#L55, so it always calls the children but wraps them with render() when the argument is true.

What I am asking is if it is passed !$preview will it be a NOP. It won't do anything during F5 as it won't call render(), it will just draw the children. During F6 it calls render() but my mental model of render() is that all it does in F6 is look for a cached Polyset from F5. If it doesn't find one it is a NOP, it just calculates the children with CGAL as it would anyway.If it does find a cached version from F5 it is a Polyset and you can tell because the cut faces are the same colour as the rest.

With this simple test:
$fn = 32;

render() difference() {
    sphere();
    cube();
}
Flush cache F6 gives this:

image

   Top level object is a 3D object:
   Simple:        yes
   Vertices:      467
   Halfedges:    2572
   Edges:        1286
   Halffacets:   1642
   Facets:        821
   Volumes:         2

F5 and then F6 gives this:

image

   Top level object is a 3D object:
   Facets:        930
If I change it to render_if(!$preview) I always get a CGAL object with the pale cut face. It is never replaced with a Polyset. 

So my question is does render() do anything at all to the F6 result when the cache hasn't been populated by F5?


On Wed, 23 Dec 2020 at 05:34, MichaelAtOz <[hidden email]> wrote:
Clarification

MichaelAtOz wrote
> Likewise F5,
*
> with render()
*
> , will render children, during which it won't re-render if in
> cache, unchanged.





-----
OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Render and F6

MichaelAtOz
Administrator

 

I suspect you have hit a bug.

 

Using this code;

 

$fn = 96;  // make it work hard so you notice CGAL

bool= (0) ? false : !$preview;  // option to set manually

 

echo(bool=bool, $preview=$preview);

render_if(bool)

  difference() {

    sphere();

    cube();

}

 

 

module render_if(render = true, convexity = 2)  

    if (render) {

        echo("render()");

        render(convexity = convexity)

            children();

    }

    else

      children();

 

And using Design/Flush-cache, after a few iterations, I got an F5 with no object in the viewing area.

Is that what you are calling a NOP?

 

This is the console;

 

Parsing design (AST generation)...

Saved backup file: /home/mebd/.local/share/OpenSCAD/backups/unsaved-backup-LhX27681.scad

Compiling design (CSG Tree generation)...

ECHO:bool = false, $preview = true

Compiling design (CSG Products generation)...

Geometries in cache: 2

Geometry cache size in bytes: 655216

CGAL Polyhedrons in cache: 0

CGAL cache size in bytes: 0

Compiling design (CSG Products normalization)...

Normalized tree has 2 elements!

Compile and preview finished.

Total rendering time: 0:00:00.023

 

Parsing design (AST generation)...

Saved backup file: /home/mebd/.local/share/OpenSCAD/backups/unsaved-backup-LhX27681.scad

Compiling design (CSG Tree generation)...

ECHO:bool = true, $preview = false

ECHO:"render()"

Rendering Polygon Mesh using CGAL...

Geometries in cache: 2

Geometry cache size in bytes: 655216

CGAL Polyhedrons in cache: 2

CGAL cache size in bytes: 20418224

Total rendering time: 0:00:06.272

   Top level object is a 3D object:

   Simple:        yes

   Vertices:     4083

   Halfedges:   23820

   Edges:       11910

   Halffacets:  15658

   Facets:       7829

   Volumes:         2

Rendering finished.

 

Parsing design (AST generation)...

Saved backup file: /home/mebd/.local/share/OpenSCAD/backups/unsaved-backup-LhX27681.scad

Compiling design (CSG Tree generation)...

ECHO:bool = false, $preview = true

Compiling design (CSG Products generation)...

Geometries in cache: 2

Geometry cache size in bytes: 655216

CGAL Polyhedrons in cache: 2

CGAL cache size in bytes: 20418224

Compiling design (CSG Products normalization)...

Normalized tree has 2 elements!

Compile and preview finished.

Total rendering time: 0:00:00.022

 

The first is F5 [render() not called - standard preview], view area normal.

The second is F6 [render() is called] - CGAL processing as per 6 seconds, view area normal.

Flush Cache, then third is F5 [render() not called, supposed to be standard preview], blank view area.

 

Once that happened it was repeatable, but after restarting not.

I suspect a cache problem.

 

2020.12.15 on Debian. I don't think I had it on Windows...yet.

 

> So my question is does render() do anything at all to the F6 result when the cache hasn't been populated by F5?

 

Unfortunately I didn't then try another F6.

But the first F6 (following F5 without render() - hence not cached), did call render() which did normal CGAL processing.

 

These are nasty bugs...

 

 


From: Discuss [mailto:[hidden email]] On Behalf Of nop head
Sent: Wed, 23 Dec 2020 21:00
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Render and F6

 

The code is here: https://github.com/nophead/NopSCADlib/blob/master/utils/core/global.scad#L55, so it always calls the children but wraps them with render() when the argument is true.

 

What I am asking is if it is passed !$preview will it be a NOP. It won't do anything during F5 as it won't call render(), it will just draw the children. During F6 it calls render() but my mental model of render() is that all it does in F6 is look for a cached Polyset from F5. If it doesn't find one it is a NOP, it just calculates the children with CGAL as it would anyway.If it does find a cached version from F5 it is a Polyset and you can tell because the cut faces are the same colour as the rest.

 

With this simple test:

$fn = 32;
 
render() difference() {
    sphere();
    cube();
}

Flush cache F6 gives this:

image

   Top level object is a 3D object:
   Simple:        yes
   Vertices:      467
   Halfedges:    2572
   Edges:        1286
   Halffacets:   1642
   Facets:        821
   Volumes:         2

F5 and then F6 gives this:

image

   Top level object is a 3D object:
   Facets:        930

If I change it to render_if(!$preview) I always get a CGAL object with the pale cut face. It is never replaced with a Polyset. 

 

So my question is does render() do anything at all to the F6 result when the cache hasn't been populated by F5?

 

 

On Wed, 23 Dec 2020 at 05:34, MichaelAtOz <[hidden email]> wrote:

Clarification

MichaelAtOz wrote
> Likewise F5,
*
> with render()
*
> , will render children, during which it won't re-render if in
> cache, unchanged.





-----
OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


Virus-free. www.avg.com

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: Render and F6

nophead
> Is that what you are calling a NOP?

No, I haven't seen any bugs. What I am asking is if I insert render_if(!preview) does it affect the result in any way? My argument is it does nothing at all and is pointless.

On Thu, 24 Dec 2020 at 02:38, MichaelAtOz <[hidden email]> wrote:

 

I suspect you have hit a bug.

 

Using this code;

 

$fn = 96;  // make it work hard so you notice CGAL

bool= (0) ? false : !$preview;  // option to set manually

 

echo(bool=bool, $preview=$preview);

render_if(bool)

  difference() {

    sphere();

    cube();

}

 

 

module render_if(render = true, convexity = 2)  

    if (render) {

        echo("render()");

        render(convexity = convexity)

            children();

    }

    else

      children();

 

And using Design/Flush-cache, after a few iterations, I got an F5 with no object in the viewing area.

Is that what you are calling a NOP?

 

This is the console;

 

Parsing design (AST generation)...

Saved backup file: /home/mebd/.local/share/OpenSCAD/backups/unsaved-backup-LhX27681.scad

Compiling design (CSG Tree generation)...

ECHO:bool = false, $preview = true

Compiling design (CSG Products generation)...

Geometries in cache: 2

Geometry cache size in bytes: 655216

CGAL Polyhedrons in cache: 0

CGAL cache size in bytes: 0

Compiling design (CSG Products normalization)...

Normalized tree has 2 elements!

Compile and preview finished.

Total rendering time: 0:00:00.023

 

Parsing design (AST generation)...

Saved backup file: /home/mebd/.local/share/OpenSCAD/backups/unsaved-backup-LhX27681.scad

Compiling design (CSG Tree generation)...

ECHO:bool = true, $preview = false

ECHO:"render()"

Rendering Polygon Mesh using CGAL...

Geometries in cache: 2

Geometry cache size in bytes: 655216

CGAL Polyhedrons in cache: 2

CGAL cache size in bytes: 20418224

Total rendering time: 0:00:06.272

   Top level object is a 3D object:

   Simple:        yes

   Vertices:     4083

   Halfedges:   23820

   Edges:       11910

   Halffacets:  15658

   Facets:       7829

   Volumes:         2

Rendering finished.

 

Parsing design (AST generation)...

Saved backup file: /home/mebd/.local/share/OpenSCAD/backups/unsaved-backup-LhX27681.scad

Compiling design (CSG Tree generation)...

ECHO:bool = false, $preview = true

Compiling design (CSG Products generation)...

Geometries in cache: 2

Geometry cache size in bytes: 655216

CGAL Polyhedrons in cache: 2

CGAL cache size in bytes: 20418224

Compiling design (CSG Products normalization)...

Normalized tree has 2 elements!

Compile and preview finished.

Total rendering time: 0:00:00.022

 

The first is F5 [render() not called - standard preview], view area normal.

The second is F6 [render() is called] - CGAL processing as per 6 seconds, view area normal.

Flush Cache, then third is F5 [render() not called, supposed to be standard preview], blank view area.

 

Once that happened it was repeatable, but after restarting not.

I suspect a cache problem.

 

2020.12.15 on Debian. I don't think I had it on Windows...yet.

 

> So my question is does render() do anything at all to the F6 result when the cache hasn't been populated by F5?

 

Unfortunately I didn't then try another F6.

But the first F6 (following F5 without render() - hence not cached), did call render() which did normal CGAL processing.

 

These are nasty bugs...

 

 


From: Discuss [mailto:[hidden email]] On Behalf Of nop head
Sent: Wed, 23 Dec 2020 21:00
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Render and F6

 

The code is here: https://github.com/nophead/NopSCADlib/blob/master/utils/core/global.scad#L55, so it always calls the children but wraps them with render() when the argument is true.

 

What I am asking is if it is passed !$preview will it be a NOP. It won't do anything during F5 as it won't call render(), it will just draw the children. During F6 it calls render() but my mental model of render() is that all it does in F6 is look for a cached Polyset from F5. If it doesn't find one it is a NOP, it just calculates the children with CGAL as it would anyway.If it does find a cached version from F5 it is a Polyset and you can tell because the cut faces are the same colour as the rest.

 

With this simple test:

$fn = 32;
 
render() difference() {
    sphere();
    cube();
}

Flush cache F6 gives this:

image

   Top level object is a 3D object:
   Simple:        yes
   Vertices:      467
   Halfedges:    2572
   Edges:        1286
   Halffacets:   1642
   Facets:        821
   Volumes:         2

F5 and then F6 gives this:

image

   Top level object is a 3D object:
   Facets:        930

If I change it to render_if(!$preview) I always get a CGAL object with the pale cut face. It is never replaced with a Polyset. 

 

So my question is does render() do anything at all to the F6 result when the cache hasn't been populated by F5?

 

 

On Wed, 23 Dec 2020 at 05:34, MichaelAtOz <[hidden email]> wrote:

Clarification

MichaelAtOz wrote
> Likewise F5,
*
> with render()
*
> , will render children, during which it won't re-render if in
> cache, unchanged.





-----
OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


Virus-free. www.avg.com
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Render and F6

MichaelAtOz'

Ok, to answer your question;

> So my question is does render() do anything at all to the F6 result when the cache hasn't been populated by F5

My understanding is render() does not ADD anything that F6 does anyway, render() is a helper for preview.

If the objects in question have not been F5+render()'ed nor F6 rendered [hence not in cache], or if flushed caches, then

the objects are not in cache, when render-process examines the object it looks it in the cache, does not find it,

then performs usual CGAL/Clipper render of the operation [either create an atomic object, or a CSG operation].

 

I'm not understanding what your concern is.

A render_if(!$preview) is pretty straight forward.

It will never call 'render() children()' with F5/preview, so IF that is what you mean as a NOP, then yes it is redundant.

With F6 it will always 'process' the render(), which just render-processes the inherent child objects, so render() during F6 is also redundant.

 

BUT that is how render_if() is written, if called with !$preview, it is redundant.

BUT that does not make it an actual NOP, without checking I expect it does a group() or similar.

You would have to think about behaviour with lazy-union tho.

 

That depends on what you mean by NOP.

 

BUT there has been a long term problem with F5 then F6 v's just F6.

That (AFAIK) is cached polyset converted from Nef CGAL or Clipper, being different to F6 Nef.

i.e. F5 render() is != F6, IMHO, causing geometry inconsistencies.

 

As I said, I'm not understanding what your concern is.

 

 


From: Discuss [mailto:[hidden email]] On Behalf Of nop head
Sent: Thu, 24 Dec 2020 18:47
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Render and F6

 

> Is that what you are calling a NOP?

 

No, I haven't seen any bugs. What I am asking is if I insert render_if(!preview) does it affect the result in any way? My argument is it does nothing at all and is pointless.

 

On Thu, 24 Dec 2020 at 02:38, MichaelAtOz <[hidden email]> wrote:

 

I suspect you have hit a bug.

 

Using this code;

 

$fn = 96;  // make it work hard so you notice CGAL

bool= (0) ? false : !$preview;  // option to set manually

 

echo(bool=bool, $preview=$preview);

render_if(bool)

  difference() {

    sphere();

    cube();

}

 

 

module render_if(render = true, convexity = 2)  

    if (render) {

        echo("render()");

        render(convexity = convexity)

            children();

    }

    else

      children();

 

And using Design/Flush-cache, after a few iterations, I got an F5 with no object in the viewing area.

Is that what you are calling a NOP?

 

This is the console;

 

Parsing design (AST generation)...

Saved backup file: /home/mebd/.local/share/OpenSCAD/backups/unsaved-backup-LhX27681.scad

Compiling design (CSG Tree generation)...

ECHO:bool = false, $preview = true

Compiling design (CSG Products generation)...

Geometries in cache: 2

Geometry cache size in bytes: 655216

CGAL Polyhedrons in cache: 0

CGAL cache size in bytes: 0

Compiling design (CSG Products normalization)...

Normalized tree has 2 elements!

Compile and preview finished.

Total rendering time: 0:00:00.023

 

Parsing design (AST generation)...

Saved backup file: /home/mebd/.local/share/OpenSCAD/backups/unsaved-backup-LhX27681.scad

Compiling design (CSG Tree generation)...

ECHO:bool = true, $preview = false

ECHO:"render()"

Rendering Polygon Mesh using CGAL...

Geometries in cache: 2

Geometry cache size in bytes: 655216

CGAL Polyhedrons in cache: 2

CGAL cache size in bytes: 20418224

Total rendering time: 0:00:06.272

   Top level object is a 3D object:

   Simple:        yes

   Vertices:     4083

   Halfedges:   23820

   Edges:       11910

   Halffacets:  15658

   Facets:       7829

   Volumes:         2

Rendering finished.

 

Parsing design (AST generation)...

Saved backup file: /home/mebd/.local/share/OpenSCAD/backups/unsaved-backup-LhX27681.scad

Compiling design (CSG Tree generation)...

ECHO:bool = false, $preview = true

Compiling design (CSG Products generation)...

Geometries in cache: 2

Geometry cache size in bytes: 655216

CGAL Polyhedrons in cache: 2

CGAL cache size in bytes: 20418224

Compiling design (CSG Products normalization)...

Normalized tree has 2 elements!

Compile and preview finished.

Total rendering time: 0:00:00.022

 

The first is F5 [render() not called - standard preview], view area normal.

The second is F6 [render() is called] - CGAL processing as per 6 seconds, view area normal.

Flush Cache, then third is F5 [render() not called, supposed to be standard preview], blank view area.

 

Once that happened it was repeatable, but after restarting not.

I suspect a cache problem.

 

2020.12.15 on Debian. I don't think I had it on Windows...yet.

 

> So my question is does render() do anything at all to the F6 result when the cache hasn't been populated by F5?

 

Unfortunately I didn't then try another F6.

But the first F6 (following F5 without render() - hence not cached), did call render() which did normal CGAL processing.

 

These are nasty bugs...

 

 


From: Discuss [mailto:[hidden email]] On Behalf Of nop head
Sent: Wed, 23 Dec 2020 21:00
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Render and F6

 

The code is here: https://github.com/nophead/NopSCADlib/blob/master/utils/core/global.scad#L55, so it always calls the children but wraps them with render() when the argument is true.

 

What I am asking is if it is passed !$preview will it be a NOP. It won't do anything during F5 as it won't call render(), it will just draw the children. During F6 it calls render() but my mental model of render() is that all it does in F6 is look for a cached Polyset from F5. If it doesn't find one it is a NOP, it just calculates the children with CGAL as it would anyway.If it does find a cached version from F5 it is a Polyset and you can tell because the cut faces are the same colour as the rest.

 

With this simple test:

$fn = 32;
 
render() difference() {
    sphere();
    cube();
}

Flush cache F6 gives this:

image

   Top level object is a 3D object:
   Simple:        yes
   Vertices:      467
   Halfedges:    2572
   Edges:        1286
   Halffacets:   1642
   Facets:        821
   Volumes:         2

F5 and then F6 gives this:

image

   Top level object is a 3D object:
   Facets:        930

If I change it to render_if(!$preview) I always get a CGAL object with the pale cut face. It is never replaced with a Polyset. 

 

So my question is does render() do anything at all to the F6 result when the cache hasn't been populated by F5?

 

 

On Wed, 23 Dec 2020 at 05:34, MichaelAtOz <[hidden email]> wrote:

Clarification

MichaelAtOz wrote
> Likewise F5,
*
> with render()
*
> , will render children, during which it won't re-render if in
> cache, unchanged.





-----
OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

 

Virus-free. www.avg.com

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Render and F6

nophead
I think render() does do something in F6. If the polyset has been cached by F5 then it uses it instead of calculating it again with CGAL. The problem is the PolySet has less resolution and no topology, so getting rid of it by flushing cache can avoid CGAL choking on it.

My concern is it was added to my library but appears to be pointless. The person adding it said he sometimes needs to add render() to get valid STLs for slicing but doesn't want to slow down the preview. Although perhaps render_if($preview) makes sense to get a valid preview, faster after the first one, without getting F6 problems.

On Thu, 24 Dec 2020 at 09:14, Michael Marx <[hidden email]> wrote:

Ok, to answer your question;

> So my question is does render() do anything at all to the F6 result when the cache hasn't been populated by F5

My understanding is render() does not ADD anything that F6 does anyway, render() is a helper for preview.

If the objects in question have not been F5+render()'ed nor F6 rendered [hence not in cache], or if flushed caches, then

the objects are not in cache, when render-process examines the object it looks it in the cache, does not find it,

then performs usual CGAL/Clipper render of the operation [either create an atomic object, or a CSG operation].

 

I'm not understanding what your concern is.

A render_if(!$preview) is pretty straight forward.

It will never call 'render() children()' with F5/preview, so IF that is what you mean as a NOP, then yes it is redundant.

With F6 it will always 'process' the render(), which just render-processes the inherent child objects, so render() during F6 is also redundant.

 

BUT that is how render_if() is written, if called with !$preview, it is redundant.

BUT that does not make it an actual NOP, without checking I expect it does a group() or similar.

You would have to think about behaviour with lazy-union tho.

 

That depends on what you mean by NOP.

 

BUT there has been a long term problem with F5 then F6 v's just F6.

That (AFAIK) is cached polyset converted from Nef CGAL or Clipper, being different to F6 Nef.

i.e. F5 render() is != F6, IMHO, causing geometry inconsistencies.

 

As I said, I'm not understanding what your concern is.

 

 


From: Discuss [mailto:[hidden email]] On Behalf Of nop head
Sent: Thu, 24 Dec 2020 18:47
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Render and F6

 

> Is that what you are calling a NOP?

 

No, I haven't seen any bugs. What I am asking is if I insert render_if(!preview) does it affect the result in any way? My argument is it does nothing at all and is pointless.

 

On Thu, 24 Dec 2020 at 02:38, MichaelAtOz <[hidden email]> wrote:

 

I suspect you have hit a bug.

 

Using this code;

 

$fn = 96;  // make it work hard so you notice CGAL

bool= (0) ? false : !$preview;  // option to set manually

 

echo(bool=bool, $preview=$preview);

render_if(bool)

  difference() {

    sphere();

    cube();

}

 

 

module render_if(render = true, convexity = 2)  

    if (render) {

        echo("render()");

        render(convexity = convexity)

            children();

    }

    else

      children();

 

And using Design/Flush-cache, after a few iterations, I got an F5 with no object in the viewing area.

Is that what you are calling a NOP?

 

This is the console;

 

Parsing design (AST generation)...

Saved backup file: /home/mebd/.local/share/OpenSCAD/backups/unsaved-backup-LhX27681.scad

Compiling design (CSG Tree generation)...

ECHO:bool = false, $preview = true

Compiling design (CSG Products generation)...

Geometries in cache: 2

Geometry cache size in bytes: 655216

CGAL Polyhedrons in cache: 0

CGAL cache size in bytes: 0

Compiling design (CSG Products normalization)...

Normalized tree has 2 elements!

Compile and preview finished.

Total rendering time: 0:00:00.023

 

Parsing design (AST generation)...

Saved backup file: /home/mebd/.local/share/OpenSCAD/backups/unsaved-backup-LhX27681.scad

Compiling design (CSG Tree generation)...

ECHO:bool = true, $preview = false

ECHO:"render()"

Rendering Polygon Mesh using CGAL...

Geometries in cache: 2

Geometry cache size in bytes: 655216

CGAL Polyhedrons in cache: 2

CGAL cache size in bytes: 20418224

Total rendering time: 0:00:06.272

   Top level object is a 3D object:

   Simple:        yes

   Vertices:     4083

   Halfedges:   23820

   Edges:       11910

   Halffacets:  15658

   Facets:       7829

   Volumes:         2

Rendering finished.

 

Parsing design (AST generation)...

Saved backup file: /home/mebd/.local/share/OpenSCAD/backups/unsaved-backup-LhX27681.scad

Compiling design (CSG Tree generation)...

ECHO:bool = false, $preview = true

Compiling design (CSG Products generation)...

Geometries in cache: 2

Geometry cache size in bytes: 655216

CGAL Polyhedrons in cache: 2

CGAL cache size in bytes: 20418224

Compiling design (CSG Products normalization)...

Normalized tree has 2 elements!

Compile and preview finished.

Total rendering time: 0:00:00.022

 

The first is F5 [render() not called - standard preview], view area normal.

The second is F6 [render() is called] - CGAL processing as per 6 seconds, view area normal.

Flush Cache, then third is F5 [render() not called, supposed to be standard preview], blank view area.

 

Once that happened it was repeatable, but after restarting not.

I suspect a cache problem.

 

2020.12.15 on Debian. I don't think I had it on Windows...yet.

 

> So my question is does render() do anything at all to the F6 result when the cache hasn't been populated by F5?

 

Unfortunately I didn't then try another F6.

But the first F6 (following F5 without render() - hence not cached), did call render() which did normal CGAL processing.

 

These are nasty bugs...

 

 


From: Discuss [mailto:[hidden email]] On Behalf Of nop head
Sent: Wed, 23 Dec 2020 21:00
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Render and F6

 

The code is here: https://github.com/nophead/NopSCADlib/blob/master/utils/core/global.scad#L55, so it always calls the children but wraps them with render() when the argument is true.

 

What I am asking is if it is passed !$preview will it be a NOP. It won't do anything during F5 as it won't call render(), it will just draw the children. During F6 it calls render() but my mental model of render() is that all it does in F6 is look for a cached Polyset from F5. If it doesn't find one it is a NOP, it just calculates the children with CGAL as it would anyway.If it does find a cached version from F5 it is a Polyset and you can tell because the cut faces are the same colour as the rest.

 

With this simple test:

$fn = 32;
 
render() difference() {
    sphere();
    cube();
}

Flush cache F6 gives this:

image

   Top level object is a 3D object:
   Simple:        yes
   Vertices:      467
   Halfedges:    2572
   Edges:        1286
   Halffacets:   1642
   Facets:        821
   Volumes:         2

F5 and then F6 gives this:

image

   Top level object is a 3D object:
   Facets:        930

If I change it to render_if(!$preview) I always get a CGAL object with the pale cut face. It is never replaced with a Polyset. 

 

So my question is does render() do anything at all to the F6 result when the cache hasn't been populated by F5?

 

 

On Wed, 23 Dec 2020 at 05:34, MichaelAtOz <[hidden email]> wrote:

Clarification

MichaelAtOz wrote
> Likewise F5,
*
> with render()
*
> , will render children, during which it won't re-render if in
> cache, unchanged.





-----
OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

 

Virus-free. www.avg.com

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org