算法拆分自相交Path2D中成若干不能自相交的路径? [英] Algorithm to split self-intersected Path2D into several not self-intersected paths?

查看:221
本文介绍了算法拆分自相交Path2D中成若干不能自相交的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的形状,以摆脱自相交。形状从一个点的数组构成,以使形状的所有段都行。 (的线,没有曲线和弧线)

I need to get rid of self-intersections in a shape. Shape is constructed from an array of points, so all segments of that shape are lines. (only lines, no curves and arcs)

previously,我试图从该点,构建一个区域,距离,然后用它的PathIterator我创建了几个Path2Ds,其中的创建Path2D中莫名其妙地的是previous路径的子路径,所以自intersetions都不见了。但是,这是不工作的一些路径 - 自交叉仍然存在。

Previously, I tried to create Path2D from that points, construct an Area from it, and then using its PathIterator I created several Path2Ds, which somehow were subpaths of previous path, and so self-intersetions were gone. But this isn't working for some paths - self-intersections still remain there.

所以,你能点我到一些地方,我可以找到很好的算法,做类似的事情?

So could you point me to some place where I can find good algorithm to do similar thing?

编辑:我还没有发现任何有用的任何地方,所以我写了我自己的算法。查看答案。

I haven't found anything useful anywhere, so I written my own algorithm. See the answers.

推荐答案

如果工作不适合你,你可以尝试使用<一个href="http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/glu/GLUtessellator.html"相对=nofollow> GLUtessellator 分解你的图形成一组三角形,或(使用的 GL_LINE_LOOP 选项)刚刚边界边。

If Area is not working for you, you could try using a GLUtessellator to decompose your Shape into a set of triangles, or (using the GL_LINE_LOOP option) just the boundary edges.

这篇关于算法拆分自相交Path2D中成若干不能自相交的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