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;
///
/// 数据校正
///
/// 层位文件
/// 井深数据
/// 输出文件
/// 进度回调
/// 影响因子
/// 断层层位
/// 等值线步长
/// 等值线标注间隔
/// 横向网格数量
/// 光滑度
/// 是否写校正量数据
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);
}
///
/// Calculates the by mesh.
///
/// The p mesh.
/// The p well data x.
/// The p well data y.
/// The p well data z.
/// The well count.
/// The out file.
/// The callback.
/// The factor.
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);
}
///
/// Calculates the adjust data.
///
/// The layer file.
/// The well file.
/// The out file.
/// The callback.
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";
///
/// The d l l_ f i l e.
///
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);
}}