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

eryar

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

Visulalize Voronoi in OpenSceneGraph

Posted on 2014-04-30 22:07 eryar 閱讀(2372) 評論(0)  編輯 收藏 引用 所屬分類: 2.OpenCASCADE

Visulalize Voronoi in OpenSceneGraph

eryar@163.com

Abstract. In mathematics a Voronoi diagram is a way of dividing space into a number of regions. A set of points, called seeds, sites, or generators is specified beforehand and for each seed there will be a correspoinding region consisting of all points closer to that seed than to any other. The regions are called Voronoi cells. It is dual to the Delaunay triangulation. It is named after Georgy Voronoy, and is also called a Voronoi tessellation, a Voronoi decomposition, a Voronoi partition, or a Dirichlet tessellation. Voronoi diagrams can be found in a large number of fields in science and technology, even in art, and they have found numerous practical and theoretical applications. The paper use OpenSceneGraph to visualize the Voronoi diagram.

Key words. Voronoi, 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)?;瘜W與物理學中稱之為Wigner-Seitz Zones,氣象學與地理學中稱之為Thiessen多邊形。Voronoi圖最早由Thiessen應用于氣象觀測站中隨機分布的研究。由于M.G. Voronoi從更通用的n維情況對其進行研究和定義,所以Voronoi圖這個名稱為大多數人所使用。

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

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

2. Implementation

用Shane O Sullivans封裝的VoronoiDiagramGenerator可以生成點集的Voronoi圖,得到剖分的線段。程序小巧,易于使用。結合OpenSceneGraph將剖分得到的線段顯示出來。程序代碼如下所示:

/*
*    Copyright (c) 2014 eryar All Rights Reserved.
*
*        File    : Main.cpp
*        Author  : eryar@163.com
*        Date    : 2014-04-30 18:28
*        Version : V1.0
*
*    Description : VoronoiViewer for voronoi library visulization.
*
*/

#include 
"VoronoiDiagramGenerator.h"

// OpenSceneGraph library.
#include <osgDB/ReadFile>
#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")


osg::Node
* BuildVoronoi(void)
{
    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();

    
const long thePointCount = 10;
    
float *xValues = new float[thePointCount] ();
    
float *yValues = new float[thePointCount] ();

    
float theMin = 0.0;
    
float theMax = 100.0;

    
float x1 = 0.0;
    
float y1 = 0.0;
    
float x2 = 0.0;
    
float y2 = 0.0;

    
// Draw the boundary box.
    theVertices->push_back(osg::Vec3(theMin, 0.0, theMin));
    theVertices
->push_back(osg::Vec3(theMin, 0.0, theMax));

    theVertices
->push_back(osg::Vec3(theMin, 0.0, theMin));
    theVertices
->push_back(osg::Vec3(theMax, 0.0, theMin));

    theVertices
->push_back(osg::Vec3(theMin, 0.0, theMax));
    theVertices
->push_back(osg::Vec3(theMax, 0.0, theMax));

    theVertices
->push_back(osg::Vec3(theMax, 0.0, theMin));
    theVertices
->push_back(osg::Vec3(theMax, 0.0, theMax));

    
// initialize random seed:
    srand(time(NULL));

    
// Sites of the Voronoi.
    for (int i = 0; i < thePointCount; ++i)
    {
        xValues[i] 
= rand() % 100;
        yValues[i] 
= rand() % 100;

        
// Draw the site.
        theVertices->push_back(osg::Vec3(xValues[i] - 1.00.0, yValues[i]));
        theVertices
->push_back(osg::Vec3(xValues[i] + 1.00.0, yValues[i]));

        theVertices
->push_back(osg::Vec3(xValues[i], 0.0, yValues[i] - 1.0));
        theVertices
->push_back(osg::Vec3(xValues[i], 0.0, yValues[i] + 1.0));
    }

    
// Generate Voronoi Diagram.
    VoronoiDiagramGenerator vdg;
    vdg.generateVoronoi(xValues, yValues, thePointCount, theMin, theMax, theMin, theMax);
    vdg.resetIterator();

    
while (vdg.getNext(x1, y1, x2, y2))
    {
        theVertices
->push_back(osg::Vec3(x1, 0.0, y1));
        theVertices
->push_back(osg::Vec3(x2, 0.0, y2));
    }

    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);

    
