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.

117 lines
5.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Construction.BatchCreateMap
{
public class WellCalibrate
{
//public ProgressEvent ProgressChanged;
/// <summary>
/// 数据校正
/// </summary>
/// <param name="layerFile">层位文件</param>
/// <param name="wellFile">井深数据</param>
/// <param name="outFile">输出文件</param>
/// <param name="callback">进度回调</param>
/// <param name="factor">影响因子</param>
/// <param name="faultLayer">断层层位</param>
/// <param name="coutourStep">等值线步长</param>
/// <param name="contourMark">等值线标注间隔</param>
/// <param name="gridM">横向网格数量</param>
/// <param name="smooth">光滑度</param>
/// <param name="writeData">是否写校正量数据</param>
public void CalculateByFile(string layerFile, string wellFile, string outFile, ProgressEvent callback=null, double factor=2.5,
string faultLayer="", double coutourStep=5.0, int contourMark=5,int times=0, int gridM=0, int smooth=0, bool writeData = true)
{
//string strLayerFile = "C:\\GeoIntelligent\\测试\\构造图.dfg";
//string strWellFile = "C:\\GeoIntelligent\\测试\\校正井.csv";
//string strOutFile = "C:\\GeoIntelligent\\测试\\构造图_IDW.dfg";
//callback = TestProgress;
IntPtr pEvent = IntPtr.Zero;
if (callback != null)
{
pEvent = Marshal.GetFunctionPointerForDelegate(callback);
}
//pEvent = Marshal.GetFunctionPointerForDelegate(callback);
CalculateByFile(layerFile, wellFile, outFile, pEvent, 2.5,
faultLayer, coutourStep, contourMark, times, gridM, smooth,
writeData);
}
/// <summary>
/// Calculates the by mesh.
/// </summary>
/// <param name="pMesh">The p mesh.</param>
/// <param name="pWellDataX">The p well data x.</param>
/// <param name="pWellDataY">The p well data y.</param>
/// <param name="pWellDataZ">The p well data z.</param>
/// <param name="wellCount">The well count.</param>
/// <param name="outFile">The out file.</param>
/// <param name="callback">The callback.</param>
/// <param name="factor">The factor.</param>
public void CalculateByMesh(IntPtr pMesh, IntPtr pWellDataX, IntPtr pWellDataY, IntPtr pWellDataZ
, int wellCount, string outFile, ProgressEvent callback = null, double factor = 2.5)
{
callback = TestProgress;
IntPtr pEvent = IntPtr.Zero;
if (callback != null)
{
pEvent = Marshal.GetFunctionPointerForDelegate(callback);
}
pEvent = Marshal.GetFunctionPointerForDelegate(callback);
CalculateByMesh(pMesh, pWellDataX, pWellDataY, pWellDataZ, wellCount, outFile, pEvent, 2.5);
}
/// <summary>
/// Calculates the adjust data.
/// </summary>
/// <param name="layerFile">The layer file.</param>
/// <param name="wellFile">The well file.</param>
/// <param name="outFile">The out file.</param>
/// <param name="callback">The callback.</param>
public void CalculateAdjustData(string layerFile, string wellFile, string outFile, ProgressEvent callback = null)
{
//string strLayerFile = "C:\\GeoIntelligent\\测试\\构造图.dfg";
//string strWellFile = "C:\\GeoIntelligent\\测试\\校正井.csv";
//string strOutFile = "C:\\GeoIntelligent\\测试\\构造图_IDW.dfg";
//callback = TestProgress;
IntPtr pEvent = IntPtr.Zero;
if (callback != null)
{
pEvent = Marshal.GetFunctionPointerForDelegate(callback);
}
CalculateAdjustData(layerFile, wellFile, outFile, pEvent);
}
private void TestProgress(string eventName, int step)
{
string str = string.Format("{0},{1}", eventName, step);
}
#if DEBUG
//const string DLL_FILE = @"C:\GeoIntelligent\Code\dirgdf\bin\Debug\WellCalibrate.dll";
const string DLL_FILE = "WellCalibrate.dll";
#else
//const string DRAWLIB = "DrawLib.dll";
/// <summary>
/// The d l l_ f i l e.
/// </summary>
const string DLL_FILE = "WellCalibrate.dll";
#endif
[DllImport(DLL_FILE, EntryPoint = "CalculateByFile", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CalculateByFile(string layerFile, string wellFile, string outFile, IntPtr callback, double factor,
string faultLayer, double contourStep, int countourMarkStep,int times, int gridM, int smooth, bool withName);
[DllImport(DLL_FILE, EntryPoint = "CalculateByMesh", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CalculateByMesh(IntPtr pMesh, IntPtr pWellDataX, IntPtr pWellDataY, IntPtr pWellDataZ
, int wellCount, string outFile, IntPtr callback, double factor);
[DllImport(DLL_FILE, EntryPoint = "CalculateAdjustData", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CalculateAdjustData(string layerFile, string wellFile, string outFile, IntPtr callBack);
}}