discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: What are degenerate facets anyway?

RW
Rogier Wolff
Tue, Feb 27, 2024 2:03 PM

On 2/25/2024 6:54 AM, I wrote:

On Sun, 25 Feb 2024 at 08:56, Carsten Arnholm arnholm@arnholm.org wrote:

On 2024-02-25 00:35, nop head via Discuss wrote:

As long as there are no self intersections it isn't too hard to remove
degenerate triangles. It isn't trivial though because if you simply
omit them you have a hole in the mesh, so you have to fix that.

Removing a triangle with zero area does not leave a hole, because the
'hole' has zero area. If you are thinking topological hole, it doesn't
apply to STL files because they don't contain any topology in the first
place, STL files are 'triangle soups'. With other formats, such as OBJ,
it is a different matter, you could be left with a zero area topological
hole.

Suppose I have a part of a geometry and for simplicty we'll use only
2D points.

Suppose I have three triangles:
[(-1,0), (0,0), (0, 1)]
[( 1,0), (0,0), (0, 1)]
[(-1,0), (1,0), (0,-1)]

The line between (0,0) and (1,0) is traversed only once by a triangle.
You might say that it IS traversed by the line from (-1,0) to (1,0),
but it needs to be that exact same coordinate pair that counts as the
second-traverse of each edge.

Jordan has asked me to add a picture.

Attached is the picture. So at first you'd think there are three
triangles. topleft, topright and one on the bottom.

The rules for STL / manifold-ness dictate that every edge beween two
vertices is traversed exactly twice (in opposite directions). If we
call the points in this picture "top", "left", "right", "bottom" and
"origin". This rule is observed for the origin-top pair of vertices:
the (right-top-origin) triangle  traverses that edge on the second edge.
The other triangle: left-origin-top traverses that same edge in the
other direction.

On the other hand, the edge between origin and left is only traversed
by that second triangle. The fact that the third triangle
(left-bottom-right) passes through the origin doesn't count.

You can see it this way... With the 2D case there is a third dimension
we can work with. If the shape suddenly springs a leak when we lift a
point into the third dimension, then the shape isn't properly closed.
With 3D shapes, the same holds: Lift all vertices one at a time into
the fourth dimension. If your shape then springs a leak it's not
properly closed. Most people have a hard time imagining this 4th
dimension. You're excused if you find it hard to imagine. It is.

You might say: "Why does it matter that each edge is traversed exactly
twice?"

First of all, it provides an easy check if the shape is "complete",
Consider my 2D example in 3D: This does not define a solid as the
outside edges are traversed only once. Computationally easy check.

A slightly more practical (but not yet(*) implemented in openscad)
reason is that with each edge being traversed exaclty twice, you can
find the "other" triangle, and perform Gouraud shading between the two
triangles (if they differ in color).

For a sphere(100); you need to set $fa = 1; to make the different
edges invisible. Do gouraud shading and you'd be fine with $fa=12; .
(for renders on the screen: indistinguisable from a sphere, for say
3D printing you'd need a more accurate subdivision).

Double checking on Gouraud shading on wikipedia:
https://en.wikipedia.org/wiki/Gouraud_shading
I leaned about Gouraud shading from Prof Blinn in 1985. Apparently he
(prof Blinn) published an improvement in 1992. (zero chance that's
someone with a similar name :-) )

Roger. 

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

On 2/25/2024 6:54 AM, I wrote: > On Sun, 25 Feb 2024 at 08:56, Carsten Arnholm <arnholm@arnholm.org> wrote: > >> On 2024-02-25 00:35, nop head via Discuss wrote: >>> As long as there are no self intersections it isn't too hard to remove >>> degenerate triangles. It isn't trivial though because if you simply >>> omit them you have a hole in the mesh, so you have to fix that. >> Removing a triangle with zero area does not leave a hole, because the >> 'hole' has zero area. If you are thinking topological hole, it doesn't >> apply to STL files because they don't contain any topology in the first >> place, STL files are 'triangle soups'. With other formats, such as OBJ, >> it is a different matter, you could be left with a zero area topological >> hole. > Suppose I have a part of a geometry and for simplicty we'll use only > 2D points. > > Suppose I have three triangles: > [(-1,0), (0,0), (0, 1)] > [( 1,0), (0,0), (0, 1)] > [(-1,0), (1,0), (0,-1)] > > The line between (0,0) and (1,0) is traversed only once by a triangle. > You might say that it IS traversed by the line from (-1,0) to (1,0), > but it needs to be that exact same coordinate pair that counts as the > second-traverse of each edge. Jordan has asked me to add a picture. Attached is the picture. So at first you'd think there are three triangles. topleft, topright and one on the bottom. The rules for STL / manifold-ness dictate that every edge beween two vertices is traversed exactly twice (in opposite directions). If we call the points in this picture "top", "left", "right", "bottom" and "origin". This rule is observed for the origin-top pair of vertices: the (right-top-origin) triangle traverses that edge on the second edge. The other triangle: left-origin-top traverses that same edge in the other direction. On the other hand, the edge between origin and left is only traversed by that second triangle. The fact that the third triangle (left-bottom-right) passes through the origin doesn't count. You can see it this way... With the 2D case there is a third dimension we can work with. If the shape suddenly springs a leak when we lift a point into the third dimension, then the shape isn't properly closed. With 3D shapes, the same holds: Lift all vertices one at a time into the fourth dimension. If your shape then springs a leak it's not properly closed. Most people have a hard time imagining this 4th dimension. You're excused if you find it hard to imagine. It is. You might say: "Why does it matter that each edge is traversed exactly twice?" First of all, it provides an easy check if the shape is "complete", Consider my 2D example in 3D: This does not define a solid as the outside edges are traversed only once. Computationally easy check. A slightly more practical (but not yet(*) implemented in openscad) reason is that with each edge being traversed exaclty twice, you can find the "other" triangle, and perform Gouraud shading between the two triangles (if they differ in color). For a sphere(100); you need to set $fa = 1; to make the different edges invisible. Do gouraud shading and you'd be fine with $fa=12; . (for renders on the screen: indistinguisable from a sphere, for say 3D printing you'd need a more accurate subdivision). Double checking on Gouraud shading on wikipedia: https://en.wikipedia.org/wiki/Gouraud_shading I leaned about Gouraud shading from Prof Blinn in 1985. Apparently he (prof Blinn) published an improvement in 1992. (zero chance that's someone with a similar name :-) ) Roger. -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a is going up. -- Chris Hadfield about flying up the space shuttle.
RW
Rogier Wolff
Tue, Feb 27, 2024 2:28 PM

The rules for STL / manifold-ness dictate that every edge beween two
vertices is traversed exactly twice (in opposite directions). If we

Forgot to add:

Where I say "exactly twice", officially any even number that is not
negative is possible. The case where it is more than 2 is also
difficult but "possbile".

Roger. 

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

> The rules for STL / manifold-ness dictate that every edge beween two > vertices is traversed exactly twice (in opposite directions). If we Forgot to add: Where I say "exactly twice", officially any even number that is not negative is possible. The case where it is more than 2 is also difficult but "possbile". Roger. -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a is going up. -- Chris Hadfield about flying up the space shuttle.