首页 / 浏览问题 / 组件GIS / 问题详情
hollowTIN地形挖洞为什么没有效果,桌面端是有效果的
3EXP 2023年11月14日
// 获取地形TIN缓存位置 var tinSctPath = "E:\\原TIN地形\\DEM@anqing.sct"; if (datasource != null) { // 获取三维面数据集 DatasetVector dataset2 = (DatasetVector)datasource.Datasets["slope"]; dataset2.Open(); // 将 DatasetVector 转换为 Recordset Recordset rdRegion = dataset2.GetRecordset(false, CursorType.Dynamic); // 获取要素的几何对象 Geometry geometry = rdRegion.GetGeometry(); // 创建一个 List 来存储 Geometry 对象 List geometryList = new List(); geometryList.Add(geometry); // 尝试进行挖洞(镂空) if (CacheProcessor3D.HollowTIN(tinSctPath, geometryList, ClippingType.KeepOutside, ConstraintType.SoftConstraint)) { Console.WriteLine($"===================,隧道挖洞成功!!!"); } } else { Console.WriteLine("Datasource is null!"); }

1个回答

您好,我这边验证该接口是没有问题的。

再次检查了一下您的代码,可能是由于您的geometry为空导致的,您需要先指针定位到recordset的具体记录集,然后再转成geometry才可以。

具体操作如下:需要先recordset.MoveFirst()移动当前记录位置到第一条记录,或recorset.MoveTo()移动当前记录位置到指定的位置,然后再recorset.GetGeometry()获取到几何对象。

希望可以帮助到您!
2,513EXP 2023年11月15日
// 获取地形TIN缓存位置
var tinSctPath = "E:\\TIN地形缓存\\原TIN地形\\DEM@anqing.sct";

if (datasource != null)
{
    // 获取三维面数据集
    DatasetVector dataset2 = (DatasetVector)datasource.Datasets["slope"];

    // 将 DatasetVector 转换为 Recordset,CursorType.Static:使用静态游标
    Recordset rdRegion = dataset2.GetRecordset(false, CursorType.Static);
    List<Geometry> geometryList = new List<Geometry>();
    while (!rdRegion.IsEOF)
    {
        Geometry geometry = rdRegion.GetGeometry();
        geometryList.Add(geometry);
        // 获取要素的几何对象
        rdRegion.MoveNext();
    }
    var outputSct= "C:\\Users\\BruceGuo\\Desktop\\新建文件夹";
    var outputSctName = "newTin";

    // 尝试进行挖洞(裁剪用ClipTIN还是HollowTIN?)
    if (CacheProcessor3D.ClipTIN(tinSctPath, geometryList, outputSct, outputSctName, ClippingType.KeepOutside, ConstraintType.SoftConstraint))
    {
        Console.WriteLine($"===================,隧道挖洞成功!!!");
    }
}
else
{
    Console.WriteLine("Datasource is null!");
}            

这是改了之后的代码,没有报错,但是没有效果呢,请问是什么问题呢

您好,看您的外码中,使用的是保留裁剪外:ClippingType.KeepOutside,实现保留裁剪外的效果,建议您使用挖洞HollowTIN。
...