ClusterElementCollection

関連する C++クラス:CClusterElementArray

導入

v1.0

詳細

Cluster オブジェクトClusterまたはClusterPropertyオブジェクト上のクラスタエレメントのコレクションです。

このオブジェクトに保存されているデータの用途は、オブジェクトが Cluster または ClusterProperty のどちらに存在するのかにより異なります。

Cluster.Elements(およびEnvelope.Elements)によって戻される ClusterElementCollection は、クラスタ内コンポーネントのインデックスとGeometryのコンポーネントのインデックス間のマッピングを可能にします。たとえば、ポリゴン Cluster のインデックス 10 は、ジオメトリ上の Polygon 45 を参照し、ClusterElementCollection.Item(10)は値 45 を持ちます。このフィールドは読み取り専用です。

特定のジオメトリコンポーネントがクラスタの一部であるかどうかを調べる場合は、この配列内を検索できます。ただし、Cluster.FindIndexを使用する方が便利で効率的です。

一方、ClusterProperty.Elements(またはEnvelope.Weights)によって戻される ClusterElementCollection は、ClusterProperty の実際のデータに対して読み取り/書き込みのアクセス権を与えます。たとえば、Vertex Color プロパティには、各コンポーネントに保存されている RGB 値に対するアクセス権が与えられます。この場合、1D は RGB 値に対応し、サイズ3を持ちます。2D はコンポーネントのインデックスに対応します。値は常にDouble値で表されます。

メソッド

FindIndex      
       

プロパティ

Arrayオペレータ Countオペレータ ItemsByIndexオペレータ  
       

VBScript の例

'

' This example demonstrates how to read and write the values on

' a weight map, using the ClusterElementCollection object.

' It also demonstrates how the indices on the cluster property

' correspond to the indices of the cluster, but that these indices do

' not directly correspond to the indices on the geometry.

NewScene ,false

set oSphere = ActiveSceneRoot.AddGeometry("Sphere","NurbsSurface")

' Create a weight map on a cluster that includes only a subset of the points

set oCluster = oSphere.ActivePrimitive.Geometry.AddCluster( _

	siVertexCluster, "MyFrontPoints", Array( 18,19,20,25,26,27) ) 

CreateWeightMap , oCluster.FullName, "MyWeightMap"

set oWM = oCluster.LocalProperties( "MyWeightMap" )

' Use the ClusterElementCollection.Array to access all the weights in a 

' single 2-dimensional array

ElArray = oWM.Elements.Array

' Set the weight on second item in the cluster, (which is point 19), to 100

ElArray(0,1) = 100

' Set the weight on point 25 to 99

ElArray(0,3) = 99

' Copy our altered array of values back onto the weight map

oWM.Elements.Array = ElArray

' Use ClusterElementCollection.Item to set an individual weight on the 

' Weight Map.  Notice how it is still using an array

'Create a 1 Dimensional array with 1 element	

dim myWeight(0)

myWeight(0) = 10

'Assign the value	

oWM.Elements.Item( 2 ) = myWeight

'Print out the contents	

set oCluster = oWM.Parent	

for i = 0 to oWM.Elements.Count - 1	

	indexOnGeometry = oCluster.Elements.Item(i)	

	logmessage "Weight at " & i & " (pnt" & indexOnGeometry  & _

		") is " & oWM.Elements.Item(i)(0)

next

'Output of running this script is:	

'INFO : "Weight at 0 (pnt18) is 1"

'INFO : "Weight at 1 (pnt19) is 100"

'INFO : "Weight at 2 (pnt20) is 10"

'INFO : "Weight at 3 (pnt25) is 99"

'INFO : "Weight at 4 (pnt26) is 1"

'INFO : "Weight at 5 (pnt27) is 1"

関連項目

Cluster.Elements ClusterProperty.Elements Envelope.Weights