怎样将Arranged_2压入General_Polygon_set_2中

Thursday, March 14, 2013

How to Jam an Arrangement_2 into a General_polygon_set_2

I spent about three hours yesterday tracking down a weird bug in CGAL - I have code that builds a general polygon set out of an
 arrangement, exports the polygons, and weirdly the polygons had duplicate points.  This is an impossibility for a valid arrangement.

昨天我花了近3个小时追踪一个怪异的CGAL的bug——我写那个程序是为了从arrangement中构建出多边形的集合,然后导出这些多边形,而奇怪的多边形
会有反复点。但在有效的arrangement里这是不可能的。

To my annoyance, I discovered today as I went to write the bug up that I knew about this bug...over three years ago. :-(  I get annoyed when I search for the answer to an obscure OpenGL problem and find my own post (e.g. I'm not going to find anything I didn't already know), but it's even more annoying to waste hours on the bug and then have that happen.
让我气愤只是的是,我今天去记录这个问题是发现我事实上在三年前就遇到过了。:-(当我搜索明显的OpengGL问题然后发现了自己的博文(我不会找到不论什么我不知道的)。可是更令人火大的是我居然花了数小时调代码并产生这个错误。
Basically if you are going to build a general polygon set by providing a pre-built arrangement, there are two things you must do:
  • Remove redundant edges - the GPS code assumes that the arrangement doesn't have needless edges (which will screw up traversal).  Fortunately, the GPS code has a utility to do this, which I just call.
  • Then you have to ensure that the direction of the underlying curves along the various edges are consistent - that is, for a given counter-clockwise boundary, every underlying curve goes either with or against the edge.
(After redundant edge removal, the arrangement will contain no antennas, so it will always be possible to get consistency on both sides of a CCB.)
基本上,假设你要从一个预先构建的arrangement中拿出通用多边形集合。有两件事必须做:
         移除冗余边——GPS代码默认arrangement不须要的边(它们会搞乱遍历过程)幸运的是GPS码有一个辅助函数供我调用帮助完毕这一工作。
         然后你必须确保作为各边基线的曲线的方向是连续的——即给定顺时针方向的边界,每个基础曲线都顺着或逆向于该边界。

I wrote code to enforce this second condition by flipping the curve of any halfedge where (1) the curve goes against the halfedge and (2) the halfedge is adjacent to the "contained" side of the map.

With this, polygon set operations work on arbitrary map input.

Why Did You Try This?

Forcing pre-made arrangements into polygon sets requires sub-classing the general polygon set template instantiation to get direect access to things like the arrangement, and it's not particularly safe.  It also requires your arrangement to have the containment flag on the face data mixed in.  Why go to the trouble?  I did this for two reasons:
  • Sometimes the polygonal set data I want to process came from an arrangement, and that arrangement is fairly huge.  Having to construct the arrangement out of polygons the normal way requires geometry tests - topology data would be lost and rediscovered.  For big maps this is really performance-painful.
  • I have some operations that work on arrangements that are precursors to boolean sets. For example, the airport surface area data are fundamentally polygon sets (e.g. in the set is the airport surface area) but some of the constructive processing (e.g. simplifying the contour) run on arrangements.
When an arrangement is turned into a polygon set, one of the results is a rather drastic map cleaning.  Since the polygon set cares only about containment (what points are in, what are out), random features like roads tend to get blown away.
原文地址:https://www.cnblogs.com/ldxsuanfa/p/9968060.html