using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; using System.Numerics; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using NaturalNeighbor; using NeighborInterpolator; namespace TestForm { public partial class Form1 : Form { public Form1() { InitializeComponent(); } internal static IEnumerable<(int, int, Vector2)> CreateGridEx( float offsetX, float offsetY, float width, float height, int rows, int cols) { float scaleX = width / (cols - 1); float scaleY = height / (rows - 1); for (int i = 0; i < rows; ++i) { var y = offsetY + i * scaleX; for (int j = 0; j < cols; ++j) { var x = offsetX + j * scaleY; yield return (i, j, new Vector2(x, y)); } } } private void button1_Click(object sender, EventArgs e) { //string strFile = "C:\\GeoIntelligent\\Test\\厚度图数据\\39SO(300).csv"; //string strResult = "C:\\GeoIntelligent\\Test\\厚度图数据\\39SO(300)-Result.dfd"; string strFile = "C:\\GeoIntelligent\\Test\\厚度图数据\\40SO(300).csv"; string strResult = "C:\\GeoIntelligent\\Test\\厚度图数据\\40SO(300)-Result.dfd"; int nCols = 100; int nRows = 100; //Vector3[] points = this.ReadData(strFile).ToArray(); //Vector3 rangeMin = new Vector3(); //Vector3 rangeMax = new Vector3(); //this.CalculateRange(points.ToArray(), ref rangeMin, ref rangeMax); //int nCount = points.Length; //for(int i=0;i // { // //SetDllDirectory(System.Windows.Forms.Application.StartupPath); // // 生成网格 // SetGridData(rangeMin.X, rangeMin.Y, resultZ, nCalCols, nCalRows, (double)dScale, (double)dScale // , rangeMin.Z, rangeMax.Z, null, 0); // // 保存网格,同时生成等值线 // SaveDrawFile(strResult, 1, 5); // DestoryXy(); // }), 2621440); // newThread.Start(); // newThread.Join(); //} //catch (Exception ex) //{ // // MessageBox.Show(ex.Message); // Trace.WriteLine(ex.Message); //} //using (StreamWriter sw = new StreamWriter(strResult, false, Encoding.Default)) //{ // for (int i = 0; i < nCalRows; i++) // { // for (int j = 0; j < nCalCols; j++) // { // sw.WriteLine($"{result[i * nCalCols + j].X+ rangeMin.X},{result[i * nCalCols + j].Y+rangeMin.Y},{resultZ[i * nCalCols + j]}"); // } // } //} string strBorderFile = string.Empty; GridCreator creater = new GridCreator(); creater.Create(strFile, strResult, strBorderFile, nCols, nRows, 3, 5, 5); MessageBox.Show("OK"); } } }