⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smoothline.cs

📁 剖面生成器
💻 CS
字号:
using System;
using SuperMapLib;

namespace ProfileCtrl
{
	/// <summary>
	/// 平滑线类
	/// </summary>
	public class SmoothLine
	{		
		double[,] desP = new double[1,2];//平滑内差点
		
//		public double[,] GetDesp()
//		{
//			set	{desP=value;}
//			get	{return desP;}
//		}
		/// <summary>
		/// 返回平滑内差点
		/// </summary>
		/// <returns></returns>
		public double[,] GetDesp()
		{
			return desP;
		}
		/// <summary>
		/// 平滑内差点赋值
		/// </summary>
		/// <param name="desP"></param>
		public void SetDesp(double[,] desP)
		{
			this.desP=desP;
		}
		

		public SmoothLine()
		{		
		}

		public soGeoLine Smooth(soGeoLine geoLine)
		{
			soPoints points = new soPoints();
			
			points = geoLine.GetPartAt(1);
			if(points.Count < 3)	return geoLine;
			soGeoLine objGeoLine = new soGeoLine();
			soPoint objPoint = new soPoint();
			soPoints objPoints = new soPoints();
			for (double cof=0;cof<=0.5;cof += 0.05)
			{			
				SmoothL(points[1],points[1],points[2],points[3],cof);
				objPoint.x = GetDesp()[0,0];
				objPoint.y = GetDesp()[0,1];
				objPoints.Add(objPoint);
			}
			if(points.Count > 3)
			{
				for(int i=1;i<points.Count-3;i++)
				{
					for (double cof=0;cof<=0.5;cof += 0.05)
					{			
						SmoothL(points[i],points[i+1],points[i+2],points[i+3],cof);
						objPoint.x = GetDesp()[0,0];
						objPoint.y = GetDesp()[0,1];
						objPoints.Add(objPoint);
					}
				}
			}
			for (double cof=0;cof<=0.5;cof += 0.05)
			{			
				SmoothL(points[points.Count-2],points[points.Count-1],points[points.Count],points[points.Count],cof);
				objPoint.x = GetDesp()[0,0];
				objPoint.y = GetDesp()[0,1];
				objPoints.Add(objPoint);
			}
			objGeoLine.AddPart(objPoints);
			return objGeoLine;
		}

		private void SmoothL(soPoint point0,soPoint point1,soPoint point2,soPoint point3,double cof)//抛物线平滑算法
		{			
			double[,] tmp=new double[1,4];
			double[,] t=new double[1,4];
			double[,] f=new double[4,4];
			double[,] p=new double[4,2];
			int D1=1;int D2=4;int D3=2;
			t[0,0]=cof*cof*cof;t[0,1]=cof*cof;t[0,2]=cof;t[0,3]=1;
			f[0,0]=-4;f[0,1]=12;f[0,2]=-12;f[0,3]=4;
			f[1,0]=4;f[1,1]=-10;f[1,2]=8;f[1,3]=-2;
			f[2,0]=-1;f[2,1]=0;f[2,2]=1;f[2,3]=0;
			f[3,0]=0;f[3,1]=1;f[3,2]=0;f[3,3]=0;
			p[0,0]=point0.x;p[0,1]=point0.y;
			p[1,0]=point1.x;p[1,1]=point1.y;
			p[2,0]=point2.x;p[2,1]=point2.y;
			p[3,0]=point3.x;p[3,1]=point3.y;
			multi(ref t,ref f,ref tmp,ref D1,ref D2,ref D2);
			multi(ref tmp,ref p,ref desP,ref D1,ref D2,ref D3);
		}
		private void multi(ref double[,] a,ref double[,] b,ref double[,] c,ref int m,ref int n,ref int t)
		{
			int i;
			int j;
			int k;
			for (i=0;i<m;i++)
			{
				for (j=0;j<t;j++)
				{
					c[i,j]=0;
					for (k=0;k<n;k++)
					{
						c[i,j]=c[i,j]+a[i,k]*b[k,j];
					}
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -