流域解析を作成する

流域解析は、サーフェスの水の流れを予測します。流域解析は、AeccSurface.SurfaceAnalysis.WatershedAnalysis プロパティに保持される AeccSurfaceAnalysisWatershed 型のオブジェクトを使用して管理します。 流域解析を作成するには、AeccSurfaceAnalysisWatershed.CalculateWatersheds メソッドを呼び出します。 これにより、サーフェスが個別のリージョンに分割され、それぞれのリージョンは独自の流水方向ターゲットを持ちます。これらすべてのリージョンのセットは、AeccSurfaceAnalysisWatershed.WatershedRegions コレクションに保持されます。

リージョンの分割方法を制御することができます。ブール演算の AeccSurfaceAnalysisWatershed.MergeAdjacentBoundaries プロパティを True に設定した場合、境界に沿ったリージョンは、それらの境界ポイントまたはセグメントが接している場合は 1 つのリージョンに統合されます。サーフェス上のくぼ地の最小平均深度が AeccSurfaceAnalysisWatershed.MergeDepression プロパティの値より小さい場合、そのくぼ地はリージョンにならず、流れ込む流域に結合されます。

oSurface.SurfaceAnalysis.WatershedAnalysis _
  .MergeAdjacentBoundaries = True
oSurface.SurfaceAnalysis.WatershedAnalysis _
  .MergeDepression = 10.65

流域リージョンのタイプ

流水方向ターゲットの性質に応じて、各流域リージョンは AeccWatershedRegion から派生した異なるタイプになります。流域リージョンのタイプの詳細は、「流域のタイプ」( AutoCAD Civil 3D ユーザ ガイド』)を参照してくださいAeccSurfaceAnalysisWatershed.WatershedRegions コレクション内の各オブジェクトの Type プロパティをチェックすることで、各リージョンのタイプを調べることができます。

' Compute water drainage over the surface.
oSurface.SurfaceAnalysis.WatershedAnalysis _
  .CalculateWatersheds
 
' Extract information from each watershed region. 
' Loop through all the regions in the WatershedRegions
' collection. For each region, determine its
' specific type. Once we cast each region object to this 
' specific type, we can learn how water drains over the
' surface.
Dim oWSAnalysis As AeccWatershedRegions
Set oWSAnalysis = oSurface.SurfaceAnalysis.WatershedAnalysis _
  .WatershedRegions
 
Dim i as Integer
For i = 0 To oWSAnalysis.Count - 1
   Select Case (oWSAnalysis.Item(i).Type)
   Case aeccWatershedBoundaryPoint
      Dim oWSPoint As AeccWatershedRegionBoundaryPoint
      Set oWSPoint = oWSAnalysis.Item(i)
 
   Case aeccWatershedBoundarySegment
      Dim oWSSegment As AeccWatershedRegionBoundarySegment
      Set oWSSegment = oWSAnalysis.Item(i)
 
   Case aeccWatershedDepression
      Dim oWSDepression As AeccWatershedRegionDepression
      Set oWSDepression = oWSAnalysis.Item(i)
 
   Case aeccWatershedFlat
      Dim oWSFlat As AeccWatershedRegionFlat
      Set oWSFlat = oWSAnalysis.Item(i)
 
   Case aeccWatershedMultiDrain
      Dim oWSMulti As AeccWatershedRegionMultiRegionDrain
      Set oWSMulti = oWSAnalysis.Item(i)
 
   Case aeccWatershedMultiDrainNotch
      Dim oWSNotch As AeccWatershedRegionMultiRegionDrainNotch
      Set oWSNotch = oWSAnalysis.Item(i)
   Case Else 'aeccWatershedUnknownSink
 
   End Select
Next i

AeccWatershedRegion から派生した操作するは、他の共通フィーチャを備えています。 これらはすべて、AeccWatershedRegion.Id プロパティに ID 番号を持ちます。 また、AeccWatershedRegion.Boundary プロパティも備えています。このプロパティには、リージョンを囲む閉じたポリゴンのポイントを含む 2 次元配列が格納されます。

Dim vBound As Variant
vBound = oWSAnalysis.Item(i).BoundaryLine
For j = 0 To UBound(vBound)
   ' Print the X, Y and Z coordinates of a border point.
   Debug.Print vBound(j, 0), vBound(j, 1), vBound(j, 2)
Next j

境界ポイント リージョン

AeccWatershedBoundaryPoint 型のリージョンでは、流水は 1 つのポイントでサーフェスの境界に到達します。 このポイントの X、Y、Z 座標は、AeccWatershedBoundaryPoint.BoundaryDrainPoint プロパティの可変配列に保持されます。

Dim oWSPoint As AeccWatershedRegionBoundaryPoint
Set oWSPoint = oWSAnalysis.Item(i)
Dim vDrainPoint As Variant
vDrainPoint = oWSPoint.BoundaryDrainPoint
Debug.Print "This region drains to point: " & vDrainPoint(0) _
  & ", " & vDrainPoint(1) & ", " & vDrainPoint(2)

境界セグメント リージョン

aeccWatershedBoundarySegment 型のリージョンは、サーフェスから一連の線分セグメントに沿って流水する領域を表します。 これらの線分セグメントの終点は、aeccWatershedBoundarySegment.BoundaryDrainSegment プロパティの倍精度 2 次元配列に格納されます。 この配列の最初の次元は各ポイントを表し、2 番目の次元はポイントの X、Y、Z 座標を表します。

Dim oWSSegment As AeccWatershedRegionBoundarySegment
Set oWSBoundarySegment = oWSAnalysis.Item(i)
Dim vDrainSegments as Variant
vDrainSegments = oWSBoundarySegment.BoundaryDrainSegment
 
Dim j as Integer
Debug.Print "This region drains through the following"
Debug.Print "line segments:"
For j = 0 To UBound(vDrainSegments, 1) - 1
   Debug.Print vDrainSegments(j, 0) & ", " _
     & vDrainSegments(j, 1) & ", " _
     & vDrainSegments(j, 2) & "  to  ";
   Debug.Print vDrainSegments(j + 1, 0) & ", " _
     & vDrainSegments(j + 1, 1) _
     & ", " & vDrainSegments(j + 1, 2)
Next j

くぼ地リージョン

aeccWatershedDepression 型のリージョンは、水が通常流れないサーフェス領域です。 くぼ地に盛土を行って、他のリージョンに水を流すことができます。水があふれるリージョン エッジの最も低いポイントと流水先のリージョンは、aeccWatershedDepression.Drains コレクションに保持されます。

Dim oWSDepression As AeccWatershedRegionDepression
Set oWSDepression = oWSAnalysis.Item(i)
Dim oDrains As AeccWatershedDrains
Set oDrains = oWSDepression.Drains
 
For j = 0 To oDrains.Count - 1
   ' See what kind of drain targets we have.
   If (UBound(oDrains.Item(j).Targets) = -1) Then
      ' This depression drains outside the surface.
      Debug.Print "Drain through point: " & _ 
        oDrains.Item(j).Location(0) & ", " & _
        oDrains.Item(j).Location(1) & ", " & _
      oDrains.Item(j).Location(2) & _
        " to the surface boundary."
   Else
      ' This depression can drain into other regions.
      Dim lTargets() As Long
      lTargets = oDrains.Item(j).Targets
      sTargets = CStr(lTargets(0))
      Dim k as Integer
      For k = 1 To UBound(lTargets)
         sTargets = sTargets & ", " & CStr(lTargets(k))
      Next k
      Debug.Print "Drain through point: " & _ 
        oDrains.Item(j).Location(0) & ", " & _
        oDrains.Item(j).Location(1) & ", " & _
        oDrains.Item(j).Location(2) & _
        " into the following regions: " & sTargets
   Endif
Next j

平面リージョン

1 つのリージョンにだけ流水する平面領域は、そのリージョンと結合されます。ある平面から複数のリージョンに流水する場合、その平面は AeccWatershedRegionFlat 型の独立したリージョンとして作成されます。その平面リージョンのフィーチャは、流水方向ターゲットの配列だけです。

Dim oWSFlat As AeccWatershedRegionFlat
Set oWSFlat = oWSAnalysis.Item(i)
 
varDrainsInto = oWSFlat.DrainsInto
sTargets = CStr(varDrainsInto(0))
For k = 1 To UBound(varDrainsInto)
   sTargets = sTargets & ", " & CStr(varDrainsInto(k))
Next k
Debug.Print "This region drains into regions " & sTargets

複合流水リージョン(ポイント)

サーフェスのリージョンは、1 つのポイントを通じて複数の異なるリージョンに流水する場合があります。このようなリージョンは、AeccWatershedRegionMultiRegionDrain 型のオブジェクトによって表されます。これらのリージョンは、水が流れるポイントと流水先のすべてのリージョンのコレクションを格納したプロパティを持ちます。

Dim oWSMulti As AeccWatershedRegionMultiRegionDrain
Set oWSMulti = oWSAnalysis.Item(i)
 
' vDrainPoint is a single point, like BoundaryPoint
vDrainPoint = oWSMulti.DrainPoint
' varDrainsInto is an array of variants, each a region ID.
varDrainsInto = oWSMulti.DrainsInto
sTargets = CStr(varDrainsInto(0))
For k = 1 To UBound(varDrainsInto)
   sTargets = sTargets & ", " & CStr(varDrainsInto(k))
Next k
 
Debug.Print "This region drains to point: " & vDrainPoint(0) _
  & ", " & vDrainPoint(1) & ", " & vDrainPoint(2) _
  & " and into the following regions: " & sTargets

複合流水リージョン(水流)

リージョンは、一連の線分セグメントを通じて他の複数のリージョンに流水する場合があります。このようなリージョンは AeccWatershedRegionMultiRegionDrainNotch 型のオブジェクトによって表され、そのリージョンのすべての流水先リージョンのリストと、そのリージョンから流水するすべてのセグメントのリストを保持します。

Dim oWSNotch As AeccWatershedRegionMultiRegionDrainNotch
Set oWSNotch = oWSAnalysis.Item(i)
' vDrainSegments is a 2-dimensional array, like BoundarySegment.
Dim vDrainSegments As Variant
vDrainSegments = oWSNotch.DrainSegment
' varDrainsInto is an array of region IDs.
Dim varDrainsInto As Variant
varDrainsInto = oWSNotch.DrainsInto
 
sTargets = CStr(varDrainsInto(0))
For k = 1 To UBound(varDrainsInto)
   sTargets = sTargets & ", " & CStr(varDrainsInto(k))
Next k
Debug.Print "This region drains through these segments: "
For j = 0 To UBound(vDrainSegments, 1) - 1
   Debug.Print vDrainSegments(j, 0) & ", " _
     & vDrainSegments(j, 1) & ", " _
     & vDrainSegments(j, 2) & "  to      ";
   Debug.Print vDrainSegments(j + 1, 0) & ", " _
     & vDrainSegments(j + 1, 1) _
     & ", " & vDrainSegments(j + 1, 2)
Next j
 
' Display each region this drains into.
Debug.Print "and into the following regions: " & sTargets