discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] stl not correct by mesh generators

P
Parkinbot
Sun, Apr 16, 2017 6:12 PM

This is a nasty problem and results from very small numerical "errors" that
occur with rotation.
As a workaround you can enlarge your first cube by a small number.

color("cyan")
translate([10, 0, 200]) rotate([0,20,0])
linear_extrude(height = 200, convexity = 10, twist = 0)
square([200, 35.01], center = true);

--
View this message in context: http://forum.openscad.org/stl-not-correct-by-mesh-generators-tp21241p21245.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

This is a nasty problem and results from very small numerical "errors" that occur with rotation. As a workaround you can enlarge your first cube by a small number. > color("cyan") > translate([10, 0, 200]) rotate([0,20,0]) > linear_extrude(height = 200, convexity = 10, twist = 0) > square([200, 35.01], center = true); -- View this message in context: http://forum.openscad.org/stl-not-correct-by-mesh-generators-tp21241p21245.html Sent from the OpenSCAD mailing list archive at Nabble.com.
RP
Ronaldo Persiano
Sun, Apr 16, 2017 7:15 PM

Scaling the linear_extrusion before the rotation and translation makes
things worst.

2017-04-16 15:12 GMT-03:00 Parkinbot rudolf@parkinbot.com:

This is a nasty problem and results from very small numerical "errors" that
occur with rotation.
As a workaround you can enlarge your first cube by a small number.

color("cyan")
translate([10, 0, 200]) rotate([0,20,0])
linear_extrude(height = 200, convexity = 10, twist = 0)
square([200, 35.01], center = true);

--
View this message in context: http://forum.openscad.org/stl-
not-correct-by-mesh-generators-tp21241p21245.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


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

Scaling the linear_extrusion before the rotation and translation makes things worst. 2017-04-16 15:12 GMT-03:00 Parkinbot <rudolf@parkinbot.com>: > This is a nasty problem and results from very small numerical "errors" that > occur with rotation. > As a workaround you can enlarge your first cube by a small number. > > > > color("cyan") > > translate([10, 0, 200]) rotate([0,20,0]) > > linear_extrude(height = 200, convexity = 10, twist = 0) > > square([200, 35.01], center = true); > > > > > > -- > View this message in context: http://forum.openscad.org/stl- > not-correct-by-mesh-generators-tp21241p21245.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
W
wolf
Mon, Apr 17, 2017 8:35 AM

For the why's, or what happens inside OpenSCAD, see my comments in
http://forum.openscad.org/template/NamlServlet.jtp?macro=reply&amp;node=21240
This is about the practical side, how to fix it.

  1. Find the trouble spots
    A sure way of creating internal rounding errors is rotating by 90 degrees.
    These rounding errors then show up in the F6 graphic (F5 works differently,
    it usually does not show it) as edges that cut straight through so-called
    "flat" polygons.
    http://forum.openscad.org/file/n21258/KingOfTomorrow.jpg
    In the picture, "A","B", . . . mark edges that would not be shown if the
    respective polygons were truly flat. By itself, that is no hassle, but when
    you try to union shapes with nearly parallel faces, CGAL starts screaming:
    ASSERTION ERROR!!!
  2. To correct it you use CGAL's ability to work without internal rounding
    errors, see this code:
    // fixed version

difference()
{
union()
{ $fn=100;
Front();
translate([80, -150, 500])  Cyl();
translate([80, -300, 500])  Cyl();
translate([80, -450, 500])  Cyl();
translate([80, -230, 500])  rotate([90,0,0])  cylinder (h = 440, r=180,
center = true);
}
translate([80, -250, 500]) rotate([90,0,0])  cylinder (h = 1200, r=150,
center = true, $fn=10);
}

module Cyl()    // ensure the cylinder's top and bottom are truly vertical
difference()
{
rotate([90,0,0])  cylinder (h = 45, r=250, center = true);
translate([0,-17.5,0]) cube([600,10,600],center=true);
translate([0,17.5,0]) cube([600,10,600],center=true);
}

module Front()
difference()
{  // with twist the extruded shape will rotate around the Z axis
union()
{
translate([10, 0, 0])
linear_extrude(height = 200, convexity = 10, twist = 0)
square([200, 45], center = true);
translate([10, 0, 200]) rotate([0,20,0])
linear_extrude(height = 200, convexity = 10, twist = 0)
square([200, 45], center = true);
translate([80, 0, 500])  rotate([90,0,0])  cylinder (h = 45, r=250,
center = true);
}
translate([80,-17.5,300]) cube([600,10,1000],center=true);
translate([80,17.5,300]) cube([600,10,1000],center=true);
}

By the way: with a $fn=100, there are far too many edges, above picture uses
$fn=10. The excess edges on the inside of the cylinder are currently
harmless, that is going to change if you do something with it . . .

wolf

--
View this message in context: http://forum.openscad.org/stl-not-correct-by-mesh-generators-tp21241p21258.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

For the why's, or what happens inside OpenSCAD, see my comments in <http://forum.openscad.org/template/NamlServlet.jtp?macro=reply&amp;node=21240> This is about the practical side, how to fix it. 1. Find the trouble spots A sure way of creating internal rounding errors is rotating by 90 degrees. These rounding errors then show up in the F6 graphic (F5 works differently, it usually does not show it) as edges that cut straight through so-called "flat" polygons. <http://forum.openscad.org/file/n21258/KingOfTomorrow.jpg> In the picture, "A","B", . . . mark edges that would not be shown if the respective polygons were truly flat. By itself, that is no hassle, but when you try to union shapes with nearly parallel faces, CGAL starts screaming: ASSERTION ERROR!!! 2. To correct it you use CGAL's ability to work without internal rounding errors, see this code: // fixed version difference() { union() { $fn=100; Front(); translate([80, -150, 500]) Cyl(); translate([80, -300, 500]) Cyl(); translate([80, -450, 500]) Cyl(); translate([80, -230, 500]) rotate([90,0,0]) cylinder (h = 440, r=180, center = true); } translate([80, -250, 500]) rotate([90,0,0]) cylinder (h = 1200, r=150, center = true, $fn=10); } module Cyl() // ensure the cylinder's top and bottom are truly vertical difference() { rotate([90,0,0]) cylinder (h = 45, r=250, center = true); translate([0,-17.5,0]) cube([600,10,600],center=true); translate([0,17.5,0]) cube([600,10,600],center=true); } module Front() difference() { // with twist the extruded shape will rotate around the Z axis union() { translate([10, 0, 0]) linear_extrude(height = 200, convexity = 10, twist = 0) square([200, 45], center = true); translate([10, 0, 200]) rotate([0,20,0]) linear_extrude(height = 200, convexity = 10, twist = 0) square([200, 45], center = true); translate([80, 0, 500]) rotate([90,0,0]) cylinder (h = 45, r=250, center = true); } translate([80,-17.5,300]) cube([600,10,1000],center=true); translate([80,17.5,300]) cube([600,10,1000],center=true); } By the way: with a $fn=100, there are far too many edges, above picture uses $fn=10. The excess edges on the inside of the cylinder are currently harmless, that is going to change if you do something with it . . . wolf -- View this message in context: http://forum.openscad.org/stl-not-correct-by-mesh-generators-tp21241p21258.html Sent from the OpenSCAD mailing list archive at Nabble.com.