discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Unnecessary triangulation in linear_extrude

NH
nop head
Sun, Jan 3, 2016 12:17 PM

A cylinder is not the same as a linear_extruded circle. The side facets of
a cylinder are rectangles whereas the linear_extrude version are a pair of
triangles. This causes ugliness if you want to union them. Using a
linear_extruded circle instead of a cylinder works in some cases but I
still seem to have problems when the height is very different.

Here is an example:-

A base made from a hull of circles linear extruded.

A cylinder made from exactly the same circle linear extruded.

The union has extra facets and vertices on the base for some reason I don't
quite understand.


Could linear extrude use rectangles in the case when there is no twist so
the points are guaranteed to be planar?

A cylinder is not the same as a linear_extruded circle. The side facets of a cylinder are rectangles whereas the linear_extrude version are a pair of triangles. This causes ugliness if you want to union them. Using a linear_extruded circle instead of a cylinder works in some cases but I still seem to have problems when the height is very different. Here is an example:- A base made from a hull of circles linear extruded. A cylinder made from exactly the same circle linear extruded. The union has extra facets and vertices on the base for some reason I don't quite understand. ​ Could linear extrude use rectangles in the case when there is no twist so the points are guaranteed to be planar?
NH
nop head
Sun, Jan 3, 2016 3:03 PM

The union seems to make up extra vertices. If I show the cylinder on its
own or the hull on its own the vertices are in the same place. Also they
are as should be with F5 but F6 introduces new vertices that should not be
there. I tried to distil it down to a simple example but that works fine.

On 3 January 2016 at 12:17, nop head nop.head@gmail.com wrote:

A cylinder is not the same as a linear_extruded circle. The side facets
of a cylinder are rectangles whereas the linear_extrude version are a pair
of triangles. This causes ugliness if you want to union them. Using a
linear_extruded circle instead of a cylinder works in some cases but I
still seem to have problems when the height is very different.

Here is an example:-

A base made from a hull of circles linear extruded.

A cylinder made from exactly the same circle linear extruded.

The union has extra facets and vertices on the base for some reason I
don't quite understand.


Could linear extrude use rectangles in the case when there is no twist so
the points are guaranteed to be planar?

The union seems to make up extra vertices. If I show the cylinder on its own or the hull on its own the vertices are in the same place. Also they are as should be with F5 but F6 introduces new vertices that should not be there. I tried to distil it down to a simple example but that works fine. On 3 January 2016 at 12:17, nop head <nop.head@gmail.com> wrote: > A cylinder is not the same as a linear_extruded circle. The side facets > of a cylinder are rectangles whereas the linear_extrude version are a pair > of triangles. This causes ugliness if you want to union them. Using a > linear_extruded circle instead of a cylinder works in some cases but I > still seem to have problems when the height is very different. > > Here is an example:- > > A base made from a hull of circles linear extruded. > > > > > A cylinder made from exactly the same circle linear extruded. > > > > The union has extra facets and vertices on the base for some reason I > don't quite understand. > > > ​ > Could linear extrude use rectangles in the case when there is no twist so > the points are guaranteed to be planar? > > >
MK
Marius Kintel
Sun, Jan 3, 2016 4:34 PM

Could linear extrude use rectangles in the case when there is no twist so the points are guaranteed to be planar?

I guess we could do this as a special case. Note that 4 vertices in floating point aren’t guaranteed to be planar, but there’s a good chance they are. CGAL is particularly picky about planarity and we have to triangulate whenever CGAL complains.

-Marius

> Could linear extrude use rectangles in the case when there is no twist so the points are guaranteed to be planar? > I guess we could do this as a special case. Note that 4 vertices in floating point aren’t guaranteed to be planar, but there’s a good chance they are. CGAL is particularly picky about planarity and we have to triangulate whenever CGAL complains. -Marius
NH
nop head
Sun, Jan 3, 2016 4:39 PM

With linear_extrude surely the top vertices have exactly the same x,y
coordinates as the bottom and just differ in Z, regardless of the
representation?

On 3 January 2016 at 16:34, Marius Kintel marius@kintel.net wrote:

Could linear extrude use rectangles in the case when there is no twist

so the points are guaranteed to be planar?

I guess we could do this as a special case. Note that 4 vertices in
floating point aren’t guaranteed to be planar, but there’s a good chance
they are. CGAL is particularly picky about planarity and we have to
triangulate whenever CGAL complains.

-Marius


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

With linear_extrude surely the top vertices have exactly the same x,y coordinates as the bottom and just differ in Z, regardless of the representation? On 3 January 2016 at 16:34, Marius Kintel <marius@kintel.net> wrote: > > > Could linear extrude use rectangles in the case when there is no twist > so the points are guaranteed to be planar? > > > I guess we could do this as a special case. Note that 4 vertices in > floating point aren’t guaranteed to be planar, but there’s a good chance > they are. CGAL is particularly picky about planarity and we have to > triangulate whenever CGAL complains. > > -Marius > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
MK
Marius Kintel
Sun, Jan 3, 2016 4:42 PM

On Jan 3, 2016, at 11:39 AM, nop head nop.head@gmail.com wrote:

With linear_extrude surely the top vertices have exactly the same x,y coordinates as the bottom and just differ in Z, regardless of the representation?

Good point. If we also disregard scale, that would indeed constitute a special case we could rely on.

-Marius

> On Jan 3, 2016, at 11:39 AM, nop head <nop.head@gmail.com> wrote: > > With linear_extrude surely the top vertices have exactly the same x,y coordinates as the bottom and just differ in Z, regardless of the representation? > Good point. If we also disregard scale, that would indeed constitute a special case we could rely on. -Marius
P
Parkinbot
Sun, Jan 3, 2016 5:04 PM

Any stl-representation finally will be triangulated. So what do you expect to
gain, if you allowed for triangles AND rectangles (or even planar rhombus)
and write double but specialized code to preserve rectangles as long as
possible?

You would have to start with two implementations for linear_extrude(), one
for calls with twist<>n*360 and one for all other cases.

I mean, what is your sense of ugliness?

  • Rudolf

--
View this message in context: http://forum.openscad.org/Unnecessary-triangulation-in-linear-extrude-tp15429p15435.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Any stl-representation finally will be triangulated. So what do you expect to gain, if you allowed for triangles AND rectangles (or even planar rhombus) and write double but specialized code to preserve rectangles as long as possible? You would have to start with two implementations for linear_extrude(), one for calls with twist<>n*360 and one for all other cases. I mean, what is your sense of ugliness? - Rudolf -- View this message in context: http://forum.openscad.org/Unnecessary-triangulation-in-linear-extrude-tp15429p15435.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Sun, Jan 3, 2016 5:22 PM

I am trying to get rid of degenerate triangles in the STL. I think they
come from these extra facets and vertices. However I now think it may be a
bug in CGAL union.

Here is the result from my code with a lot removed. There are extra facets


Here is my simple test code to re-create the bug, but it doesn't happen.

$fa = 5;
$fs = 0.5;

union() {
cylinder(r = 4, h= 100);

linear_extrude(height = 10) hull() {
        circle(4);

    translate([30, 10, 0])
        circle(4);

    translate([10, 30, 0])
        circle(4);
}

}

This is what it should look like because the vertices on the top and bottom
of the cylinder should exactly match those of the rounded corner,
regardless of number representation as they are all created by circle or
cylinder with the same parameters.

On 3 January 2016 at 17:04, Parkinbot rudolf@parkinbot.com wrote:

Any stl-representation finally will be triangulated. So what do you expect
to
gain, if you allowed for triangles AND rectangles (or even planar rhombus)
and write double but specialized code to preserve rectangles as long as
possible?

You would have to start with two implementations for linear_extrude(), one
for calls with twist<>n*360 and one for all other cases.

I mean, what is your sense of ugliness?

  • Rudolf

--
View this message in context:
http://forum.openscad.org/Unnecessary-triangulation-in-linear-extrude-tp15429p15435.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

I am trying to get rid of degenerate triangles in the STL. I think they come from these extra facets and vertices. However I now think it may be a bug in CGAL union. Here is the result from my code with a lot removed. There are extra facets ​ Here is my simple test code to re-create the bug, but it doesn't happen. $fa = 5; $fs = 0.5; union() { cylinder(r = 4, h= 100); linear_extrude(height = 10) hull() { circle(4); translate([30, 10, 0]) circle(4); translate([10, 30, 0]) circle(4); } } This is what it should look like because the vertices on the top and bottom of the cylinder should exactly match those of the rounded corner, regardless of number representation as they are all created by circle or cylinder with the same parameters. On 3 January 2016 at 17:04, Parkinbot <rudolf@parkinbot.com> wrote: > Any stl-representation finally will be triangulated. So what do you expect > to > gain, if you allowed for triangles AND rectangles (or even planar rhombus) > and write double but specialized code to preserve rectangles as long as > possible? > > You would have to start with two implementations for linear_extrude(), one > for calls with twist<>n*360 and one for all other cases. > > I mean, what is your sense of ugliness? > > - Rudolf > > > > -- > View this message in context: > http://forum.openscad.org/Unnecessary-triangulation-in-linear-extrude-tp15429p15435.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 >
CA
Carsten Arnholm
Sun, Jan 3, 2016 7:36 PM

On 03. jan. 2016 17:42, Marius Kintel wrote:

Good point. If we also disregard scale, that would indeed constitute a special case we could rely on.

This will fail (generate nonplanar quads) if you apply the right skewing
with multmatrix.

Carsten Arnholm

On 03. jan. 2016 17:42, Marius Kintel wrote: > Good point. If we also disregard scale, that would indeed constitute a special case we could rely on. This will fail (generate nonplanar quads) if you apply the right skewing with multmatrix. Carsten Arnholm
NH
nop head
Sun, Jan 3, 2016 7:51 PM

How does it handle cylinder then?

On 3 January 2016 at 19:36, Carsten Arnholm arnholm@arnholm.org wrote:

On 03. jan. 2016 17:42, Marius Kintel wrote:

Good point. If we also disregard scale, that would indeed constitute a
special case we could rely on.

This will fail (generate nonplanar quads) if you apply the right skewing
with multmatrix.

Carsten Arnholm


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

How does it handle cylinder then? On 3 January 2016 at 19:36, Carsten Arnholm <arnholm@arnholm.org> wrote: > On 03. jan. 2016 17:42, Marius Kintel wrote: > >> Good point. If we also disregard scale, that would indeed constitute a >> special case we could rely on. >> > > This will fail (generate nonplanar quads) if you apply the right skewing > with multmatrix. > > Carsten Arnholm > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
CA
Carsten Arnholm
Sun, Jan 3, 2016 8:37 PM

On 03. jan. 2016 20:51, nop head wrote:

How does it handle cylinder then?

Better than what i expected, or so it it seems :-) I may have been to
quick. I tried things like this:

multmatrix([
[1, 0.8, 0, 0],
[0.2, 1, 0.95, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]]) {
cylinder($fn = 12, h = 100, r1 = 20, r2 = 20);
}

From the looks only, it does indeed seem the quads remain planar.
However, there could be numerical issues.

Carsten Arnholm

On 03. jan. 2016 20:51, nop head wrote: > How does it handle cylinder then? Better than what i expected, or so it it seems :-) I may have been to quick. I tried things like this: multmatrix([ [1, 0.8, 0, 0], [0.2, 1, 0.95, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { cylinder($fn = 12, h = 100, r1 = 20, r2 = 20); } From the looks only, it does indeed seem the quads remain planar. However, there could be numerical issues. Carsten Arnholm