C:\Program Files (x86)\Autodesk\Help\softimage2014\en_us\sdkguide\index.html

you want CClusterElementArray.FindIndex()

Clusters are metadata of the geometry.  The elements in a cluster are the 
indices in a lookup table that maps the cluster to the geometry.  You must 
get the indices from the cluster, then look them up in the lookup table 
using CClusterElementArray.FindIndex() (or another equivalent method 
available elsewhere in the SDK).  The returned value is the index of the 
subcomponent as seen on the geometry.

If the cluster is complete, then the indices in the cluster usually map 1:1 
to the geometry indices, but that is not a guarantee.  Why?  Because the 
geometry's construction history may have live topology operators 
adding/removing components.  As long as those operators are live, they'll 
reserve the subcomponent indices they point to even if they are deleted. 
Once the operators are frozen or deleted, the topology is updated and the 
geometry indices are re-ordered to account for the additions/removals caused 
by the operators.  The cluster index lookup table is then updated so the 
indices in the cluster map to the proper geometry subcomponent indices. 
Think of a cluster as an associative array.  The cluster element index is 
the key, the mapped subcomponent index returned is the value.  e.g.

    GeometrySubComponentIndex = ClusterElementArray.FindIndex( 
clusterElementIndex );

Example:

if a complete polygon cluster is created on a polygon mesh cube, the cluster 
element list will have 6 entries numbered 0-5.  If you request index 3, 
you'll get a returned value of 3.  Now delete polygon 3 and you'll notice 
polygons 4 and 5 hold their respective indices, and will continue to do so 
as long as the delete component operator remains in the construction 
history.  The moment you freeze construction history, polygons 4 and 5 will 
slide down to fill the void created by the deletion of polygon 3, and will 
then be renumbered as polygon indices 3 and 4 to keep the list of 
subcomponent indices contiguous.  polygon index 5 will no longer exist.  The 
ClusterElementArray indices, however, will always be numbered 0...N-1, where 
N is the number of elements in the cluster.

The cluster element list lookup table is really important if the cluster is 
not complete (usually the case for point, edge, and polygon clusters).  If 
you simply grab the indices contained in the cluster, you'll get incorrect 
results as those indices are the indices of the cluster lookup table, not 
the geometry subcomponent indices they represent.  That is why you use 
ClusterElementArray.FindIndex().


Matt


Date: Sat, 2 Sep 2017 09:40:19 +0300
From: Andrew Prostrelov <[email protected]>
To: "Official Softimage Users Mailing List.
https://groups.google.com/forum/#!forum/xsi_list";

    Ok. Today question is about Clusters in C++.
    I'm trying to get actualized geometry elements from cluster.
    And i thought that i can get it this way
        for (LONG i = 0; i < curClusters.GetCount(); i++)
        {
            CRef curref; curref.Set(curClusters[i]);
            Application().LogMessage(L"CollectClusterComps::curClusters[i]:
" + curClusters[i] );
            Cluster cur_cls(curref);
            if (cur_cls.IsValid())
            {
                CLongArray prev_comps = cur_cls.GetElements().GetArray();
                Application().LogMessage(L"CollectClusterComps::prev_comps:
" + prev_comps.GetAsText() );
            }
        }
    But this way i get wrong components ids.
    So. I guess if i can literally see right components indices

    [image: ?????????? ??????????? 1]

    there should be a way to get it without changing current selection
(Cluster.SelectMembers() commands etc).


------
Softimage Mailing List.
To unsubscribe, send a mail to [email protected] with 
"unsubscribe" in the subject, and reply to confirm.

Reply via email to