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 Supnik at 12:20
PM
 

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

  1. 面试 16:栈的压入压出队列(剑指 Offer 第 22 题)

    我们今天继续来看看周五留下的习题: 面试题:输入两个整数序列,第一个序列表示栈的压入顺序,请判断二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如:压入序列为{1,2,3,4,5},那{ ...

  2. 剑指offer(21)栈的压入、弹出序列

    题目描述 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序 ...

  3. 《剑指offer》-栈的压入、弹出序列

    输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一 ...

  4. 剑指offer-第四章解决面试题的思路(栈的压入和弹出序列)

    题目:输入两个整数序列,第一个序列表示栈的压入序列,请判断第二个序列是否为弹出序列. 思路:定义两个指针sPush和sPop分别指向两个整数序列的开头,借助一个辅助的栈,将第一个序列的数据依次压入栈中 ...

  5. 【剑指Offer】21、栈的压入、弹出序列

      题目描述:   输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否可能为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2 ...

  6. 剑指Offer-21.栈的压入、弹出序列(C++/Java)

    题目: 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否可能为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈 ...

  7. 剑指offer31----栈的压入、弹出序列

    题目:输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对 ...

  8. 剑指Offer面试题:20.栈的压入、弹出序列

    一.题目:栈的压入.弹出序列 题目:输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1.2.3.4.5是某栈的压栈序列,序列4 ...

  9. 剑指Offer:面试题22——栈的压入,弹出序列(java实现)

    题目描述: 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈 ...

随机推荐

  1. getopt--parse command line options

    getopt解析命令行选项 getopt, getopt_long, getopt_long_only, optarg, optind, opterr, optopt - Parse command- ...

  2. 关于HTTP的长连接和短连接

    1. HTTP协议与TCP/IP协议的关系 HTTP的长连接和短连接本质上是TCP长连接和短连接.HTTP属于应用层协议,在传输层使用TCP协议,在网络层使用IP协议. IP协议主要解决网络路由和寻址 ...

  3. js学习笔记22----BOM属性和方法

    BOM基本概念 : Browser Object Model 浏览器对象模型. BOM属性: window.navigator.userAgent : 浏览器信息 判断是否是某个浏览器,可以用 ind ...

  4. Hive三种不同的数据导出的方式

    转自:http://blog.chinaunix.net/uid-27177626-id-4653808.html Hive三种不同的数据导出的方式,根据导出的地方不一样,将这些方法分为三类:(1)导 ...

  5. 判断站点访问的终端类型(移动端还是pc端)的方法(转)

    要了解某个网站是在移动设备上打开的还是在pc web浏览器中打开的,我们可以有以下综合的几种方式来搞定: 通过判断Request.UserAgent中的具体信息来分析判断,因为UserAgent包含了 ...

  6. macosx下apache的默认用户为daemon

    环境macosx, xampp. 其中apache的默认账户为daemon,若想对htdocs下的文件做写操作,必须改动该文件夹的用户权限: chown daemon:daemon MYDIR chm ...

  7. THINKPHP5获取设置缓存的例子

    在THINKPHP5中 缓存的配置放在了config.php文件中 代码如下 如何设置缓存? 可以使用静态方法 Cache::set('key',$value,3600);//存储缓存 Cache:: ...

  8. IOS 开发之 -- 获取本机通讯录里面所有的联系人,并传到后台

    项目中遇到一个需求,就是需要在入口的时候,获取通讯录的权限,并把所有的联系人,以接口参数的形式传到后台,通过网上查资料,历时3个小时,终于完成, 话不多,直接上代码: 1,导入系统库 #import ...

  9. js文章收藏

    js文件被浏览器缓存的问题:http://www.cnblogs.com/wangtao_20/p/4589898.html

  10. ios 更改UITableview group形式 两个section之间的距离

    -(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section { return 1.0 ...