discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Reusing intermediary shapes to reduce computation

ML
Matthias Liffers
Fri, Jul 23, 2021 10:57 PM

Good morning,

Long time lurker, first time poster.

I'm trying to create a case for a PCB. I have the PCB as an STL, and I'm
using projection and hull to create an outline as a basis for the case,
like so:

case_internal_offset = 2;
case_wall_thickness = 5;

difference() {
offset(r = case_internal_offset + case_wall_thickness )
projection(cut = true)
import("pcb.stl");
offset(r = case_internal_offset )
projection(cut = true)
import("pcb.stl");
}

It looks like projection is computationally intensive, so I would like to
perform the projection computation only once, and reuse the results of it
several times.

Or is OpenSCAD already doing this for me, and I need to find some other way
to speed things up? (such as saving the results of the projection as a DXF)

Thanks,

Matthias.

Good morning, Long time lurker, first time poster. I'm trying to create a case for a PCB. I have the PCB as an STL, and I'm using projection and hull to create an outline as a basis for the case, like so: case_internal_offset = 2; case_wall_thickness = 5; difference() { offset(r = case_internal_offset + case_wall_thickness ) projection(cut = true) import("pcb.stl"); offset(r = case_internal_offset ) projection(cut = true) import("pcb.stl"); } It looks like projection is computationally intensive, so I would like to perform the projection computation only once, and reuse the results of it several times. Or is OpenSCAD already doing this for me, and I need to find some other way to speed things up? (such as saving the results of the projection as a DXF) Thanks, Matthias.
M
MichaelAtOz
Fri, Jul 23, 2021 11:16 PM

OpenSCAD caches it, assuming it has enough memory. You may want to increase the two CGAL cache sizes in Preferences/Advanced.

One way to force it is to use render() before the projection().

And it is clearer in code if you stick that in a module and call it twice, it indicates it is identical code.


From: Matthias Liffers [mailto:m@tthi.as]
Sent: Sat, 24 Jul 2021 08:57
To: OpenSCAD general discussion
Subject: [OpenSCAD] Reusing intermediary shapes to reduce computation

Good morning,

Long time lurker, first time poster.

I'm trying to create a case for a PCB. I have the PCB as an STL, and I'm using projection and hull to create an outline as a basis for the case, like so:

case_internal_offset = 2;

case_wall_thickness = 5;

difference() {

offset(r = case_internal_offset + case_wall_thickness )

    projection(cut = true)

        import("pcb.stl");

offset(r = case_internal_offset )

    projection(cut = true)

        import("pcb.stl");

}

It looks like projection is computationally intensive, so I would like to perform the projection computation only once, and reuse the results of it several times.

Or is OpenSCAD already doing this for me, and I need to find some other way to speed things up? (such as saving the results of the projection as a DXF)

Thanks,

Matthias.

--
This email has been checked for viruses by AVG.
https://www.avg.com

OpenSCAD caches it, assuming it has enough memory. You may want to increase the two CGAL cache sizes in Preferences/Advanced. One way to force it is to use render() before the projection(). And it is clearer in code if you stick that in a module and call it twice, it indicates it is identical code. _____ From: Matthias Liffers [mailto:m@tthi.as] Sent: Sat, 24 Jul 2021 08:57 To: OpenSCAD general discussion Subject: [OpenSCAD] Reusing intermediary shapes to reduce computation Good morning, Long time lurker, first time poster. I'm trying to create a case for a PCB. I have the PCB as an STL, and I'm using projection and hull to create an outline as a basis for the case, like so: case_internal_offset = 2; case_wall_thickness = 5; difference() { offset(r = case_internal_offset + case_wall_thickness ) projection(cut = true) import("pcb.stl"); offset(r = case_internal_offset ) projection(cut = true) import("pcb.stl"); } It looks like projection is computationally intensive, so I would like to perform the projection computation only once, and reuse the results of it several times. Or is OpenSCAD already doing this for me, and I need to find some other way to speed things up? (such as saving the results of the projection as a DXF) Thanks, Matthias. -- This email has been checked for viruses by AVG. https://www.avg.com