TIN サーフェスをスムージングする

サーフェスのスムージングは、自然近隣補間(NNI)またはクリギング法を使用してシステムで決定された標高にポイントを追加します。その結果、等高線が重なることなくスムージングされます。サポートされている 2 つのスムージング メソッドの詳細は、 AutoCAD Civil 3D ユーザ ガイド』 を参照してください。

TinSurface オブジェクトは、SmoothSurfaceByNNI() および SmoothSurfaceByKriging() メソッドを使用して、これら 2 つのスムージング操作を開示します。

次の 2 つのの手順により、スムージング操作を設定します。

  1. SurfacePointOutputOptions オブジェクトを作成します。
  2. (SurfacePointOutputLocationsType によって列挙された)OutputLocations プロパティを設定して、出力場所を指定します。SurfacePointOutputOptions に対して設定する必要があるその他のオプションは、次の設定の指定内容によって異なります。
    1. EdgeMidPoints – サーフェスのエッジを表す Edges プロパティ(TinSurfaceEdge オブジェクトの配列)を指定します。
    2. RandomPoints – ポイント数(RandomPointsNumber)と出力リージョン(OutputRegions、Point3dCollection)を指定します。
    3. CentroidsOutputRegions プロパティを指定します。
    4. GridBasedOutputRegions プロパティ、グリッド間隔(GridSpacingX および GridSpacingY)、グリッド方向(GridOrientation)を設定します。
  3. クリギング法を使用している場合は、KrigingMethodOptions オブジェクトを作成して、このメソッドに次のオプションを設定する必要があります。
    1. SemivariogramModel プロパティ – KrigingSemivariogramType によって列挙されたモデルの 1 つに設定します。
    2. SampleVertices プロパティ – スムージングする頂点のコレクションに設定します(たとえば、TinSurface.GetVerticesInsidePolylines() を使用してこのコレクションを取得できます)。
    3. 選択したモデルに応じて、任意に NuggetEffectVariogramParamAVariogramParamC を設定します。
  4. オプションを SmoothSurfaceByNNI() または SmoothSurfaceByKriging() に渡します。これらのメソッドは、操作に出力ポイント数を含む SurfaceOperationSmooth オブジェクトを返します。

次の例は、Centroids 出力場所を使用した、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); }
    }
}