discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Polyhedron tube with irregular sides -- is it possible ?

P
Parkinbot
Mon, Dec 10, 2018 10:55 AM

Oh, how stupid I didn't check this little detail :-( . My first approach was
to use a polygon with the same point sequence, but that didn't work, because
my sweep() currently also puts vertical walls along the kerfs. So if CGAL
would cooperate, one could easily implement sweep() to omit those walls.

http://forum.openscad.org/file/t887/sweepwithholes.png

use <Naca_sweep.scad>
a = circle(30, 0, 10, -1);
b = circle(6, 0, 100, 1);

q = prepsweep([a, each forN_(b, 17)]);
sweep([q, Tz_(10, q)]);

function prepsweep(P) = [each P[0], each for(p=[1:len(P)-1]) each [P[p],
[P[p][0]], [P[0][len(P[0])-1]]]];
function forN_(P, r=0, N=6) = [for(i=[0:N-1]) T_(rsin(360/Ni),
rcos(360/Ni), 0, P)];
function circle(r=10, z = 0, N=10, dir=1) = [for(i=[0:N-1])
[rcos(dir360/Ni), rsin(dir360/Ni), z]];

--
Sent from: http://forum.openscad.org/

Oh, how stupid I didn't check this little detail :-( . My first approach was to use a polygon with the same point sequence, but that didn't work, because my sweep() currently also puts vertical walls along the kerfs. So if CGAL would cooperate, one could easily implement sweep() to omit those walls. <http://forum.openscad.org/file/t887/sweepwithholes.png> use <Naca_sweep.scad> a = circle(30, 0, 10, -1); b = circle(6, 0, 100, 1); q = prepsweep([a, each forN_(b, 17)]); sweep([q, Tz_(10, q)]); function prepsweep(P) = [each P[0], each for(p=[1:len(P)-1]) each [P[p], [P[p][0]], [P[0][len(P[0])-1]]]]; function forN_(P, r=0, N=6) = [for(i=[0:N-1]) T_(r*sin(360/N*i), r*cos(360/N*i), 0, P)]; function circle(r=10, z = 0, N=10, dir=1) = [for(i=[0:N-1]) [r*cos(dir*360/N*i), r*sin(dir*360/N*i), z]]; -- Sent from: http://forum.openscad.org/
P
Parkinbot
Mon, Dec 10, 2018 12:42 PM

A multi-hole sweep can be also implemented straight forward and does not need
this hack. It has to provide its own triangulation of the first and last
faces with holes and just can't rely on CGAL to do it. CGAL gets slow
anyway, when it starts with "trying alternative construction". The rest is
just building the walls like a vectorized sweep.

The new call will be something like:

sweep(outerpolygon_sequence=a, listofholes_sequence=b)

As soon as I find time, I'm gonna try it.

--
Sent from: http://forum.openscad.org/

A multi-hole sweep can be also implemented straight forward and does not need this hack. It has to provide its own triangulation of the first and last faces with holes and just can't rely on CGAL to do it. CGAL gets slow anyway, when it starts with "trying alternative construction". The rest is just building the walls like a vectorized sweep. The new call will be something like: sweep(outerpolygon_sequence=a, listofholes_sequence=b) As soon as I find time, I'm gonna try it. -- Sent from: http://forum.openscad.org/
N
NateTG
Mon, Dec 10, 2018 6:16 PM

You could just use clockwise-counterclockwise to identify holes.

I did write a triangulation thing for bending text, though there's probably
a better way.

https://gist.github.com/NateTG/b350378c56f436d3996a2107f7cba965

--
Sent from: http://forum.openscad.org/

You could just use clockwise-counterclockwise to identify holes. I did write a triangulation thing for bending text, though there's probably a better way. https://gist.github.com/NateTG/b350378c56f436d3996a2107f7cba965 -- Sent from: http://forum.openscad.org/
NH
nop head
Mon, Dec 10, 2018 6:45 PM

With a polyhedron counter-clockwise is already used to mean a face facing
the other way, which is different from a hole in a face. E.g. in runsun's
numbered example the bottom face is listed counter-clockwise looking from
the top because it is pointing downwards.

Perhaps the first polygon in the face could be assumed the outward facing
direction and any polygons in the same face that go the opposite direction
to be holes in it.

On Mon, 10 Dec 2018 at 18:17, NateTG nate-openscadforum@pedantic.org
wrote:

You could just use clockwise-counterclockwise to identify holes.

I did write a triangulation thing for bending text, though there's probably
a better way.

https://gist.github.com/NateTG/b350378c56f436d3996a2107f7cba965

--
Sent from: http://forum.openscad.org/


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

With a polyhedron counter-clockwise is already used to mean a face facing the other way, which is different from a hole in a face. E.g. in runsun's numbered example the bottom face is listed counter-clockwise looking from the top because it is pointing downwards. Perhaps the first polygon in the face could be assumed the outward facing direction and any polygons in the same face that go the opposite direction to be holes in it. On Mon, 10 Dec 2018 at 18:17, NateTG <nate-openscadforum@pedantic.org> wrote: > You could just use clockwise-counterclockwise to identify holes. > > I did write a triangulation thing for bending text, though there's probably > a better way. > > https://gist.github.com/NateTG/b350378c56f436d3996a2107f7cba965 > > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
R
runsun
Mon, Dec 10, 2018 6:48 PM

Thx for the check, nophead. Wondering how OpenSCAD allows it to render
correctly when it's stand-alone.


$  Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText  ( OpenSCAD lexer ); $ Tips ; $ Snippets

--
Sent from: http://forum.openscad.org/

Thx for the check, nophead. Wondering how OpenSCAD allows it to render correctly when it's stand-alone. ----- $ Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText ( OpenSCAD lexer );&nbsp;$ Tips ;&nbsp;$ Snippets -- Sent from: http://forum.openscad.org/
NH
nop head
Mon, Dec 10, 2018 7:04 PM

OpenCSG just draws all the triangles and if they cover all the pixels it
looks OK. CGAL on the other hand needs a mainfold mesh, not one with self
intersections in its planes.

On Mon, 10 Dec 2018 at 18:49, runsun runsun@gmail.com wrote:

Thx for the check, nophead. Wondering how OpenSCAD allows it to render
correctly when it's stand-alone.


$  Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc (
git ), runscad.py ( 2 , git ), editor of choice: CudaText  ( OpenSCAD lexer
); $ Tips ; $ Snippets

--
Sent from: http://forum.openscad.org/


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

OpenCSG just draws all the triangles and if they cover all the pixels it looks OK. CGAL on the other hand needs a mainfold mesh, not one with self intersections in its planes. On Mon, 10 Dec 2018 at 18:49, runsun <runsun@gmail.com> wrote: > Thx for the check, nophead. Wondering how OpenSCAD allows it to render > correctly when it's stand-alone. > > > > ----- > > $ Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( > git ), runscad.py ( 2 , git ), editor of choice: CudaText ( OpenSCAD lexer > );&nbsp;$ Tips ;&nbsp;$ Snippets > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Mon, Dec 10, 2018 7:05 PM

I should add CGAL is avoided if there are no CSG ops.

On Mon, 10 Dec 2018 at 19:04, nop head nop.head@gmail.com wrote:

OpenCSG just draws all the triangles and if they cover all the pixels it
looks OK. CGAL on the other hand needs a mainfold mesh, not one with self
intersections in its planes.

On Mon, 10 Dec 2018 at 18:49, runsun runsun@gmail.com wrote:

Thx for the check, nophead. Wondering how OpenSCAD allows it to render
correctly when it's stand-alone.


$  Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc (
git ), runscad.py ( 2 , git ), editor of choice: CudaText  ( OpenSCAD lexer
); $ Tips ; $ Snippets

--
Sent from: http://forum.openscad.org/


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

I should add CGAL is avoided if there are no CSG ops. On Mon, 10 Dec 2018 at 19:04, nop head <nop.head@gmail.com> wrote: > OpenCSG just draws all the triangles and if they cover all the pixels it > looks OK. CGAL on the other hand needs a mainfold mesh, not one with self > intersections in its planes. > > On Mon, 10 Dec 2018 at 18:49, runsun <runsun@gmail.com> wrote: > >> Thx for the check, nophead. Wondering how OpenSCAD allows it to render >> correctly when it's stand-alone. >> >> >> >> ----- >> >> $ Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( >> git ), runscad.py ( 2 , git ), editor of choice: CudaText ( OpenSCAD lexer >> );&nbsp;$ Tips ;&nbsp;$ Snippets >> >> -- >> Sent from: http://forum.openscad.org/ >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >
P
Parkinbot
Mon, Dec 10, 2018 8:06 PM

A triangulation like earcut with holes will be cumbersome to implement in
OpenSCAD. However a fast and viable solution for implementing the multi-hole
sweep is to use a vectorized lazy union sweep for the holes and difference
the result from the sweep of the outer polygon. For export one will have to
use a Boolean operation to do a CGAL check anyway.

--
Sent from: http://forum.openscad.org/

A triangulation like earcut with holes will be cumbersome to implement in OpenSCAD. However a fast and viable solution for implementing the multi-hole sweep is to use a vectorized lazy union sweep for the holes and difference the result from the sweep of the outer polygon. For export one will have to use a Boolean operation to do a CGAL check anyway. -- Sent from: http://forum.openscad.org/
R
runsun
Mon, Dec 10, 2018 8:13 PM

Just applied the union rendering check on the  alternative face description
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Alternate_Face_Descriptions
described in the documentation and found it failed the same way.
nophead wrote

It's happy to preview but doesn't work with a union with a unit cube and
F6.


$  Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText  ( OpenSCAD lexer ); $ Tips ; $ Snippets

--
Sent from: http://forum.openscad.org/

Just applied the union rendering check on the alternative face description <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Alternate_Face_Descriptions> described in the documentation and found it failed the same way. nophead wrote > It's happy to preview but doesn't work with a union with a unit cube and > F6. ----- $ Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText ( OpenSCAD lexer );&nbsp;$ Tips ;&nbsp;$ Snippets -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Thu, Dec 13, 2018 11:57 AM

You are right: it doesn't work. I created that section based on the
examples of 2D polygons with holes. I had checked it then with F6 but had
not done a full check with a cube union. Sorry by that.

What is strange (or inconsistent) is that 2D polygons with holes render
fine even with a full check.

I have deleted the section from the manual. It can be retrieved from the
wiki history anyway.

Ronaldo

Em seg, 10 de dez de 2018 às 20:14, runsun runsun@gmail.com escreveu:

You are right: it doesn't work. I created that section based on the examples of 2D polygons with holes. I had checked it then with F6 but had not done a full check with a cube union. Sorry by that. What is strange (or inconsistent) is that 2D polygons with holes render fine even with a full check. I have deleted the section from the manual. It can be retrieved from the wiki history anyway. Ronaldo Em seg, 10 de dez de 2018 às 20:14, runsun <runsun@gmail.com> escreveu: > Just applied the union rendering check on the alternative face description > <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Alternate_Face_Descriptions> > described in the documentation and found it failed the same way. > > nophead wrote > It's happy to preview but doesn't work with a union with a unit cube and > F6. > > $ <http://forum.openscad.org/mailing_list/MailingListOptions.jtp?forum=1> *Runsun > Pan, PhD* > $ *libs*: scadx <https://bitbucket.org/runsun/scadx>, doctest > <https://github.com/runsun/openscad_doctest>, faces > <http://forum.openscad.org/A-faces-function-for-simple-polyhedrons-td12809.html> > (git <https://github.com/runsun/faces.scad>), offline doc > <http://forum.openscad.org/Use-openscad-offliner-for-offline-documentation-td13096.html> > (git <https://github.com/runsun/openscad_offliner>), runscad.py > <http://forum.openscad.org/Animating-gif-with-3D-rotation-tp14011p14029.html> > (2 <http://forum.openscad.org/Symmetrical-Rotation-tp14062p14075.html>,git > <https://gist.github.com/runsun/995250a8002386ab9abc>), editor of choice: > CudaText > <http://forum.openscad.org/Syntax-highlighting-tp23247p23258.html> ( OpenSCAD > lexer <http://www.thingiverse.com/thing:1237864>); $ Tips > <https://github.com/runsun/OpenSCAD_Tips>; $ Snippets > <https://github.com/runsun/OpenSCAD_Tips/blob/master/snippets.md> > > ------------------------------ > Sent from the OpenSCAD mailing list archive <http://forum.openscad.org/> > at Nabble.com. > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >