You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
4.5 KiB
C#
103 lines
4.5 KiB
C#
using GeoSigmaDrawLib;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace QuikGridCS
|
|
{
|
|
public class Interface
|
|
{
|
|
/// <summary>
|
|
/// 快速网格化算法生成网格.
|
|
/// </summary>
|
|
/// <param name="inputFile">输入的散点文件.</param>
|
|
/// <param name="outputFile">输出结果文件.</param>
|
|
/// <param name="xCount">The x count.</param>
|
|
/// <param name="yCount">The y count.</param>
|
|
/// <param name="contourSpace">The contour space.</param>
|
|
/// <param name="contourLable">The contour lable.</param>
|
|
/// <returns>A bool.</returns>
|
|
public static bool QuikGridCreate(string inputFile,string outputFile, int xCount, int yCount, double contourSpace, int contourLable, double smoothFactor)
|
|
{
|
|
if (Interface.QuikGridFromFile(inputFile, xCount, xCount) == true)
|
|
{
|
|
Interface.QuikGridGenerateGrid();
|
|
double xMin = 0;
|
|
double xMax = 0;
|
|
double yMin = 0;
|
|
double yMax = 0;
|
|
int countX = 0;
|
|
int countY = 0;
|
|
double zMin = 0;
|
|
double zMax = 0;
|
|
|
|
int nReturn = Interface.QuikGridGetView(ref xMin, ref xMax, ref yMin, ref yMax, ref countX, ref countY, ref zMin, ref zMax);
|
|
if (nReturn == 0)
|
|
{
|
|
return false;
|
|
}
|
|
double dStepX = (xMax - xMin) / (countX - 1);
|
|
double dStepY = (yMax - yMin) / (countY - 1);
|
|
//string strFileOut = this.txtOutput.Text;
|
|
//if (!string.IsNullOrEmpty(strFileOut))
|
|
//{
|
|
// Interface.QuikGridSaveFileGrd(strFileOut);
|
|
//}
|
|
string strFileKev = outputFile;
|
|
if (!string.IsNullOrEmpty(strFileKev))
|
|
{
|
|
IntPtr ptrValues = Interface.QuikGridGridValue();
|
|
|
|
DrawerData drawer = new DrawerData();
|
|
long pos = drawer.CreateMesh("背景", ptrValues, xMin, yMin, countX, countY, dStepX, dStepY, zMin, zMax);
|
|
|
|
if (smoothFactor > 0.001)
|
|
{
|
|
drawer.MeshSmooth(pos, smoothFactor);
|
|
}
|
|
if (contourSpace > 0 && contourLable > 0)
|
|
{
|
|
drawer.CreateContour(pos, contourSpace, contourLable);
|
|
}
|
|
|
|
drawer.SaveAs(strFileKev);
|
|
drawer.Dispose();
|
|
// 释放数据指针
|
|
GeoSigmaLib.PointerArrayDelete(ptrValues);
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
#if DEBUG
|
|
const string SIGMALIB = "QUIKGRIDLIB.dll";
|
|
#else
|
|
const string SIGMALIB = "QuikGridLib.dll";
|
|
#endif
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "QuikGridLoadFileXyz", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern int QuikGridLoadFileXyz(string fileName);
|
|
[DllImport(SIGMALIB, EntryPoint = "QuikGridFromFile", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern bool QuikGridFromFile(string fileName, int xCount, int yCount);
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "QuikGridGetView", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern int QuikGridGetView(ref double xMin, ref double xMax, ref double yMin, ref double yMax
|
|
, ref int countX, ref int countY, ref double zMin, ref double zMax);
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "QuikGridGenerateGrid", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern bool QuikGridGenerateGrid();
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "QuikGridSaveFileGrd", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern int QuikGridSaveFileGrd(string fileName);
|
|
[DllImport(SIGMALIB, EntryPoint = "QuikGridGridValue", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern IntPtr QuikGridGridValue();
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "QuikGridRecreate", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern bool QuikGridRecreate(int xCount, int yCount);
|
|
}
|
|
}
|