AutoCAD Civil 3D Help: Smoothing a TIN Surface

把一个曲面变平滑


通过using Natural Neighbor Interpolation (NNI) 或 Kriging方法为曲面添加一些由系统决定的高程,可以使曲面变得平滑,使得平滑之后的等高线不存在重叠。关于这两个方法,请参照AutoCAD Civil 3D用户指南(AutoCAD Civil 3D User’s Guide)获取更多信息。

TinSurface对象通过SmoothSurfaceByNNI() and SmoothSurfaceByKriging()方法开放了这两个平滑操作。

通过下列步骤可以设定一个平滑操作:

  1. 创建一个SurfacePointOutputOptions对象。
  2. 设置OutputLocations属性(可以用SurfacePointOutputLocations类型枚举)以指明输出位置。根据情况,你可能需要在SurfacePointOutputOptions设置其他选项:
    1. EdgeMidPoints – 指明Edges属性,它是一个TinSurfaceEdge对象的数组,表示曲面的边缘。
    2. RandomPoints– 指明点的数量(RandomPointsNumber)和输出区域(OutputRegions,是一个Point3d集合。
    3. Centroids– 指明OutputRegions属性
    4. GridBased– 设置OutputRegions 属性、网格间隔 (GridSpacingX and GridSpacingY)和网格朝向(GridOrientation)。
  3. 如果你正在使用Kriging方法,你还需要创建一个KrigingMethodOptions对象用于给该方法设置选项:
    1. SemivariogramModel 属性 – 设置KrigingSemivariogram枚举类型的其中之一。
    2. SampleVertices 属性 – 为平滑对象设置顶点集合 (比如,你可以用 TinSurface.GetVerticesInsidePolylines()方法取得该集合)。
    3. 根据选点的模式,你可能还需要设置NuggetEffect,VariogramParamA and VariogramParamC.
  4. 把选项传递给SmoothSurfaceByNNI() 或SmoothSurfaceByKriging()方法,这两个方法返回一个包含输出点数量的SurfaceOperaionSmooth对象。

下面的例子展示了设置和使用SmoothSurfaceByNNI()方法,采用了几何图心作为输出位置:

[CommandMethod("SmoothTinSurface")]
public void SmoothTinSurface()
{
    using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
    {
        try
        {
            // Select a TIN Surface:     
            ObjectId surfaceId = promptForEntity("Select a TIN surface to smooth\n", typeof(TinSurface));
            TinSurface oSurface = surfaceId.GetObject(OpenMode.ForWrite) as TinSurface;

            // Select a polyline to define the output region:
            ObjectId polylineId = promptForEntity("Select a polyline to define the output region\n", typeof(Polyline));
            Point3dCollection points = new Point3dCollection();
            Polyline polyline = polylineId.GetObject(OpenMode.ForRead) as Polyline;

            // Convert the polyline into a collection of points:
            int count = polyline.NumberOfVertices;
            for (int i = 0; i < count; i++)
            {
                points.Add(polyline.GetPoint3dAt(i));
            }

            // Set the options:
            SurfacePointOutputOptions output = new SurfacePointOutputOptions();
            output.OutputLocations = SurfacePointOutputLocationsType.Centroids;
            output.OutputRegions = new Point3dCollection[] { points };

            SurfaceOperationSmooth op = oSurface.SmoothSurfaceByNNI(output);

            editor.WriteMessage("Output Points: {0}\n", op.OutPutPoints.Count);

            // Commit the transaction
            ts.Commit();
        }
        catch (System.Exception e) { editor.WriteMessage(e.Message); }
    }
}

父主题:

使用三角网曲面

results matching ""

    No results matching ""