discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Reversed faces

NH
nop head
Mon, Jan 11, 2016 10:29 AM

Since the problem of reversed polyhedron faces comes up about once a week I
was wondering why OpenScad doesn't detect them by default. Isn't it just a
matter of checking all the edges of a polyhedron are a pair of opposite
direction half edges, or is it more complicated than that?

I suppose if all the faces where reversed it would need some extra test to
detect it was completely inside out. Perhaps check all the inward face
normals intersect with at least one other face? Again it doesn't seem
particularly expensive if done once on construction and cached.

It would be nice if it reported reversed faces and always highlighted them,
not just in thrown together mode. If it is simply a matter of checking half
edges it could be done for every polyhedron construction and stored in a
valid flag. That could issue a warning on every F5 or F6 and also flag that
the inside of the polygon should be drawn purple when it is rendered. It
would also detect holes and T junctions.

The current situation is doubly confusing because the CGAL exception is
only printed once and it can take a cache flush to get the polygon to
display after fixing it.

Now that flush clears the font cache and it takes a while to rebuild having
to flush the cache is a pain.

Since the problem of reversed polyhedron faces comes up about once a week I was wondering why OpenScad doesn't detect them by default. Isn't it just a matter of checking all the edges of a polyhedron are a pair of opposite direction half edges, or is it more complicated than that? I suppose if all the faces where reversed it would need some extra test to detect it was completely inside out. Perhaps check all the inward face normals intersect with at least one other face? Again it doesn't seem particularly expensive if done once on construction and cached. It would be nice if it reported reversed faces and always highlighted them, not just in thrown together mode. If it is simply a matter of checking half edges it could be done for every polyhedron construction and stored in a valid flag. That could issue a warning on every F5 or F6 and also flag that the inside of the polygon should be drawn purple when it is rendered. It would also detect holes and T junctions. The current situation is doubly confusing because the CGAL exception is only printed once and it can take a cache flush to get the polygon to display after fixing it. Now that flush clears the font cache and it takes a while to rebuild having to flush the cache is a pain.
M
MichaelAtOz
Mon, Jan 11, 2016 11:54 AM

I seem to recall this was discussed before.
Apart from the purple faces, I never understood what thrown together was
for, it just seemed to put noise in the way of finding that issue.

A warning to the console would seem to be called for.

Also the caching causing lack of repeated console messages is problematic,
perhaps the cached nodes could carry the error/warning, so it can be
repeated to the console. ?

(on rereading nophead's post, I think the above was just +1)

Separate naive question: "suppose if all the faces where reversed", is there
ever any valid reason for that?


Newly minted Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/Reversed-faces-tp15649p15650.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I seem to recall this was discussed before. Apart from the purple faces, I never understood what thrown together was for, it just seemed to put noise in the way of finding that issue. A warning to the console would seem to be called for. Also the caching causing lack of repeated console messages is problematic, perhaps the cached nodes could carry the error/warning, so it can be repeated to the console. ? (on rereading nophead's post, I think the above was just +1) Separate naive question: "suppose if all the faces where reversed", is there ever any valid reason for that? ----- Newly minted Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/Reversed-faces-tp15649p15650.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Mon, Jan 11, 2016 12:01 PM

Separate naive question: "suppose if all the faces where reversed", is

there ever any valid reason for that?

Logically it would make a negative volume that isn't a valid object in
OpenScad and I think all subsequent CGAL operations fail.

On 11 January 2016 at 11:54, MichaelAtOz oz.at.michael@gmail.com wrote:

I seem to recall this was discussed before.
Apart from the purple faces, I never understood what thrown together was
for, it just seemed to put noise in the way of finding that issue.

A warning to the console would seem to be called for.

Also the caching causing lack of repeated console messages is problematic,
perhaps the cached nodes could carry the error/warning, so it can be
repeated to the console. ?

(on rereading nophead's post, I think the above was just +1)

Separate naive question: "suppose if all the faces where reversed", is
there
ever any valid reason for that?


Newly minted Admin - PM me if you need anything, or if I've done something
stupid...

Unless specifically shown otherwise above, my contribution is in the
Public Domain; to the extent possible under law, I have waived all
copyright and related or neighbouring rights to this work. Obviously
inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it!
http://www.ourfairdeal.org/  time is running out!

View this message in context:
http://forum.openscad.org/Reversed-faces-tp15649p15650.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

>Separate naive question: "suppose if all the faces where reversed", is there ever any valid reason for that? Logically it would make a negative volume that isn't a valid object in OpenScad and I think all subsequent CGAL operations fail. On 11 January 2016 at 11:54, MichaelAtOz <oz.at.michael@gmail.com> wrote: > I seem to recall this was discussed before. > Apart from the purple faces, I never understood what thrown together was > for, it just seemed to put noise in the way of finding that issue. > > A warning to the console would seem to be called for. > > Also the caching causing lack of repeated console messages is problematic, > perhaps the cached nodes could carry the error/warning, so it can be > repeated to the console. ? > > (on rereading nophead's post, I think the above was just +1) > > Separate naive question: "suppose if all the faces where reversed", is > there > ever any valid reason for that? > > > > ----- > Newly minted Admin - PM me if you need anything, or if I've done something > stupid... > > Unless specifically shown otherwise above, my contribution is in the > Public Domain; to the extent possible under law, I have waived all > copyright and related or neighbouring rights to this work. Obviously > inclusion of works of previous authors is not included in the above. > > The TPP is no simple “trade agreement.” Fight it! > http://www.ourfairdeal.org/ time is running out! > -- > View this message in context: > http://forum.openscad.org/Reversed-faces-tp15649p15650.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 >
DM
doug moen
Mon, Jan 11, 2016 1:40 PM

"suppose all the faces were reversed"

In solid modelling systems based on functional representation, such as
ImplicitCAD and Antimony, there is a complement operator. For example,
complement(cube) is an infinite solid that fills all of space, except for a
cube shaped hole. (This is different from a negative object.) In an F-Rep
system, difference(a,b) is defined as intersection(a, complement(b)). (By
contrast, a negative object cuts a hole in a solid when it is unioned with
that solid, by my definition.)

I don't know CGAL very well, but I notice that there is a complement
operator. It makes sense to me that complement is implemented by reversing
all of the faces in a mesh, and it looks like the code is doing that, but I
can't be sure. I'm guessing that a face-reversed solid is a legal CGAL
object, an infinite object, different from a negative object.

In F-Rep solid modeling systems, infinite solids and the complement
operator are very useful, due to the increased expressive power of F-Rep.
You can't export an infinite solid to an STL file, but they are useful for
building other objects.

In OpenSCAD, due to the limitations of what you can represent with a mesh,
I think this would be a lot less useful, so I am not advocating that we
extend OpenSCAD with a complement operation. I'm just providing background
information.

On 11 January 2016 at 07:01, nop head nop.head@gmail.com wrote:

Separate naive question: "suppose if all the faces where reversed", is

there ever any valid reason for that?

Logically it would make a negative volume that isn't a valid object in
OpenScad and I think all subsequent CGAL operations fail.

On 11 January 2016 at 11:54, MichaelAtOz oz.at.michael@gmail.com wrote:

I seem to recall this was discussed before.
Apart from the purple faces, I never understood what thrown together was
for, it just seemed to put noise in the way of finding that issue.

A warning to the console would seem to be called for.

Also the caching causing lack of repeated console messages is problematic,
perhaps the cached nodes could carry the error/warning, so it can be
repeated to the console. ?

(on rereading nophead's post, I think the above was just +1)

Separate naive question: "suppose if all the faces where reversed", is
there
ever any valid reason for that?


Newly minted Admin - PM me if you need anything, or if I've done
something stupid...

Unless specifically shown otherwise above, my contribution is in the
Public Domain; to the extent possible under law, I have waived all
copyright and related or neighbouring rights to this work. Obviously
inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it!
http://www.ourfairdeal.org/  time is running out!

View this message in context:
http://forum.openscad.org/Reversed-faces-tp15649p15650.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

"suppose all the faces were reversed" In solid modelling systems based on functional representation, such as ImplicitCAD and Antimony, there is a complement operator. For example, complement(cube) is an infinite solid that fills all of space, except for a cube shaped hole. (This is different from a negative object.) In an F-Rep system, difference(a,b) is defined as intersection(a, complement(b)). (By contrast, a negative object cuts a hole in a solid when it is unioned with that solid, by my definition.) I don't know CGAL very well, but I notice that there is a complement operator. It makes sense to me that complement is implemented by reversing all of the faces in a mesh, and it looks like the code is doing that, but I can't be sure. I'm guessing that a face-reversed solid is a legal CGAL object, an infinite object, different from a negative object. In F-Rep solid modeling systems, infinite solids and the complement operator are very useful, due to the increased expressive power of F-Rep. You can't export an infinite solid to an STL file, but they are useful for building other objects. In OpenSCAD, due to the limitations of what you can represent with a mesh, I think this would be a lot less useful, so I am not advocating that we extend OpenSCAD with a complement operation. I'm just providing background information. On 11 January 2016 at 07:01, nop head <nop.head@gmail.com> wrote: > >Separate naive question: "suppose if all the faces where reversed", is > there ever any valid reason for that? > > Logically it would make a negative volume that isn't a valid object in > OpenScad and I think all subsequent CGAL operations fail. > > On 11 January 2016 at 11:54, MichaelAtOz <oz.at.michael@gmail.com> wrote: > >> I seem to recall this was discussed before. >> Apart from the purple faces, I never understood what thrown together was >> for, it just seemed to put noise in the way of finding that issue. >> >> A warning to the console would seem to be called for. >> >> Also the caching causing lack of repeated console messages is problematic, >> perhaps the cached nodes could carry the error/warning, so it can be >> repeated to the console. ? >> >> (on rereading nophead's post, I think the above was just +1) >> >> Separate naive question: "suppose if all the faces where reversed", is >> there >> ever any valid reason for that? >> >> >> >> ----- >> Newly minted Admin - PM me if you need anything, or if I've done >> something stupid... >> >> Unless specifically shown otherwise above, my contribution is in the >> Public Domain; to the extent possible under law, I have waived all >> copyright and related or neighbouring rights to this work. Obviously >> inclusion of works of previous authors is not included in the above. >> >> The TPP is no simple “trade agreement.” Fight it! >> http://www.ourfairdeal.org/ time is running out! >> -- >> View this message in context: >> http://forum.openscad.org/Reversed-faces-tp15649p15650.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 >> > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
MK
Marius Kintel
Mon, Jan 11, 2016 1:53 PM

On Jan 11, 2016, at 07:01 AM, nop head nop.head@gmail.com wrote:

Separate naive question: "suppose if all the faces where reversed", is there ever any valid reason for that?

Logically it would make a negative volume that isn't a valid object in OpenScad and I think all subsequent CGAL operations fail.

Also, if you want to build e.g. a hollow cube, you’d build a mesh consisting of two separate volumes: The outer cube and the inner cube, That inner cube will have all its faces reversed.

-Marius

> On Jan 11, 2016, at 07:01 AM, nop head <nop.head@gmail.com> wrote: > > >Separate naive question: "suppose if all the faces where reversed", is there ever any valid reason for that? > > Logically it would make a negative volume that isn't a valid object in OpenScad and I think all subsequent CGAL operations fail. > Also, if you want to build e.g. a hollow cube, you’d build a mesh consisting of two separate volumes: The outer cube and the inner cube, That inner cube will have all its faces reversed. -Marius
MK
Marius Kintel
Mon, Jan 11, 2016 1:59 PM

Some related issues:

https://github.com/openscad/openscad/issues/348
https://github.com/openscad/openscad/issues/1042
https://github.com/openscad/openscad/issues/590

Two things:
o We should rewrite our mesh class to support tests and operators like this. This would also be a good step towards repairing imported STLs which CGAL struggles with. We could also look at external libraries with good mesh classes.
o Highlights of reversed faces in preview mode: It should be possible to simply turn this on.

-Marius

Some related issues: https://github.com/openscad/openscad/issues/348 https://github.com/openscad/openscad/issues/1042 https://github.com/openscad/openscad/issues/590 Two things: o We should rewrite our mesh class to support tests and operators like this. This would also be a good step towards repairing imported STLs which CGAL struggles with. We could also look at external libraries with good mesh classes. o Highlights of reversed faces in preview mode: It should be possible to simply turn this on. -Marius
NH
nop head
Mon, Jan 11, 2016 3:06 PM

o Highlights of reversed faces in preview mode: It should be possible to

simply turn this on.
That would stop a lot of questions I think.

On 11 January 2016 at 13:59, Marius Kintel marius@kintel.net wrote:

Some related issues:

https://github.com/openscad/openscad/issues/348
https://github.com/openscad/openscad/issues/1042
https://github.com/openscad/openscad/issues/590

Two things:
o We should rewrite our mesh class to support tests and operators like
this. This would also be a good step towards repairing imported STLs which
CGAL struggles with. We could also look at external libraries with good
mesh classes.
o Highlights of reversed faces in preview mode: It should be possible to
simply turn this on.

-Marius


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

> o Highlights of reversed faces in preview mode: It should be possible to simply turn this on. That would stop a lot of questions I think. On 11 January 2016 at 13:59, Marius Kintel <marius@kintel.net> wrote: > Some related issues: > > https://github.com/openscad/openscad/issues/348 > https://github.com/openscad/openscad/issues/1042 > https://github.com/openscad/openscad/issues/590 > > Two things: > o We should rewrite our mesh class to support tests and operators like > this. This would also be a good step towards repairing imported STLs which > CGAL struggles with. We could also look at external libraries with good > mesh classes. > o Highlights of reversed faces in preview mode: It should be possible to > simply turn this on. > > -Marius > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
A
arnholm@arnholm.org
Mon, Jan 11, 2016 3:40 PM

On 2016-01-11 14:53, Marius Kintel wrote:

Also, if you want to build e.g. a hollow cube, you’d build a mesh
consisting of two separate volumes: The outer cube and the inner cube,
That inner cube will have all its faces reversed.

"Reversed faces" is a relative term and therefore somewhat confusing (to
me, anyway). Isn't the absolute and general rule simply that any face
normal should always point away from the material? This definition
should work for any number of internal voids and also the external
surface.

The face normal for a triangle with vertices v[0], v[1] and v[2] could
be defined as the cross product between 2 vectors

vec0, from v[0] to v[1]
vec1, from v[0] to v[2]

face_normal = vec0 x vec1

(quite possibly the other way around....).

Carsten Arnholm

On 2016-01-11 14:53, Marius Kintel wrote: > Also, if you want to build e.g. a hollow cube, you’d build a mesh > consisting of two separate volumes: The outer cube and the inner cube, > That inner cube will have all its faces reversed. "Reversed faces" is a relative term and therefore somewhat confusing (to me, anyway). Isn't the absolute and general rule simply that any face normal should always point away from the material? This definition should work for any number of internal voids and also the external surface. The face normal for a triangle with vertices v[0], v[1] and v[2] could be defined as the cross product between 2 vectors vec0, from v[0] to v[1] vec1, from v[0] to v[2] face_normal = vec0 x vec1 (quite possibly the other way around....). Carsten Arnholm
MK
Marius Kintel
Mon, Jan 11, 2016 3:51 PM

On Jan 11, 2016, at 10:40 AM, arnholm@arnholm.org wrote:
Isn't the absolute and general rule simply that any face normal should always point away from the material? This definition should work for any number of internal voids and also the external surface.

“reversed faces” is just used to follow the original topic. In this context it means that the vertex order of the faces is reversed.

-Marius

> On Jan 11, 2016, at 10:40 AM, arnholm@arnholm.org wrote: > Isn't the absolute and general rule simply that any face normal should always point away from the material? This definition should work for any number of internal voids and also the external surface. > “reversed faces” is just used to follow the original topic. In this context it means that the vertex order of the faces is reversed. -Marius
NH
nop head
Mon, Jan 11, 2016 4:05 PM

Pointing away from the material is a bit ambiguous for concave polyhedra as
a normal pointing outwards could hit another part of the object.

On 11 January 2016 at 15:51, Marius Kintel marius@kintel.net wrote:

On Jan 11, 2016, at 10:40 AM, arnholm@arnholm.org wrote:
Isn't the absolute and general rule simply that any face normal should

always point away from the material? This definition should work for any
number of internal voids and also the external surface.

“reversed faces” is just used to follow the original topic. In this
context it means that the vertex order of the faces is reversed.

-Marius


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

Pointing away from the material is a bit ambiguous for concave polyhedra as a normal pointing outwards could hit another part of the object. On 11 January 2016 at 15:51, Marius Kintel <marius@kintel.net> wrote: > > On Jan 11, 2016, at 10:40 AM, arnholm@arnholm.org wrote: > > Isn't the absolute and general rule simply that any face normal should > always point away from the material? This definition should work for any > number of internal voids and also the external surface. > > > “reversed faces” is just used to follow the original topic. In this > context it means that the vertex order of the faces is reversed. > > -Marius > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >