discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: STL best practices & tools

NH
nop head
Wed, Jun 7, 2023 9:54 PM

Not sure why you say bottleneck. I have designed hundreds of objects and
never had a problem with them having overlaps so that they create solid
objects. My threads all slightly overlap the inner or outer cylinders
because they are created by a reusable routine that does that.

On Wed, 7 Jun 2023, 22:44 neri-engineering via Discuss, <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: neri-engineering neri-engineering@protonmail.com
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc:
Bcc:
Date: Wed, 07 Jun 2023 21:43:02 +0000
Subject: [OpenSCAD] Re: STL best practices & tools
Yes, I understand your "overlap by nudging a diameter slightly" strategy.
I see traces of that in other people's open source code, all over the place.

It's "only a workaround" (not good practice in general) because if you
want to begin to do truly powerful things, by combining pieces of re-usable
code in various ways, in ways that you have not yet even considered, then
you'll soon realize that the "nudge strategy" will lead to all sorts of
bottlenecks.  This is why I've decided that the only elegant solution is to
address the issue in OpenSCAD, in CGAL, or in any other piece of code that
is forcing you to do things this way.

By the way... "bottlenecks" and "forcing you to do things"... hrm where
else do I see that pattern.

I am still investigating.  This is a large undertaking.

Sent with Proton Mail https://proton.me/ secure email.

------- Original Message -------
On Wednesday, June 7th, 2023 at 3:24 PM, nop head nop.head@gmail.com
wrote:

I don't know how you get 11 volumes. It should be just two. If made an
object like that with my library it would just be two, the inside and the
outside. My threads slightly overlap the cylinder they surround and gears
are just linear extruded from 2D versions so are always just one piece.

On Wed, 7 Jun 2023, 21:13 neri-engineering via Discuss, <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: neri-engineering neri-engineering@protonmail.com
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc:
Bcc:
Date: Wed, 07 Jun 2023 20:12:18 +0000
Subject: [OpenSCAD] Re: STL best practices & tools
By the way I'm not necessarily looking for a solution. I am studying an
interesting issue because that study itself is a very worthwhile endeavor;
such studies oftentimes lead to very interesting new techniques for solving
problems.

I'm going bottom-up and top-down at the same time to try to nail down a
simple example (consisting of two simple polyhedron) which demonstrates my
"issue that I am studying" - which is an STL file compiled without warnings
or errors, yet which contains more than one volume (where two polyhedron
are touching at a face, in a very natural and non-disturbing manner).

I am starting on the bottom-up approach, but I did manage to isolate
something from the top-down avenue; this screenshot below shows that I'm
able to compile a part without errors or warnings from CGAL yet it consists
of more than one 3D piece. So no, I wasn't imagining things, and I wasn't
delusional, in my earlier statements.

[image: screw.png]

I'm still working on the bottom-up so I can give code for exposing this
issue, then I will continue further on studying possible workarounds to
this issue (whether post-STL-generation or actually finding an easy fix in
OpenSCAD and/or CGAL, e.g. maybe it's just a matter of casting to 32 bits
too early).

I'm not looking for a temporary workaround; I find the study itself to be
fascinating. I want to get to the bottom of this to see if there are any
elegant low-hanging-fruit solutions that can be suggested.

The fact that my models consist of many pieces does not bother me
whatsoever. However, eventually it will become an issue. For example
working with other tools sometimes leads to issues, e.g. the to->FreeCAD
importer, and I also had some machinists complain about my STL files, which
was embarrassing to me.

Sent with Proton Mail https://proton.me/ secure email.

------- Original Message -------
On Wednesday, June 7th, 2023 at 2:32 PM, Carsten Arnholm <
arnholm@arnholm.org> wrote:

On 07.06.2023 19:04, neri-engineering wrote:

Are there any tips/docs on how to use polyfix.

It is a command line program with these options

Usage: polyfix [-verbose] [-maxiter <str>] [-dtol <str>] [-atol <str>]
[-lumps] [-nflip] [-remesh <str>] [-overwrite] [-out <str>] [-zip]
[-v] <input_filename>
-verbose Verbose messages
-maxiter=<str> [heal] Max iterations (def=10)
-dtol=<str> [heal] Distance tolerance (def=1.0E-2)
-atol=<str> [heal] Area tolerance (def=1.0E-6)
-lumps [heal] Split into lumps (not supported for stl output)
-nflip [heal] Flip faces with inward normals (experimental)
-remesh=<str> [remesh] Heal & remesh surfaces to given edge length (set
dtol to small value ~1.E-6)
-overwrite [output] allow file overwrite, including input file.
-out=<str> [output] output filename/format (.obj, .off, .amf, .stl,
.astl)
-zip [output] save output also to compressed zip file
-v Show version number only

In the short term I want to pass in a single STL file and have it reconcile faces that are coplanar and overlapping by area, facing in opposite directions (relative to "outside").  This operation could be done on a single connected polyhedron which has "spikes" that touch or very nearly touch, as well.  I presume that an epsilon value is being used; I saw something in the source code.

The dtol parameter is your epsilon parameter, it is the tolerance for
merging vertices of the "triangle soup" that is STL.

The atol parameter is the minimal triangle area required for an STL
triangle to be valid.

example use, merge STL vertices and remove resulting zero area faces,
output as *.off format

$ polyfix vase_with_handle.stl -out=off

Parameters:
input_file = vase_with_handle.stl
out = off

polyhedron 0 ================= volume=3789.18, dtol=0.01, atol=1e-06,
maxiter=10
iteration 0: vertices=108390 faces=36130
warning: nonmanifold edges: uc(1)=108390
merged 90337 vertices
removed 24 collapsed or zero area faces
total changes=90361
no warnings

iteration 1: vertices=18053 faces=36106
total changes=0
no warnings

Summary:
polyhedron 0: vertices=18053 faces=36106 : no warnings

Writing: vase_with_handle.off
... polyfix finished, time used: 0d 00h 00m 01s

Obviously you can override the defaults for dtol, atol etc.

Good luck

Carsten Arnholm

---------- Forwarded message ----------
From: neri-engineering via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc: neri-engineering neri-engineering@protonmail.com
Bcc:
Date: Wed, 07 Jun 2023 20:12:18 +0000
Subject: [OpenSCAD] Re: STL best practices & tools


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: neri-engineering via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc: neri-engineering neri-engineering@protonmail.com
Bcc:
Date: Wed, 07 Jun 2023 21:43:02 +0000
Subject: [OpenSCAD] Re: STL best practices & tools


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Not sure why you say bottleneck. I have designed hundreds of objects and never had a problem with them having overlaps so that they create solid objects. My threads all slightly overlap the inner or outer cylinders because they are created by a reusable routine that does that. On Wed, 7 Jun 2023, 22:44 neri-engineering via Discuss, < discuss@lists.openscad.org> wrote: > > > > ---------- Forwarded message ---------- > From: neri-engineering <neri-engineering@protonmail.com> > To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> > Cc: > Bcc: > Date: Wed, 07 Jun 2023 21:43:02 +0000 > Subject: [OpenSCAD] Re: STL best practices & tools > Yes, I understand your "overlap by nudging a diameter slightly" strategy. > I see traces of that in other people's open source code, all over the place. > > It's "only a workaround" (not good practice in general) because if you > want to begin to do truly powerful things, by combining pieces of re-usable > code in various ways, in ways that you have not yet even considered, then > you'll soon realize that the "nudge strategy" will lead to all sorts of > bottlenecks. This is why I've decided that the only elegant solution is to > address the issue in OpenSCAD, in CGAL, or in any other piece of code that > is forcing you to do things this way. > > By the way... "bottlenecks" and "forcing you to do things"... hrm where > else do I see that pattern. > > I am still investigating. This is a large undertaking. > > Sent with Proton Mail <https://proton.me/> secure email. > > ------- Original Message ------- > On Wednesday, June 7th, 2023 at 3:24 PM, nop head <nop.head@gmail.com> > wrote: > > I don't know how you get 11 volumes. It should be just two. If made an > object like that with my library it would just be two, the inside and the > outside. My threads slightly overlap the cylinder they surround and gears > are just linear extruded from 2D versions so are always just one piece. > > On Wed, 7 Jun 2023, 21:13 neri-engineering via Discuss, < > discuss@lists.openscad.org> wrote: > >> >> >> >> ---------- Forwarded message ---------- >> From: neri-engineering <neri-engineering@protonmail.com> >> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> >> Cc: >> Bcc: >> Date: Wed, 07 Jun 2023 20:12:18 +0000 >> Subject: [OpenSCAD] Re: STL best practices & tools >> By the way I'm not necessarily looking for a solution. I am studying an >> interesting issue because that study itself is a very worthwhile endeavor; >> such studies oftentimes lead to very interesting new techniques for solving >> problems. >> >> I'm going bottom-up and top-down at the same time to try to nail down a >> simple example (consisting of two simple polyhedron) which demonstrates my >> "issue that I am studying" - which is an STL file compiled without warnings >> or errors, yet which contains more than one volume (where two polyhedron >> are touching at a face, in a very natural and non-disturbing manner). >> >> I am starting on the bottom-up approach, but I did manage to isolate >> something from the top-down avenue; this screenshot below shows that I'm >> able to compile a part without errors or warnings from CGAL yet it consists >> of more than one 3D piece. So no, I wasn't imagining things, and I wasn't >> delusional, in my earlier statements. >> >> [image: screw.png] >> >> I'm still working on the bottom-up so I can give code for exposing this >> issue, then I will continue further on studying possible workarounds to >> this issue (whether post-STL-generation or actually finding an easy fix in >> OpenSCAD and/or CGAL, e.g. maybe it's just a matter of casting to 32 bits >> too early). >> >> I'm not looking for a temporary workaround; I find the study itself to be >> fascinating. I want to get to the bottom of this to see if there are any >> elegant low-hanging-fruit solutions that can be suggested. >> >> The fact that my models consist of many pieces does not bother me >> whatsoever. However, eventually it will become an issue. For example >> working with other tools sometimes leads to issues, e.g. the to->FreeCAD >> importer, and I also had some machinists complain about my STL files, which >> was embarrassing to me. >> >> Sent with Proton Mail <https://proton.me/> secure email. >> >> ------- Original Message ------- >> On Wednesday, June 7th, 2023 at 2:32 PM, Carsten Arnholm < >> arnholm@arnholm.org> wrote: >> >> On 07.06.2023 19:04, neri-engineering wrote: >> >> Are there any tips/docs on how to use polyfix. >> >> It is a command line program with these options >> >> Usage: polyfix [-verbose] [-maxiter <str>] [-dtol <str>] [-atol <str>] >> [-lumps] [-nflip] [-remesh <str>] [-overwrite] [-out <str>] [-zip] >> [-v] <input_filename> >> -verbose Verbose messages >> -maxiter=<str> [heal] Max iterations (def=10) >> -dtol=<str> [heal] Distance tolerance (def=1.0E-2) >> -atol=<str> [heal] Area tolerance (def=1.0E-6) >> -lumps [heal] Split into lumps (not supported for stl output) >> -nflip [heal] Flip faces with inward normals (experimental) >> -remesh=<str> [remesh] Heal & remesh surfaces to given edge length (set >> dtol to small value ~1.E-6) >> -overwrite [output] allow file overwrite, including input file. >> -out=<str> [output] output filename/format (.obj, .off, .amf, .stl, >> .astl) >> -zip [output] save output also to compressed zip file >> -v Show version number only >> >> In the short term I want to pass in a single STL file and have it reconcile faces that are coplanar and overlapping by area, facing in opposite directions (relative to "outside"). This operation could be done on a single connected polyhedron which has "spikes" that touch or very nearly touch, as well. I presume that an epsilon value is being used; I saw something in the source code. >> >> The dtol parameter is your epsilon parameter, it is the tolerance for >> merging vertices of the "triangle soup" that is STL. >> >> The atol parameter is the minimal triangle area required for an STL >> triangle to be valid. >> >> example use, merge STL vertices and remove resulting zero area faces, >> output as *.off format >> >> $ polyfix vase_with_handle.stl -out=off >> >> Parameters: >> input_file = vase_with_handle.stl >> out = off >> >> >> polyhedron 0 ================= volume=3789.18, dtol=0.01, atol=1e-06, >> maxiter=10 >> iteration 0: vertices=108390 faces=36130 >> warning: nonmanifold edges: uc(1)=108390 >> merged 90337 vertices >> removed 24 collapsed or zero area faces >> total changes=90361 >> no warnings >> >> iteration 1: vertices=18053 faces=36106 >> total changes=0 >> no warnings >> >> Summary: >> polyhedron 0: vertices=18053 faces=36106 : no warnings >> >> Writing: vase_with_handle.off >> ... polyfix finished, time used: 0d 00h 00m 01s >> >> Obviously you can override the defaults for dtol, atol etc. >> >> Good luck >> >> Carsten Arnholm >> >> >> >> >> >> ---------- Forwarded message ---------- >> From: neri-engineering via Discuss <discuss@lists.openscad.org> >> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> >> Cc: neri-engineering <neri-engineering@protonmail.com> >> Bcc: >> Date: Wed, 07 Jun 2023 20:12:18 +0000 >> Subject: [OpenSCAD] Re: STL best practices & tools >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > > > > > ---------- Forwarded message ---------- > From: neri-engineering via Discuss <discuss@lists.openscad.org> > To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> > Cc: neri-engineering <neri-engineering@protonmail.com> > Bcc: > Date: Wed, 07 Jun 2023 21:43:02 +0000 > Subject: [OpenSCAD] Re: STL best practices & tools > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >