discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

STL problem - globoid worm gear system

P
Parkinbot
Wed, Dec 27, 2017 1:23 AM

With reference to  this thread
http://forum.openscad.org/Parametric-hyperbolic-worm-gear-scripts-tp22724.html
I am currently evaluating a simple and straight forward method to easily
construct properly fitted globoid worm gear / helical gear pairs on the
basis of a simple 2D gear given as polygon. To everyone who is interested,
the math I'm using is rather simple:

  1. I calculate the position of the upper face of a properly twisted (and
    radially distanced) helical gear and do a 360° "Moebius type" sweep with one
    tooth twist.
  2. I do the same with the lower face of the helical gear.
  3. I difference both donuts from a ring and get a properly shaped worm gear
    (see 1st image)

While CGAL tried its best to make my life miserable, I was finally
successful in outputting a non-faulty STL. CGAL forced me to turn down
resolution significantly.  (40 slices per 360° sweep, distance beetween two
polygon points >0.2)

With this done, it was straight forward to difference the worm gear from a
pie to tailor a perfectly adapted tooth allowing spur gear construction.

z = 20;      // # teeth of wormgear
h = 10;    // height of wormgear
m=2;          // modulus
min_r = 10;  // pitch circle radius of worm
Rad = z+min_r;  // outer cycle radius

wormgear();

module wormgear()
{
w = 180/z;
//  forN(0, z)  // arrange z teeth
difference()
{
pie(25, h-.2, -w-.1, w+.1);
color("gold") translate([Rad, 0, 0]) import("worm1.stl");
}
}

module pie(r = 1, h=1, w1=0, w2=0)
rotate([0, 0, w1])  rotate_extrude(angle =  (w2-w1+360)%360)
translate([0,-h/2])  square([r,h]);

The operation looks like that (golden part marking the subtrahend):
http://forum.openscad.org/file/t887/wormgear.png

and shouldn't be too difficult. OpenSCAD (both 2015.3 and 2017.1) lets me
successfully F6-render it and export a STL. I can also construct an entire
spur gear by a union of 20 pies and export that as STL. Here the full 20:1
system after reimport.
http://forum.openscad.org/file/t887/wormgear1.png

The problem now is that OpenSCAD exports faulty STLs containing empty
triags. Here the single pie element
http://forum.openscad.org/file/t887/wormgear2.png

Any ideas?
To me it appears that OpenSCAD doesn't remove faces being mapped to 'empty'
triags in ASCII STL representation. Wouldn't that be easy to implement?

Here the files:
worm1.stl https://www.dropbox.com/s/igusndl4islaigc/worm1.stl?dl=0
faulty pie STL
https://www.dropbox.com/s/x729s57a3sdexfw/wormgear_seg.stl?dl=0

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

With reference to this thread <http://forum.openscad.org/Parametric-hyperbolic-worm-gear-scripts-tp22724.html> I am currently evaluating a simple and straight forward method to easily construct properly fitted globoid worm gear / helical gear pairs on the basis of a simple 2D gear given as polygon. To everyone who is interested, the math I'm using is rather simple: 1. I calculate the position of the upper face of a properly twisted (and radially distanced) helical gear and do a 360° "Moebius type" sweep with one tooth twist. 2. I do the same with the lower face of the helical gear. 3. I difference both donuts from a ring and get a properly shaped worm gear (see 1st image) While CGAL tried its best to make my life miserable, I was finally successful in outputting a non-faulty STL. CGAL forced me to turn down resolution significantly. (40 slices per 360° sweep, distance beetween two polygon points >0.2) With this done, it was straight forward to difference the worm gear from a pie to tailor a perfectly adapted tooth allowing spur gear construction. z = 20; // # teeth of wormgear h = 10; // height of wormgear m=2; // modulus min_r = 10; // pitch circle radius of worm Rad = z+min_r; // outer cycle radius wormgear(); module wormgear() { w = 180/z; // forN(0, z) // arrange z teeth difference() { pie(25, h-.2, -w-.1, w+.1); color("gold") translate([Rad, 0, 0]) import("worm1.stl"); } } module pie(r = 1, h=1, w1=0, w2=0) rotate([0, 0, w1]) rotate_extrude(angle = (w2-w1+360)%360) translate([0,-h/2]) square([r,h]); The operation looks like that (golden part marking the subtrahend): <http://forum.openscad.org/file/t887/wormgear.png> and shouldn't be too difficult. OpenSCAD (both 2015.3 and 2017.1) lets me successfully F6-render it and export a STL. I can also construct an entire spur gear by a union of 20 pies and export that as STL. Here the full 20:1 system after reimport. <http://forum.openscad.org/file/t887/wormgear1.png> The *problem* now is that *OpenSCAD exports faulty STLs* containing empty triags. Here the single pie element <http://forum.openscad.org/file/t887/wormgear2.png> Any ideas? To me it appears that OpenSCAD doesn't remove faces being mapped to 'empty' triags in ASCII STL representation. Wouldn't that be easy to implement? Here the files: worm1.stl <https://www.dropbox.com/s/igusndl4islaigc/worm1.stl?dl=0> faulty pie STL <https://www.dropbox.com/s/x729s57a3sdexfw/wormgear_seg.stl?dl=0> -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Thu, Dec 28, 2017 6:41 PM

​I have no problem​ to render the intersection of the wormgear_seg.stl with
a cube. The same with the wormgear pie I have generated. Besides, I
generated the spur gear from the wormgear(), saved its STL, and rendered
the intersection of that STL with a cube without any trouble.Are you sure
your STL is faulty? By "empty triags" do you mean missing triangles?

2017-12-26 23:23 GMT-02:00 Parkinbot rudolf@parkinbot.com:

With reference to  this thread
<http://forum.openscad.org/Parametric-hyperbolic-worm-
gear-scripts-tp22724.html>
I am currently evaluating a simple and straight forward method to easily
construct properly fitted globoid worm gear / helical gear pairs on the
basis of a simple 2D gear given as polygon. To everyone who is interested,
the math I'm using is rather simple:

  1. I calculate the position of the upper face of a properly twisted (and
    radially distanced) helical gear and do a 360° "Moebius type" sweep with
    one
    tooth twist.
  2. I do the same with the lower face of the helical gear.
  3. I difference both donuts from a ring and get a properly shaped worm gear
    (see 1st image)

While CGAL tried its best to make my life miserable, I was finally
successful in outputting a non-faulty STL. CGAL forced me to turn down
resolution significantly.  (40 slices per 360° sweep, distance beetween two
polygon points >0.2)

With this done, it was straight forward to difference the worm gear from a
pie to tailor a perfectly adapted tooth allowing spur gear construction.

z = 20;      // # teeth of wormgear
h = 10;    // height of wormgear
m=2;          // modulus
min_r = 10;  // pitch circle radius of worm
Rad = z+min_r;  // outer cycle radius

wormgear();

module wormgear()
{
w = 180/z;
//  forN(0, z)  // arrange z teeth
difference()
{
pie(25, h-.2, -w-.1, w+.1);
color("gold") translate([Rad, 0, 0]) import("worm1.stl");
}
}

module pie(r = 1, h=1, w1=0, w2=0)
rotate([0, 0, w1])  rotate_extrude(angle =  (w2-w1+360)%360)
translate([0,-h/2])  square([r,h]);

The operation looks like that (golden part marking the subtrahend):
http://forum.openscad.org/file/t887/wormgear.png

and shouldn't be too difficult. OpenSCAD (both 2015.3 and 2017.1) lets me
successfully F6-render it and export a STL. I can also construct an entire
spur gear by a union of 20 pies and export that as STL. Here the full 20:1
system after reimport.
http://forum.openscad.org/file/t887/wormgear1.png

The problem now is that OpenSCAD exports faulty STLs containing empty
triags. Here the single pie element
http://forum.openscad.org/file/t887/wormgear2.png

Any ideas?
To me it appears that OpenSCAD doesn't remove faces being mapped to 'empty'
triags in ASCII STL representation. Wouldn't that be easy to implement?

Here the files:
worm1.stl https://www.dropbox.com/s/igusndl4islaigc/worm1.stl?dl=0
faulty pie STL
https://www.dropbox.com/s/x729s57a3sdexfw/wormgear_seg.stl?dl=0

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


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

​I have no problem​ to render the intersection of the wormgear_seg.stl with a cube. The same with the wormgear pie I have generated. Besides, I generated the spur gear from the wormgear(), saved its STL, and rendered the intersection of that STL with a cube without any trouble.Are you sure your STL is faulty? By "empty triags" do you mean missing triangles? 2017-12-26 23:23 GMT-02:00 Parkinbot <rudolf@parkinbot.com>: > With reference to this thread > <http://forum.openscad.org/Parametric-hyperbolic-worm- > gear-scripts-tp22724.html> > I am currently evaluating a simple and straight forward method to easily > construct properly fitted globoid worm gear / helical gear pairs on the > basis of a simple 2D gear given as polygon. To everyone who is interested, > the math I'm using is rather simple: > > 1. I calculate the position of the upper face of a properly twisted (and > radially distanced) helical gear and do a 360° "Moebius type" sweep with > one > tooth twist. > 2. I do the same with the lower face of the helical gear. > 3. I difference both donuts from a ring and get a properly shaped worm gear > (see 1st image) > > While CGAL tried its best to make my life miserable, I was finally > successful in outputting a non-faulty STL. CGAL forced me to turn down > resolution significantly. (40 slices per 360° sweep, distance beetween two > polygon points >0.2) > > With this done, it was straight forward to difference the worm gear from a > pie to tailor a perfectly adapted tooth allowing spur gear construction. > > z = 20; // # teeth of wormgear > h = 10; // height of wormgear > m=2; // modulus > min_r = 10; // pitch circle radius of worm > Rad = z+min_r; // outer cycle radius > > wormgear(); > > module wormgear() > { > w = 180/z; > // forN(0, z) // arrange z teeth > difference() > { > pie(25, h-.2, -w-.1, w+.1); > color("gold") translate([Rad, 0, 0]) import("worm1.stl"); > } > } > > module pie(r = 1, h=1, w1=0, w2=0) > rotate([0, 0, w1]) rotate_extrude(angle = (w2-w1+360)%360) > translate([0,-h/2]) square([r,h]); > > The operation looks like that (golden part marking the subtrahend): > <http://forum.openscad.org/file/t887/wormgear.png> > > and shouldn't be too difficult. OpenSCAD (both 2015.3 and 2017.1) lets me > successfully F6-render it and export a STL. I can also construct an entire > spur gear by a union of 20 pies and export that as STL. Here the full 20:1 > system after reimport. > <http://forum.openscad.org/file/t887/wormgear1.png> > > The *problem* now is that *OpenSCAD exports faulty STLs* containing empty > triags. Here the single pie element > <http://forum.openscad.org/file/t887/wormgear2.png> > > Any ideas? > To me it appears that OpenSCAD doesn't remove faces being mapped to 'empty' > triags in ASCII STL representation. Wouldn't that be easy to implement? > > Here the files: > worm1.stl <https://www.dropbox.com/s/igusndl4islaigc/worm1.stl?dl=0> > faulty pie STL > <https://www.dropbox.com/s/x729s57a3sdexfw/wormgear_seg.stl?dl=0> > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
P
Parkinbot
Thu, Dec 28, 2017 10:35 PM

Ronaldo

thanks for checking. You are right, CGAL doesn't complain about this STL
(might have been either a stricken session, or the update to 2017.11 I
installed today resolved it). But see, what Kisslicer reports when loading
the spur gear:
http://forum.openscad.org/file/t887/wormgear3.png
every blue line refers to a "blade edge" triangle indicated in green color.
It is about a hundred instances.

Meanwhile I have ceased to use the involute gear primitive and switched to a
minimalistic geometry, as a worm gear system does not derive any benefit
from involute gears. As expected this speeded up rendering significantly and
squeezed the now faultless STLs by a factor of 6. My test print of a 15:1
system was successful and I will publish the code in Thingiverse, as soon I
find time to comment the code.

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

Ronaldo thanks for checking. You are right, CGAL doesn't complain about this STL (might have been either a stricken session, or the update to 2017.11 I installed today resolved it). But see, what Kisslicer reports when loading the spur gear: <http://forum.openscad.org/file/t887/wormgear3.png> every blue line refers to a "blade edge" triangle indicated in green color. It is about a hundred instances. Meanwhile I have ceased to use the involute gear primitive and switched to a minimalistic geometry, as a worm gear system does not derive any benefit from involute gears. As expected this speeded up rendering significantly and squeezed the now faultless STLs by a factor of 6. My test print of a 15:1 system was successful and I will publish the code in Thingiverse, as soon I find time to comment the code. -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Thu, Dec 28, 2017 11:28 PM

Good to hear that. Well, read it :)

I have tested it with the version 2017.8 .

That is the first time I read that a STL file was accepted by CGAL and
rejected by other program due to degenerated triangles.

Great that you found a better way to do it. I will be waiting for the
thingverse publishing. Great project.

2017-12-28 20:35 GMT-02:00 Parkinbot rudolf@parkinbot.com:

Ronaldo

thanks for checking. You are right, CGAL doesn't complain about this STL
(might have been either a stricken session, or the update to 2017.11 I
installed today resolved it). But see, what Kisslicer reports when loading
the spur gear:
http://forum.openscad.org/file/t887/wormgear3.png
every blue line refers to a "blade edge" triangle indicated in green color.
It is about a hundred instances.

Meanwhile I have ceased to use the involute gear primitive and switched to
a
minimalistic geometry, as a worm gear system does not derive any benefit
from involute gears. As expected this speeded up rendering significantly
and
squeezed the now faultless STLs by a factor of 6. My test print of a 15:1
system was successful and I will publish the code in Thingiverse, as soon I
find time to comment the code.

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


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

Good to hear that. Well, read it :) I have tested it with the version 2017.8 . That is the first time I read that a STL file was accepted by CGAL and rejected by other program due to degenerated triangles. Great that you found a better way to do it. I will be waiting for the thingverse publishing. Great project. 2017-12-28 20:35 GMT-02:00 Parkinbot <rudolf@parkinbot.com>: > Ronaldo > > thanks for checking. You are right, CGAL doesn't complain about this STL > (might have been either a stricken session, or the update to 2017.11 I > installed today resolved it). But see, what Kisslicer reports when loading > the spur gear: > <http://forum.openscad.org/file/t887/wormgear3.png> > every blue line refers to a "blade edge" triangle indicated in green color. > It is about a hundred instances. > > Meanwhile I have ceased to use the involute gear primitive and switched to > a > minimalistic geometry, as a worm gear system does not derive any benefit > from involute gears. As expected this speeded up rendering significantly > and > squeezed the now faultless STLs by a factor of 6. My test print of a 15:1 > system was successful and I will publish the code in Thingiverse, as soon I > find time to comment the code. > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Thu, Dec 28, 2017 11:42 PM

I think that happens often because when exporting to STL the vertices are
converted to floats from infinite precision rationals. Ones that are very
close get collapsed causing degenerate triangles.

On 28 December 2017 at 23:28, Ronaldo Persiano rcmpersiano@gmail.com
wrote:

Good to hear that. Well, read it :)

I have tested it with the version 2017.8 .

That is the first time I read that a STL file was accepted by CGAL and
rejected by other program due to degenerated triangles.

Great that you found a better way to do it. I will be waiting for the
thingverse publishing. Great project.

2017-12-28 20:35 GMT-02:00 Parkinbot rudolf@parkinbot.com:

Ronaldo

thanks for checking. You are right, CGAL doesn't complain about this STL
(might have been either a stricken session, or the update to 2017.11 I
installed today resolved it). But see, what Kisslicer reports when loading
the spur gear:
http://forum.openscad.org/file/t887/wormgear3.png
every blue line refers to a "blade edge" triangle indicated in green
color.
It is about a hundred instances.

Meanwhile I have ceased to use the involute gear primitive and switched
to a
minimalistic geometry, as a worm gear system does not derive any benefit
from involute gears. As expected this speeded up rendering significantly
and
squeezed the now faultless STLs by a factor of 6. My test print of a 15:1
system was successful and I will publish the code in Thingiverse, as soon
I
find time to comment the code.

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


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

I think that happens often because when exporting to STL the vertices are converted to floats from infinite precision rationals. Ones that are very close get collapsed causing degenerate triangles. On 28 December 2017 at 23:28, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > Good to hear that. Well, read it :) > > I have tested it with the version 2017.8 . > > That is the first time I read that a STL file was accepted by CGAL and > rejected by other program due to degenerated triangles. > > Great that you found a better way to do it. I will be waiting for the > thingverse publishing. Great project. > > 2017-12-28 20:35 GMT-02:00 Parkinbot <rudolf@parkinbot.com>: > >> Ronaldo >> >> thanks for checking. You are right, CGAL doesn't complain about this STL >> (might have been either a stricken session, or the update to 2017.11 I >> installed today resolved it). But see, what Kisslicer reports when loading >> the spur gear: >> <http://forum.openscad.org/file/t887/wormgear3.png> >> every blue line refers to a "blade edge" triangle indicated in green >> color. >> It is about a hundred instances. >> >> Meanwhile I have ceased to use the involute gear primitive and switched >> to a >> minimalistic geometry, as a worm gear system does not derive any benefit >> from involute gears. As expected this speeded up rendering significantly >> and >> squeezed the now faultless STLs by a factor of 6. My test print of a 15:1 >> system was successful and I will publish the code in Thingiverse, as soon >> I >> find time to comment the code. >> >> >> >> -- >> Sent from: http://forum.openscad.org/ >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
P
Parkinbot
Fri, Dec 29, 2017 1:09 PM

nophead,

this was my point. Such a collapse can be easily anticipated before
export. The treatment would be to merge a degenerated or blade edge triag
with one of the two neighbor triags have a long edge in common and get a
simpler, but valid STL.

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

nophead, this was my point. Such a collapse can be easily anticipated *before* export. The treatment would be to merge a degenerated or blade edge triag with one of the two neighbor triags have a long edge in common and get a simpler, but valid STL. -- Sent from: http://forum.openscad.org/
AC
Alan Cox
Sat, Dec 30, 2017 7:44 PM

On Thu, 28 Dec 2017 23:42:51 +0000
nop head nop.head@gmail.com wrote:

I think that happens often because when exporting to STL the vertices are
converted to floats from infinite precision rationals. Ones that are very
close get collapsed causing degenerate triangles.

It's basically a bug in the STL exporter involved. An STL exporter isn't
supposed to produce degenerate triangles. It should use a point
dictionary so it notices when two points co-incide and if so either
eliminate the degenerate triangles or jiggle the values so the point (and
sometimes several points) are moved by the smallest fractional value to
make them distinct IEEE floating point values.

OpenSCAD at least defaults away from using binary stl formats which are
the worst for this.

Alan

On Thu, 28 Dec 2017 23:42:51 +0000 nop head <nop.head@gmail.com> wrote: > I think that happens often because when exporting to STL the vertices are > converted to floats from infinite precision rationals. Ones that are very > close get collapsed causing degenerate triangles. It's basically a bug in the STL exporter involved. An STL exporter isn't supposed to produce degenerate triangles. It should use a point dictionary so it notices when two points co-incide and if so either eliminate the degenerate triangles or jiggle the values so the point (and sometimes several points) are moved by the smallest fractional value to make them distinct IEEE floating point values. OpenSCAD at least defaults away from using binary stl formats which are the worst for this. Alan
MK
Marius Kintel
Sat, Dec 30, 2017 8:16 PM

On Dec 29, 2017, at 8:09 AM, Parkinbot rudolf@parkinbot.com wrote:

he treatment would be to merge a degenerated or blade edge triag
with one of the two neighbor triags have a long edge in common and get a
simpler, but valid STL.

That’s indeed a way to fixup a bad mesh, but not as trivial to implement once you dig deeper, see here for some discussion:
https://github.com/openscad/openscad/issues/1580

There was also a bit of discussion on this topic on the mailing list a while back. Carsten implemented an algorithm that seems to work well. He used some proprietary components and couldn’t share his code, but he did outline his algorithm. Cannot find the post atm..

-Marius

> On Dec 29, 2017, at 8:09 AM, Parkinbot <rudolf@parkinbot.com> wrote: > > he treatment would be to merge a degenerated or blade edge triag > with one of the two neighbor triags have a long edge in common and get a > simpler, but valid STL. > That’s indeed a way to fixup a bad mesh, but not as trivial to implement once you dig deeper, see here for some discussion: https://github.com/openscad/openscad/issues/1580 There was also a bit of discussion on this topic on the mailing list a while back. Carsten implemented an algorithm that seems to work well. He used some proprietary components and couldn’t share his code, but he did outline his algorithm. Cannot find the post atm.. -Marius
CA
Carsten Arnholm
Sun, Dec 31, 2017 1:47 PM

