discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Strange things happening when doing difference

T
Troberg
Mon, Dec 11, 2017 12:52 PM

Look at the following code to draw a heart (it's Christmas, after all). The
first module draws a heart, but I also wanted just a heart outline, so I
made the second. It works by drawing a heart, then drawing a heart of
similar size, do a negative offset, extrude and difference.

module hjarta(width,tjocklek){
spets=width*0.7;

color([1,0,0])
linear_extrude(tjocklek)
union(){
    hull(){
        translate([-width/4,spets,0])
        circle(d=width/2);
        
        polygon([[0,0],[1,spets],[-width/2,spets]]);
    }
    hull(){
        translate([width/4,spets,0])
        circle(d=width/2);
        
        polygon([[0,0],[width/2,spets],[-1,spets]]);
    }
}

}

module hjartaoutline(width,outlinewidth,tjocklek){
spets=width*0.7;

color([1,0,0])
difference(){
    hjarta(width,tjocklek);
    
    translate([0,0,-1])
    linear_extrude(tjocklek+2)
    offset(delta=-outlinewidth)
    union(){
        hull(){
            translate([-width/4,spets,0])
            circle(d=width/2);
            
            polygon([[0,0],[1,spets],[-width/2,spets]]);
        }
        hull(){
            translate([width/4,spets,0])
            circle(d=width/2);
            
            polygon([[0,0],[width/2,spets],[-1,spets]]);
        }
    }
}

}

hjartaoutline(60,5,10);

It looks great from above, but zoom in and look from a low angle at the area
around the inner tip, and it looks like faces are missing.

What am I doing wrong?

(Of course, if anyone wants to use the heart code, have fun.)

--
Sent from: http://forum.openscad.org/

Look at the following code to draw a heart (it's Christmas, after all). The first module draws a heart, but I also wanted just a heart outline, so I made the second. It works by drawing a heart, then drawing a heart of similar size, do a negative offset, extrude and difference. module hjarta(width,tjocklek){ spets=width*0.7; color([1,0,0]) linear_extrude(tjocklek) union(){ hull(){ translate([-width/4,spets,0]) circle(d=width/2); polygon([[0,0],[1,spets],[-width/2,spets]]); } hull(){ translate([width/4,spets,0]) circle(d=width/2); polygon([[0,0],[width/2,spets],[-1,spets]]); } } } module hjartaoutline(width,outlinewidth,tjocklek){ spets=width*0.7; color([1,0,0]) difference(){ hjarta(width,tjocklek); translate([0,0,-1]) linear_extrude(tjocklek+2) offset(delta=-outlinewidth) union(){ hull(){ translate([-width/4,spets,0]) circle(d=width/2); polygon([[0,0],[1,spets],[-width/2,spets]]); } hull(){ translate([width/4,spets,0]) circle(d=width/2); polygon([[0,0],[width/2,spets],[-1,spets]]); } } } } hjartaoutline(60,5,10); It looks great from above, but zoom in and look from a low angle at the area around the inner tip, and it looks like faces are missing. What am I doing wrong? (Of course, if anyone wants to use the heart code, have fun.) -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Mon, Dec 11, 2017 1:19 PM

Your rendered model is fine. The missing faces are artifacts of the preview
process. To avoid them just add the argument convexity=10 to all
linear_extrude().

See:
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/2D_to_3D_Extrusion#Linear_Extrude
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/2D_to_3D_Extrusion#Linear_Extrude

2017-12-11 10:52 GMT-02:00 Troberg troberg.anders@gmail.com:

Look at the following code to draw a heart (it's Christmas, after all). The
first module draws a heart, but I also wanted just a heart outline, so I
made the second. It works by drawing a heart, then drawing a heart of
similar size, do a negative offset, extrude and difference.

module hjarta(width,tjocklek){
spets=width*0.7;

 color([1,0,0])
 linear_extrude(tjocklek)
 union(){
     hull(){
         translate([-width/4,spets,0])
         circle(d=width/2);

         polygon([[0,0],[1,spets],[-width/2,spets]]);
     }
     hull(){
         translate([width/4,spets,0])
         circle(d=width/2);

         polygon([[0,0],[width/2,spets],[-1,spets]]);
     }
 }

}

module hjartaoutline(width,outlinewidth,tjocklek){
spets=width*0.7;

 color([1,0,0])
 difference(){
     hjarta(width,tjocklek);

     translate([0,0,-1])
     linear_extrude(tjocklek+2)
     offset(delta=-outlinewidth)
     union(){
         hull(){
             translate([-width/4,spets,0])
             circle(d=width/2);

             polygon([[0,0],[1,spets],[-width/2,spets]]);
         }
         hull(){
             translate([width/4,spets,0])
             circle(d=width/2);

             polygon([[0,0],[width/2,spets],[-1,spets]]);
         }
     }
 }

}

hjartaoutline(60,5,10);

It looks great from above, but zoom in and look from a low angle at the
area
around the inner tip, and it looks like faces are missing.

What am I doing wrong?

(Of course, if anyone wants to use the heart code, have fun.)

--
Sent from: http://forum.openscad.org/


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

Your rendered model is fine. The missing faces are artifacts of the preview process. To avoid them just add the argument convexity=10 to all linear_extrude(). See: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/2D_to_3D_Extrusion#Linear_Extrude <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/2D_to_3D_Extrusion#Linear_Extrude> 2017-12-11 10:52 GMT-02:00 Troberg <troberg.anders@gmail.com>: > Look at the following code to draw a heart (it's Christmas, after all). The > first module draws a heart, but I also wanted just a heart outline, so I > made the second. It works by drawing a heart, then drawing a heart of > similar size, do a negative offset, extrude and difference. > > module hjarta(width,tjocklek){ > spets=width*0.7; > > color([1,0,0]) > linear_extrude(tjocklek) > union(){ > hull(){ > translate([-width/4,spets,0]) > circle(d=width/2); > > polygon([[0,0],[1,spets],[-width/2,spets]]); > } > hull(){ > translate([width/4,spets,0]) > circle(d=width/2); > > polygon([[0,0],[width/2,spets],[-1,spets]]); > } > } > } > > module hjartaoutline(width,outlinewidth,tjocklek){ > spets=width*0.7; > > color([1,0,0]) > difference(){ > hjarta(width,tjocklek); > > translate([0,0,-1]) > linear_extrude(tjocklek+2) > offset(delta=-outlinewidth) > union(){ > hull(){ > translate([-width/4,spets,0]) > circle(d=width/2); > > polygon([[0,0],[1,spets],[-width/2,spets]]); > } > hull(){ > translate([width/4,spets,0]) > circle(d=width/2); > > polygon([[0,0],[width/2,spets],[-1,spets]]); > } > } > } > } > > hjartaoutline(60,5,10); > > It looks great from above, but zoom in and look from a low angle at the > area > around the inner tip, and it looks like faces are missing. > > What am I doing wrong? > > (Of course, if anyone wants to use the heart code, have fun.) > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
T
Troberg
Mon, Dec 11, 2017 2:12 PM

Worked like a charm!

I kept think I've done something wrong in my logic, and kept checking that.
I didn't think as far as the under the hood considerations.

--
Sent from: http://forum.openscad.org/

Worked like a charm! I kept think I've done something wrong in my logic, and kept checking that. I didn't think as far as the under the hood considerations. -- Sent from: http://forum.openscad.org/
JB
Jordan Brown
Mon, Dec 11, 2017 4:02 PM

On 12/11/2017 5:19 AM, Ronaldo Persiano wrote:

Your rendered model is fine. The missing faces are artifacts of the
preview process. To avoid them just add the argument convexity=10 to
all linear_extrude().

Why isn't convexity=10 (or whatever) the default?  What's the downside? 
Should I be defining my own linear_extrude module that just always slaps
in a convexity=10?

On 12/11/2017 5:19 AM, Ronaldo Persiano wrote: > Your rendered model is fine. The missing faces are artifacts of the > preview process. To avoid them just add the argument convexity=10 to > all linear_extrude(). Why isn't convexity=10 (or whatever) the default?  What's the downside?  Should I be defining my own linear_extrude module that just always slaps in a convexity=10?
ER
Ezra Reynolds
Mon, Dec 11, 2017 4:47 PM

There is a performance penalty for convexity.  More convex shapes need a higher convexity setting; setting it manually allows for user control.

Sent from my iPhone

On Dec 11, 2017, at 11:02 AM, Jordan Brown openscad@jordan.maileater.net wrote:

On 12/11/2017 5:19 AM, Ronaldo Persiano wrote:
Your rendered model is fine. The missing faces are artifacts of the preview process. To avoid them just add the argument convexity=10 to all linear_extrude().

Why isn't convexity=10 (or whatever) the default?  What's the downside?  Should I be defining my own linear_extrude module that just always slaps in a convexity=10?


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

There is a performance penalty for convexity. More convex shapes need a higher convexity setting; setting it manually allows for user control. Sent from my iPhone > On Dec 11, 2017, at 11:02 AM, Jordan Brown <openscad@jordan.maileater.net> wrote: > >> On 12/11/2017 5:19 AM, Ronaldo Persiano wrote: >> Your rendered model is fine. The missing faces are artifacts of the preview process. To avoid them just add the argument convexity=10 to all linear_extrude(). > > Why isn't convexity=10 (or whatever) the default? What's the downside? Should I be defining my own linear_extrude module that just always slaps in a convexity=10? > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
T
Troberg
Mon, Dec 11, 2017 8:45 PM

Well, he has a point. Perhaps a higher default would make sense.

Why?

  • Because the people who are likely to run into performance issues are the
    ones who are more advanced users. They can probably explicitly set a lower
    limit.

  • Because performance of the hardware is increasing all the time, so
    performance issues are likely to go away, given time.

  • Standard programming wisdom: Make it work first, then look at performance.

  • It wouldn't break existing code.

--
Sent from: http://forum.openscad.org/

Well, he has a point. Perhaps a higher default would make sense. Why? * Because the people who are likely to run into performance issues are the ones who are more advanced users. They can probably explicitly set a lower limit. * Because performance of the hardware is increasing all the time, so performance issues are likely to go away, given time. * Standard programming wisdom: Make it work first, then look at performance. * It wouldn't break existing code. -- Sent from: http://forum.openscad.org/
CC
Chris Camacho
Mon, Dec 11, 2017 10:00 PM
  • Because the people who are likely to run into performance issues are the
    ones who are more advanced users. They can probably explicitly set a lower
    limit.

Save for the fact that often on this list people complaining of
excessive "compile" times are those that have (seemingly) randomly
changed defaults and unknowingly created models with a bazillion vertices...

> * Because the people who are likely to run into performance issues are the > ones who are more advanced users. They can probably explicitly set a lower > limit. Save for the fact that often on this list people complaining of excessive "compile" times are those that have (seemingly) randomly changed defaults and unknowingly created models with a bazillion vertices...
NH
nop head
Mon, Dec 11, 2017 11:16 PM

convexity only affects F5 preview times. It doesn't seem to affect it much
either. When I can be bothered I set it appropriately, other times a random
number big enough.

On 11 December 2017 at 22:00, Chris Camacho chris@bedroomcoders.co.uk
wrote:

  • Because the people who are likely to run into performance issues are the

ones who are more advanced users. They can probably explicitly set a lower
limit.

Save for the fact that often on this list people complaining of excessive
"compile" times are those that have (seemingly) randomly changed defaults
and unknowingly created models with a bazillion vertices...


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

convexity only affects F5 preview times. It doesn't seem to affect it much either. When I can be bothered I set it appropriately, other times a random number big enough. On 11 December 2017 at 22:00, Chris Camacho <chris@bedroomcoders.co.uk> wrote: > * Because the people who are likely to run into performance issues are the >> ones who are more advanced users. They can probably explicitly set a lower >> limit. >> > Save for the fact that often on this list people complaining of excessive > "compile" times are those that have (seemingly) randomly changed defaults > and unknowingly created models with a bazillion vertices... > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >