OpenScad 2013.06 (OS X) rendering CGAL extremely slow. Code check?

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

OpenScad 2013.06 (OS X) rendering CGAL extremely slow. Code check?

WestMD
Hi, I run OpenScad 2013.06 on a Mac Mini server (2011) 4Gb RAM and even very simple objects take extremely long to render. My guess is that I am doing something wrong. I'm a beginner and I draw very intuitively and probably use lots of bad practises.

Can you guys take a look at my code and tell me how I could improve it and make rendering a lot faster?

This object renders on my mac in approximatively 9 min. Here the OpenScad summary.

Module cache size: 0 modules
Compiling design (CSG Tree generation)...
Rendering Polygon Mesh using CGAL...
PolySets in cache: 0
PolySet cache size in bytes: 0
CGAL Polyhedrons in cache: 40
CGAL cache size in bytes: 5718408
   Top level object is a 3D object:
   Simple:        yes
   Valid:         yes
   Vertices:      760
   Halfedges:    2450
   Edges:        1225
   Halffacets:    992
   Facets:        496
   Volumes:        14
Total rendering time: 0 hours, 9 minutes, 41 seconds
Rendering finished.


[code]

// *******************************************************
// *                 DECLARATIONS                        *
// *******************************************************

// Joint
Jw=8; //Joint Width X should be same as Fdhw
Jd=2.9; //Joint depth Y should be same as Fdhd
Jh=10; //Joint Height Z should be same as Ahh
Jhr=1.6; //Joint hole radius
Jg=0.5; //Joint gears height Y and thickness Z
Jgq=24; //Number of gears on the joint circle

//Arm

Aw=50; //Arm Width X
Ad=7; //Arm depth Y should be same as Ahd
Ah=10; //Arm Height Z should be same as Jh and Ahh

//Platform
Axw=25; //Arm Extension Width X Should be >= Pr
Axd=7; //Arm Extension depth Y
Axh=4; //Arm Extension Height Z

Pr=20; //Platform radius
Phr=2; //Radius hole in platform



// *******************************************************
// *                      MODULES                        *
// *******************************************************

//Joint
module jbase() //joint base
{
//Joint half circle
translate([Jh/2,Ad/2,Jh/2])
        {
        rotate ([90,0,0]) cylinder (h = Jd, r=Jh/2, center = true, $fn=20);
       
        }

//Joint gears front
translate([Jh/2,Ad/2-Jd/2-Jg/2,Jh/2])

        {
for ( i = [0 : Jgq/2] )
{
        rotate (i * 720/Jgq, [0, 1, 0]) cylinder (h = Jh, r1 = Jg/2, r2 = Jg/6 , center = true, $fn=10);
        }
}

//Joint Base
translate([Jh/2,Ad/2-Jd/2,0])
        {
        cube([Jw,Jd,Jh]);
        }
}
// Joint hole
module jhole()
{
translate([Jh/2,Ad/2,Jh/2])
        {
        rotate ([90,0,0]) cylinder (h = Jd*2, r=Jhr, center = true, $fn=20);
        }
}

//Arm
module arm() //Arm
{
translate([Jh/2+Jw,0,0])
        {
        cube([Aw,Ad,Ah]);
        }
}

//Platform
module plat()
{
//Arm extension
translate([Jh/2+Jw+Aw,0,0])
        {
        cube([Axw,Axd,Axh]);
        }

//Platform
translate([Jh/2+Jw+Aw+Axw,Ad/2,0])
        {
        cylinder (h = Axh, r=Pr, $fn=20);
        }
}
//Platform hole

module plathole()
{
translate([Jh/2+Jw+Aw+Axw,Ad/2,0])
        {
        cylinder (h = Axh, r=Phr, $fn=20);
        }
}



// *******************************************************
// *                      CODE                           *
// *******************************************************

difference()
        {
        jbase();
        jhole();
        }

arm();

difference()
        {
        plat();
        plathole();
        }

[/code]
Reply | Threaded
Open this post in threaded view
|

Re: OpenScad 2013.06 (OS X) rendering CGAL extremely slow. Code check?

devlaam
On 18-12-13 13:46, Westmd wrote:

> Module cache size: 0 modules
> Compiling design (CSG Tree generation)...
> Rendering Polygon Mesh using CGAL...
> PolySets in cache: 0
> PolySet cache size in bytes: 0
> CGAL Polyhedrons in cache: 40
> CGAL cache size in bytes: 5718408
>     Top level object is a 3D object:
>     Simple:        yes
>     Valid:         yes
>     Vertices:      760
>     Halfedges:    2450
>     Edges:        1225
>     Halffacets:    992
>     Facets:        496
>     Volumes:        14
> Total rendering time: 0 hours, 9 minutes, 41 seconds
> Rendering finished.

These are my times (MacBook Pro, i7):

Module cache size: 0 modules
Compiling design (CSG Tree generation)...
Rendering Polygon Mesh using CGAL...
PolySets in cache: 0
PolySet cache size in bytes: 0
CGAL Polyhedrons in cache: 40
CGAL cache size in bytes: 5718408
    Top level object is a 3D object:
    Simple:        yes
    Valid:         yes
    Vertices:      760
    Halfedges:    2450
    Edges:        1225
    Halffacets:    992
    Facets:        496
    Volumes:        14
Total rendering time: 0 hours, 5 minutes, 54 seconds
Rendering finished.

I do not see anything 'wrong' with your design per se,
but there are more knowledgeable people around here :-)

You know that you do not need to render it using CGAL
every time? Use F5 during design, and let it render
at the end while having a coffee break. I have designs
that take up to one hour to render. I would advise
to increase fn somewhat (to 50 or so) gives a much
smoother image, increases the render time to 14 minutes,
23 seconds though


Ruud


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: OpenScad 2013.06 (OS X) rendering CGAL extremely slow. Code check?

WestMD
Hi Ruud,

Thanks a lot for taking the time to render it and have a look at my code. So your MBP i7 is twice as fast as my Mac Mini Server :)
Also thank for the F5 tip, didn't know that. Always thought F5 would just compile the code without rendering the image.
Reply | Threaded
Open this post in threaded view
|

Re: OpenScad 2013.06 (OS X) rendering CGAL extremely slow. Code check?

nophead
The thing that makes is slow is the intersecting cylinders in the "joint gear". If you stop them meeting in the middle  it only takes seconds to render with F6.


On 18 December 2013 14:32, Westmd <[hidden email]> wrote:
Hi Ruud,

Thanks a lot for taking the time to render it and have a look at my code. So
your MBP i7 is twice as fast as my Mac Mini Server :)
Also thank for the F5 tip, didn't know that. Always thought F5 would just
compile the code without rendering the image.



--
View this message in context: http://forum.openscad.org/OpenScad-2013-06-OS-X-rendering-CGAL-extremely-slow-Code-check-tp6265p6267.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: OpenScad 2013.06 (OS X) rendering CGAL extremely slow. Code check?

devlaam
You see? This guy is a lot smarter then i am!
Thanks for this insight nop head.

On 18-12-13 16:23, nop head wrote:

> The thing that makes is slow is the intersecting cylinders in the "joint
> gear". If you stop them meeting in the middle  it only takes seconds to
> render with F6.
>
>
> On 18 December 2013 14:32, Westmd <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi Ruud,
>
>     Thanks a lot for taking the time to render it and have a look at my
>     code. So
>     your MBP i7 is twice as fast as my Mac Mini Server :)
>     Also thank for the F5 tip, didn't know that. Always thought F5 would
>     just
>     compile the code without rendering the image.
>
>
>
>     --
>     View this message in context:
>     http://forum.openscad.org/OpenScad-2013-06-OS-X-rendering-CGAL-extremely-slow-Code-check-tp6265p6267.html
>     Sent from the OpenSCAD mailing list archive at Nabble.com.
>     _______________________________________________
>     OpenSCAD mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://rocklinux.net/mailman/listinfo/openscad
>     http://openscad.org - https://flattr.com/thing/121566
>
>
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
> http://openscad.org - https://flattr.com/thing/121566
>

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: OpenScad 2013.06 (OS X) rendering CGAL extremely slow. Code check?

WestMD
In reply to this post by nophead
wow, really? Thanks, great insight!