青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

eryar

PipeCAD - Plant Piping Design Software.
PlantAssistant - Translate AVEVA RVM/SP3D VUE to glTF, STEP, etc.
posts - 606, comments - 590, trackbacks - 0, articles - 0

Visulalization Boost Voronoi in OpenSceneGraph

eryar@163.com

Abstract. One of the important features of the boost polygon library is the implementation of the generic sweepline algorithm to construct Voronoi diagrams of points and linear segments in 2D(developed as part of the Google Summer of Code 2010 program). Voronoi diagram data structure has applications in image segmentation, optical character recognition, nearest neighbor queries execution. It is closely related with the other computational geometry conectps: Delaunay triangulation, medial axis, straight skeleton, the largest empty circle. The paper focus on the usage of Boost.Polygon Voronoi Diagram and visualize it in OpenSceneGraph.

Key words. Voronoi, Boost.Polygon, C++, OpenSceneGraph, Visualization

1. Introduction

計算幾何(Computational Geometry)作為一門學科,起源于20世紀70年代,經過近四十多年的發展,其研究內容不斷擴大,涉及Voronoi圖、三角剖分、凸包、直線與多邊形求交、可見性、路徑規劃、多邊形剖分等內容。據相關統計,在數以千計的相關文章中,約有15%是關于Voronoi圖及其對偶(dual)圖Delaunay三角剖分(Delaunay Triangulation)的研究。由于Voronoi圖具有最近性、鄰接性等眾多性質和比較系統的理論體系,如今已經在計算機圖形學、機械工程、地理信息系統、機器人、圖像處理、大數據分析與處理、生物計算及無線傳感網絡等領域得到了廣泛應用,同時也是解決碰撞檢測、路徑規劃、可見性計算、骨架計算以及凸包計算等計算幾何所涉及的其他問題的有效工具。

Voronoi圖的起源最早可以追溯到17世紀。1644年,Descartes用類似Voronoi圖的結構顯示太陽系中物質的分布。數學家G.L. Dirichlet和M.G.Voronoi分別于1850年和1908年在他們的論文中討論了Voronoi圖的概念,所以Voronoi圖又叫Dirichlet tessellation。在其他領域,這個概念也曾獨立地出現,如生物學和生理學中稱之為中軸變換(Medial Axis Transform)或骨架(Skeleton)。化學與物理學中稱之為Wigner-Seitz Zones,氣象學與地理學中稱之為Thiessen多邊形。Voronoi圖最早由Thiessen應用于氣象觀測站中隨機分布的研究。由于M.G. Voronoi從更通用的n維情況對其進行研究和定義,所以Voronoi圖這個名稱為大多數人所使用。

在路徑規劃、機械加工、模式識別、虛擬現實、生物計算等領域,將站點從離散點擴展到線段圓弧等生成Voronoi圖的方式也是非常常見的。

目前可用于生成Voronoi圖的庫有一些,很多是開源庫。像CGAL庫、boost中也提供了生成Voronoi圖的算法。本文根據Boost.Polygon中的Voronoi庫,并用OpenSceneGraph顯示出剖分結果。

2. Boost.Polygon Voronoi Diagram

Boost.Polygon庫提供了構造Voronoi圖的接口,可根據點集、線段集來生成Voronoi圖,如下圖所示:

wps_clip_image-28950

Figure 2.1 Voronoi Diagram generated by Boost.Polygon Voronoi Algorithms

Boost.Polygon中的基于掃描線算法(sweep-line algorithm)Voronoi庫可以實現如下功能:

v 輸入數據可以是點集和線段;

v 算法的穩定性高及輸出完整的拓樸信息;

v 可以控制輸出的幾何信息的精度;

計算幾何方面以穩定性著稱的CGAL庫中的Voronoi算法只滿足前兩個功能。S-Hull庫以上功能都沒有很好的滿足。下面是一些Boost.Polygon,CGAL,S-Hull庫的對比數據:

wps_clip_image-24820

wps_clip_image-17491

Figure 2.2 Construction time for 10 random points

