Cluster

Object Hierarchy | Related C++ Class: Cluster

Inheritance

SIObject

ProjectItem

SceneItem

Cluster

Description

A cluster represents a set of components on a Geometry. For example, the polygons of the left arm of a human model might be grouped together by creating a cluster.

A cluster has a SIObject.Type which corresponds to the component type that it contains, (pnt, knot, poly). A geometry can have multiple clusters, including clusters of different types. Any particular component might be included in multiple clusters. The ClusterTypes that are supported on a geometry depend on the type of object. For example only NurbsSurface or NurbsCurve can have a siKnotCluster.

Clusters can be created on the geometry of a ParticleCloud. These clusters are of type siVertexCluster but they contain Particles.

A cluster that includes all the components of a particular type is said to be "always complete", which you can verify with the Cluster.IsAlwaysComplete method. An always-complete cluster always covers all components of the geometry, even when components are added by a modeling operation; however, notice that a cluster which covers all components of a geometry is not necessarily always-complete. Other clusters may contain a subset of components. In all cases the indices of the components in the cluster do not directly match the indices of the component on the geometry. The mapping between cluster indices and geometry indices is available through Cluster.Elements and Cluster.FindIndices.

Clusters are useful for storing per-component data with a ClusterProperty or UserDataMap. Clusters can also have their own CustomProperty objects. All these properties can be created with SceneItem.AddProperty and enumerated with SceneItem.LocalProperties. Notice that some types of ClusterProperty require the cluster to be always complete.

Warning: Operations that change the geometry, for example adding an edge to a mesh, can result in the cluster growing or shrinking.

Note: As of v5.0, the base property SIObject.Parent called on a Cluster object returns a Primitive instead of an X3DObject.

Methods

AddCustomOp AddCustomProperty AddMaterial AddProperty
AddScriptedOp AddScriptedOpFromFile AnimatedParameters2 ApplyEnvelope
BelongsTo operator CreateSubComponent EvaluateAt FindIndex
FindIndices GetICEAttributeFromName GetLocalPropertyFromName GetPropertyFromName
GetStaticKinematicStates operator HasStaticKinematicState operator IsA IsAlwaysComplete operator
IsAnimated2 IsClassOf operator IsEqualTo operator IsKindOf
IsLocked operator IsSelected operator LockOwners SetAsSelected operator
SetCapabilityFlag operator SetLock SetMaterial TaggedParameters
UnSetLock      
       

Properties

Application BranchFlag operator Capabilities operator Categories
CenterReference Elements operator Envelopes EvaluationID
Families operator FullName operator Help HierarchicalEvaluationID
ICEAttributes LocalProperties LockLevel operator LockMasters operator
LockType operator Material Model Name operator
NestedObjects ObjectID Origin OriginPath
Owners PPGLayout operator Parameters operator Parent
Parent3DObject Properties Selected operator Type operator

Examples

1. VBScript Example

