Simple optimisation

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

Simple optimisation

Oakapple
I have some code:

dome (100,8);
rotate ([90,0,0]) dome (100,8);
rotate ([0,90,0]) dome (100,8);

Which takes an object, rotates around x and y axes and creates the union of all three objects.

I would like to think that there was some way of “storing” the original object and performing a transform on each copy, but things may not work like that.

If there is a way of “storing” and reusing the object, what is it? If there isn’t a way, it would be good to know to stop me wasting time trying to find it.

Thanks,

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

Re: Simple optimisation

kintel
Administrator
If the purpose of “storing” and “reusing” the object is to save time and memory generating it, you’re already doing the correct thing:
OpenSCAD will implicitly cache all geometry, so there is no penalty by using it multiple times. The cache is based on a normalized source code representation so any code block with equivalent source code will be reused automatically, even if it spans a whole hierarchy of objects.

 -Marius

> On Aug 21, 2016, at 13:45, Colin Smart <[hidden email]> wrote:
>
> I have some code:
>
> dome (100,8);
> rotate ([90,0,0]) dome (100,8);
> rotate ([0,90,0]) dome (100,8);
>
> Which takes an object, rotates around x and y axes and creates the union of all three objects.
>
> I would like to think that there was some way of “storing” the original object and performing a transform on each copy, but things may not work like that.
>
> If there is a way of “storing” and reusing the object, what is it? If there isn’t a way, it would be good to know to stop me wasting time trying to find it.
>
> Thanks,
>
> Colin
> _______________________________________________
> 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: Simple optimisation

Ronaldo
Kintel,

Even very big/complex objects are cached? Object renderization is also cached?

Colin,

If you don't want to spend time rebuilding complex unchanged parts, may be helpful to save them in a stl file and importing it as needed.

2016-08-21 14:54 GMT-03:00 Marius Kintel <[hidden email]>:
If the purpose of “storing” and “reusing” the object is to save time and memory generating it, you’re already doing the correct thing:
OpenSCAD will implicitly cache all geometry, so there is no penalty by using it multiple times. The cache is based on a normalized source code representation so any code block with equivalent source code will be reused automatically, even if it spans a whole hierarchy of objects.

 -Marius

> On Aug 21, 2016, at 13:45, Colin Smart <[hidden email]> wrote:
>
> I have some code:
>
> dome (100,8);
> rotate ([90,0,0]) dome (100,8);
> rotate ([0,90,0]) dome (100,8);
>
> Which takes an object, rotates around x and y axes and creates the union of all three objects.
>
> I would like to think that there was some way of “storing” the original object and performing a transform on each copy, but things may not work like that.
>
> If there is a way of “storing” and reusing the object, what is it? If there isn’t a way, it would be good to know to stop me wasting time trying to find it.
>
> Thanks,
>
> Colin
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Simple optimisation

kintel
Administrator
On Aug 21, 2016, at 16:23, Ronaldo Persiano <[hidden email]> wrote:
>
> Even very big/complex objects are cached? Object renderization is also cached?
>
Big objects are cached, as long as there is enough memory.
Geometry evaluation is cached, e.g. results of time-consuming CSG operations.

 -Marius


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

Re: Simple optimisation

rk
In reply to this post by Oakapple
Hi,

On Sun, Aug 21, 2016 at 06:45:16PM +0100, Colin Smart wrote:
> I have some code:
>
> dome (100,8);
> rotate ([90,0,0]) dome (100,8);
> rotate ([0,90,0]) dome (100,8);

You can try:

module dome2(a,b)
{
    render()
    dome(a,b);
}
dome2(100,8);
rotate([90,0,0]) dome2(100,8);
rotate([0,90,0]) dome2(100,8);

Does this help?


I often use render() to speed-up viewing complex objects: It takes longer
to create the 1st preview, but viewing/rotating it is much faster.


Best regards,
Roland



PS: In fact, I usually use:

render_color_enable = true;
module render_color(c)
{
    if(render_color_enable) {
        color(c)
        render()
        children();
    }
    else {
        color(c)
        children();
    }
}

And add render_color(...) to many of my objects.


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

Re: Simple optimisation

MichaelAtOz
Administrator
Testing... sorry to hijack, but testing mailing list/forum, as this thread didn't make it there.

> -----Original Message-----
> From: Discuss [mailto:[hidden email]] On Behalf Of Roland Koebler
> Sent: Friday, 26 August 2016 3:58 AM
> To: [hidden email]
> Subject: Re: [OpenSCAD] Simple optimisation
>
> Hi,
>
> On Sun, Aug 21, 2016 at 06:45:16PM +0100, Colin Smart wrote:
> > I have some code:
> >
> > dome (100,8);
> > rotate ([90,0,0]) dome (100,8);
> > rotate ([0,90,0]) dome (100,8);
>
> You can try:
>
> module dome2(a,b)
> {
>     render()
>     dome(a,b);
> }
> dome2(100,8);
> rotate([90,0,0]) dome2(100,8);
> rotate([0,90,0]) dome2(100,8);
>
> Does this help?
>
>
> I often use render() to speed-up viewing complex objects: It takes longer
> to create the 1st preview, but viewing/rotating it is much faster.
>
>
> Best regards,
> Roland
>
>
>
> PS: In fact, I usually use:
>
> render_color_enable = true;
> module render_color(c)
> {
>     if(render_color_enable) {
>         color(c)
>         render()
>         children();
>     }
>     else {
>         color(c)
>         children();
>     }
> }
>
> And add render_color(...) to many of my objects.
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2016.0.7752 / Virus Database: 4647/12876 - Release Date: 08/25/16



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Admin - email* me if you need anything,
or if I've done something stupid...
* 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.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Reply | Threaded
Open this post in threaded view
|

Re: Simple optimisation

Ronaldo
Michael, it seems the issue is with the archive. I have received messages from the thread "Living Hinges" but it doesn't appear in the archive.

2016-08-25 21:15 GMT-03:00 OzAtMichael <[hidden email]>:
Testing... sorry to hijack, but testing mailing list/forum, as this thread didn't make it there.

> -----Original Message-----
> From: Discuss [mailto:[hidden email]] On Behalf Of Roland Koebler
> Sent: Friday, 26 August 2016 3:58 AM
> To: [hidden email]
> Subject: Re: [OpenSCAD] Simple optimisation
>
> Hi,
>
> On Sun, Aug 21, 2016 at 06:45:16PM +0100, Colin Smart wrote:
> > I have some code:
> >
> > dome (100,8);
> > rotate ([90,0,0]) dome (100,8);
> > rotate ([0,90,0]) dome (100,8);
>
> You can try:
>
> module dome2(a,b)
> {
>     render()
>     dome(a,b);
> }
> dome2(100,8);
> rotate([90,0,0]) dome2(100,8);
> rotate([0,90,0]) dome2(100,8);
>
> Does this help?
>
>
> I often use render() to speed-up viewing complex objects: It takes longer
> to create the 1st preview, but viewing/rotating it is much faster.
>
>
> Best regards,
> Roland
>
>
>
> PS: In fact, I usually use:
>
> render_color_enable = true;
> module render_color(c)
> {
>     if(render_color_enable) {
>         color(c)
>         render()
>         children();
>     }
>     else {
>         color(c)
>         children();
>     }
> }
>
> And add render_color(...) to many of my objects.
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2016.0.7752 / Virus Database: 4647/12876 - Release Date: 08/25/16



_______________________________________________
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: Simple optimisation

drxenocide
The "living hinges" thread I started was sent from my email to the openscad general discussion email address, if that has anything to do with anything.


On Thu, Aug 25, 2016 at 10:15 PM, Ronaldo Persiano <[hidden email]> wrote:
Michael, it seems the issue is with the archive. I have received messages from the thread "Living Hinges" but it doesn't appear in the archive.

2016-08-25 21:15 GMT-03:00 OzAtMichael <[hidden email]>:
Testing... sorry to hijack, but testing mailing list/forum, as this thread didn't make it there.

> -----Original Message-----
> From: Discuss [mailto:[hidden email]] On Behalf Of Roland Koebler
> Sent: Friday, 26 August 2016 3:58 AM
> To: [hidden email]
> Subject: Re: [OpenSCAD] Simple optimisation
>
> Hi,
>
> On Sun, Aug 21, 2016 at 06:45:16PM +0100, Colin Smart wrote:
> > I have some code:
> >
> > dome (100,8);
> > rotate ([90,0,0]) dome (100,8);
> > rotate ([0,90,0]) dome (100,8);
>
> You can try:
>
> module dome2(a,b)
> {
>     render()
>     dome(a,b);
> }
> dome2(100,8);
> rotate([90,0,0]) dome2(100,8);
> rotate([0,90,0]) dome2(100,8);
>
> Does this help?
>
>
> I often use render() to speed-up viewing complex objects: It takes longer
> to create the 1st preview, but viewing/rotating it is much faster.
>
>
> Best regards,
> Roland
>
>
>
> PS: In fact, I usually use:
>
> render_color_enable = true;
> module render_color(c)
> {
>     if(render_color_enable) {
>         color(c)
>         render()
>         children();
>     }
>     else {
>         color(c)
>         children();
>     }
> }
>
> And add render_color(...) to many of my objects.
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2016.0.7752 / Virus Database: 4647/12876 - Release Date: 08/25/16



_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Simple optimisation

MichaelAtOz
Administrator

This is how I think it works. The input to “Match to Thread?” is in backlog ATM.

 

 

 

 


From: Discuss [mailto:[hidden email]] On Behalf Of Ari Diacou
Sent: Monday, 29 August 2016 10:31 AM
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Simple optimisation

 

The "living hinges" thread I started was sent from my email to the openscad general discussion email address, if that has anything to do with anything.

 

 

On Thu, Aug 25, 2016 at 10:15 PM, Ronaldo Persiano <[hidden email]> wrote:

Michael, it seems the issue is with the archive. I have received messages from the thread "Living Hinges" but it doesn't appear in the archive.

 

2016-08-25 21:15 GMT-03:00 OzAtMichael <[hidden email]>:

Testing... sorry to hijack, but testing mailing list/forum, as this thread didn't make it there.


> -----Original Message-----
> From: Discuss [mailto:[hidden email]] On Behalf Of Roland Koebler
> Sent: Friday, 26 August 2016 3:58 AM
> To: [hidden email]
> Subject: Re: [OpenSCAD] Simple optimisation
>
> Hi,
>
> On Sun, Aug 21, 2016 at 06:45:16PM +0100, Colin Smart wrote:
> > I have some code:
> >
> > dome (100,8);
> > rotate ([90,0,0]) dome (100,8);
> > rotate ([0,90,0]) dome (100,8);
>
> You can try:
>
> module dome2(a,b)
> {
>     render()
>     dome(a,b);
> }
> dome2(100,8);
> rotate([90,0,0]) dome2(100,8);
> rotate([0,90,0]) dome2(100,8);
>
> Does this help?
>
>
> I often use render() to speed-up viewing complex objects: It takes longer
> to create the 1st preview, but viewing/rotating it is much faster.
>
>
> Best regards,
> Roland
>
>
>
> PS: In fact, I usually use:
>
> render_color_enable = true;
> module render_color(c)
> {
>     if(render_color_enable) {
>         color(c)
>         render()
>         children();
>     }
>     else {
>         color(c)
>         children();
>     }
> }
>
> And add render_color(...) to many of my objects.
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
>

> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2016.0.7752 / Virus Database: 4647/12876 - Release Date: 08/25/16




_______________________________________________
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
Admin - email* me if you need anything,
or if I've done something stupid...
* 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.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!