• 大小: 112KB
    文件类型: .rar
    金币: 2
    下载: 2 次
    发布日期: 2021-06-08
  • 语言: C#
  • 标签: Voronoi  c#  增点法  Delaunay  

资源简介

实现Voronoi图[C#],增点法先生成Delaunay三角网后对偶生成V图,转的资源

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Threading;

namespace TINVoronoi
{
    public partial class Delaynay
    {
       
        public List HullPoint;  //凸壳顶点链表
        private struct PntV_ID
        {
            public long Value;
            public long ID;
        }
        
        //建立凸壳
        public void CreateConvex()
        {
            //初始化凸壳顶点链表
            if (HullPoint == null)
                HullPoint = new List();
            else
            {
                for (int i = 0; i < HullPoint.Count; i++)
                    DS.Vertex[HullPoint[i]].isHullEdge = 0;  //去除凸壳标记
                HullPoint.Clear();
            }

            #region 计算x-y和x+y的最大、最小点
            PntV_ID MaxMinus MinMinus MaxAdd MinAdd;
            MaxMinus.ID = MinMinus.ID = MaxAdd.ID = MinAdd.ID = DS.Vertex[0].ID;//用第一点初始化
            MaxMinus.Value = MinMinus.Value = DS.Vertex[0].x - DS.Vertex[0].y;
            MaxAdd.Value = MinAdd.Value = DS.Vertex[0].x + DS.Vertex[0].y;

            long temp;
            for (int i = 1; i < DS.VerticesNum; i++)
            {
                temp = DS.Vertex[i].x - DS.Vertex[i].y;
                if (temp > MaxMinus.Value)
                {
                    MaxMinus.Value = temp;
                    MaxMinus.ID = DS.Vertex[i].ID;
                }
                if (temp < MinMinus.Value)
                {
                    MinMinus.Value = temp;
                    MinMinus.ID = DS.Vertex[i].ID;
                }

                temp = DS.Vertex[i].x + DS.Vertex[i].y;
                if (temp > MaxAdd.Value)
                {
                    MaxAdd.Value = temp;
                    MaxAdd.ID = DS.Vertex[i].ID;
                }
                if (temp < MinAdd.Value)
                {
                    MinAdd.Value = temp;
                    MinAdd.ID = DS.Vertex[i].ID;
                }
            }
            #endregion

            //加入链表
            HullPoint.Add(MinMinus.ID);
            HullPoint.Add(MaxAdd.ID);
            HullPoint.Add(MaxMinus.ID); 
            HullPoint.Add(MinAdd.ID);
            //还要去除重复点……
            for (int i = 0; i < HullPoint.Count; i++)
            {
                if (HullPoint[i] == HullPoint[(i + 1) % HullPoint.Count])
                    HullPoint.RemoveAt(i);
            }

            //将点标记,下一步不再处理
            for (int i = 0; i < HullPoint.Count; i++)
                DS.Vertex[HullPoint[i]].isHullEdge = -1;  

            #region 插入其他点
            for (int i = 0; i < DS.VerticesNum; i++)
            {
                if (DS.Vertex[i].isHullEdge == -1)
                    continue;

                //判断点i与每条边的关系
                double isOnRight;
                for (int j = 0; j < HullPoint.Count; j++)
                {
                    PointF pnt1 = new P

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        920  2012-03-24 10:32  TINVoronoi.sln

     文件       6314  2012-03-24 10:32  UpgradeLog.xml

     文件       3348  2012-03-24 10:32  _UpgradeReport_Files\UpgradeReport.css

     文件      12505  2010-05-04 01:19  _UpgradeReport_Files\UpgradeReport.xslt

     文件         69  2012-03-24 10:32  _UpgradeReport_Files\UpgradeReport_Minus.gif

     文件         71  2012-03-24 10:32  _UpgradeReport_Files\UpgradeReport_Plus.gif

     文件       6972  2009-05-02 16:54  Backup\TINVoronoi\ConvexTin.cs

     文件      17020  2009-05-05 16:33  Backup\TINVoronoi\CoreClass.cs

     文件       2630  2009-05-05 16:28  Backup\TINVoronoi\DataMonitor.cs

     文件       2248  2009-05-05 15:14  Backup\TINVoronoi\DataMonitor.Designer.cs

     文件       5814  2009-05-05 15:14  Backup\TINVoronoi\DataMonitor.resx

     文件       2535  2009-04-30 17:40  Backup\TINVoronoi\DataStruct.cs

     文件      11665  2009-05-05 16:31  Backup\TINVoronoi\Form1.cs

     文件      11859  2009-05-02 18:22  Backup\TINVoronoi\Form1.Designer.cs

     文件       6012  2009-05-02 18:22  Backup\TINVoronoi\Form1.resx

     文件        469  2009-04-22 21:39  Backup\TINVoronoi\Program.cs

     文件       1176  2009-04-01 13:28  Backup\TINVoronoi\Properties\AssemblyInfo.cs

     文件       2842  2009-05-02 17:33  Backup\TINVoronoi\Properties\Resources.Designer.cs

     文件       5612  2009-04-01 13:28  Backup\TINVoronoi\Properties\Resources.resx

     文件       1106  2009-05-02 17:33  Backup\TINVoronoi\Properties\Settings.Designer.cs

     文件        249  2009-04-01 13:28  Backup\TINVoronoi\Properties\Settings.settings

     文件       3804  2009-05-02 17:38  Backup\TINVoronoi\TINVoronoi.csproj

     文件        919  2009-04-01 13:28  Backup\TINVoronoi.sln

     文件       6972  2009-05-02 16:54  TINVoronoi\ConvexTin.cs

     文件      17020  2009-05-05 16:33  TINVoronoi\CoreClass.cs

     文件       2630  2009-05-05 16:28  TINVoronoi\DataMonitor.cs

     文件       2248  2009-05-05 15:14  TINVoronoi\DataMonitor.Designer.cs

     文件       5814  2009-05-05 15:14  TINVoronoi\DataMonitor.resx

     文件       2535  2009-04-30 17:40  TINVoronoi\DataStruct.cs

     文件        680  2009-05-03 10:25  TINVoronoi\Debug\BadHull.sfg

............此处省略45个文件信息

评论

共有 条评论