// Free the meomry.
    delete [] xValues;
    delete [] yValues;

    
return theGeode.release();
}


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

    myViewer.setSceneData(BuildVoronoi());

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

    
return myViewer.run();
}

 

上述程序生成結果如下所示:

wps_clip_image-21060

Figure 2.1 Voronoi Diagram in OpenSceneGraph

修改站點的數量,生成的Voronoi圖如下所示:

修改范圍時也要修改生成范圍中點的隨機函數的取余操作,避免生成點超出范圍。

wps_clip_image-21063

Figure 2.2 Less Sites of the Voronoi Diagram

wps_clip_image-15223

Figure 2.3 More Sites of the Voronoi Diagram

3. Conclusion

Shane O Sullivans封裝的庫小巧,使用方便,速度還很快。也有些不足,如不能取得一個站點對應的多邊形,即某個點屬于哪個區域。不能得到帶權點集的Voronoi剖分。

源程序小巧,借助程序代碼來對Voronoi的概念進行理解還是不錯的。

4. References

1. Shane O Sullivans, http://www.skynet.ie/~sos/mapviewer/voronoi.php

2. http://ect.bell-labs.com/who/sjf/

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

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

PDF Version and Source code: Visualization Voronoi in OpenSceneGraph

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲精品男同| 亚洲天堂网站在线观看视频| 欧美专区日韩视频| 国产精品社区| 午夜激情久久久| 香蕉久久夜色精品| 红桃视频欧美| 亚洲国产高清在线| 欧美日韩网址| 欧美综合77777色婷婷| 久久精品国产免费观看| 亚洲第一级黄色片| 亚洲国产免费| 国产精品欧美激情| 裸体一区二区| 欧美日韩国产成人在线观看| 午夜亚洲福利| 久久在线免费视频| 亚洲欧美日韩国产中文| 久久精品中文| 一本色道久久综合亚洲精品按摩| 亚洲中字黄色| 亚洲国产精品久久久久婷婷884| 亚洲欧洲另类国产综合| 国产精品乱看| 亚洲高清影视| 国产精品一区二区在线观看网站 | 久久影视三级福利片| 欧美成人免费网站| 欧美在线视频一区| 欧美成人自拍| 久久综合九色九九| 国产精品大片| 亚洲精美视频| 亚洲成色999久久网站| 中国女人久久久| 亚洲精品久久| 久久成人羞羞网站| 亚洲综合好骚| 欧美另类一区| 农村妇女精品| 国产综合久久久久久| 一本大道久久a久久综合婷婷| 在线观看国产日韩| 午夜国产不卡在线观看视频| 一区二区三区国产在线| 久久综合一区| 久久午夜精品一区二区| 国产精品亚洲一区| av成人免费| 一本色道久久综合亚洲精品不卡| 久久久久久久综合| 久久久久一区二区| 国产日韩一区二区三区在线| 亚洲视频在线视频| 这里只有精品视频在线| 欧美精品一区二区三区四区| 亚洲黄一区二区| 亚洲人成在线播放| 女同性一区二区三区人了人一| 久久久91精品国产一区二区三区| 国产精品每日更新| 中文日韩在线| 亚洲欧美日韩国产成人| 欧美日韩高清区| 亚洲免费观看在线观看| a91a精品视频在线观看| 欧美经典一区二区| 亚洲精品一二| 亚洲国产综合91精品麻豆| 欧美在线观看视频一区二区| 久久久久国色av免费看影院| 国产精品羞羞答答| 久久se精品一区精品二区| 久久资源在线| 亚洲国产激情| 欧美人交a欧美精品| 99精品国产热久久91蜜凸| 亚洲一区在线直播| 国产欧美精品日韩| 中文在线资源观看网站视频免费不卡 | 亚洲大胆视频| 美女日韩在线中文字幕| 欧美日韩精品系列| 亚洲精品欧美日韩| 亚洲免费影视第一页| 国产精品主播| 久久精品在线观看| 欧美国产一区视频在线观看| 夜夜爽夜夜爽精品视频| 国产精品激情电影| 欧美一区二区视频在线| 免费看成人av| 亚洲一级二级在线| 国语自产在线不卡| 欧美精品一区二区三区蜜桃| 亚洲欧美另类久久久精品2019| 久久久久久九九九九| 最新中文字幕一区二区三区| 国产精品久久久久久久app| 午夜在线不卡| 亚洲欧洲日本国产| 久久精品国产99| 亚洲国产精品精华液2区45| 欧美亚男人的天堂| 久久久青草婷婷精品综合日韩| 亚洲看片一区| 麻豆freexxxx性91精品| 亚洲午夜精品久久| 尤物在线精品| 国产精品久久久久久久久动漫| 久久艳片www.17c.com| 亚洲伊人伊色伊影伊综合网| 欧美va天堂va视频va在线| 午夜激情久久久| 99re66热这里只有精品3直播| 依依成人综合视频| 国产精品区一区二区三区| 老司机午夜精品视频| 亚洲欧美三级伦理| 欧美色图一区二区三区| 久久综合999| 欧美中文在线观看| 中日韩在线视频| 亚洲精选国产| 欧美激情欧美狂野欧美精品 | 亚洲天堂男人| 亚洲人成网站影音先锋播放| 黑人巨大精品欧美黑白配亚洲| 欧美性事在线| 欧美日韩一级片在线观看| 久热re这里精品视频在线6| 欧美一区二区播放| 亚洲视频图片小说| 99国产精品| 亚洲伦理网站| 亚洲乱码国产乱码精品精98午夜| 欧美1区2区视频| 美国三级日本三级久久99| 久久国产免费看| 久久精品国产一区二区三区| 欧美专区亚洲专区| 性欧美xxxx大乳国产app| 亚洲欧美资源在线| 先锋影音网一区二区| 午夜精品免费在线| 欧美一级大片在线观看| 香蕉成人伊视频在线观看| 午夜精品久久久久久久久久久久久| 中文av一区特黄| 亚洲一区视频在线| 欧美有码视频| 久久人人97超碰人人澡爱香蕉| 久久人人看视频| 欧美成人伊人久久综合网| 亚洲第一视频网站| 91久久久久久国产精品| 日韩午夜高潮| 亚洲一区日韩在线| 亚洲视频精品| 性久久久久久| 免费欧美在线视频| 亚洲人成在线观看网站高清| 亚洲精品国精品久久99热| 一区二区成人精品 | 欧美国产在线电影| 亚洲国产精品123| 亚洲乱码国产乱码精品精天堂| 亚洲视频免费观看| 久久国产精品网站| 欧美h视频在线| 欧美午夜久久| 精品999成人| 这里只有精品在线播放| 欧美一级网站| 欧美国产一区二区在线观看| 99综合电影在线视频| 欧美亚洲视频| 欧美成年视频| 国产欧美欧洲在线观看| 亚洲精品一区在线观看香蕉| 亚洲欧美日韩在线| 欧美成人在线免费观看| 在线亚洲成人| 每日更新成人在线视频| 欧美午夜精品久久久久久久| 黄网动漫久久久| 亚洲一区成人| 欧美高清自拍一区| 亚洲一区免费视频| 欧美精品一区二区三区久久久竹菊| 国产日韩欧美a| 日韩视频在线播放| 久久久综合网| 亚洲一区精品在线| 欧美日韩亚洲国产一区| 1769国产精品| 久久精品国产精品亚洲综合| 国产在线精品成人一区二区三区| 一本色道久久88综合日韩精品|