discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Combining different sweeps does not work

JJ
Johan Jonker
Sat, Nov 5, 2016 1:16 PM

Wow,
I see that I make this mistake also with a lot of other files.
So there is work to do. I let you know the results.

--
View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18947.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Wow, I see that I make this mistake also with a lot of other files. So there is work to do. I let you know the results. -- View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18947.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JJ
Johan Jonker
Sun, Nov 6, 2016 8:47 PM

http://forum.openscad.org/file/n18963/sweep4.jpg After rewriting the code
it still doesn't work well.
And I don't understand why.

The image shows from top to bottom the lineair extrusion of the two 2D
layers. They look fine.
The lowest object is the sweep of the two 2D objects.

The 2D objects are build from 900 point and start on the left lower corner
follow the quarter circle to the bottom and then go counter clockwise back
to the start.
It is strange that there seem to appear crossing lines. They only appear at
the top and the bottom.

engelvleugel_v8_res.scad
http://forum.openscad.org/file/n18963/engelvleugel_v8_res.scad

B

--
View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18963.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

<http://forum.openscad.org/file/n18963/sweep4.jpg> After rewriting the code it still doesn't work well. And I don't understand why. The image shows from top to bottom the lineair extrusion of the two 2D layers. They look fine. The lowest object is the sweep of the two 2D objects. The 2D objects are build from 900 point and start on the left lower corner follow the quarter circle to the bottom and then go counter clockwise back to the start. It is strange that there seem to appear crossing lines. They only appear at the top and the bottom. engelvleugel_v8_res.scad <http://forum.openscad.org/file/n18963/engelvleugel_v8_res.scad> B -- View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18963.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JJ
Johan Jonker
Sun, Nov 6, 2016 9:24 PM

http://forum.openscad.org/file/n18964/sweep5.jpg

I printed all the points of the two layers and exported them to excel and
checked if the points in both layers correspond. And the do.

What I think that happens is that the top and the bottom of the sweeped
object are in fact open. Openscad closes this by drawing triangles between
the different points of the top and bottom layer. You cannot control the
points they choose to connect.

Can someone explain how Openscad closes the top and bottom layers of a
sweeped object?

--
View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18964.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

<http://forum.openscad.org/file/n18964/sweep5.jpg> I printed all the points of the two layers and exported them to excel and checked if the points in both layers correspond. And the do. What I think that happens is that the top and the bottom of the sweeped object are in fact open. Openscad closes this by drawing triangles between the different points of the top and bottom layer. You cannot control the points they choose to connect. Can someone explain how Openscad closes the top and bottom layers of a sweeped object? -- View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18964.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JJ
Johan Jonker
Sun, Nov 6, 2016 9:27 PM

Maybe interesting to add the excel file sweep.xlsx
http://forum.openscad.org/file/n18965/sweep.xlsx

--
View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18965.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Maybe interesting to add the excel file sweep.xlsx <http://forum.openscad.org/file/n18965/sweep.xlsx> -- View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18965.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Sun, Nov 6, 2016 9:28 PM

To me your code looks fine and the sweep also works fine with 2016.04.06
using F5 and F6.
Sometimes it is a good idea to empty the cache or even to restart OpenSCAD

--
View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18966.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

To me your code looks fine and the sweep also works fine with 2016.04.06 using F5 and F6. Sometimes it is a good idea to empty the cache or even to restart OpenSCAD -- View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18966.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Sun, Nov 6, 2016 9:49 PM

Johan Jonker wrote

Can someone explain how Openscad closes the top and bottom layers of a
sweeped object?

Your question reduces to how Openscad triangulates the face of a polyhedron,
when it has more than 3 points. In an earlier version my sweep() did this
triangulation on its own. I used some sloppy algorithm that exploited some
symmetry of the point generator function I used for my airfoils. Later I
changed that and used the system's triangulation. For planar faces OpenSCAD
can do its own magic (I guess some ear cut algorithm or even a faster
routine). And - as you saw - for non-planar faces CGAL is used and tries
some alternate construction that can introduce curves and extra points to
the cap.

BTW, I never had problems with that, as long as the polygon was 'simple'
i.e. welldefined. That means: no self intersection, no double points.

--
View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18967.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Johan Jonker wrote > Can someone explain how Openscad closes the top and bottom layers of a > sweeped object? Your question reduces to how Openscad triangulates the face of a polyhedron, when it has more than 3 points. In an earlier version my sweep() did this triangulation on its own. I used some sloppy algorithm that exploited some symmetry of the point generator function I used for my airfoils. Later I changed that and used the system's triangulation. For planar faces OpenSCAD can do its own magic (I guess some ear cut algorithm or even a faster routine). And - as you saw - for non-planar faces CGAL is used and tries some alternate construction that can introduce curves and extra points to the cap. BTW, I never had problems with that, as long as the polygon was 'simple' i.e. welldefined. That means: no self intersection, no double points. -- View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18967.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Sun, Nov 6, 2016 10:25 PM

Here some nice and simple code allowing you to study non-planar triangulation
and the "minimal surfaces" the system generates. Seems to me like some
foward-backward ear-cut algorithm.
If you run the animation e.g. with 100 steps, you will see, that the
triangulation algorithm will work up to a certain slope but freaks out at
some point, making the result more or less unpredictable.

use
<Naca_sweep.scad>

N = 100;
t = 100;

T1 = -100*($t-.5);
T2 = 250*($t-.5);

sweep([gen(0, T1), gen(200, T2)]);

function gen(shift=0, T = 0) =
[for (i=[0:360/N:360]) [tsin(i), tcos(i), Tsin(2i)+shift]];

Here some nice and simple code allowing you to study non-planar triangulation and the "minimal surfaces" the system generates. Seems to me like some foward-backward ear-cut algorithm. If you run the animation e.g. with 100 steps, you will see, that the triangulation algorithm will work up to a certain slope but freaks out at some point, making the result more or less unpredictable. > use > <Naca_sweep.scad> > > N = 100; > t = 100; > > T1 = -100*($t-.5); > T2 = 250*($t-.5); > > sweep([gen(0, T1), gen(200, T2)]); > > function gen(shift=0, T = 0) = > [for (i=[0:360/N:360]) [t*sin(i), t*cos(i), T*sin(2*i)+shift]]; <http://forum.openscad.org/file/n18970/jonker3.png> <http://forum.openscad.org/file/n18970/jonker4.png> -- View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18970.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JJ
Johan Jonker
Mon, Nov 7, 2016 6:40 AM

Nice example.

I still see a remarkable difference between sweep and lineair extrusion with
the following code.
Do I use the wrong sweep version then? Or do you have the same results?

$fn=60;

use <Naca_sweep.scad>

punten =
[[0,0],[10,0],[10,8],[9,8],[9,1],[5,1],[5,9],[10,9],[10,10],[0,10]];
linear_extrude(height = 10, center = true, convexity = 10, twist = 0)
translate([10,10,10])
polygon(points= punten);

dat = vec3D(punten);
shape = [T_(0,0,0,dat),T_(0,0,10,dat)];
sweep(shape);

http://forum.openscad.org/file/n18983/sweep6.jpg

--
View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18983.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Nice example. I still see a remarkable difference between sweep and lineair extrusion with the following code. Do I use the wrong sweep version then? Or do you have the same results? $fn=60; use <Naca_sweep.scad> punten = [[0,0],[10,0],[10,8],[9,8],[9,1],[5,1],[5,9],[10,9],[10,10],[0,10]]; linear_extrude(height = 10, center = true, convexity = 10, twist = 0) translate([10,10,10]) polygon(points= punten); dat = vec3D(punten); shape = [T_(0,0,0,dat),T_(0,0,10,dat)]; sweep(shape); <http://forum.openscad.org/file/n18983/sweep6.jpg> -- View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18983.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Mon, Nov 7, 2016 2:25 PM

Johan Jonker wrote

I still see a remarkable difference between sweep and lineair extrusion
with the following code.
Do I use the wrong sweep version then? Or do you have the same results?

The first problem is that your polygon is defined in reverse order for the
sweep you do (my code doesn't check for this). If you extrude shape =
[T_(0,0,0,dat),T_(0,0,-10,dat)];
to the reverse direction, or reverse your
definition, it should work (at least for the side parts of the extrusion).

The second problem is that the caps are not correctly triangulated by
polyhedron (i.e. the system). To be honest, I haven't yet encountered this
case yet and don't have an immediate solution for it. But cycling your
polygon definition around a bit, shows that it can work:

$fn=60;
use
<Naca_sweep.scad>

punten = [[9,8],[9,1],[5,1],[5,9], [10,9],[10,10],[0,10],
[0,0],[10,0],[10,8]];

dat = vec3D(punten);
shape = [T_(0,0,0,dat),T_(0,0,-10,dat)];
sweep(shape);

Therefore, I suspect polyhedron to employ a buggy triangulation. Unless
this doesn't get repaired, I'll implement my own triangulation when I find
time for it ... You can try to put this two constructions  into a polyhedron
example
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#polyhedron
(sweep automatically constructs a polyhedron!) and announce the bug in a new
thread.

As workaround you always can try  skin()
https://github.com/openscad/list-comprehension-demos  instead of sweep().
You have to install  scad-utils https://github.com/openscad/scad-utils
to settle its references. Then you can use it as you would use sweep(). It
does what you want - at least in this case.

Best Rudolf

--
View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18988.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Johan Jonker wrote > I still see a remarkable difference between sweep and lineair extrusion > with the following code. > Do I use the wrong sweep version then? Or do you have the same results? The first problem is that your polygon is defined in reverse order for the sweep you do (my code doesn't check for this). If you extrude *shape = [T_(0,0,0,dat),T_(0,0,-10,dat)];* to the reverse direction, or reverse your definition, it should work (at least for the side parts of the extrusion). The second problem is that the caps are not correctly triangulated by polyhedron (i.e. the system). To be honest, I haven't yet encountered this case yet and don't have an immediate solution for it. *But* cycling your polygon definition around a bit, shows that it can work: > $fn=60; > use > <Naca_sweep.scad> > > punten = [[9,8],[9,1],[5,1],[5,9], [10,9],[10,10],[0,10], > [0,0],[10,0],[10,8]]; > > dat = vec3D(punten); > shape = [T_(0,0,0,dat),T_(0,0,-10,dat)]; > sweep(shape); Therefore, I suspect *polyhedron to employ a buggy triangulation*. Unless this doesn't get repaired, I'll implement my own triangulation when I find time for it ... You can try to put this two constructions into a polyhedron example <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#polyhedron> (sweep automatically constructs a polyhedron!) and announce the bug in a new thread. As workaround you always can try skin() <https://github.com/openscad/list-comprehension-demos> instead of sweep(). You have to install scad-utils <https://github.com/openscad/scad-utils> to settle its references. Then you can use it as you would use sweep(). It does what you want - at least in this case. Best Rudolf -- View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18988.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Mon, Nov 7, 2016 2:47 PM

Parkinbot wrote

The second problem is that the caps are not correctly triangulated by
polyhedron (i.e. the system). To be honest, I haven't yet encountered this
case yet and don't have an immediate solution for it.

But

cycling your polygon definition around a bit, shows that it can work:

I must correct myself in this point. The caps are correctly triangulated by
the system. I seems, you didn't use the newest version of Naca_sweep.scad,
which dates from 07-02-16.

So, reversing your polygon definition or your extrusion direction or using
skin() will solve your problem.

--
View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18990.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Parkinbot wrote > The second problem is that the caps are not correctly triangulated by > polyhedron (i.e. the system). To be honest, I haven't yet encountered this > case yet and don't have an immediate solution for it. * > But * > cycling your polygon definition around a bit, shows that it can work: I must correct myself in this point. The caps are correctly triangulated by the system. I seems, you didn't use the newest version of Naca_sweep.scad, which dates from 07-02-16. So, reversing your polygon definition or your extrusion direction or using skin() will solve your problem. -- View this message in context: http://forum.openscad.org/Combining-different-sweeps-does-not-work-tp18937p18990.html Sent from the OpenSCAD mailing list archive at Nabble.com.