On 30. des. 2017 21:16, Marius Kintel wrote:

On Dec 29, 2017, at 8:09 AM, Parkinbot rudolf@parkinbot.com wrote:

he treatment would be to merge a degenerated or blade edge triag
with one of the two neighbor triags have a long edge in common and
get a simpler, but valid STL.

That’s indeed a way to fixup a bad mesh, but not as trivial to
implement once you dig deeper, see here for some discussion:
https://github.com/openscad/openscad/issues/1580

There was also a bit of discussion on this topic on the mailing list
a while back. Carsten implemented an algorithm that seems to work
well. He used some proprietary components and couldn’t share his code,
but he did outline his algorithm. Cannot find the post atm..

On 30. des. 2017 21:16, Marius Kintel wrote: > >> On Dec 29, 2017, at 8:09 AM, Parkinbot <rudolf@parkinbot.com> wrote: >> >> he treatment would be to merge a degenerated or blade edge triag >> with one of the two neighbor triags have a long edge in common and >> get a simpler, but valid STL. >> > That’s indeed a way to fixup a bad mesh, but not as trivial to > implement once you dig deeper, see here for some discussion: > https://github.com/openscad/openscad/issues/1580 > > There was also a bit of discussion on this topic on the mailing list > a while back. Carsten implemented an algorithm that seems to work > well. He used some proprietary components and couldn’t share his code, > but he did outline his algorithm. Cannot find the post atm.. > That post is at: http://forum.openscad.org/Why-is-this-not-an-error-td19430.html#a19440 Carsten Arnholm
P
Parkinbot
Mon, Jan 1, 2018 4:43 PM

Marius,

I wouldn't mix up mesh repair for input and mesh coarsing for output.
For output, where you start with a supposedly valid representation, it is as
easy as merging two vertices too close to be distiguishable by the used
output format into one and suppressing the two facets affected by this
operation.

As the code and STL excerpt below show, STL output is done on the basis of 6
valid decimal digits, while a single (23 bit mantissa) can express the range
-3,40282347 to 3,40282347 which is obviously almost 8.5 decimals. Therefore
any proper STL output must have a coarsening step in the proposed way. I
don't know how OpenSCAD actually deals with it internally, but if I had to
implement it, I would use a compare of the 6 digit decimal representation or
at least a minimal distance criterion that sufficiently covers this loss of
precision.

cube(sqrt(2)); translate([100, 0, 0]) cube(sqrt(2));

...
facet normal 0 -1 -0
outer loop
vertex 1.41421 0 1.41421
vertex 0 0 0
vertex 1.41421 0 0
endloop
endfacet
facet normal -1 0 0
outer loop
vertex 100 0 0
vertex 100 1.41421 1.41421
vertex 100 1.41421 0
endloop
endfacet
...

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

Marius, I wouldn't mix up mesh repair for input and mesh coarsing for output. For output, where you start with a supposedly valid representation, it is as easy as merging two vertices too close to be distiguishable by the used output format into one and suppressing the two facets affected by this operation. As the code and STL excerpt below show, STL output is done on the basis of 6 valid decimal digits, while a single (23 bit mantissa) can express the range -3,40282347 to 3,40282347 which is obviously almost 8.5 decimals. Therefore any proper STL output must have a coarsening step in the proposed way. I don't know how OpenSCAD actually deals with it internally, but if I had to implement it, I would use a compare of the 6 digit decimal representation or at least a minimal distance criterion that sufficiently covers this loss of precision. cube(sqrt(2)); translate([100, 0, 0]) cube(sqrt(2)); ... facet normal 0 -1 -0 outer loop vertex 1.41421 0 1.41421 vertex 0 0 0 vertex 1.41421 0 0 endloop endfacet facet normal -1 0 0 outer loop vertex 100 0 0 vertex 100 1.41421 1.41421 vertex 100 1.41421 0 endloop endfacet ... -- Sent from: http://forum.openscad.org/