wps_clip_image-6204

Figure 2.3 Construction time for 100 random points

wps_clip_image-7587

Figure 2.4 Construction time for 1000 random points

wps_clip_image-22652

Figure 2.5 Construction time for 10000 random points

wps_clip_image-7032

Figure 2.6 Memory usage for 100000 random points

wps_clip_image-14814

Figure 2.7 Logarithmic Execution Time

結論:

v 在輸入上沒有限制這點上CGAL要優于Boost.Polygon;

v Boost.Polygon Voronoi的穩定性要高于S-Hull;

v Boost.Polygon Voronoi和S-Hull的時間復雜度為N*log(N),而CGAL的不是;

v Boost.Polygon Voronoi的輸出頂點的精度高于CGAL庫;

v Boost.Polygon Voronoi的速度快;

v Boost.Polygon Voronoi根據10000個點或1000個線段來構造Voronoi的時間為0.02秒以內,所以可用來處理有實時性要求的場景;

3. Implementation

Boost.Polygon的Voronoi算法使用簡單,只需要輸入點集或線段集合,就可以直接構造出Voronoi圖了。最簡單的程序示例代碼如下:

 

/*
*    Copyright (c) 2014 eryar All Rights Reserved.
*
*        File    : Main.cpp
*        Author  : eryar@163.com
*        Date    : 2014-05-06 18:28
*        Version : V1.0
*
*    Description : The Simplest example for boost voronoi library.
*      Key words : boost voronoi, C++
*
*/

#include 
"boost/polygon/voronoi.hpp"

using namespace boost::polygon;

typedef 
int coordinate_type;
typedef point_data
<coordinate_type> Point;
typedef voronoi_diagram
<double> VD;

int main(int argc, char* argv[])
{
    std::vector
<Point> points;

    points.push_back(Point(
00));
    points.push_back(Point(
16));
    points.push_back(Point(
-45));
    points.push_back(Point(
5-1));
    points.push_back(Point(
3-11));
    points.push_back(Point(
13-1));

    VD vd;
    construct_voronoi(points.begin(), points.end(), 
&vd);

    
return 0;
}

且Boost.Polygon的Voronoi算法遍歷Voronoi邊Edges,Voronoi單元cell,Voronoi頂點Vertex也很直接。如下代碼所示為遍歷所有邊,來將剖分結果可視化:

 

/*
*    Copyright (c) 2014 eryar All Rights Reserved.
*
*        File    : Main.cpp
*        Author  : eryar@163.com
*        Date    : 2014-05-06 18:28
*        Version : V1.0
*
*    Description : VoronoiViewer for boost voronoi library visulization.
*      Key words : boost voronoi, C++, OpenSceneGraph
*
*/

#include 
<osgViewer/Viewer>
#include 
<osgGA/StateSetManipulator>
#include 
<osgViewer/ViewerEventHandlers>

#pragma comment(lib, 
"osgd.lib")
#pragma comment(lib, 
"osgDBd.lib")
#pragma comment(lib, 
"osgGAd.lib")
#pragma comment(lib, 
"osgViewerd.lib")


#include 
"boost/polygon/voronoi.hpp"

using namespace boost::polygon;

typedef 
double coordinate_type;
typedef point_data
<coordinate_type> Point;
typedef voronoi_diagram
<coordinate_type> VD;


osg::Node
* BuildVoronoiDiagram(void)
{
    srand(static_cast
<unsigned int> (time(NULL)));

    osg::ref_ptr
<osg::Geode> theGeode = new osg::Geode();
    osg::ref_ptr
<osg::Geometry> theLines = new osg::Geometry();
    osg::ref_ptr
<osg::Vec3Array> theVertices = new osg::Vec3Array();

    VD vd;
    std::vector
<Point> thePoints;

    
// Add points for the Voronoi Diagram.
    for (int i = 0; i < 100++i)
    {
        
int x = rand() % 100;
        
int y = rand() % 100;

        thePoints.push_back(Point(x, y));

        
// Display the site of the Voronoi Diagram.
        theVertices->push_back(osg::Vec3(x - 10.0, y));
        theVertices
->push_back(osg::Vec3(x + 10.0, y));

        theVertices
->push_back(osg::Vec3(x, 0.0, y - 1));
        theVertices
->push_back(osg::Vec3(x, 0.0, y + 1));
    }

    construct_voronoi(thePoints.begin(), thePoints.end(), 
&vd);

    
// Visualize the edge of the Voronoi Diagram.
    
// Traversing Voronoi edges using edge iterator.
    for (VD::const_edge_iterator it = vd.edges().begin(); it != vd.edges().end(); ++it)
    {
        
if (it->is_primary())
        {
            
if (it->is_finite())
            {
                theVertices
->push_back(osg::Vec3(it->vertex0()->x(), 0.0, it->vertex0()->y()));
                theVertices
->push_back(osg::Vec3(it->vertex1()->x(), 0.0, it->vertex1()->y()));
            }
            
else
            {
                Point p1 
= thePoints[it->cell()->source_index()];
                Point p2 
= thePoints[it->twin()->cell()->source_index()];
                Point origin;
                Point direction;
                coordinate_type koef 
= 1.0;

                origin.x((p1.x() 
+ p2.x()) * 0.5);
                origin.y((p1.y() 
+ p2.y()) * 0.5);

                direction.x(p1.y() 
- p2.y());
                direction.y(p2.x() 
- p1.x());

                
if (it->vertex0() == NULL)
                {
                    theVertices
->push_back(osg::Vec3(
                        origin.x() 
- direction.x() * koef, 
                        
0.0,
                        origin.y() 
- direction.y() * koef));
                }
                
else
                {
                    theVertices
->push_back(osg::Vec3(it->vertex0()->x(), 0.0, it->vertex0()->y()));
                }

                
if (it->vertex1() == NULL)
                {
                    theVertices
->push_back(osg::Vec3(
                        origin.x() 
+ direction.x() * koef, 
                        
0.0,
                        origin.y() 
+ direction.y() * koef));
                }
                
else
                {
                    theVertices
->push_back(osg::Vec3(it->vertex1()->x(), 0.0, it->vertex1()->y()));
                }
            }
        }
    }
    
    theLines
->setVertexArray(theVertices);

    
// Set the colors.
    osg::ref_ptr<osg::Vec4Array> theColors = new osg::Vec4Array();
    theColors
->push_back(osg::Vec4(1.0f1.0f0.0f1.0f));

    theLines
->setColorArray(theColors);
    theLines
->setColorBinding(osg::Geometry::BIND_OVERALL);

    
// Set the normal.
    osg::ref_ptr<osg::Vec3Array> theNormals = new osg::Vec3Array();
    theNormals
->push_back(osg::Vec3(0.0f-1.0f0.0f));

    theLines
->setNormalArray(theNormals);
    theLines
->setNormalBinding(osg::Geometry::BIND_OVERALL);

    theLines
->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES, 0, theVertices->size()));
    
    theGeode
->addDrawable(theLines);

    
return theGeode.release();
}


int main(int argc, char *argv[])
{
    osgViewer::Viewer theViewer;

    theViewer.setSceneData(BuildVoronoiDiagram());
    theViewer.addEventHandler(
new osgGA::StateSetManipulator(theViewer.getCamera()->getOrCreateStateSet()));
    theViewer.addEventHandler(
new osgViewer::StatsHandler);
    theViewer.addEventHandler(
new osgViewer::WindowSizeHandler);

    
return theViewer.run();
}

繪制Voronoi的邊時,當邊是有限的finite時,直接可以畫出直線;當邊是infinite時,根據定義計算出了無界邊的方向。顯示結果如下圖所示:

wps_clip_image-8913

Figure 3.1 Construct Voronoi Diagram by 10 random points by Boost.Polygon

wps_clip_image-27895

Figure 3.2 Construct Voronoi Diagram by 100 random points by Boost.Polygon

4. Conclusion

