怎样将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.

Posted by Benjamin Supnikat 12:20
PM

时间: 2025-01-20 02:02:41

怎样将Arranged_2压入General_Polygon_set_2中的相关文章

剑指Offer-栈的压入、弹出序列

题目: 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出序列.(注意:这两个序列的长度是相等的) 思路: 将pushV中的元素依次压入栈中,并从头比较popV中的元素.若元素相同,则从栈中弹出该元素并向后移动popV,直到pushV中所有的元素都被压入栈中.若最终栈中元素为空,证明弹出顺序

栈的压入、弹出序列——22

输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1.2.3.4.5是某栈的压栈顺序,序列4.5.3.2.1是该压栈序列对应的一个弹出序列,但4.3.5.1.2就不可能是该压栈序列的弹出序列. 首先,可以在第一个序列也就是压栈顺序中找第二个序列中第一个元素,是4,因为第二个序列中第一个元素是第一个被弹出的,那么在压入顺序中,被弹出数据之前的所有数据都被压入了栈中且还没有被弹出,也就是连续压进去了1.2.3.4,然后弹出第一个

栈的压入与弹出

这个题目,其实考的是栈的本质问题,也就是它的压入和弹出的顺序.首先我们分析题目 中所给的那几个例子,也就是数据的压入顺序是1.2.3.4.5.但是弹出的顺序是4.5. 3.2.1.这个好办啦,猜都能猜到它是如何操作的. 我们直观上看是这样,但是实际上,给你一个压入数组,一个弹出的数组,如何去判断它 的正确性呢? 其实我们可以根据这两个数组进行分析: 从上面可以看到,首先弹出的是4,因此栈顶肯定是4啦,但是此时栈里只有4吗? 肯定不是,因为先入先出嘛,看第一个数组,先压入了1.2.3.再压入了4,

21、剑指offer--栈的压入、弹出序列

题目描述 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出序列.(注意:这两个序列的长度是相等的) 解题思路:首先该题采用辅助栈来实现,j记录弹出元素处理到的位置 1)将待压入栈中的数据,先压入辅助栈 2)然后循环判断判断辅助栈栈顶是否等于待弹出栈的相应元素,相等,就弹出,并且j++,若不

数据结构和算法之栈和队列二:栈的压入,弹出序列

当时我在学习这个的时候也是非常不理解这个问题,一个栈的压入和弹出序列的判断一看不就知道了么,还去判断干嘛.只要符合后进先出的规则就行.但是我在这里简单说一下这个压入和弹出序列是怎么回事.就是我们给定假设的两个序列,一个为压入序列,一个为弹出序列.然后我们再通过一个辅助的栈,把压入序列的数据一个一个push()进入临时的辅助栈中,如果栈顶元素刚好和弹出序列的数据一样,那么我们就弹出,如果不一样我们就将压入序列的数据继续压入临时栈中,直到到达序列结束.如果压入序列结束,临时栈全部数据弹出那么就是一个

面试题——栈的压入、弹出顺序

题目描述: 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否可能为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出序列.(注意:这两个序列的长度是相等的) 思路: 对于例子,先给出模拟的规律: 对于压入顺序1,2,3,4,5以及弹出序列4,5,3,2,1 考虑弹出序列第一个元素4,4既然是第一个被抛出的元素,那么由压入元素的顺序可知,1,

剑指offer: 栈的压入和弹出序列

输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出序列.(注意:这两个序列的长度是相等的) (1)如果下一个弹出的数字刚好是栈顶数字,那么直接弹出:(2)如果一下个弹出的数字不在栈顶,则把压栈序列中还没有入栈的数字压入辅助栈,直到把下一个需要弹出的数字压入栈顶:(3)如果所有数字都压入栈仍然

剑指offer 栈的压入弹出 顺序

判断: 如果下一个弹出的数字刚好是栈顶元素,那么直接弹出 如果下一个弹出的数字不在栈顶,我们要把压栈序列中,还没有入栈的数字压入辅助栈,知道把下一个需要弹出的数字压入栈顶 如果所有的数字都入栈,但是仍然没有找到下一个弹出的数字,那么该序列不可能为弹出序列. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 class Solution { public:     bool IsPopOrder(vector<int> 

栈的压入、弹出序列-剑指Offer

栈的压入.弹出序列 题目描述 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出序列. 思路 需要一个辅助栈 如果下一个弹出栈的数字刚好是栈顶数字,那么直接弹出.若不是,把压栈序列中没有入栈的的数字压入辅助栈,直到把下一个需要弹出的数字压入栈顶为止.若所有数字都压入栈仍然没有找到下一个弹出的