Polyhedron tube with irregular sides -- is it possible ?

classic Classic list List threaded Threaded
112 messages Options
123456
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

nophead
The 2D subsystem uses clipper, which is very good at sorting out self intersections, etc. CGALseems to be the opposite. It just rejects all non-manifold faces rather than attempting to heal them. However the 2D problem is simpler. Normally you just reverse the winding order to make holes or use the odd even rule.

Perhaps when the polyhedron face is considered planar clipper could be used to clean it up.

On Thu, 13 Dec 2018 at 11:58, Ronaldo Persiano <[hidden email]> wrote:
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 <[hidden email]> escreveu:
Just applied the union rendering check on the alternative face description 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 the OpenSCAD mailing list archive at Nabble.com.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

Parkinbot
Since the following code is accepted by CGAL

pts =  [[0, 0], [6, 0], [6, 5], [0, 5], [0, 0], [2, 1], [5, 2], [3, 4], [2,
1]];
linear_extrude(2)
  polygon(pts);
cube(1);

and obviously uses triangulation

<http://forum.openscad.org/file/t887/hole.png>

it shouldn't be too difficult to provide a built-in triangulate2D() function
that uses clipper and returns a [verts, triags] list.

vertsfaceslist = triangulate2D(pts);  // builtin call using clipper
returning a [verts, triags] list
// ... use vertsfaceslist


the prototype could be:

function triangulate2D(polygon, z=undef) = ...

If provided z would add the given value as z coordinate to the verts (vec3
conversion) for intended polyhedron usage. Doesn't this sound like a nice
feature request?





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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

Ronaldo
Parkinbot <[hidden email]> wrote:
it shouldn't be too difficult to provide a built-in triangulate2D() function
that uses clipper and returns a [verts, triags] list.


Clipper library doesn't have any polygon triangulation procedure. According to @Kintel, OpenScad uses a modified version of libtess2 to triangulate polygons (see http://forum.openscad.org/Simple-polygon-triangulation-tp16755p16762.html) and libtess2 is unable to deal with holes. I have found a polygon triangulation library supposedly robust and fast that accepts polygons with holes: poly2tri (https://doc-snapshots.qt.io/qt5-5.9/qtlocation-attribution-poly2tri.html) with a BSD 3 license clause. Is that license compatible with OpenScad GPL license?

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

cacb
On 16.12.2018 18:08, Ronaldo Persiano wrote:

> Parkinbot <[hidden email] <mailto:[hidden email]>>
> wrote:
>
>     it shouldn't be too difficult to provide a built-in triangulate2D()
>     function
>     that uses clipper and returns a [verts, triags] list.
>
>
> Clipper library doesn't have any polygon triangulation procedure.
> According to @Kintel, OpenScad uses a modified version of libtess2 to
> triangulate polygons (see
> http://forum.openscad.org/Simple-polygon-triangulation-tp16755p16762.html)
> and libtess2 is unable to deal with holes.

I don't believe this statement is correct, in my experience libtess2
deals with holes quite well, at least for the cases I have seen. Do you
have any examples showing it does not work with holes?

Carsten Arnholm


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

Parkinbot
In reply to this post by Ronaldo
Ronaldo wrote
> Parkinbot &lt;

> rudolf@

> &gt; wrote:
>
> Clipper library doesn't have any polygon triangulation procedure.
> According
> to @Kintel, OpenScad uses a modified version of libtess2 to triangulate
> polygons (see
> http://forum.openscad.org/Simple-polygon-triangulation-tp16755p16762.html)
> and libtess2 is unable to deal with holes.

I was referring to the post of nophead, without checking that.

nophead wrote
> The 2D subsystem uses clipper, which is very good at sorting out self
> intersections, etc. CGALseems to be the opposite. I

But in the thread you are referring to, the theme was almost planar polygons
in 3D. Here we are talking about the 2D subsystem. And linear_extrude
obviously uses a correct tesselation. Where does it come from?  





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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

nophead
I don't think faces need to be tesselated for CGAL. It can handle polygonal faces, so all linear_extrude would need to do is join the top and bottom polygons with quads.

I think the problem with polyhedron is the interface. I.e. it doesn't allow holes to be expressed in polygonal faces.

On Sun, 16 Dec 2018 at 18:33, Parkinbot <[hidden email]> wrote:
Ronaldo wrote
> Parkinbot &lt;

> rudolf@

> &gt; wrote:
>
> Clipper library doesn't have any polygon triangulation procedure.
> According
> to @Kintel, OpenScad uses a modified version of libtess2 to triangulate
> polygons (see
> http://forum.openscad.org/Simple-polygon-triangulation-tp16755p16762.html)
> and libtess2 is unable to deal with holes.

I was referring to the post of nophead, without checking that.

nophead wrote
> The 2D subsystem uses clipper, which is very good at sorting out self
> intersections, etc. CGALseems to be the opposite. I

But in the thread you are referring to, the theme was almost planar polygons
in 3D. Here we are talking about the 2D subsystem. And linear_extrude
obviously uses a correct tesselation. Where does it come from? 





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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

Parkinbot
nophead wrote
> I don't think faces need to be tesselated for CGAL.

but for polyhedron. And linear_extrude obviously uses a tesselation when it
extrudes a polygon with hole.



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

nophead
What makes you think that? It is definitely tesilated with F5

image.png

But not with F6, unless it hides it better.

image.png



On Sun, 16 Dec 2018 at 21:08, Parkinbot <[hidden email]> wrote:
nophead wrote
> I don't think faces need to be tesselated for CGAL.

but for polyhedron. And linear_extrude obviously uses a tesselation when it
extrudes a polygon with hole.



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

cacb
On 2018-12-16 22:21, nop head wrote:
> What makes you think that? It is definitely tesilated with F5
>
> But not with F6, unless it hides it better.
>

Save it to STL or any other format requiring triangles.

Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

nophead
Yes but I beleive CGAL objects get tesilated when they are converted to STL. The can have single facets that are pologons. They aren't triangle meshes.

On Sun, 16 Dec 2018 at 21:27, <[hidden email]> wrote:
On 2018-12-16 22:21, nop head wrote:
> What makes you think that? It is definitely tesilated with F5
>
> But not with F6, unless it hides it better.
>

Save it to STL or any other format requiring triangles.

Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

Parkinbot
Sorry nophead,

I meant that I can see that F5 tessellates a polygon with holes for use with
linear_extrude and we could use the underlying functionality to provide a
function that tesselates a 2D polygon given as list.  

Btw, I see a F5 tesselation but not a F6 tesselation for

sphere(10);

Maybe OpenSCAD just doesn't display it?



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

Parkinbot
Parkinbot wrote
> Btw, I see a F5 tesselation but not a F6 tesselation for
>
> sphere(10);
>
> Maybe OpenSCAD just doesn't display it?

It looks like it is only displayed when a boolean operation is involved

translate([20, 0, 0])
cube(5);
sphere(10);




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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

nophead
In reply to this post by Parkinbot
If you just have sphere(10) without any CSG ops CGAL is not involved. OpenScad has its own 3D representation and when that is displayed show edges does not work.

If you add a unit cube then CGAL generates the union and the final result is then a CGAL object and show edges works.

image.png

It is mostly tesselated with triangles but there are some quads and polgonal poles. Wierd, but that is probably just how it is constructed, not by using a tessalator.

When you do F5 the tessalation is totally different. I think OpenCSG tesselates everything to triangles when it displayes.



On Sun, 16 Dec 2018 at 23:40, Parkinbot <[hidden email]> wrote:
Sorry nophead,

I meant that I can see that F5 tessellates a polygon with holes for use with
linear_extrude and we could use the underlying functionality to provide a
function that tesselates a 2D polygon given as list. 

Btw, I see a F5 tesselation but not a F6 tesselation for

sphere(10);

Maybe OpenSCAD just doesn't display it?



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

Parkinbot
Ronaldo had noticed it some time ago that CGAL changes tesselation on its own
will.

I created a cube by means of sweep(). So I am sure that it is tesselated in
triags. See how it is displayed by F6 with a unit cube unioned.
<http://forum.openscad.org/file/t887/sweep.png>




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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

nophead
Looks like CGAL de-tesselates triangles in the same plane to make pologons. That makes it hard to know what the internal representation of anything is. It used to always be CGAL nef_polyhreda I think but now it switches back and forth to polysets. When the result is a polyset you don't get all the vertex / edge info and show edges does not work. Also I think it switches from rationals to doubles for the vertices.

On Mon, 17 Dec 2018 at 00:19, Parkinbot <[hidden email]> wrote:
Ronaldo had noticed it some time ago that CGAL changes tesselation on its own
will.

I created a cube by means of sweep(). So I am sure that it is tesselated in
triags. See how it is displayed by F6 with a unit cube unioned.
<http://forum.openscad.org/file/t887/sweep.png>




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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

Parkinbot
Clearly, CGAL is only called when a Boolean operation is present. Thus the
polyset to nef_polyhreda conversion is not necessary for primitives like a
polyhedron and can't be displayed.  
When CGAL is called, it seems to try to reduce faces.

Nevertheless there is a tesselation of polygon with holes for F5 and this
one could be exposed to the user.



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

nophead
Yes but I don't think tessalation is the issue with polyhedron. The problem seems to be the interface to polyhedron has no way to express holes.

It could detect faces that are coplanar with an encolsing face pass them through clipper to sort out the holes. Or it could allow the keyhole contruction, detect the loops and remove the extra edges between loops. So each face becomes a list of loops with counter clockwise ones being holes.

Tessalation should only be needed when the faces are not planar.


On Mon, 17 Dec 2018 at 00:54, Parkinbot <[hidden email]> wrote:
Clearly, CGAL is only called when a Boolean operation is present. Thus the
polyset to nef_polyhreda conversion is not necessary for primitives like a
polyhedron and can't be displayed. 
When CGAL is called, it seems to try to reduce faces.

Nevertheless there is a tesselation of polygon with holes for F5 and this
one could be exposed to the user.



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

Parkinbot
If there is a tesselation, a sweep with more than one hole can be
implemented. Wasn't this at least part the aim?



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

nophead
I don't understand why you think it needs tesselation to represent a polygonal face with holes in it. OpenSCAD can handle such faces no problem and tesselates them when triangles are required, such as for STL export. The issue is that polyhedron can't create faces with holes. It nearly can with the keyhole method but they are not acceptable to CGAL in that format as they are not manifold. Simply removing the connections between loops and ensuring the correct winding order should fix that.

On Mon, 17 Dec 2018 at 10:13, Parkinbot <[hidden email]> wrote:
If there is a tesselation, a sweep with more than one hole can be
implemented. Wasn't this at least part the aim?



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron tube with irregular sides -- is it possible ?

Parkinbot
nophead wrote
> I don't understand why you think it needs tesselation to represent a
> polygonal face with holes in it. OpenSCAD can handle such faces no problem
> and tesselates them when triangles are required, such as for STL export.
> The issue is that polyhedron can't create faces with holes.

The target of a sweep is a polyhedron. For this it interprets a vector of
polygons. The first polygon in this vector defines the starting face, and
the last the end face. Any two consecutive polygons define a piece of wall.

If I have a function that I can use to tesselate the first and last faces, I
can implement a sweep for any tube-like structures with holes, because it is
easy for me to find holes in polygons, but very expensive to implement an
earcut with holes for 2D-polygons.

Alternatively polyhedron could allow me to use (planar) faces with holes. In
this case, polyhedron could use internally the same function that a
linear_extrude obviously uses, when it extrudes a polygon with holes. BUT: I
don't see this coming soon, because it requires a tesselation of almost
planar faces in 3D. To use the suspected given 2D tesselation, the
implementation could employ some coordinate transformation like I just
presented in the other  thread
<http://forum.openscad.org/Rotation-question-tp24970p24992.html>  , then
project the almost planar face down to xy, and finally find the tesselation
by calling this ominous function. The problem of the "almost planar" will
stay. How will you define it? How much deviation will be allowed. How will
an "alternative construction" work?

However, even if polyhedron will accept polygons with holes some day, it
would be a nice-to-have, to get an explicite tesselation of a polygon with
holes from a built-in OpenSCAD function, just like cross() and norm()
operate over a list of numbers.






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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
123456