Boost.Polygon中的Voronoi圖算法穩定性及性能較高,且可以根據站點查找相關的拓樸信息,如根據站點查找Voronoi單元等;惟一不足的就是默認只處理整數點集。

當輸入有線段時,生成的Voronoi圖中有曲線,曲線的繪制可參考相關例子實現。

Boost.Polygon中的Voronoi算法都以模板實現,編譯時只需要包含相關的頭文件即可,不依賴其他庫,使用還是很方便的。

5. References

1. http://www.boost.org/

2. Boost.Polygon,http://www.boost.org/doc/libs/1_55_0/libs/polygon/doc/index.htm

3. Voronoi Basic Tutorial,\boost_1_54_0\libs\polygon\doc\voronoi_basic_tutorial.htm

4. 汪嘉業, 王文平, 屠長河, 楊承磊. 計算幾何及應用. 科學出版社. 2011

5. 楊承磊, 呂琳, 楊義軍, 孟祥旭. Voronoi圖及其應用. 清華大學出版社. 2013

 

Feedback

# re: Visulalization Boost Voronoi in OpenSceneGraph  回復  更多評論   

2014-05-08 10:37 by OpenCASCAE->3D
韋恩圖,在我們地理信息專業也有涉及,真棒,又受教了,哈哈。

# re: Visulalization Boost Voronoi in OpenSceneGraph  回復  更多評論   

2014-05-08 13:11 by eryar
是的,Voronoi圖的作用很大,我也是要學習中,看看能不能應用一下
@OpenCASCAE-&gt;3D

只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国产精品久久一区二区三区| 欧美色中文字幕| 亚洲乱码国产乱码精品精天堂 | 影音先锋久久久| 亚洲高清三级视频| 国产精品国产三级国产普通话三级 | 久久亚洲综合色| 欧美日韩1区2区3区| 久久亚洲一区二区| 国产欧美日韩综合一区在线播放| 最新国产精品拍自在线播放| 国产在线欧美日韩| 日韩一区二区精品在线观看| 亚洲国产精品福利| 久久免费午夜影院| 久久精品亚洲精品| 国产精品国产亚洲精品看不卡15| 亚洲国产aⅴ天堂久久| 在线成人中文字幕| 久久精品国产亚洲5555| 欧美一区二区精美| 国产精品极品美女粉嫩高清在线| 亚洲人精品午夜在线观看| 亚洲国产日韩精品| 久久中文字幕一区| 欧美fxxxxxx另类| 精品99一区二区| 久久精品视频免费| 久久天堂精品| 激情成人av| 久久精品一区| 麻豆视频一区二区| 亚洲第一页中文字幕| 久久亚洲春色中文字幕久久久| 久久亚洲春色中文字幕| 精品不卡一区二区三区| 久久香蕉国产线看观看av| 毛片一区二区三区| 亚洲国产日韩一区| 欧美黑人国产人伦爽爽爽| 亚洲国产一区二区三区在线播| 日韩视频在线你懂得| 欧美日韩国产高清| 亚洲一区二区精品在线观看| 久久爱www久久做| 狠狠久久亚洲欧美| 欧美成人激情视频| 一道本一区二区| 午夜欧美精品| 一区二区三区我不卡| 欧美国产高潮xxxx1819| 99精品黄色片免费大全| 欧美在线不卡视频| 在线看成人片| 欧美调教vk| 欧美一区二区三区在线看| 欧美成人一区二免费视频软件| 亚洲国内精品| 欧美精品在线观看91| 亚洲欧美激情精品一区二区| 在线观看日产精品| 美日韩精品视频免费看| 99国产精品久久久久久久| 欧美一区三区二区在线观看| 黄色成人在线观看| 欧美日韩精品系列| 欧美一区二区三区婷婷月色| 91久久久久久| 国产精品99免费看| 亚洲精品视频在线看| 激情综合久久| 亚洲综合色视频| 欧美成人a视频| 亚洲午夜电影| 欧美国产第二页| 欧美一区二区三区视频免费播放| 永久免费精品影视网站| 欧美午夜精品理论片a级按摩| 久久精品毛片| 亚洲一级片在线观看| 亚洲国产欧美不卡在线观看| 欧美在线视频网站| 亚洲网在线观看| 亚洲激情午夜| 激情久久综艺| 国产嫩草一区二区三区在线观看| 欧美国产日韩一区二区| 久久狠狠婷婷| 亚洲一区二区欧美日韩| 亚洲精品久久久久久久久| 欧美**人妖| 久久全球大尺度高清视频| 亚洲欧美清纯在线制服| 日韩一二三在线视频播| 亚洲国产一区二区三区高清| 国产视频精品xxxx| 国产精品久久久久国产精品日日| 猛干欧美女孩| 久久夜色精品国产| 久久久久国产精品麻豆ai换脸| 亚洲主播在线| 亚洲自拍16p| 一区二区三区精品| 99精品视频免费全部在线| 亚洲国产欧美在线人成| 亚洲国产精品久久91精品| 欧美 日韩 国产在线| 欧美chengren| 亚洲国产精品va在线看黑人| 欧美成人一区二区在线| 久久一二三区| 免费av成人在线| 女仆av观看一区| 亚洲国产高清aⅴ视频| 亚洲国产高清在线| 91久久香蕉国产日韩欧美9色 | 亚洲欧洲一区二区在线观看| 在线精品观看| 亚洲人成网在线播放| 亚洲精品少妇网址| 日韩视频在线免费观看| 99成人在线| 亚洲自拍偷拍麻豆| 久久不射中文字幕| 久久综合狠狠综合久久综合88 | 欧美一区二区免费视频| 欧美在线观看视频| 久久亚洲一区| 亚洲国产美女| 宅男在线国产精品| 午夜影院日韩| 久久亚洲美女| 欧美日韩不卡视频| 国产精品入口尤物| 伊人久久综合| 中文精品视频| 久久久xxx| 亚洲丁香婷深爱综合| 一本色道久久88亚洲综合88| 亚洲欧美在线磁力| 免费一级欧美片在线播放| 欧美日韩一区二区三区在线视频 | 欧美午夜寂寞影院| 国产欧美日韩视频在线观看 | 一区二区三区黄色| 久久精品成人| 亚洲电影av在线| 亚洲男人天堂2024| 另类天堂视频在线观看| 欧美日韩专区在线| 一区二区三区在线观看视频| aa日韩免费精品视频一| 久久久999| 亚洲精品一区二区三区不| 午夜精品久久久久久 | 亚洲欧美在线x视频| 蜜臀av性久久久久蜜臀aⅴ四虎| 欧美日韩一级黄| 极品少妇一区二区| 亚洲主播在线| 亚洲第一天堂无码专区| 香蕉尹人综合在线观看| 欧美日本高清一区| 激情婷婷欧美| 欧美一区二区精美| 亚洲精品免费一二三区| 久久久久综合网| 国产精品久久一卡二卡| 亚洲第一区在线| 性高湖久久久久久久久| 最新国产精品拍自在线播放| 欧美一区二区视频网站| 欧美日韩国产高清视频| 亚洲国产精品悠悠久久琪琪| 久久av一区二区三区漫画| 99精品欧美| 欧美激情网站在线观看| 一区二区三区无毛| 久久九九国产| 亚洲一区二区三区四区中文| 欧美精品一区二区三区在线看午夜 | 亚洲永久精品国产| 亚洲人成在线播放| 久久婷婷国产综合国色天香| 国产一区二区福利| 小处雏高清一区二区三区| 日韩一级精品视频在线观看| 久久夜色撩人精品| 国产精品福利片| 日韩一级在线观看| 亚洲免费电影在线观看| 老鸭窝毛片一区二区三区| 韩日精品在线| 久久婷婷国产综合尤物精品| 亚洲欧美国产日韩天堂区| 国产精品xxxxx| 亚洲综合日韩在线| 亚洲男人av电影| 国产日韩欧美中文在线播放| 欧美影院一区|