discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Render and F6

NH
nop head
Thu, Dec 24, 2020 10:00 AM

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 michael@marx.id.au 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:discuss-bounces@lists.openscad.org] *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 oz.at.michael@gmail.com 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:discuss-bounces@lists.openscad.org] *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: image]
https://user-images.githubusercontent.com/566149/102900396-200be180-4464-11eb-93a5-f2b1ac825245.png

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: image]
https://user-images.githubusercontent.com/566149/102900596-6c572180-4464-11eb-98d5-d7285b11bb49.png

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 oz.at.michael@gmail.com 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient

Virus-free. www.avg.com
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient

<#m_3411100097794982626_m_-981585787335799987_DAB4FAD8-2DD7-40B>


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <michael@marx.id.au> 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:discuss-bounces@lists.openscad.org] *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 <oz.at.michael@gmail.com> 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:discuss-bounces@lists.openscad.org] *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: image] > <https://user-images.githubusercontent.com/566149/102900396-200be180-4464-11eb-93a5-f2b1ac825245.png> > > 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: image] > <https://user-images.githubusercontent.com/566149/102900596-6c572180-4464-11eb-98d5-d7285b11bb49.png> > > 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 <oz.at.michael@gmail.com> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> > > Virus-free. www.avg.com > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> > > <#m_3411100097794982626_m_-981585787335799987_DAB4FAD8-2DD7-40B> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
JC
Juan C.Cilleruelo
Thu, Dec 24, 2020 10:10 AM

Yes. I saw it. It was a mistake! Sorry!

:(

On 24/12/2020 10:56, MichaelAtOz wrote:

Juan, please do not reply to another thread with a new topic.
You replied to my post 'Re: [OpenSCAD] Render and F6' with your
new subject 'Re: What't the alternative to rotate_extrude?'.
But because the email history has a tag, it gets posted to the original
thread.

If you want to raise a new topic, create a new email to
discuss@lists.openscad.org with a new subject.

I have moved your post in the forum.

RE your question, I note the wiki says "You must use parameter names due to
a backward compatibility issue." so use angle=


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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Yes. I saw it. It was a mistake! Sorry! :( On 24/12/2020 10:56, MichaelAtOz wrote: > Juan, please do not reply to another thread with a new topic. > You replied to my post 'Re: [OpenSCAD] Render and F6' with your > new subject 'Re: What't the alternative to rotate_extrude?'. > But because the email history has a tag, it gets posted to the original > thread. > > If you want to raise a new topic, create a new email to > discuss@lists.openscad.org with a new subject. > > I have moved your post in the forum. > > RE your question, I note the wiki says "You must use parameter names due to > a backward compatibility issue." so use angle= > > > > ----- > 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org