|
|
|
|
|
using GeoSigma.SigmaDrawerUtil;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
using System.ServiceModel.Channels;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
|
|
namespace GeoSigmaDrawLib
|
|
|
|
|
|
{
|
|
|
|
|
|
public struct PointData
|
|
|
|
|
|
{
|
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
public double X { get; set; }
|
|
|
|
|
|
public double Y { get; set; }
|
|
|
|
|
|
public double Z { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public struct CurvePointData
|
|
|
|
|
|
{
|
|
|
|
|
|
public double X { get; set; }
|
|
|
|
|
|
public double Y { get; set; }
|
|
|
|
|
|
public double? Z { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class CurveData
|
|
|
|
|
|
{
|
|
|
|
|
|
public CurveData()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CurveData(string name, List<CurvePointData> points)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (name == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(name));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (points == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(points));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Name = name;
|
|
|
|
|
|
Points = points;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
|
|
public List<CurvePointData> Points { get; set; } = new List<CurvePointData>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 网格元数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
|
public struct MeshMetadata
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 网格总行数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int Rows;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 网格总列数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int Columns;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 最小 x 值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double MinX;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 最大 x 值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double MaxX;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 最小 z 值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double MinY;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 最大 z 值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double MaxY;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 网格水平宽度 (一个网格)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double Dx;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 网格垂直间隔 (一个网格)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double Dy;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 最小 z 值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double ZMin;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 最大 z 值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double ZMax;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 网格点信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
|
public struct MeshPoint
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// x 实际坐标
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double X;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// y 实际坐标
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double Y;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// z 实际坐标
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double Z;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class MeshGridData
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="MeshGridData"/> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="metadata"></param>
|
|
|
|
|
|
/// <param name="x"></param>
|
|
|
|
|
|
/// <param name="y"></param>
|
|
|
|
|
|
/// <param name="z"></param>
|
|
|
|
|
|
public MeshGridData(MeshMetadata metadata, double[] x, double[] y, double[] z)
|
|
|
|
|
|
{
|
|
|
|
|
|
Metadata = metadata;
|
|
|
|
|
|
|
|
|
|
|
|
if (x.Length * y.Length != z.Length)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentException("z 值数量必须等于 x 和 y 数据乘积");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.x = x;
|
|
|
|
|
|
this.y = y;
|
|
|
|
|
|
this.z = z;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 表格元数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public MeshMetadata Metadata { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
private readonly double[] x;
|
|
|
|
|
|
private readonly double[] y;
|
|
|
|
|
|
private readonly double[] z;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// X 坐标
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double[] XValues
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return x;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// y 坐标
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double[] YValues
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return y;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// z 值,按行顺序存储的 z 值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double[] ZValues
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return z;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取指定行的 x 实际坐标
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="row">行数,下标从0开始</param>
|
|
|
|
|
|
/// <returns>x 实际坐标</returns>
|
|
|
|
|
|
/// <exception cref="IndexOutOfRangeException"></exception>
|
|
|
|
|
|
public double X(int row)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (row < 0 || row >= Metadata.Rows)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new IndexOutOfRangeException(nameof(row));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return x[row];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取指定行的 y 实际坐标
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="column">列数,下标从0开始</param>
|
|
|
|
|
|
/// <returns>y 实际坐标</returns>
|
|
|
|
|
|
/// <exception cref="IndexOutOfRangeException"></exception>
|
|
|
|
|
|
public double Y(int column)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (column < 0 || column >= Metadata.Columns)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new IndexOutOfRangeException(nameof(column));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return y[column];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取指定位置上的 z 值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="row">行数</param>
|
|
|
|
|
|
/// <param name="column">列数</param>
|
|
|
|
|
|
/// <returns>z 值,实际坐标</returns>
|
|
|
|
|
|
/// <exception cref="IndexOutOfRangeException"></exception>
|
|
|
|
|
|
public double Z(int row, int column)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (row < 0 || row >= Metadata.Rows)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new IndexOutOfRangeException(nameof(row));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (column < 0 || column >= Metadata.Columns)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new IndexOutOfRangeException(nameof(column));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return z[row * Metadata.Columns + column];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 图形文件的数据管理类
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class DrawerData : MarshalByRefObject, IDisposable
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 网格操作类型
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public enum MeshOperatoionMode
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 无效化
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Invalidate,
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 抹平
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Flatten,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打开的图件对象标识
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public IntPtr pXy { get; set; } = IntPtr.Zero;
|
|
|
|
|
|
|
|
|
|
|
|
public bool OpenWithDraw { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否持有该 pXy,如果这个 pXy 不是自己打开文件得来的,而是外部传递进来的
|
|
|
|
|
|
/// DrawerData 将不负责它的释放
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool OwnXy { get; private set; } = true;
|
|
|
|
|
|
|
|
|
|
|
|
//IntPtr pView = IntPtr.Zero;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="DrawerData"/> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public DrawerData()
|
|
|
|
|
|
{
|
|
|
|
|
|
pXy = XyCreate();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="DrawerData"/> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">xy</param>
|
|
|
|
|
|
public DrawerData(IntPtr pXy)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(DrawerConfig.StartupPath))
|
|
|
|
|
|
{
|
|
|
|
|
|
GeoSigmaXY.FileUtility_SetStartupDirectory(DrawerConfig.StartupPath);
|
|
|
|
|
|
}
|
|
|
|
|
|
this.OpenXy(pXy);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Finalizes an instance of the <see cref="DrawerData"/> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
~DrawerData()
|
|
|
|
|
|
{
|
|
|
|
|
|
Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (pXy != IntPtr.Zero && OwnXy)
|
|
|
|
|
|
{
|
|
|
|
|
|
DestroyXy(pXy);
|
|
|
|
|
|
pXy = IntPtr.Zero;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Implement IDisposable.
|
|
|
|
|
|
// Do not make this method virtual.
|
|
|
|
|
|
// A derived class should not be able to override this method.
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Disposes this instance.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
|
{
|
|
|
|
|
|
Dispose(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打开图形文件.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="filePath">文件全路径.</param>
|
|
|
|
|
|
/// <returns>是否成功.</returns>
|
|
|
|
|
|
public bool OpenFile(string filePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(filePath);
|
|
|
|
|
|
if (filePath == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(filePath));
|
|
|
|
|
|
}
|
|
|
|
|
|
System.Diagnostics.Trace.WriteLine("Begin");
|
|
|
|
|
|
return XyOpenFile(pXy, filePath, OpenWithDraw);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打开 pXy,这里主要为了让 pView 能够调用 DrawerData 的接口,pView 那边拿到自己的 pXy 过来
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">打开的 pXy 对象</param>
|
|
|
|
|
|
/// <exception cref="ArgumentException">pXy为0</exception>
|
|
|
|
|
|
public void OpenXy(IntPtr pXy)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (pXy == IntPtr.Zero)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentException($"{nameof(pXy)} 不能为 IntPtr.Zero");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.pXy = pXy;
|
|
|
|
|
|
OwnXy = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将文件绘制到画布句柄
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="filePath">文件路径</param>
|
|
|
|
|
|
/// <param name="hdcMem">绘图句柄</param>
|
|
|
|
|
|
/// <param name="left"></param>
|
|
|
|
|
|
/// <param name="top"></param>
|
|
|
|
|
|
/// <param name="width">宽度</param>
|
|
|
|
|
|
/// <param name="height">高度</param>
|
|
|
|
|
|
/// <returns>是否成功</returns>
|
|
|
|
|
|
public bool DrawFile(string filePath, IntPtr hdcMem, int left, int top, int width, int height)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (filePath == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(filePath));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (hdcMem == IntPtr.Zero)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentException("参数不能为 IntPtr.Zero", nameof(hdcMem));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.OpenFile(filePath) == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XyDrawFile(pXy, hdcMem, left, top, width, height);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 另存为.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="fileName">Name of the file.</param>
|
|
|
|
|
|
/// <returns><c>true</c> 如果 保存成功, 否则<c>false</c>.</returns>
|
|
|
|
|
|
public bool SaveAs(string fileName, int version = -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (fileName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(fileName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pXy == IntPtr.Zero)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new XyNotOpenException(nameof(pXy));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XySaveAs(pXy, fileName, version);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 合并文件.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="fileName">Name of the file.</param>
|
|
|
|
|
|
/// <returns><c>true</c> 如果合并成功, 否则<c>false</c>.</returns>
|
|
|
|
|
|
public bool MergeFile(string fileName)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (fileName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(fileName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pXy == IntPtr.Zero)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new XyNotOpenException(nameof(pXy));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XyMerge(pXy, fileName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Inserts the file after position.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="fileName">The file name.</param>
|
|
|
|
|
|
/// <param name="pos">The pos.</param>
|
|
|
|
|
|
/// <returns>A bool.</returns>
|
|
|
|
|
|
public bool InsertFileAfter(string fileName, long pos)
|
|
|
|
|
|
{
|
|
|
|
|
|
return XyInsertFileAfter(pXy, fileName, pos);
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 插入数据到最底层
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="drawData">要插入的数据</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool XyInsertDataBottom(string drawData, string newLayer)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntPtr pBuff = Marshal.StringToHGlobalAnsi(drawData);
|
|
|
|
|
|
int nLen = Encoding.Default.GetByteCount(drawData);
|
|
|
|
|
|
bool bSuccess = XyInsertDataBottom(this.pXy, pBuff, nLen, newLayer);
|
|
|
|
|
|
Marshal.FreeHGlobal(pBuff);
|
|
|
|
|
|
return bSuccess;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 合并文件.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sourceFile">基础文件.</param>
|
|
|
|
|
|
/// <param name="mergeFile">要合并的文件.</param>
|
|
|
|
|
|
/// <param name="destFile">合并后的保存文件.</param>
|
|
|
|
|
|
/// <returns><c>true</c> if 合并成功, <c>false</c> otherwise.</returns>
|
|
|
|
|
|
public static bool MergeFile(string sourceFile, string mergeFile
|
|
|
|
|
|
, string destFile = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sourceFile == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(sourceFile));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (mergeFile == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(mergeFile));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string strSaveFile = destFile;
|
|
|
|
|
|
if (string.IsNullOrEmpty(destFile))
|
|
|
|
|
|
{
|
|
|
|
|
|
strSaveFile = sourceFile;
|
|
|
|
|
|
}
|
|
|
|
|
|
bool bSuccess = false;
|
|
|
|
|
|
DrawerData drawer = new DrawerData();
|
|
|
|
|
|
if (drawer.OpenFile(sourceFile) == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (drawer.MergeFile(mergeFile) == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
bSuccess = drawer.SaveAs(strSaveFile);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
drawer.Dispose();
|
|
|
|
|
|
return bSuccess;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取位图 IntPtr
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="filePath"></param>
|
|
|
|
|
|
/// <param name="width"></param>
|
|
|
|
|
|
/// <param name="height"></param>
|
|
|
|
|
|
/// <param name="inflate"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="ArgumentNullException"></exception>
|
|
|
|
|
|
public IntPtr GetBitmapHandle(string filePath, int width, int height, int inflate = 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (filePath == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(filePath));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (width <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(width));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (height <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(height));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.OpenFile(filePath) == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
return IntPtr.Zero;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IntPtr pBuffer = GetBitmap(this.pXy, width, height, inflate);
|
|
|
|
|
|
return pBuffer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 生成一个图件的 bitmap?这个需要手动释放,不然会内存泄露
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy"></param>
|
|
|
|
|
|
/// <param name="width"></param>
|
|
|
|
|
|
/// <param name="height"></param>
|
|
|
|
|
|
/// <param name="inflate"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public IntPtr GetBitmapHandle(int width, int height, int inflate = 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (pXy == IntPtr.Zero)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentException("参数不能为 IntPtr.Zero", nameof(pXy));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (width <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(width));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (height <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(height));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return GetBitmap(this.pXy, width, height, inflate);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="hBmp"></param>
|
|
|
|
|
|
public void DeleteHbmp(IntPtr hBmp)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (hBmp == IntPtr.Zero)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentException("参数不能为 IntPtr.Zero", nameof(hBmp));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DeleteHBITMAP(hBmp);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the bitmap.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sourceFile">The source file.</param>
|
|
|
|
|
|
/// <param name="width">The width.</param>
|
|
|
|
|
|
/// <param name="height">The height.</param>
|
|
|
|
|
|
/// <param name="inflate"></param>
|
|
|
|
|
|
/// <param inflate="inflate">边界缩进</param>
|
|
|
|
|
|
/// <param name="autoClip">自动裁切</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public Bitmap GetBitmap(string sourceFile, int width, int height, int inflate = 0, bool autoClip = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sourceFile == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(sourceFile));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (OpenFile(sourceFile) == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return GetBitmap(width, height, inflate, autoClip);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 生成图片
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="width">宽度</param>
|
|
|
|
|
|
/// <param name="height">高度</param>
|
|
|
|
|
|
/// <param name="inflate">边缘</param>
|
|
|
|
|
|
/// <param name="autoClip">自动缩放</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public Bitmap GetBitmap(int width, int height, int inflate = 0, bool autoClip = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
int nBmpWidth = width;
|
|
|
|
|
|
int nBmpHeight = height;
|
|
|
|
|
|
|
|
|
|
|
|
if (autoClip == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
double dXMin = 0, dXMax = 0, dYMin = 0, dYMax = 0;
|
|
|
|
|
|
GetMapSize(this.pXy, ref dXMin, ref dYMin, ref dXMax, ref dYMax);
|
|
|
|
|
|
|
|
|
|
|
|
double dWidth = dXMax - dXMin;
|
|
|
|
|
|
double dHeight = dYMax - dYMin;
|
|
|
|
|
|
|
|
|
|
|
|
double dScaleX = dWidth / width;
|
|
|
|
|
|
double dScaleY = dHeight / height;
|
|
|
|
|
|
double dScale = dScaleX;
|
|
|
|
|
|
if (dScaleX >= dScaleY)
|
|
|
|
|
|
{
|
|
|
|
|
|
nBmpWidth = (int)Math.Round(dWidth / dScale);
|
|
|
|
|
|
nBmpHeight = (int)Math.Ceiling(dHeight / dScale);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dScale = dScaleY;
|
|
|
|
|
|
nBmpWidth = (int)Math.Ceiling(dWidth / dScale);
|
|
|
|
|
|
nBmpHeight = (int)Math.Round(dHeight / dScale);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 消除网格锯齿
|
|
|
|
|
|
XyEnableMeshPackage(this.pXy, true);
|
|
|
|
|
|
IntPtr pBuffer = GetBitmap(this.pXy, nBmpWidth, nBmpHeight, inflate);
|
|
|
|
|
|
|
|
|
|
|
|
Bitmap bmp = Bitmap.FromHbitmap(pBuffer);
|
|
|
|
|
|
DeleteHBITMAP(pBuffer);
|
|
|
|
|
|
return bmp;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得图层下的所有曲线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName">图层名称</param>
|
|
|
|
|
|
/// <param name="curveData">曲线图元数据</param>
|
|
|
|
|
|
/// <returns>获取的曲线个数</returns>
|
|
|
|
|
|
public int LayerGetCurves(string layerName, ref string curveData, bool withChild=true)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IntPtr ptData = IntPtr.Zero;
|
|
|
|
|
|
int nDataLen = 0;
|
|
|
|
|
|
int nCount = Layer_GetCurves(this.pXy, layerName, ref ptData, ref nDataLen, withChild);
|
|
|
|
|
|
if (nCount == 0 || ptData == IntPtr.Zero || nDataLen == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
//byte[] btCurve = new byte[nDataLen];
|
|
|
|
|
|
//Marshal.Copy((IntPtr)ptData, btCurve, 0, nDataLen);
|
|
|
|
|
|
// curveData = System.Text.Encoding.Default.GetString(btCurve);
|
|
|
|
|
|
curveData = Marshal.PtrToStringAnsi(ptData, nDataLen);
|
|
|
|
|
|
GeoSigmaLib.PointerFree(ptData);
|
|
|
|
|
|
return nCount;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 导出文件中的数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="withLine">是否导出线类数据</param>
|
|
|
|
|
|
/// <param name="withPoint">是否导出点类数据</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public string ExportFileData(bool withLine, bool withPoint)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntPtr pStr = XyExportFileData(this.pXy, withLine, withPoint);
|
|
|
|
|
|
if (pStr == IntPtr.Zero)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 将IntPtr转换为C#字符串
|
|
|
|
|
|
string result = Marshal.PtrToStringAnsi(pStr);
|
|
|
|
|
|
|
|
|
|
|
|
// 释放C++端分配的内存
|
|
|
|
|
|
GeoSigmaLib.PointerArrayDelete(pStr);
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 列出所有图元 position
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>postion列表,一个position代表一个图层对象</returns>
|
|
|
|
|
|
public long[] ListAllElements()
|
|
|
|
|
|
{
|
|
|
|
|
|
IntPtr pStr = XyListAllElements(this.pXy);
|
|
|
|
|
|
string positions = MarshalHelper.ToString(pStr);
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(positions))
|
|
|
|
|
|
{
|
|
|
|
|
|
return Array.Empty<long>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return positions.Split(',').Select(long.Parse).ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加图元,以 dfd 格式字符串的方式添加
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="data"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public int AddBufferData(string data)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
//throw new ArgumentNullException(nameof(data));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pXy == IntPtr.Zero)
|
|
|
|
|
|
{
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
//throw new XyNotOpenException("图件未打开");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XyAddBufferData(pXy, data);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加曲线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName">要添加的图层</param>
|
|
|
|
|
|
/// <param name="curve">曲线</param>
|
|
|
|
|
|
/// <returns>成功/失败</returns>
|
|
|
|
|
|
public bool AddCurve(string layerName, CurveData curve)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (curve == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(curve));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<double> x = new List<double>();
|
|
|
|
|
|
List<double> y = new List<double>();
|
|
|
|
|
|
List<double> z = new List<double>();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var point in curve.Points)
|
|
|
|
|
|
{
|
|
|
|
|
|
x.Add(point.X);
|
|
|
|
|
|
y.Add(point.Y);
|
|
|
|
|
|
if (point.Z != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
z.Add(point.Z.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (z.Count != 0 && z.Count != x.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new InvalidOperationException("z 值要么没有,要么必须和 x y 数量一样");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XyCurveAdd(pXy, layerName, curve.Name, x.ToArray(), y.ToArray(), z.ToArray(), z.Count() > 0, x.Count);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加点数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName">图层名</param>
|
|
|
|
|
|
/// <param name="point">点</param>
|
|
|
|
|
|
/// <returns>成功/失败</returns>
|
|
|
|
|
|
public bool AddPoint(string layerName, PointData point)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XyAddPoint(pXy, layerName, point.Name, point.X, point.Y, point.Z);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将数据添加为符号
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="data"></param>
|
|
|
|
|
|
/// <param name="symbolName"></param>
|
|
|
|
|
|
/// <param name="overwrite"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public int AddDataAsSymble(string data, string symbolName, bool overwrite = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
return XyAddDataAsSymble(this.pXy, data, symbolName, overwrite);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 以CSV格式输出统计数据.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layers">图层名称.</param>
|
|
|
|
|
|
/// <param name="childNode">if set to <c>true</c> [包含子节点].</param>
|
|
|
|
|
|
/// <param name="statisticType">统计内容的类型.</param>
|
|
|
|
|
|
/// <param name="resultFile">统计结果要写入的文件.</param>
|
|
|
|
|
|
/// <returns>统计数据的内容</returns>
|
|
|
|
|
|
public string StatisticCsv(string[] layers, bool childNode, StatisticType statisticType, string resultFile = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntPtr ptr = StatisticCsv(pXy, layers, layers.Length, childNode, (int)statisticType, 0);
|
|
|
|
|
|
string strData = MarshalHelper.ToString(ptr);
|
|
|
|
|
|
if (!string.IsNullOrEmpty(resultFile))
|
|
|
|
|
|
{
|
|
|
|
|
|
File.WriteAllText(resultFile, strData, Encoding.Default);
|
|
|
|
|
|
}
|
|
|
|
|
|
Marshal.FreeBSTR(Marshal.StringToBSTR(strData));
|
|
|
|
|
|
return strData;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 统计面积衡量厚度.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="blockData">区块的边界坐标.</param>
|
|
|
|
|
|
/// <returns>厚度</returns>
|
|
|
|
|
|
public double StaticTradeArea(string blockData)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (blockData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(blockData));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return StaticTradeArea(pXy, blockData);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public double StaticTradeAreaByContour(string blockData, string controuLayer, string faultLayer)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (blockData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return StaticTradeAreaByContour(pXy, blockData, controuLayer, faultLayer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 计算区域的体积
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="blockData">区块的边界坐标.</param>
|
|
|
|
|
|
/// <returns>体积</returns>
|
|
|
|
|
|
public double CaculateVolume(string blockData)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (blockData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(blockData));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return CaculateVolume(pXy, blockData);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取网格Z值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="ptX"></param>
|
|
|
|
|
|
/// <param name="ptY"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public double MeshGetZ(double ptX, double ptY)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Mesh_GetZ(pXy, ptX, ptY);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取网格Z值 返回zmin和zmax区间值 超出返回-1e100
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="ptX"></param>
|
|
|
|
|
|
/// <param name="ptY"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public double MeshGetZ1(double ptX, double ptY)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Mesh_GetZ1(pXy, ptX, ptY);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 统计井的Z值.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="blockLine">The block line.</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public string StaticWellsZ(string blockLine)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (blockLine == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(blockLine));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IntPtr ptr = StaticWellsZ(pXy, blockLine);
|
|
|
|
|
|
return MarshalHelper.ToString(ptr);
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 区域连通计算
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="blockLines">区域,Pline格式</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public string ConnectPolygons(string blockLines)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (blockLines == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(blockLines));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IntPtr ptr = DrawerData.DrawerConnectPolygons(blockLines);
|
|
|
|
|
|
return MarshalHelper.ToString(ptr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 生成龟背图
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="borderLine">边界线</param>
|
|
|
|
|
|
/// <param name="points">散点</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public string CreateVoronoi(string borderLine, string points)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (borderLine == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(borderLine));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (points == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(points));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IntPtr ptr = CreateVoronoi(pXy, borderLine, points);
|
|
|
|
|
|
return MarshalHelper.ToString(ptr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 使用线数据对文件进行切图处理.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="curveData">The curve data.</param>
|
|
|
|
|
|
/// <param name="sourceFile">The source file.</param>
|
|
|
|
|
|
/// <param name="destFile">The dest file.</param>
|
|
|
|
|
|
/// <returns>执行结果,成功返回大于0的数</returns>
|
|
|
|
|
|
public static int CutOutFileByLine(string curveData, string sourceFile, string destFile)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (curveData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(curveData));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (sourceFile == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(sourceFile));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (destFile == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(destFile));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return MarshalHelper.Call(curveData, (pBuff, nLen) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
return CutOutFileByLine(pBuff, nLen, sourceFile, destFile);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据名称查找图元
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="eleName">图元名称</param>
|
|
|
|
|
|
/// <returns>成功返回对应的字符串,失败返回空字符串</returns>
|
|
|
|
|
|
public string FindPointByName(string eleName)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (eleName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(eleName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string strData = string.Empty;
|
|
|
|
|
|
IntPtr pData = IntPtr.Zero;
|
|
|
|
|
|
int nDataLen = 0;
|
|
|
|
|
|
if (FindPointByName(this.pXy, eleName, ref pData, ref nDataLen))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (nDataLen > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] btData = new byte[nDataLen];
|
|
|
|
|
|
Marshal.Copy((IntPtr)pData, btData, 0, nDataLen);
|
|
|
|
|
|
strData = System.Text.Encoding.Default.GetString(btData);
|
|
|
|
|
|
GeoSigmaLib.PointerFree((IntPtr)pData);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return strData;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得范围内的图元
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="borderPos">边界数据指针</param>
|
|
|
|
|
|
/// <param name="layerName">图层名称</param>
|
|
|
|
|
|
/// <param name="elementType">图元类型</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public string GetElementsByRange(long borderPos, string layerName, int elementType)
|
|
|
|
|
|
{
|
|
|
|
|
|
long pData = 0;
|
|
|
|
|
|
int dataLength = 0;
|
|
|
|
|
|
XyGetElementsByRange(this.pXy, borderPos, layerName, elementType, ref pData, ref dataLength);
|
|
|
|
|
|
if (dataLength == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
byte[] btData = new byte[dataLength];
|
|
|
|
|
|
Marshal.Copy((IntPtr)pData, btData, 0, dataLength);
|
|
|
|
|
|
string data = System.Text.Encoding.Default.GetString(btData);
|
|
|
|
|
|
GeoSigmaLib.PointerFree((IntPtr)pData);
|
|
|
|
|
|
return data;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private const string PositionMessage = "position 不能 <= 0";
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 通过 position 获取图元
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="position"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public string GetElementByPosition(long position)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (position <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(position));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string strElementData = string.Empty;
|
|
|
|
|
|
long lpDataBuffer = 0;
|
|
|
|
|
|
int dataLength = 0;
|
|
|
|
|
|
bool bSuccess = GetElementByPosition(this.pXy, ref lpDataBuffer, ref dataLength, position);
|
|
|
|
|
|
if (bSuccess != true)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
//换下面的方法:by:lgz,20250329
|
|
|
|
|
|
//if (dataLength > 0)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// byte[] btCurve = new byte[dataLength];
|
|
|
|
|
|
// Marshal.Copy((IntPtr)lpDataBuffer, btCurve, 0, dataLength);
|
|
|
|
|
|
// strElementData = System.Text.Encoding.Default.GetString(btCurve);
|
|
|
|
|
|
// GeoSigmaLib.PointerFree((IntPtr)lpDataBuffer);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
if (lpDataBuffer > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
// strElementData = Marshal.PtrToStringBSTR((IntPtr)lpDataBuffer);
|
|
|
|
|
|
strElementData = Marshal.PtrToStringAnsi((IntPtr)lpDataBuffer,dataLength);
|
|
|
|
|
|
GeoSigmaLib.PointerFree((IntPtr)lpDataBuffer);
|
|
|
|
|
|
// Marshal.FreeBSTR((IntPtr)lpDataBuffer);//
|
|
|
|
|
|
}
|
|
|
|
|
|
return strElementData;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public long FindPointByInfo(string elementName, double x, double y, string layerName)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (elementName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(elementName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long pos = 0;
|
|
|
|
|
|
FindPointByInfo(this.pXy, ref pos, elementName, x, y, layerName);
|
|
|
|
|
|
return pos;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool SetElementData(string elementData, long position)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (elementData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(elementData));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (position <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(position));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return MarshalHelper.Call(elementData, (pBuff, nLen) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
return SetElement(this.pXy, pBuff, nLen, position);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 过滤等值线,将不在范围内的等值线过滤掉,并且将网格 z 值小于 0 的设置为 0
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layer">等值线所在图层</param>
|
|
|
|
|
|
/// <param name="minValue">等值线最小值</param>
|
|
|
|
|
|
/// <param name="maxValue">等值线最大值</param>
|
|
|
|
|
|
/// <returns>返回生成文件路径</returns>
|
|
|
|
|
|
public void FilterContourLines(string layer, double minValue = -1.23E300, double maxValue = 1.23E300)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (maxValue < minValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(maxValue), "maxValue should be greater than minValue.");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (layer == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layer));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
XyFilterContourLines(pXy, layer, minValue, maxValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将网格 z 值映射到指定范围,小于最小值设置为最小值,大小最大值设置为最大值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="minValue">z 轴最小值</param>
|
|
|
|
|
|
/// <param name="maxValue">z 轴最大值</param>
|
|
|
|
|
|
/// <param name="mode">网格操作模式</param>
|
|
|
|
|
|
public void MapMeshValueRange(double minValue, double maxValue, MeshOperatoionMode mode)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (maxValue < minValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(maxValue), "maxValue 应该大于 minValue.");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int n = (mode == MeshOperatoionMode.Invalidate ? 1 : 2);
|
|
|
|
|
|
|
|
|
|
|
|
XyMapMeshValueRange(pXy, minValue, maxValue, n);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查找井点数据.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pointName">The point name.</param>
|
|
|
|
|
|
/// <param name="needZ">If true, need z.</param>
|
|
|
|
|
|
/// <returns>A string.</returns>
|
|
|
|
|
|
public string FindPoint(string pointName, bool needZ = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntPtr ptr = XYFindPoint(pXy, pointName, needZ);
|
|
|
|
|
|
if (ptr == IntPtr.Zero)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
string strData = Marshal.PtrToStringBSTR(ptr);
|
|
|
|
|
|
Marshal.FreeBSTR(ptr);
|
|
|
|
|
|
return strData;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 统计区域内井的数量
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="blockLine">边界线坐标</param>
|
|
|
|
|
|
/// <returns>XML格式的井列表</returns>
|
|
|
|
|
|
public string StaticBlockWells(string blockLine)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (blockLine == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(blockLine));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IntPtr ptr = XYStaticBlockWells(pXy, blockLine);
|
|
|
|
|
|
if (ptr == IntPtr.Zero)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
string strData = Marshal.PtrToStringBSTR(ptr);
|
|
|
|
|
|
Marshal.FreeBSTR(ptr);
|
|
|
|
|
|
return strData;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 创建图层曲线样式/修饰
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName">图层名</param>
|
|
|
|
|
|
/// <param name="type">样式/修饰类型</param>
|
|
|
|
|
|
/// <param name="data">样式/修饰内容,xml 格式</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool CreateLayerCurveStyle(string layerName, CurveStyleType type, string data)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(data));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return MarshalHelper.Call(data, (pBuff, nLen) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
return XyCreateLayerCurveStyle(pXy, layerName, (int)type, pBuff, nLen);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置曲线样式/修饰
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName"></param>
|
|
|
|
|
|
/// <param name="data"></param>
|
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool SetLayerHowtoViewCurve(string layerName, string data, int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(data));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return MarshalHelper.Call(data, (pBuff, nLen) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
return XySetLayerHowtoViewCurve(pXy, layerName, pBuff, nLen, index);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取图层样式数据.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName">The layer name.</param>
|
|
|
|
|
|
/// <param name="curveStyle">The curve style.</param>
|
|
|
|
|
|
/// <param name="pointStyle">The point style.</param>
|
|
|
|
|
|
/// <returns>A bool.</returns>
|
|
|
|
|
|
public bool GetLayerStyleData(string layerName, ref string curveStyle, ref string pointStyle)
|
|
|
|
|
|
{
|
|
|
|
|
|
long pCurve = 0, pPoint = 0;
|
|
|
|
|
|
int nCurveLen = 0, nPointLen = 0;
|
|
|
|
|
|
bool bSuccess = XyGetLayerStyleData(pXy, layerName, ref pCurve, ref nCurveLen, ref pPoint, ref nPointLen);
|
|
|
|
|
|
if (bSuccess != true) return false;
|
|
|
|
|
|
if (nCurveLen == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
curveStyle = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] btCurve = new byte[nCurveLen];
|
|
|
|
|
|
Marshal.Copy((IntPtr)pCurve, btCurve, 0, nCurveLen);
|
|
|
|
|
|
curveStyle = System.Text.Encoding.Default.GetString(btCurve);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (nPointLen == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
pointStyle = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] btPoint = new byte[nPointLen];
|
|
|
|
|
|
Marshal.Copy((IntPtr)pPoint, btPoint, 0, nPointLen);
|
|
|
|
|
|
pointStyle = System.Text.Encoding.Default.GetString(btPoint);
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Sets 图层的点样式.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName">The layer name.</param>
|
|
|
|
|
|
/// <param name="styleData">The style data.</param>
|
|
|
|
|
|
/// <param name="replace">If true, replace.</param>
|
|
|
|
|
|
/// <returns>A bool.</returns>
|
|
|
|
|
|
public bool SetLayerHowtoViewPoint(string layerName, string styleData, bool replace)
|
|
|
|
|
|
{
|
|
|
|
|
|
return MarshalHelper.Call(styleData, (pBuff, nLen) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
return XySetLayerHowtoViewPoint(pXy, layerName, pBuff, nLen, replace);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加图层
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layer">图层名</param>
|
|
|
|
|
|
/// <returns>成功/失败</returns>
|
|
|
|
|
|
public bool AddLayer(string layer)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layer == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layer));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XyAddLayer(pXy, layer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取图层信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="withStatus"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public string GetLayers(bool withStatus = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
long pData = 0;
|
|
|
|
|
|
int nDesLen = 0;
|
|
|
|
|
|
XyGetLayers(pXy, ref pData, ref nDesLen, withStatus);
|
|
|
|
|
|
if (nDesLen == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
//byte[] btDest = new byte[nDesLen];
|
|
|
|
|
|
//Marshal.Copy((IntPtr)pData, btDest, 0, nDesLen);
|
|
|
|
|
|
//string strOut = Encoding.Default.GetString(btDest);
|
|
|
|
|
|
var strOut = Marshal.PtrToStringAnsi((IntPtr)pData, nDesLen);
|
|
|
|
|
|
GeoSigmaLib.PointerArrayDelete((IntPtr)pData);
|
|
|
|
|
|
return strOut;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 删除图层
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layers">图层列表</param>
|
|
|
|
|
|
/// <param name="withSublayer">是否包含子图层</param>
|
|
|
|
|
|
public void DeleteLayer(string[] layers, bool withSublayer = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
XyDeleteLayer(this.pXy, layers, layers.Length, withSublayer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将图层移动到目标图层之下
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layer">当前图层名</param>
|
|
|
|
|
|
/// <param name="parentLayer">目标图层名</param>
|
|
|
|
|
|
public bool MoveLayerUnderTargetLayer(string layer, string parentLayer)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layer == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layer));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (parentLayer == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(parentLayer));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pXy == IntPtr.Zero)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception($"{nameof(pXy)} 不能为 IntPtr.Zero");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XyMoveLayerUnderTargetLayer(pXy, layer, parentLayer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Deletes the layer element.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layer">The layer.</param>
|
|
|
|
|
|
/// <param name="withSublayer">If true, with sublayer.</param>
|
|
|
|
|
|
public void DeleteLayerElement(string layer, bool withSublayer = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
XyDeleteLayerElement(this.pXy, layer, withSublayer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool CreateFaultStatistic(string statisticFile, string faultLayer, int markType)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (statisticFile == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(statisticFile));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (faultLayer == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(faultLayer));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XyCreateFaultStatistic(pXy, statisticFile, faultLayer, markType);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 断裂划分
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="faultLayer">断层图层</param>
|
|
|
|
|
|
/// <param name="classStart">分级起始值</param>
|
|
|
|
|
|
/// <param name="classEnd">分级结束值</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool CreateFaultDelimit(string faultLayer
|
|
|
|
|
|
, double[] classStart, double[] classEnd)
|
|
|
|
|
|
{
|
|
|
|
|
|
return XyCreateFaultDelimit(this.pXy, faultLayer, classStart, classEnd, classStart.Length);
|
|
|
|
|
|
}
|
|
|
|
|
|
public bool XyCreateFaultDelimitByAngle(string faultLayer, double[] classStart, double[] classEnd)
|
|
|
|
|
|
{
|
|
|
|
|
|
return XyCreateFaultDelimitByAngle(this.pXy, faultLayer, classStart, classEnd, classStart.Length);
|
|
|
|
|
|
}
|
|
|
|
|
|
public bool XyCreateFaultDelimitByLength(string faultLayer, double[] classStart, double[] classEnd)
|
|
|
|
|
|
{
|
|
|
|
|
|
return XyCreateFaultDelimitByLength(this.pXy, faultLayer, classStart, classEnd, classStart.Length);
|
|
|
|
|
|
}
|
|
|
|
|
|
public RectangleD GetRange()
|
|
|
|
|
|
{
|
|
|
|
|
|
long[] positions = ListAllElements();
|
|
|
|
|
|
return GetRange(positions);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取图元范围
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pos">position</param>
|
|
|
|
|
|
/// <param name="left">左侧坐标</param>
|
|
|
|
|
|
/// <param name="top">上边坐标</param>
|
|
|
|
|
|
/// <param name="right">右侧坐标</param>
|
|
|
|
|
|
/// <param name="bottom">底层坐标</param>
|
|
|
|
|
|
/// <returns>成功/失败</returns>
|
|
|
|
|
|
public RectangleD GetRange(long pos)
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetRange(new[] { pos });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得图元列表的坐标范围
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="lstPos">图元列表</param>
|
|
|
|
|
|
/// <param name="left">左</param>
|
|
|
|
|
|
/// <param name="bottom">下</param>
|
|
|
|
|
|
/// <param name="right">右</param>
|
|
|
|
|
|
/// <param name="top">上</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public RectangleD GetRange(long[] arrayPos)
|
|
|
|
|
|
{
|
|
|
|
|
|
double left = 0;
|
|
|
|
|
|
double bottom = 0;
|
|
|
|
|
|
double right = 0;
|
|
|
|
|
|
double top = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (XyGetElementsRange(this.pXy, arrayPos, arrayPos.Length, ref left, ref bottom, ref right, ref top))
|
|
|
|
|
|
{
|
|
|
|
|
|
// 上面接口获取到的是笛卡尔坐标系,下面这个 RectangleD 是屏幕坐标系,需要交换一下 bottom 和 top
|
|
|
|
|
|
return RectangleD.FromLTRB(left, bottom, right, top);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return new RectangleD();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 合并图件里的符号到当前图件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="fileName"></param>
|
|
|
|
|
|
public bool MergeSymbol(string fileName)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (fileName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(fileName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XyMergeSymbol(pXy, fileName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 给指定图层曲线映射上随机颜色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName">图层名</param>
|
|
|
|
|
|
/// <param name="includeSubLayer">是否包含子层</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="ArgumentNullException">参数空异常</exception>
|
|
|
|
|
|
public bool CurveMappingRandColor(string layerName, bool includeSubLayer)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XyCurveMappingRandColor(pXy, layerName, includeSubLayer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 存储指定图层图元的修饰
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName">要存储的图层</param>
|
|
|
|
|
|
/// <param name="includeSubLayer">是否包含子层</param>
|
|
|
|
|
|
public void SaveElementsEmbellish(string layerName, bool includeSubLayer)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
XySaveElementsEmbellish(pXy, layerName, includeSubLayer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 恢复图层修饰
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void RestoreElementsEmbellish()
|
|
|
|
|
|
{
|
|
|
|
|
|
XyRestoreElementsEmbellish(pXy);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 清理图导中图元的修饰
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName">图层</param>
|
|
|
|
|
|
/// <param name="includeSubLayer">是否包含子层</param>
|
|
|
|
|
|
public void ClearLayerElementsEmbellish(string layerName, bool includeSubLayer)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
XyClearLayerElementsEmbellish(pXy, layerName, includeSubLayer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取图元范围
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="arrayPos">目标图元的 position</param>
|
|
|
|
|
|
/// <param name="left">left</param>
|
|
|
|
|
|
/// <param name="bottom">bottom</param>
|
|
|
|
|
|
/// <param name="right">right</param>
|
|
|
|
|
|
/// <param name="top">top</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool GetElementsRange(long[] arrayPos, ref double left, ref double bottom, ref double right, ref double top)
|
|
|
|
|
|
{
|
|
|
|
|
|
return XyGetElementsRange(this.pXy, arrayPos, arrayPos.Length, ref left, ref bottom, ref right, ref top);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取曲线长度
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pos">曲线的 psoition</param>
|
|
|
|
|
|
/// <returns>曲线长度</returns>
|
|
|
|
|
|
public double XyGetCurveLength(long pos)
|
|
|
|
|
|
{
|
|
|
|
|
|
return XyGetCurveLength(pXy, pos);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询接口,根据图元名称进行匹配,目前仅支持点和线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="searchText">搜索的内容</param>
|
|
|
|
|
|
/// <param name="ignoreCase">忽略大小写</param>
|
|
|
|
|
|
/// <param name="matchWholeWord">全内容匹配</param>
|
|
|
|
|
|
/// <returns>图元指针列表</returns>
|
|
|
|
|
|
public List<long> SearchElement(string searchText, bool ignoreCase, bool matchWholeWord)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntPtr ptr = XySearchElement(pXy, searchText, ignoreCase, matchWholeWord);
|
|
|
|
|
|
string result = MarshalHelper.ToString(ptr);
|
|
|
|
|
|
Marshal.FreeBSTR(ptr);
|
|
|
|
|
|
return CsvPositionToList(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取某一类型的图元列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="elementType">图元类型</param>
|
|
|
|
|
|
/// <returns>图元指针列表</returns>
|
|
|
|
|
|
public long[] SearchElementByType(int elementType)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntPtr arrayPtr;
|
|
|
|
|
|
int size;
|
|
|
|
|
|
bool bSuccess = XySearchElementByType(pXy, elementType, out arrayPtr, out size);
|
|
|
|
|
|
if (bSuccess == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
long[] arrPos = new long[size];
|
|
|
|
|
|
Marshal.Copy(arrayPtr, arrPos, 0, size);
|
|
|
|
|
|
//GeoSigmaLib.PointerFree(arrayPtr);
|
|
|
|
|
|
return arrPos;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取不包含某类图元的所有图元 position
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="elementType">图元类型</param>
|
|
|
|
|
|
/// <returns>图元指针列表</returns>
|
|
|
|
|
|
public long[] SearchElementExcludingType(int[] elementType)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntPtr arrayPtr;
|
|
|
|
|
|
int size;
|
|
|
|
|
|
bool bSuccess = XySearchElementExcludingType(pXy, elementType, elementType.Length, out arrayPtr, out size);
|
|
|
|
|
|
if (!bSuccess)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new long[] { };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long[] arrPos = new long[size];
|
|
|
|
|
|
Marshal.Copy(arrayPtr, arrPos, 0, size);
|
|
|
|
|
|
return arrPos;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取某一图层所有图元列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public long[] SearchElementByLayer(string layerName)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntPtr arrayPtr;
|
|
|
|
|
|
int size;
|
|
|
|
|
|
bool bSuccess = XySearchElementByLayer(pXy, layerName, out arrayPtr, out size);
|
|
|
|
|
|
if (bSuccess == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
long[] arrPos = new long[size];
|
|
|
|
|
|
Marshal.Copy(arrayPtr, arrPos, 0, size);
|
|
|
|
|
|
// 释放分配的内存
|
|
|
|
|
|
//GeoSigmaLib.PointerFree(arrayPtr);
|
|
|
|
|
|
//Marshal.FreeHGlobal(arrayPtr);
|
|
|
|
|
|
return arrPos;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取网格数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>xml 格式数据</returns>
|
|
|
|
|
|
public MeshGridData GetMesh()
|
|
|
|
|
|
{
|
|
|
|
|
|
MeshMetadata metadata = new MeshMetadata();
|
|
|
|
|
|
|
|
|
|
|
|
if (XyGetMesh(pXy, ref metadata, out IntPtr x, out IntPtr y, out IntPtr z))
|
|
|
|
|
|
{
|
|
|
|
|
|
int length = metadata.Rows * metadata.Columns;
|
|
|
|
|
|
double[] xs = MarshalHelper.ToDoubleArray(x, metadata.Rows);
|
|
|
|
|
|
double[] ys = MarshalHelper.ToDoubleArray(y, metadata.Columns);
|
|
|
|
|
|
double[] zs = MarshalHelper.ToDoubleArray(z, length);
|
|
|
|
|
|
return new MeshGridData(metadata, xs, ys, zs);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得网格的信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public string XyGetMeshInfo()
|
|
|
|
|
|
{
|
|
|
|
|
|
long pData = 0;
|
|
|
|
|
|
int dataLength = 0;
|
|
|
|
|
|
bool bSuccess = XyGetMeshInfo(pXy, ref pData, ref dataLength);
|
|
|
|
|
|
if (bSuccess != true) return string.Empty;
|
|
|
|
|
|
byte[] btCurve = new byte[dataLength];
|
|
|
|
|
|
Marshal.Copy((IntPtr)pData, btCurve, 0, dataLength);
|
|
|
|
|
|
string elementData = System.Text.Encoding.Default.GetString(btCurve);
|
|
|
|
|
|
GeoSigmaLib.PointerFree((IntPtr)pData);
|
|
|
|
|
|
return elementData;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置网格信息,如颜色模版等
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="infoData"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool XySetMeshInfo(string infoData)
|
|
|
|
|
|
{
|
|
|
|
|
|
return XySetMeshInfo(this.pXy, infoData);
|
|
|
|
|
|
}
|
|
|
|
|
|
public bool XyGetMeshData(ref double xMin, ref double yMin, ref int xNum, ref int yNum, ref double xStep, ref double yStep, ref long pValue, ref double zMin, ref double zMax)
|
|
|
|
|
|
{
|
|
|
|
|
|
return XyGetMeshData(this.pXy, ref xMin, ref yMin, ref xNum, ref yNum, ref xStep, ref yStep, ref pValue, ref zMin, ref zMax);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据 x y 坐标获取 z 值,x y z 长度必须一致
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="x">x 坐标组成的数组</param>
|
|
|
|
|
|
/// <param name="y">y 坐标组成的数组</param>
|
|
|
|
|
|
/// <param name="z">出参,z 值将放在这里</param>
|
|
|
|
|
|
/// <returns>成功/失败</returns>
|
|
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
|
|
public bool GetMeshZValue(double[] x, double[] y, double[] z)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (x.Length != y.Length)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentException("x y 数组长度必须一致");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (x.Length != z.Length)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentException("x z 数组长度必须一致");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XyGetMeshZValue(pXy, x, y, z, x.Length);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加网格
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName">要添加的目标图层</param>
|
|
|
|
|
|
/// <param name="meshGrid">要添加的网格数据</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="ArgumentNullException"></exception>
|
|
|
|
|
|
public bool AddMesh(string layerName, MeshGridData meshGrid)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (meshGrid == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(meshGrid));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(MeshMetadata)));
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
Marshal.StructureToPtr(meshGrid.Metadata, ptr, false);
|
|
|
|
|
|
return XyAddMesh(pXy, layerName, ptr, meshGrid.XValues, meshGrid.YValues, meshGrid.ZValues);
|
|
|
|
|
|
}
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
Marshal.FreeHGlobal(ptr);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public long CreateMesh(string layerName, IntPtr values,
|
|
|
|
|
|
double xMin, double yMin, int xCount, int yCount, double stepX, double stepY,
|
|
|
|
|
|
double zMin, double zMax)
|
|
|
|
|
|
{
|
|
|
|
|
|
long pos = XyCreateMesh(this.pXy, layerName, values, xMin, yMin, xCount, yCount, stepX, stepY, zMin, zMax);
|
|
|
|
|
|
return pos;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void MeshSmooth(long posMesh, double smoothFactor, int smoothTimes = 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
XyMeshSmooth(this.pXy, posMesh, smoothFactor, smoothTimes);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void CreateContour(long posMesh, double contourStep, int contourMarkSpace)
|
|
|
|
|
|
{
|
|
|
|
|
|
XyCreateContour(this.pXy, posMesh, contourStep, contourMarkSpace);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<long> CsvPositionToList(string positions)
|
|
|
|
|
|
{
|
|
|
|
|
|
return positions.Split(',')
|
|
|
|
|
|
.Select(text => long.Parse(text))?
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将指定图层的元素置顶
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layer">图层名称</param>
|
|
|
|
|
|
/// <param name="withSubLayer">是否连子层元素一起置顶</param>
|
|
|
|
|
|
public void LayerElementOrderTop(string layer, bool withSubLayer = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
XyLayerElementOrderTop(pXy, layer, withSubLayer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将指定图层的元素置底
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layer">图层名称</param>
|
|
|
|
|
|
/// <param name="withSubLayer">是否连子层元素一起置顶</param>
|
|
|
|
|
|
public void LayerElementOrderBottom(string layer, bool withSubLayer = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
XyLayerElementOrderBottom(pXy, layer, withSubLayer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将指定图层的元素上移一层,该接口暂时不能正常工作
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layer">图层名称</param>
|
|
|
|
|
|
/// <param name="withSubLayer">是否连子层元素一起置顶</param>
|
|
|
|
|
|
public void LayerElementOrderUp(string layer, bool withSubLayer = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
XyLayerElementOrderUp(pXy, layer, withSubLayer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将指定图层的元素下移一层,该接口暂时不能正常工作
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layer">图层名称</param>
|
|
|
|
|
|
/// <param name="withSubLayer">是否连子层元素一起置顶</param>
|
|
|
|
|
|
public void LayerElementOrderDown(string layer, bool withSubLayer = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
XyLayerElementOrderDown(pXy, layer, withSubLayer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 应用样式到其它文件,它的作用是将当前图件中所有图层的样式一一复制到目标图件中同名图层中
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="targetFilePath">目标图件地址</param>
|
|
|
|
|
|
public void ApplyStyleTo(string targetFilePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(targetFilePath))
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentException($"{nameof(targetFilePath)} 不能是 null 或空白字符");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
XyApplyStyleToFile(pXy, targetFilePath);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加图例
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="x">图例左下角 x 坐标</param>
|
|
|
|
|
|
/// <param name="y">图例左下角 y 坐标</param>
|
|
|
|
|
|
/// <param name="width">宽度</param>
|
|
|
|
|
|
/// <param name="rows">多少行</param>
|
|
|
|
|
|
/// <param name="layerNames">要生成图例的图层</param>
|
|
|
|
|
|
public void LegendAdd(double x, double y, double width, int rows, string layerNames)
|
|
|
|
|
|
{
|
|
|
|
|
|
XyLegendAdd(pXy, x, y, width, rows, layerNames);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 测量图例空间占用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="width">宽高</param>
|
|
|
|
|
|
/// <param name="rows">多少行</param>
|
|
|
|
|
|
/// <param name="layerNames">要生成图例的图层</param>
|
|
|
|
|
|
/// <param name="height">图例高度</param>
|
|
|
|
|
|
/// <exception cref="Exception">底层代码存在 bug</exception>
|
|
|
|
|
|
public void LegendMeasure(double width, int rows, string layerNames, out double height)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntPtr pStr = XyLegendMeasure(pXy, width, rows, layerNames);
|
|
|
|
|
|
string widthHeight = MarshalHelper.ToString(pStr);
|
|
|
|
|
|
string[] result = widthHeight.Split(',');
|
|
|
|
|
|
if (result.Length < 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("XyLegend_Measure 返回值有误,该函数有 bug");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//width = double.Parse(result[0]);
|
|
|
|
|
|
height = double.Parse(result[1]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加边框
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName">要将边框添加到的图层名</param>
|
|
|
|
|
|
/// <param name="clip">与元素保持多大的间距</param>
|
|
|
|
|
|
public void BorderAdd(string layerName, double clip)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
XyBorderAdd(pXy, layerName, clip);
|
|
|
|
|
|
}
|
|
|
|
|
|
public int AddWellGroup(string layerName, string wellGroupData)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(layerName))
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
IntPtr pBuff = Marshal.StringToHGlobalAnsi(wellGroupData);
|
|
|
|
|
|
int nLen = Encoding.Default.GetByteCount(wellGroupData);
|
|
|
|
|
|
int nResult = XyWellGroupAdd(pXy, layerName, pBuff, nLen);
|
|
|
|
|
|
Marshal.FreeHGlobal(pBuff);
|
|
|
|
|
|
return nResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据网格 z 值填充曲线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName">要生成的目标图层名</param>
|
|
|
|
|
|
/// <param name="x1">第一个点 x 坐标</param>
|
|
|
|
|
|
/// <param name="y1">第一个点 y 坐标</param>
|
|
|
|
|
|
/// <param name="x2">第二个点 x 坐标</param>
|
|
|
|
|
|
/// <param name="y2">第二个点 y 坐标</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool CreateCurveFillZ(string layerName, double x1, double y1, double x2, double y2)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException (nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XyCreateCurveFillZ(pXy, layerName, x1, y1, x2, y2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存图层内容到另一个图件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="filePath">要保存的图件名称</param>
|
|
|
|
|
|
/// <param name="layerName">图层名</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool SaveLayer(string filePath, string layerName)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (filePath == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(filePath));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XySaveLayer(pXy, filePath, layerName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将图件转换为 Dfd 字符串对象
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="Exception"></exception>
|
|
|
|
|
|
public string ToDfdString()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (pXy == IntPtr.Zero)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception($"{nameof(pXy)} 不能为 null");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IntPtr pBuff = XyToDfdString(pXy);
|
|
|
|
|
|
return MarshalHelper.ToString(pBuff);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool SavePDFFile(string sourceFile, int paperType, int cType, int dType, double left, double right, double top, double bottom, int num)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sourceFile == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(sourceFile));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SavePDFFile(this.pXy, sourceFile, paperType, cType, dType,
|
|
|
|
|
|
left, right, top, bottom, num);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool MergePDFs(string[] list, int count, string filePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
return MergePDFFiles(list, count, filePath);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 创建有利区
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="layerName">曲线生成的图层</param>
|
|
|
|
|
|
/// <param name="zMin">最小 z 值</param>
|
|
|
|
|
|
/// <param name="zMax">最大 z 值</param>
|
|
|
|
|
|
/// <returns>创建的区域数量</returns>
|
|
|
|
|
|
public int CreateFavorableArea(IntPtr pTargetXy, string layerName, double zMin, double zMax)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layerName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(layerName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (zMin > zMax)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(zMin));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return XyCreateFavorableArea(pXy, pTargetXy, layerName, zMin, zMax);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 复杂条件查询
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="filterXml">过滤器 xml 结构</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public long[] GetElement(string filterXml)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (filterXml == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(filterXml));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IntPtr pBuffer = XyGetElement(pXy, filterXml);
|
|
|
|
|
|
string str = MarshalHelper.ToString(pBuffer);
|
|
|
|
|
|
|
|
|
|
|
|
return str.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
|
|
|
|
|
.Select(s => s.Trim())
|
|
|
|
|
|
.Where(s => long.TryParse(s, out _))
|
|
|
|
|
|
.Select(long.Parse)
|
|
|
|
|
|
.ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
|
private const string SIGMALIB = "GeoSigmaDraw.dll";
|
|
|
|
|
|
#else
|
|
|
|
|
|
private const string SIGMALIB = "GeoSigmaDraw.dll";
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyCreate", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr XyCreate();
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "DestroyXy", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool DestroyXy(IntPtr pXy);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyOpenFile", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyOpenFile(IntPtr pXy, string filePath, bool realTimeDraw);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "StatisticCsv", CharSet = CharSet.Unicode, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr StatisticCsv(IntPtr pView, [MarshalAs(UnmanagedType.LPArray)] string[] layers, int layerCount, bool childNode, int nStatMode, int surfaceType);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyDrawFile", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyDrawFile(IntPtr pXy, IntPtr hdcMem, int left, int top, int width, int height);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "GetBitmap", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr GetBitmap(IntPtr pXy, int width, int height, int inflate);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "GetMapSize", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool GetMapSize(IntPtr pXy, ref double xMin, ref double yMin, ref double xMax, ref double yMax);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "DeleteHBITMAP", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void DeleteHBITMAP(IntPtr hBmp);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyInsertFileAfter", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyInsertFileAfter(IntPtr pXy, string mergeFile, long pos);
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyInsertDataBottom", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyInsertDataBottom(IntPtr pXy, IntPtr data, int dataLen, string newLayer);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyMerge", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyMerge(IntPtr pXy, string mergeFile);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XySaveAs", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XySaveAs(IntPtr pxy, string saveFile, int version);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyEnableMeshPackage", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyEnableMeshPackage(IntPtr pXy, bool enable);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyLayer_GetCurves", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern int Layer_GetCurves(IntPtr pXy, string layerName, ref IntPtr buffElement, ref int buffLen, bool withChild=true);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyAddBufferData", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern int XyAddBufferData(IntPtr pXy, string data);
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyAddPolygonTree", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern int XyAddPolygonTree(IntPtr pXy, IntPtr pPolygonTree, string layerName);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyAddDataAsSymble", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern int XyAddDataAsSymble(IntPtr pXy, string data, string symbolName, bool bOverwrite);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyExportFileData", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr XyExportFileData(IntPtr pxy, bool withLine, bool withPoint);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Cuts the out file.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="rangeFile">范围文件.</param>
|
|
|
|
|
|
/// <param name="sourceFile">原始文件.</param>
|
|
|
|
|
|
/// <param name="destFile">剪切后文件.</param>
|
|
|
|
|
|
/// <returns>处理结果</returns>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "CutOutFile", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern int CutOutFile(string rangeFile, string sourceFile, string destFile);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "CutOutFileByLine", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern int CutOutFileByLine(IntPtr pBuffer, int dataLength, string sourceFile, string destFile);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyFindPointByName", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool FindPointByName(IntPtr pxy, string elementName, ref IntPtr dataBuffer, ref int dataLen);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyFindPointByInfo", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool FindPointByInfo(IntPtr pxy, ref long pos, string elementName, double x, double y, string layerName);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyGetElementByPosition", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool GetElementByPosition(IntPtr pxy, ref Int64 bufferElement, ref int buffLength, long position);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XySetElement", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool SetElement(IntPtr pxy, IntPtr buffElement, int buffLen, long position);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "StaticTradeArea", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern double StaticTradeArea(IntPtr pXy, string blockLine);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "StaticTradeAreaByContour", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern double StaticTradeAreaByContour(IntPtr pXy, string blockLine, string contourLayer, string faultLayer);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "CaculateVolume", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern double CaculateVolume(IntPtr pXy, string blockLine);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "Mesh_GetZ", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern double Mesh_GetZ(IntPtr pXy, double ptX, double ptY);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "Mesh_GetZ1", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern double Mesh_GetZ1(IntPtr pXy, double ptX, double ptY);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "StaticWellsZ", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr StaticWellsZ(IntPtr pXy, string blockLine);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "CreateVoronoi", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr CreateVoronoi(IntPtr pXy, string borderLine, string points);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "ConnectPolygons", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr DrawerConnectPolygons(string blockLine);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 过滤等值线,将 z 值超过范围的等值线剔除
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">pXy</param>
|
|
|
|
|
|
/// <param name="layerName">图层名称</param>
|
|
|
|
|
|
/// <param name="minValue">等值线 z 轴最小值</param>
|
|
|
|
|
|
/// <param name="maxValue">等值线 z 轴最大值</param>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyFilterContourLines", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
|
|
|
|
|
|
public static extern void XyFilterContourLines(IntPtr pXy, string layerName, double minValue, double maxValue);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将网格 z 值映射到指定范围,小于最小值设置为最小值,大小最大值设置为最大值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">pXy</param>
|
|
|
|
|
|
/// <param name="minValue">z 轴最小值</param>
|
|
|
|
|
|
/// <param name="maxValue">z 轴最大值</param>
|
|
|
|
|
|
/// <param name="mode">操作模式,1 无效化,2 抹平</param>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyMapMeshValueRange", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyMapMeshValueRange(IntPtr pXy, double minValue, double maxValue, int mode);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XYFindPoint", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr XYFindPoint(IntPtr pXy, string pointName, bool needZ);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XYStaticBlockWells", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr XYStaticBlockWells(IntPtr pXy, string blockLines);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyCreateLayerCurveStyle", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyCreateLayerCurveStyle(IntPtr pXy, string layerName, int type, IntPtr buffer, int bufferLen);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XySetLayerHowtoViewCurve", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XySetLayerHowtoViewCurve(IntPtr pXy, string layerName, IntPtr buffer, int bufferLen, int index);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyGetLayerStyleData", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyGetLayerStyleData(IntPtr pView, string layerName, ref Int64 bufferCurve, ref int lenCurve, ref Int64 bufferPoint, ref int lenPoint);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyAddLayer", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyAddLayer(IntPtr pXy, string layer);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyGetLayers", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyGetLayers(IntPtr pXy, ref long dataBuff, ref int destLen, bool withStatus);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyDeleteLayer", CharSet = CharSet.Unicode, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyDeleteLayer(IntPtr pXy, [MarshalAs(UnmanagedType.LPArray)] string[] layers, int length, bool withSublayer);
|
|
|
|
|
|
// public static extern void XyDeleteLayer(IntPtr pXy, string layers, int length, bool withSublayer);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>[MarshalAs(UnmanagedType.LPArray)]
|
|
|
|
|
|
/// 将图层移动到目标图层之下
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">图件对象</param>
|
|
|
|
|
|
/// <param name="layer">当前图层名</param>
|
|
|
|
|
|
/// <param name="parentLayer">目标图层名</param>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyMoveLayerUnderTargetLayer", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyMoveLayerUnderTargetLayer(IntPtr pXy, string layer, string parentLayer);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyDeleteLayerElement", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyDeleteLayerElement(IntPtr pXy, string layers, bool withSublayer);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyCreateFaultStatistic", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyCreateFaultStatistic(IntPtr pXy, string statisticFile, string faultLayer, int markType);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyCreateFaultDelimit", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyCreateFaultDelimit(IntPtr pXy, string faultLayer, double[] classStart, double[] classEnd, int classCount);
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyCreateFaultDelimitByAngle", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyCreateFaultDelimitByAngle(IntPtr pXy, string faultLayer, double[] classStart, double[] classEnd, int classCount);
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyCreateFaultDelimitByLength", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyCreateFaultDelimitByLength(IntPtr pXy, string faultLayer, double[] classStart, double[] classEnd, int classCount);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyBorderCount", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern int XyBorderCount(IntPtr pXy);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyCreateDefaultBorder", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern int XyCreateDefaultBorder(IntPtr pXy);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyGetRange", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyGetRange(IntPtr pXy, long pos, ref double left, ref double top, ref double right, ref double bottom);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyGetElementsRange", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyGetElementsRange(IntPtr pXy, long[] posArray, int elementCount, ref double minX, ref double minY, ref double maxX, ref double maxY);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyGetCurveLength", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern double XyGetCurveLength(IntPtr pXy, long pos);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询接口,根据图元名字进行查询
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">图件</param>
|
|
|
|
|
|
/// <param name="searchText">要搜索的内容</param>
|
|
|
|
|
|
/// <param name="ignoreCase">忽略大小写</param>
|
|
|
|
|
|
/// <param name="matchWholeWord">内容全匹配</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XySearchElement", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr XySearchElement(IntPtr pXy, string searchText, bool ignoreCase, bool matchWholeWord);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XySearchElementByType", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XySearchElementByType(IntPtr pXy, int elementType, out IntPtr arr, out int size);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XySearchElementExcludingType", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XySearchElementExcludingType(IntPtr pXy, int[] elementTypes, int elementTypeLength, out IntPtr arr, out int size);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XySearchElementByLayer", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XySearchElementByLayer(IntPtr pXy, string layerName, out IntPtr arr, out int size);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 复杂查询接口
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">图件</param>
|
|
|
|
|
|
/// <param name="filter">筛选条件</param>
|
|
|
|
|
|
/// <returns>由 position 组成的字符串,以 "," 分割</returns>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyGetElementByFilter", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern string XyGetElementByFilter(IntPtr pXy, string filter);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取网格数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">pXy</param>
|
|
|
|
|
|
/// <param name="metadata">网格元数据</param>
|
|
|
|
|
|
/// <param name="x">x 坐标的 double 数组</param>
|
|
|
|
|
|
/// <param name="y">y 坐标的 double 数组</param>
|
|
|
|
|
|
/// <param name="z">z 坐标的 double 数组</param>
|
|
|
|
|
|
/// <returns>成功/失败</returns>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyGetMesh", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
[return: MarshalAs(UnmanagedType.I1)] // 为了正确接收 C++ 的 bool 返回值
|
|
|
|
|
|
public static extern bool XyGetMesh(IntPtr pXy, ref MeshMetadata metadata, out IntPtr x, out IntPtr y, out IntPtr z);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置网格数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">pXy</param>
|
|
|
|
|
|
/// <param name="layerName">要添加到的图层</param>
|
|
|
|
|
|
/// <param name="metadata">网格元数据</param>
|
|
|
|
|
|
/// <param name="x">x 坐标的 double 数组</param>
|
|
|
|
|
|
/// <param name="y">y 坐标的 double 数组</param>
|
|
|
|
|
|
/// <param name="z">z 坐标的 double 数组</param>
|
|
|
|
|
|
/// <returns>成功/失败</returns>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyAddMesh", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
[return: MarshalAs(UnmanagedType.I1)] // 为了正确接收 C++ 的 bool 返回值
|
|
|
|
|
|
public static extern bool XyAddMesh(IntPtr pXy, string layerName, IntPtr metadata, double[] x, double[] y, double[] z);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyCreateMesh", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern long XyCreateMesh(IntPtr pXy, string layerName, IntPtr values,
|
|
|
|
|
|
double xMin, double yMin, int xCount, int yCount, double stepX, double stepY,
|
|
|
|
|
|
double zMin, double zMax);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyCreateContour", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyCreateContour(IntPtr pXy, long posMesh, double contourStep, int contourMarkStep);
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyMeshSmooth", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyMeshSmooth(IntPtr pXy, long posMesh, double smoothFactor, int smoothTimes = 2);
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyGetMeshInfo", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyGetMeshInfo(IntPtr pXy, ref Int64 infoData, ref int buffLength);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XySetMeshInfo", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XySetMeshInfo(IntPtr pXy, string infoData);
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 从XY获取网格数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy"></param>
|
|
|
|
|
|
/// <param name="xMin"></param>
|
|
|
|
|
|
/// <param name="yMin"></param>
|
|
|
|
|
|
/// <param name="xNum"></param>
|
|
|
|
|
|
/// <param name="yNum"></param>
|
|
|
|
|
|
/// <param name="xStep"></param>
|
|
|
|
|
|
/// <param name="yStep"></param>
|
|
|
|
|
|
/// <param name="pValue"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyGetMeshData", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyGetMeshData(IntPtr pXy, ref double xMin, ref double yMin, ref int xNum, ref int yNum, ref double xStep, ref double yStep, ref long pValue, ref double zMin, ref double zMax);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据 x 和 y 实际坐标获取 z 值,注意,三个数组长度必须一致
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">pXy</param>
|
|
|
|
|
|
/// <param name="x">x 实际坐标数组</param>
|
|
|
|
|
|
/// <param name="y">y 实际坐标数组</param>
|
|
|
|
|
|
/// <param name="z">出参,z 的实际组数组</param>
|
|
|
|
|
|
/// <param name="size">数组长度</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyGetMeshZValue", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
[return: MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
|
public static extern bool XyGetMeshZValue(IntPtr pXy, double[] x, double[] y, double[] z, int size);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XySetLayerHowtoViewPoint", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XySetLayerHowtoViewPoint(IntPtr pXy, string layerName, IntPtr buffCurve, int bufLen, bool replace);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将指定图层的元素置顶
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">pXy</param>
|
|
|
|
|
|
/// <param name="layer">图层名称</param>
|
|
|
|
|
|
/// <param name="withSubLayer">是否连子层元素一起置顶</param>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyLayerElementOrderTop", CharSet = CharSet.Unicode, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyLayerElementOrderTop(IntPtr pXy, string layer, bool withSubLayer);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将指定图层的元素置顶
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">pXy</param>
|
|
|
|
|
|
/// <param name="layer">图层名称</param>
|
|
|
|
|
|
/// <param name="withSubLayer">是否连子层元素一起置顶</param>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyLayerElementOrderBottom", CharSet = CharSet.Unicode, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyLayerElementOrderBottom(IntPtr pXy, string layer, bool withSubLayer);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将指定图层的元素上移一层
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">pXy</param>
|
|
|
|
|
|
/// <param name="layer">图层名称</param>
|
|
|
|
|
|
/// <param name="withSubLayer">是否连子层元素一起置顶</param>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyLayerElementOrderUp", CharSet = CharSet.Unicode, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyLayerElementOrderUp(IntPtr pXy, string layer, bool withSubLayer);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将指定图层的元素下移一层
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">pXy</param>
|
|
|
|
|
|
/// <param name="layer">图层名称</param>
|
|
|
|
|
|
/// <param name="withSubLayer">是否连子层元素一起置顶</param>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyLayerElementOrderDown", CharSet = CharSet.Unicode, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyLayerElementOrderDown(IntPtr pXy, string layer, bool withSubLayer);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取图件中所有 position
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">pXy</param>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyListAllElements", CharSet = CharSet.Unicode, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr XyListAllElements(IntPtr pXy);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 应用样式到其它文件,它的作用是将当前图件中所有图层的样式一一复制到目标图件中同名图层中
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">源图件</param>
|
|
|
|
|
|
/// <param name="targetFilePath">目标图件名</param>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyApplyStyleToFile", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyApplyStyleToFile(IntPtr pXy, string targetFilePath);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyGetElementsByRange", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyGetElementsByRange(IntPtr pXy, Int64 borderPos, string layerName, int elementType, ref Int64 bufferElement, ref int buffLengt);
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加图例
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">要添加图例的图件</param>
|
|
|
|
|
|
/// <param name="x">图例左下角 x 坐标</param>
|
|
|
|
|
|
/// <param name="y">图例左下角 y 坐标</param>
|
|
|
|
|
|
/// <param name="width">图例宽度</param>
|
|
|
|
|
|
/// <param name="rows">要添加多少行</param>
|
|
|
|
|
|
/// <param name="layerNames"></param>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyLegendAdd", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyLegendAdd(IntPtr pXy, double x, double y, double width, int rows, string layerNames);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 测量图例
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">要测量的图件</param>
|
|
|
|
|
|
/// <param name="width">图例宽度</param>
|
|
|
|
|
|
/// <param name="rows">要添加多少行</param>
|
|
|
|
|
|
/// <param name="layerNames">要添加的图层</param>
|
|
|
|
|
|
/// <returns>图例宽高,由逗号分割,"{width},{height}"</returns>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyLegendMeasure", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr XyLegendMeasure(IntPtr pXy, double width, int rows, string layerNames);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加边框
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">要添加边框的图件</param>
|
|
|
|
|
|
/// <param name="layerName">要将边框添加到的图层名</param>
|
|
|
|
|
|
/// <param name="clip">与元素保持多大的间距</param>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyBorderAdd", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyBorderAdd(IntPtr pXy, string layerName, double clip);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyCurveAdd", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyCurveAdd(IntPtr pXy, string layerName, string curveName, double[] x, double[] y, double[] z, bool hasZ, int pointCount);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyAddPoint", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyAddPoint(IntPtr pXy, string layerName, string pointName, double x, double y, double z);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加井组
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">图件</param>
|
|
|
|
|
|
/// <param name="layerName">图层名称</param>
|
|
|
|
|
|
/// <param name="byteBuffer">PCG格式的数据井组数据</param>
|
|
|
|
|
|
/// <param name="len">数据长度</param>
|
|
|
|
|
|
/// <returns>是否添加成功,1-成功,否则为失败</returns>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyWellGroupAdd", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern int XyWellGroupAdd(IntPtr pXy, string layerName, IntPtr byteBuffer, int len);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据网格 z 值填充曲线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">图件</param>
|
|
|
|
|
|
/// <param name="layerName">要生成的目标图层名</param>
|
|
|
|
|
|
/// <param name="x1">第一个点 x 坐标</param>
|
|
|
|
|
|
/// <param name="y1">第一个点 y 坐标</param>
|
|
|
|
|
|
/// <param name="x2">第二个点 x 坐标</param>
|
|
|
|
|
|
/// <param name="y2">第二个点 y 坐标</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyCreateCurveFillZ", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyCreateCurveFillZ(IntPtr pXy, string layerName, double x1, double y1, double x2, double y2);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存图层内容到另一个图件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">图件对象</param>
|
|
|
|
|
|
/// <param name="filePath">要保存的图件名称</param>
|
|
|
|
|
|
/// <param name="layerName">图层名</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XySaveLayer", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XySaveLayer(IntPtr pXy, string filePath, string layerName);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将图件转为 Dfd 内容的字符串
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pXy">图件对象</param>
|
|
|
|
|
|
/// <returns>Dfd 格式字符串</returns>
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyToDfdString", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr XyToDfdString(IntPtr pXy);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyMergeSymbol", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyMergeSymbol(IntPtr pXy, string filePath);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyCurveMappingRandColor", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool XyCurveMappingRandColor(IntPtr pXy, string layerName, bool includeSubLayer);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XySaveElementsEmbellish", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XySaveElementsEmbellish(IntPtr pXy, string layerName, bool includeSubLayer);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyRestoreElementsEmbellish", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyRestoreElementsEmbellish(IntPtr pXy);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyClearLayerElementsEmbellish", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern void XyClearLayerElementsEmbellish(IntPtr pXy, string layerName, bool includeSubLayer);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "SavePDFFile", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool SavePDFFile(IntPtr pXy, string filePath, int paperType, int cType, int dType,
|
|
|
|
|
|
double left, double right, double top, double bottom, int num);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "MergePDFFiles", CharSet = CharSet.Unicode, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern bool MergePDFFiles([MarshalAs(UnmanagedType.LPArray)] string[] list, int count, string filePath);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyCreateFavorableArea", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern int XyCreateFavorableArea(IntPtr pSourceXy, IntPtr pTargetXy, string layerName, double zMin, double zMax);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(SIGMALIB, EntryPoint = "XyGetElement", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
|
public static extern IntPtr XyGetElement(IntPtr pXy, string filterXml);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|