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

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

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

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

在路徑規(guī)劃、機(jī)械加工、模式識(shí)別、虛擬現(xiàn)實(shí)、生物計(jì)算等領(lǐng)域,將站點(diǎn)從離散點(diǎn)擴(kuò)展到線段圓弧等生成Voronoi圖的方式也是非常常見(jiàn)的。

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

2. Boost.Polygon Voronoi Diagram

Boost.Polygon庫(kù)提供了構(gòu)造Voronoi圖的接口,可根據(jù)點(diǎn)集、線段集來(lái)生成Voronoi圖,如下圖所示:

wps_clip_image-28950

Figure 2.1 Voronoi Diagram generated by Boost.Polygon Voronoi Algorithms

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

v 輸入數(shù)據(jù)可以是點(diǎn)集和線段;

v 算法的穩(wěn)定性高及輸出完整的拓樸信息;

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

計(jì)算幾何方面以穩(wěn)定性著稱(chēng)的CGAL庫(kù)中的Voronoi算法只滿足前兩個(gè)功能。S-Hull庫(kù)以上功能都沒(méi)有很好的滿足。下面是一些Boost.Polygon,CGAL,S-Hull庫(kù)的對(duì)比數(shù)據(jù):

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

結(jié)論:

v 在輸入上沒(méi)有限制這點(diǎn)上CGAL要優(yōu)于Boost.Polygon;

v Boost.Polygon Voronoi的穩(wěn)定性要高于S-Hull;

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

v Boost.Polygon Voronoi的輸出頂點(diǎn)的精度高于CGAL庫(kù);

v Boost.Polygon Voronoi的速度快;

v Boost.Polygon Voronoi根據(jù)10000個(gè)點(diǎn)或1000個(gè)線段來(lái)構(gòu)造Voronoi的時(shí)間為0.02秒以?xún)?nèi),所以可用來(lái)處理有實(shí)時(shí)性要求的場(chǎng)景;

3. Implementation

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

 

/*
*    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頂點(diǎn)Vertex也很直接。如下代碼所示為遍歷所有邊,來(lái)將剖分結(jié)果可視化:

 

/*
*    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的邊時(shí),當(dāng)邊是有限的finite時(shí),直接可以畫(huà)出直線;當(dāng)邊是infinite時(shí),根據(jù)定義計(jì)算出了無(wú)界邊的方向。顯示結(jié)果如下圖所示:

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圖算法穩(wěn)定性及性能較高,且可以根據(jù)站點(diǎn)查找相關(guān)的拓樸信息,如根據(jù)站點(diǎn)查找Voronoi單元等;惟一不足的就是默認(rèn)只處理整數(shù)點(diǎn)集。

當(dāng)輸入有線段時(shí),生成的Voronoi圖中有曲線,曲線的繪制可參考相關(guān)例子實(shí)現(xiàn)。

Boost.Polygon中的Voronoi算法都以模板實(shí)現(xiàn),編譯時(shí)只需要包含相關(guān)的頭文件即可,不依賴(lài)其他庫(kù),使用還是很方便的。

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. 汪嘉業(yè), 王文平, 屠長(zhǎng)河, 楊承磊. 計(jì)算幾何及應(yīng)用. 科學(xué)出版社. 2011

5. 楊承磊, 呂琳, 楊義軍, 孟祥旭. Voronoi圖及其應(yīng)用. 清華大學(xué)出版社. 2013

 

Feedback

# re: Visulalization Boost Voronoi in OpenSceneGraph  回復(fù)  更多評(píng)論   

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

# re: Visulalization Boost Voronoi in OpenSceneGraph  回復(fù)  更多評(píng)論   

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

只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   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>
            国产精品久久久久久久久久免费| 亚洲女ⅴideoshd黑人| 国产免费观看久久黄| 欧美国产一区在线| 亚洲免费小视频| 国产精品自拍网站| 亚洲欧美另类中文字幕| 午夜激情亚洲| 一本久道久久综合婷婷鲸鱼| 香蕉久久a毛片| 久久经典综合| 亚洲永久免费av| 日韩一区二区电影网| 亚洲欧美日本另类| 久久综合色播五月| 国产亚洲女人久久久久毛片| 欧美日韩视频第一区| 久久激情网站| 欧美小视频在线观看| 麻豆精品国产91久久久久久| 欧美aaa级| 国产精品区一区| 欧美一区二区三区电影在线观看| 久久久久久久综合| 欧美一区二区在线| 国产一区二区三区日韩| 亚洲第一色在线| 一区二区三区日韩| 亚洲小少妇裸体bbw| 99在线精品观看| 亚洲精品免费在线| 国产精品第一区| 中日韩美女免费视频网址在线观看| 欧美日韩国产大片| 欧美福利一区| 麻豆成人综合网| 亚洲精品视频中文字幕| 欧美1区3d| 久久国产日本精品| 国产欧美日韩三区| 久久不射电影网| 久久久久9999亚洲精品| 亚洲综合精品四区| 亚洲电影免费观看高清完整版在线观看 | 欧美一区午夜精品| 国产日本欧美一区二区| 亚洲欧美日韩区| 欧美一区2区视频在线观看| 另类亚洲自拍| 国产精品成av人在线视午夜片| 影音先锋中文字幕一区| 小黄鸭精品aⅴ导航网站入口| 最新精品在线| aa级大片欧美三级| 欧美一区免费视频| 这里只有精品视频| 国产伪娘ts一区| 欧美性猛交xxxx乱大交退制版| 久久香蕉国产线看观看av| 亚洲国产视频一区二区| 亚洲尤物视频网| 亚洲欧美日韩国产一区二区三区| 亚洲激情女人| 曰本成人黄色| 国产夜色精品一区二区av| 久久天堂精品| 玖玖玖国产精品| 亚洲高清视频一区| 91久久中文| 久久久久在线| 裸体女人亚洲精品一区| 国产午夜精品在线| 中文欧美日韩| 久久精品亚洲一区二区三区浴池 | 久久久久久有精品国产| 亚洲欧美日韩一区二区三区在线观看| 国产亚洲精品高潮| 日韩视频免费观看| 国产一区二区三区奇米久涩 | 免费不卡在线观看av| 欧美一区日韩一区| 欧美性猛交xxxx乱大交蜜桃| 欧美大学生性色视频| 国产欧美一区二区精品忘忧草| 亚洲国产黄色片| 国产亚洲一区在线| 亚洲永久网站| 亚洲图片自拍偷拍| 欧美精品aa| 亚洲国产精品激情在线观看| 国产一级揄自揄精品视频| 在线亚洲欧美| 一区二区成人精品 | 欧美一区二区播放| 亚洲欧美美女| 欧美午夜免费电影| 亚洲精品一区二区三区婷婷月| 一区二区在线视频| 久久婷婷av| 久久永久免费| 国产中文一区| 性视频1819p久久| 欧美一区=区| 国产精品视频999| 亚洲欧美在线播放| 午夜影院日韩| 国产精品免费视频xxxx| 中文日韩在线| 欧美在线观看一区二区| 国产精品区一区二区三区| 校园春色国产精品| 久久精品国产第一区二区三区| 国产乱码精品| 亚洲一区二区三区四区五区黄| 亚洲综合视频1区| 国产精品超碰97尤物18| 欧美中文字幕第一页| 久久久久久久波多野高潮日日| 国模精品娜娜一二三区| 欧美专区在线观看| 久久综合中文| 亚洲第一综合天堂另类专| 欧美在线二区| 欧美一区二区性| 久久久91精品国产| 久久久91精品国产一区二区三区| 亚洲人成亚洲人成在线观看| 国产精品免费电影| 国产女人水真多18毛片18精品视频| 国产欧美日韩一区二区三区| 在线精品视频免费观看| 午夜亚洲福利在线老司机| 亚洲女人天堂av| 久久欧美肥婆一二区| 国产精品久久久久久亚洲调教| 午夜伦欧美伦电影理论片| 欧美日韩一区在线观看视频| 亚洲一区精彩视频| 一本久道久久综合中文字幕| 男女精品网站| 99re6热在线精品视频播放速度| 亚洲午夜精品| 国产视频久久久久| 亚洲欧美三级伦理| 男女av一区三区二区色多| 亚洲精品久久| 欧美日韩亚洲一区二区| 一区二区三区.www| 久久精品在线播放| 久久看片网站| 99精品热6080yy久久| 久久综合网络一区二区| 99精品视频免费观看| 国产在线国偷精品产拍免费yy| 蜜臀av性久久久久蜜臀aⅴ四虎| 午夜精品久久久久久久99水蜜桃 | 亚洲精品韩国| 亚洲欧美中日韩| 免费视频一区| 国产精品最新自拍| 亚洲一区视频在线观看视频| 久久男人av资源网站| 亚洲男女毛片无遮挡| 欧美激情一区二区三区 | 亚洲高清在线| 欧美日本在线视频| 久久久国产亚洲精品| 一区二区三区 在线观看视频| 国产一区二区激情| 欧美大胆成人| 久久人人97超碰国产公开结果| 99re66热这里只有精品3直播| 欧美成人免费小视频| 亚洲欧美日韩成人| 欧美日本免费一区二区三区| 亚洲欧美在线aaa| 99视频超级精品| 久久在线视频| 久久国产视频网| 亚洲欧美高清| 一区二区不卡在线视频 午夜欧美不卡在 | 蜜桃精品久久久久久久免费影院| 亚洲一区二区三区影院| 亚洲高清视频在线观看| 国产精品区一区| 国产精品高清网站| 欧美国产日韩一区二区在线观看| 亚洲无线观看| 亚洲精品日韩精品| 亚洲国产另类 国产精品国产免费| 欧美一区精品| 国产精品女人网站| 久久精品国产第一区二区三区| 香港久久久电影| 在线综合+亚洲+欧美中文字幕| 久久国产精品久久久| 亚洲一区二区三区高清不卡| 日韩视频―中文字幕| 亚洲制服欧美中文字幕中文字幕| 久久欧美肥婆一二区|