

I thought that it should be possible to make in one sweep a hollow object like a cup. And the following code works without the use of the difference function :
$fn=32;//quality of curve
echo($fn=$fn);
use <splines.scad>
use <Naca_sweep.scad>
use <skin.scad>
cupout = [ for (l= [each [0:1:10]])
[10,
l]];
cupin = [ for (l= [each [0:1:10]])
[8,
10l]];
cup = concat(cupout,cupin);
objcup = generate(cup);
sweep(objcup);
function draw_point_c(r,i) = [r*sin(i*360/$fn),r*cos(i*360/$fn)];
// draw a circle with $fn points
function drawcircle_(r) = [ for (i=[0:1:$fn1]) draw_point_c(r,i)];
//  draw all of the bore
function generate(S) = [
for (i= [0:1:len(S)1])
let(dat = vec3D( drawcircle_( S[i][0]))
)
T_(0,0,S[i][1],dat) ];
Any suggestions how to make a tube without use of the difference function?


I don't know how to do it with Parkinbot's sweep but, yes, it is possible:
Tube_example.scad


This post was updated on .
Very nice example and I even succeeded in understanding it so well that I could generate a tube or ring.
So I have 4 ways now to make a ring:
 difference of two cylinders
 lineair extrude of a 2D ring
 difference of two sweeped cylinders (works also with skin)
 creating polyhedrons
I added this to one of my examples files called "lord_of_the_rings.scad" ;).
lord_of_the_rings.scad
Is there another way to make the complete olympic serie??


Method nr. 5:
color("green") translate([20,20,0])
{
rotate_extrude(angle=360, convexity=10)
translate([8,0,0])
square([2,10]);
}


Nice summary, Johan. Conceptually, your sweep example is not distinct from the difference of cylinders: it only generates the cylinders in an alternative way. Essentially, sweep is a polyhedron construction.
You want a fifth one... make two half rings by rotate_extruding squares and union them. In a snapshot version, you can do rotate_extrude specifying an angle.


It is not too difficult to write a sweep function that connects a dual sequence of polygons into a hollow solid like a pipe. At best you commit yourself to obey to some rules to ease triangulation.
inner and outer polygons must
0. not selfintersect or mutually intersect !!! (no intersection at all )
1. use a defined orientation
(2. be coplanar  i.e. at best they use the same affine 2D>3D transformation)
(3. have the same number of points)
(4. use minimally distanced start points and suitable sequencing.)
2 can be omitted, if you know, what you do.
3 and 4 are good if you want to use a trivial connection scheme like quads for the first and last face. If you find some other nice triangulation scheme they can be omitted. For the extruded inner and outer surfaces you can use a trivial connection scheme like quads.
But honestly, I don't see any progress beyond saving some CPU time against just differencing an inner solid from an outer solid. If both solids are proper manifolds, the result will also be. If not, your new scheme will not be any better.


Ronaldo wrote
Nice fifth solution, Johan. I don't see why I divided the ring in two parts
in proposal. Ahrgh.
because this is the way, you can do it (and even more) with sweep/skin operations, see http://www.thingiverse.com/thing:1659079


Johan, btw. your first code seemlessly works with my newest version of Naca_sweep.scad which meanwhile also supports closed extrusions. I uploaded it for you. Get it at: http://www.thingiverse.com/thing:900137To use the new feature just alter the sweep() call into:
sweep(objcup, close = true);


Method number 6:
//
// Method: sweep and union
//
tube2out = [ for (l= [each [0:1:10]]) [10,l]];
tube2in = [ for (l= [each [0:1:10]]) [8,l]];
outsidel = generatel(tube2out,tube2in);
outsider = generater(tube2out,tube2in);
function generater(S,T) = [
for (i= [0:len(S)1])[
for (angle=[0:$fn1])
(angle<$fn/2)? [S[i][0]*sin(angle*360/$fn),S[i][0]*cos(angle*360/$fn),S[i][1]]:
[T[i][0]*sin(($fnangle1)*360/$fn),T[i][0]*cos(($fnangle1)*360/$fn),T[i][1]]]
];
function generatel(S,T) = [
for (i= [0:len(S)1])[
for (angle=[0:$fn+3])
(angle<=$fn/2+1)? [S[i][0]*sin(($fn/2+angle1)*360/$fn),S[i][0]*cos(($fn/2+angle1)*360/$fn),S[i][1]]:
[T[i][0]*sin(($fn/2+$fnangle+2)*360/$fn),T[i][0]*cos(($fn/2+$fnangle+2)*360/$fn),T[i][1]]]
];
color("orange") translate([60,20,0])
{
union()
{
sweep(outsider);
sweep(outsidel);
}
}


This post was updated on .
@parkinbot
Since I often make designs for wind instruments most of my designs are hollow solids. I still do not understand well how to prevent all errors like non manifold and non planar. Most of them happen when I use the difference function.
So I like to have alternatives for that and also nice examples as some kind of memory.
I think your rules give important information for me to prevent problems, but I do not understand it 100%.
Ad. 0) Selfintersection is in the figure below? But what is mutually intersect?
And I think I know the rule, but to be honest I do not really understand what goes wrong when it is intersecting
Ad. 1) A defined orientation. I think I understand that. But when does it go wrong? Can you give an example.
Ad. 2) I don't know what coplanar is
Ad. 3) Ronaldo gave a good example in another item.
Ad. 4) I don't understand what this means.


Coplanar means that they are in the same plane. This condition is redundant: if a connected set of facets are in the same plane and exactly two meet at each edge, there will be almost two nondisjoint facets in the set.
Or, in other terms, if you project the facets of a 2manifold without border in a plane, at least two projected facets will have a 2D intersection (meaning with a non zero area). So, this conditions is covered by the first.


Johan Jonker wrote
Most of them happen when I use the difference function.<br>
They for sure "happen" somewhere else, but it is the boolean operations, who indicate them, as they are executed through CGAL.
See my last post. You can use my sweep()  and also skin(), I guess  with your initial code. That means:
You choose a trajectory that starts e.g. at the bottom and outer circle, goes up along the outer skin, jumps at the "end" to the inner circle and goes the way back to the start where it will be finally connected. In other words, you define a looped trajectory for each point in the polygon you start with.
As looped trajectories seem to be viable for you, you don't have to understand or implement the procedure I proposed, which uses a sequence of paired polygons describing the inner and outer surface skeleton. Both approaches are equivalent!
But nevertheless here are some answers:
ad 0. imagine two circles with different radi. They are both not self intersecting, but they can insect at one or two points. Avoid also this!
ad 1 you have to decide for either CW or CCW polygons when you setup a connection scheme. Otherwise you can end up with insideout solids. Of course you could use tests, but this costs time and code.
ad 2 when you start in 2D, all points are in one plane and thus coplanar. To ensure they stay coplanar you can use the same affine transformation. In most (= non pathologic) cases this will guarantee you that they will not intersect in 3D.
ad 4 think about describing the area between two circles with different radii, but identical center. Say, you use two polygons to describe the circles, each containing N points. For the faces list it is best to use quads or triangles. Look at the following code, which uses quads. It will only work properly, if the points in the two polygons are arranged in a beneficial way. This is what I meant.
N = 10;
points = concat(circ(100, N), circ(90, N));
polyhedron(points, face(N));
function circ(r, N) = [for (i=[0:N1]) let (a =360/N*i) [r * cos(a), r * sin(a), 0] ];
function face(N) = [for (i=[0:N1]) [i, (i+1)%N, (i+1)%N+N, i+N]];


Parkinbot: when you said "my newest" I realized that I do not have any
way to know when you post updates. Any hints on the best way to stay
current?
On 12/22/2016 11:36 AM, Parkinbot wrote:
> Johan, btw. your first code seemlessly works with my newest version of
> Naca_sweep.scad which meanwhile also supports closed extrusions. I uploaded
> it for you. Get it at: http://www.thingiverse.com/thing:900137>
> To use the new feature just alter the sweep() call into:
>
>
>> sweep(objcup, close = true);
>
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


Jon, just stay tuned to this forum.
Only after having read Johan's initial code more seriously, I realized that my last private update would do the job. So I published it, since Johan is the only one I know, who is seriously (and in many times also desperately) using my libs in his workflows.
Usually I don't publish new features with old projects, because there is always a chance to unwillingly break peoples code. Also I would feel that I have to document the new stuff and give examples on how to use it. That takes much time and keeps me away from my own current projects. While the close=true option opens my primitive sweep() for toric topology (= the class of manifolds with one hole) my nSpline() does not yet support this topology, and going into that lib again is a very nasty job. When I need it myself one day, I'll code it, but not just for completeness.


Jon and Parkinbot,
I have an implementation of a spline interpolant that is more general than the one in splines.scad. For instance, it includes many end conditions and also periodic splines, that is, interpolation splines for closed loops. I have just tested it with the knot() module of splines.scad and it worked as a charm. If that is what is missing, I can provide the code.


Ronaldo,
as I wrote, when I need it, I'll extend my code. (For me it saves much time, to use my own code.)
But it would be nice of course, if you published and documented your code together with some examples. Thingiverse is a good platform for things like that.