'
'       This example shows how to create many different cluster types.
'       It also shows how to find all clusters in a scene
'
NewScene ,false
set oRoot = Application.ActiveProject.ActiveScene.Root
set grid = oRoot.AddGeometry("Grid","MeshSurface")
set gridGeometry = grid.ActivePrimitive.Geometry
'Only certain types makes sense on a MeshSurface        
'This cluster we will create as a subset of the vertices
gridGeometry.AddCluster siVertexCluster,"PntCluster",Array(1,4,7,10,13,16,19,22)
'The rest we will create as complete clusters
gridGeometry.AddCluster siPolygonCluster,"PolygonC"
gridGeometry.AddCluster siEdgeCluster
gridGeometry.AddCluster siSampledPointCluster
'A different set makes sense with Nurbs
set torus = oRoot.AddGeometry("Torus","NurbsSurface")
set torusGeometry = torus.ActivePrimitive.Geometry
torusGeometry.AddCluster siVertexCluster,"PntCluster"
torusGeometry.AddCluster siSampledPointCluster
torusGeometry.AddCluster siSurfaceCurveCluster 
torusGeometry.AddCluster siKnotCurveUCluster
torusGeometry.AddCluster siKnotCurveVCluster
torusGeometry.AddCluster siBoundaryCluster
torusGeometry.AddCluster siKnotCluster 
torusGeometry.AddCluster siTrimCurveCluster
torusGeometry.AddCluster siIsoLineUCluster 
torusGeometry.AddCluster siIsoLineVCluster
torusGeometry.AddCluster siSubSurfaceCluster
set circle = oRoot.AddGeometry("Circle","NurbsCurve")
set circleGeometry = circle.ActivePrimitive.Geometry
circleGeometry.AddCluster siIsoPointCluster
circleGeometry.AddCluster siVertexCluster,"PntCluster"
circleGeometry.AddCluster siKnotCluster 
set particleCloud = CreateParticleCloud().Item(0)
particleCloud.ActivePrimitive.Geometry.AddCluster siVertexCluster, "MyParticles"
' Now traverse the scene finding all the clusters
logmessage "Clusters in Scene......................"
set oSceneObjs = ActiveSceneRoot.FindChildren()
for each oItem in oSceneObjs
        'Use error handling to skip over the objects that don't
        'support clusters               
        on error resume next    
        set oClusters = oItem.ActivePrimitive.Geometry.Clusters
        if ( err = 0 ) then
                logmessage oItem & " has " & oClusters.Count & " Clusters: "
                for each oCls in oClusters
                        logmessage "    " & oCls & " (type: " & oCls.Type & ")"
                next
        end if  
next
'The output of this script is:
'INFO : "Clusters in Scene......................"
'INFO : "grid has 4 Clusters: "
'INFO : "    grid.polymsh.cls.PntCluster (type: pnt)"
'INFO : "    grid.polymsh.cls.edge.clslist.Edge (type: edge)"
'INFO : "    grid.polymsh.cls.PolygonC (type: poly)"
'INFO : "    grid.polymsh.cls.sample.clslist.Sample (type: sample)"
'INFO : "torus has 11 Clusters: "
'INFO : "    torus.surfmsh.cls.V_Knot_Curve (type: knotcrvv)"
'INFO : "    torus.surfmsh.cls.U_Knot_Curve (type: knotcrvu)"
'INFO : "    torus.surfmsh.cls.sample.clslist.Sample (type: sample)"
'INFO : "    torus.surfmsh.cls.PntCluster (type: pnt)"
'INFO : "    torus.surfmsh.cls.Surface_Curve (type: srfcrv)"
'INFO : "    torus.surfmsh.cls.V_Isoline (type: isolinev)"
'INFO : "    torus.surfmsh.cls.knot.clslist.Knot (type: knot)"
'INFO : "    torus.surfmsh.cls.Boundary (type: bndry)"
'INFO : "    torus.surfmsh.cls.Subsurface (type: subsrf)"
'INFO : "    torus.surfmsh.cls.U_Isoline (type: isolineu)"
'INFO : "    torus.surfmsh.cls.Trim_Curve (type: trimcrv)"
'INFO : "circle has 3 Clusters: "
'INFO : "    circle.crvlist.cls.Isopoint (type: isopnt)"
'INFO : "    circle.crvlist.cls.PntCluster (type: pnt)"
'INFO : "    circle.crvlist.cls.knot.clslist.Knot (type: knot)"
'INFO : "cloud has 1 Clusters: "
'INFO : "    cloud.cloud.cls.MyParticles (type: pnt)"

2. JScript Example

//Step 1: Simulate the user creating a scene and selecting
//some points on a grid
var oGrid = ActiveSceneRoot.AddGeometry( "Grid", "MeshSurface" ) ;
SelectObj( oGrid ) ;
ActivateVertexSelTool();
AddToSelection( oGrid.Name + ".pnt[0-8]", null, true);
//Step 2: Get the selected components using OM
var oSubComponent = Selection(0).SubComponent ;
//Expect that 9 components were selected
logmessage( oSubComponent.ComponentCollection.Count ) ;
//Step 3: it is simple to create a cluster
var oCluster = oSubComponent.CreateCluster() ;
logmessage( oCluster.FullName  ) ;
//Output of this example:
//INFO : "9"
//INFO : "grid.polymsh.cls.Point"

See Also

ClusterProperty Geometry.AddCluster Geometry.Clusters Geometry.SaveShapeKey