discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Tips to keep the speed acceptable

M
MichaelAtOz
Sun, Dec 6, 2015 9:03 PM

Firstly, Your post is still flagged as "This post has NOT been accepted by
the mailing list yet", so nobody gets it unless they look. You need to
subscribe to the  mailing list
http://forum.openscad.org/mailing_list/MailingListOptions.jtp?forum=1  ,
and respond to the registration email.

Perhaps you can share your code and we can suggest improvements?


Newly minted Admin - PM me if you need anything, or if I've done something stupid...

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!

View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p14988.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Firstly, Your post is still flagged as "This post has NOT been accepted by the mailing list yet", so nobody gets it unless they look. You need to subscribe to the mailing list <http://forum.openscad.org/mailing_list/MailingListOptions.jtp?forum=1> , and respond to the registration email. Perhaps you can share your code and we can suggest improvements? ----- Newly minted Admin - PM me if you need anything, or if I've done something stupid... 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! -- View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p14988.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JJ
Johan Jonker
Sun, Dec 6, 2015 10:04 PM

Below is the code I use.
When I change the line 24 union into difference.
The rendering take only 8 seconds but my screen becomes white. The object
does not appear in the screen or very slooooooow.

//bass clarinet bell
// version 3
// J.G.Jonker
// date: 6-12-2015
$fn=40;
maxheight = 150;
d_btm_inside = 41;
d_btm_wall =17.5;
d_top_inside = 138;
d_top_wall = 2;
t_top = 60;
rotatie_top = 45;
mildfactor = 0.5;
h_tenon = 5;
//---------------
astraal = maxheight/sin(rotatie_top);

difference()
{
//difference()
union()
{
calyx(buiten=true);
calyx(buiten=false);
}

}

module calyx()
{
delta = 1;
for (height = [0:delta:maxheight-delta])
{
percentage = height/maxheight;
percentage2 = (height+delta)/maxheight;

    d_inside    = d_top_inside 
                - sqrt(sqrt(1-percentage))* (d_top_inside -

d_btm_inside);
d_inside2  = d_top_inside
- sqrt(sqrt(1-percentage2))* (d_top_inside -
d_btm_inside);

    d_wall      =   d_top_wall;
    d_wall2     =   d_wall;

    dx_raw      = (d_inside2-d_inside)/2;
    s_raw       = sqrt(dx_raw*dx_raw+delta*delta);
    dx          = d_wall * delta/s_raw;
    dy          = d_wall * dx_raw/s_raw;

    // bepaal de walldikte

    //--------------------------
    hoek = rotatie_top*percentage;
    hoek2 = rotatie_top*percentage2;
        
    if (buiten == true)
        {                      
            cylinder_pie(hoek, hoek2, 
                    -astraal*(1-cos(hoek*percentage))*mildfactor,
                    -astraal*(1-cos(hoek2*percentage2))*mildfactor,
                    height, height+delta-dy,d_inside/2+2*dx,d_inside2/2

+2dx);
}
else
{
cylinder_pie(hoek, hoek2,
-astraal
(1-cos(hoekpercentage))mildfactor,
-astraal
(1-cos(hoek2
percentage2))*mildfactor,
height, height+delta,d_inside/2,d_inside2/2);
}
}
}

module cylinder_pie(angle1, angle2, dx1,dx2,dy1,dy2,r1,r2)
{
// draw top and bottom cylinders
// rotate the cylinder
// hull the cylinders
//
d=0.1;
hull()
{

             translate([ 0,dx1,dy1])
             rotate( angle1, ([1,0,0]))
             translate([0,0,-d])
             cylinder(d,r1, r1, center=false);
           
             translate([ 0,dx2,dy2])
             rotate( angle2, ([1,0,0]))
             translate([0,0,d])  
             cylinder(d,r2, r2, center=false);
      }
}

--
View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p14994.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Below is the code I use. When I change the line 24 union into difference. The rendering take only 8 seconds but my screen becomes white. The object does not appear in the screen or very slooooooow. //bass clarinet bell // version 3 // J.G.Jonker // date: 6-12-2015 $fn=40; maxheight = 150; d_btm_inside = 41; d_btm_wall =17.5; d_top_inside = 138; d_top_wall = 2; t_top = 60; rotatie_top = 45; mildfactor = 0.5; h_tenon = 5; //--------------- astraal = maxheight/sin(rotatie_top); difference() { //difference() union() { calyx(buiten=true); calyx(buiten=false); } } module calyx() { delta = 1; for (height = [0:delta:maxheight-delta]) { percentage = height/maxheight; percentage2 = (height+delta)/maxheight; d_inside = d_top_inside - sqrt(sqrt(1-percentage))* (d_top_inside - d_btm_inside); d_inside2 = d_top_inside - sqrt(sqrt(1-percentage2))* (d_top_inside - d_btm_inside); d_wall = d_top_wall; d_wall2 = d_wall; dx_raw = (d_inside2-d_inside)/2; s_raw = sqrt(dx_raw*dx_raw+delta*delta); dx = d_wall * delta/s_raw; dy = d_wall * dx_raw/s_raw; // bepaal de walldikte //-------------------------- hoek = rotatie_top*percentage; hoek2 = rotatie_top*percentage2; if (buiten == true) { cylinder_pie(hoek, hoek2, -astraal*(1-cos(hoek*percentage))*mildfactor, -astraal*(1-cos(hoek2*percentage2))*mildfactor, height, height+delta-dy,d_inside/2+2*dx,d_inside2/2 +2*dx); } else { cylinder_pie(hoek, hoek2, -astraal*(1-cos(hoek*percentage))*mildfactor, -astraal*(1-cos(hoek2*percentage2))*mildfactor, height, height+delta,d_inside/2,d_inside2/2); } } } module cylinder_pie(angle1, angle2, dx1,dx2,dy1,dy2,r1,r2) { // draw top and bottom cylinders // rotate the cylinder // hull the cylinders // d=0.1; hull() { translate([ 0,dx1,dy1]) rotate( angle1, ([1,0,0])) translate([0,0,-d]) cylinder(d,r1, r1, center=false); translate([ 0,dx2,dy2]) rotate( angle2, ([1,0,0])) translate([0,0,d]) cylinder(d,r2, r2, center=false); } } -- View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p14994.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JJ
Johan Jonker
Sun, Dec 6, 2015 10:35 PM
Some pictures: <http://forum.openscad.org/file/n15000/Bell_2.jpg> <http://forum.openscad.org/file/n15000/kelk.jpg> -- View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15000.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JJ
Johan Jonker
Sun, Dec 6, 2015 10:45 PM

Using import of stl is a very good idea.
It works for $fn=40 and results is a fast object.

http://forum.openscad.org/file/n15001/kelk_solved.jpg

--
View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15001.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Using import of stl is a very good idea. It works for $fn=40 and results is a fast object. <http://forum.openscad.org/file/n15001/kelk_solved.jpg> -- View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15001.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
Neon22
Mon, Dec 7, 2015 5:29 AM

The stepsize for each ring is called Delta in your calyx module.
If you change this to 5 you will see more clearly that the hull() is not
working quite right.
Each step is not the same as the Delta+1 step.
http://forum.openscad.org/file/n15007/bell-hull.png

Mnay ways to refactor but possibly you could refactoring so that you pass in
the thickness of the wall as an arg to the module and calculate the next
ring(for the hull) on basis of +1 to Delta.

So calculation is simple for the inner and outer shapes for the difference.

--
View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15007.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

The stepsize for each ring is called Delta in your calyx module. If you change this to 5 you will see more clearly that the hull() is not working quite right. Each step is not the same as the Delta+1 step. <http://forum.openscad.org/file/n15007/bell-hull.png> Mnay ways to refactor but possibly you could refactoring so that you pass in the thickness of the wall as an arg to the module and calculate the next ring(for the hull) on basis of +1 to Delta. So calculation is simple for the inner and outer shapes for the difference. -- View this message in context: http://forum.openscad.org/Tips-to-keep-the-speed-acceptable-tp14952p15007.html Sent from the OpenSCAD mailing list archive at Nabble.com.