AlCluster

Encapsulates creation, deletion and manipulation of clusters.

Synopsis

#include <AlCluster.h>
class AlCluster : public AlObject
AlCluster();
virtual ~AlCluster();
virtual statusCode deleteObject();
virtual AlObject* copyWrapper() const;
statusCode create();
AlObjectType type() const;
AlCluster* asClusterPtr();
AlCluster* nextCluster() const;
statusCode nextClusterD();
AlCluster* prevCluster() const;
statusCode prevClusterD();
AlClusterNode* clusterNode() const;
boolean isEmpty() const;
int numberOfMembers() const;
AlClusterMember* firstMember() const;
statusCode applyIteratorToMembers( AlIterator*, int& ) const;
statusCode clusterRestrict( AlClusterRestrict& ) const;
statusCode setClusterRestrict( AlClusterRestrict );
// Obsolete .. moved to AlClusterable, AlClusterMember
statusCode addMember( const AlClusterable*, double = 1.0 );
statusCode removeMember( AlClusterable* );
statusCode removeMember( AlClusterMember* );
AlClusterMember* hasMember( const AlClusterable* ) const;
double percentEffect( AlClusterable* ) const;
statusCode setPercentEffect( AlClusterable*, double );
static statusCode removeFromAllClusters( AlClusterable* );

Description

This class encapsulates the functionality for creating, manipulating and deleting a cluster. A cluster is a group of dag nodes and/or curve and surface control points, which are grouped as such for deformation purposes. Every cluster has a cluster dag node which is in the universe's dag. Adding and removing nodes and control points to and from a cluster does not affect the topology of the universe's dag. Transforming the cluster dag node affects the transformations of the objects in the cluster.

Empty clusters are allowed. An object can be in more than one cluster at a time, provided that those clusters are of type kMultiCluster. When an object is added to a cluster, it is given a weight that indicates how much of the cluster's leaf transformation is applied to the object. The default weight is 100%. If a dag node is added to a cluster the percentages of each individual CV may be manipulated separately without actually adding the CVs themselves to the cluster.

To create a cluster, the user must instantiate and call create on an AlCluster object. This also creates an AlClusterNode which gets attached to the AlCluster and which is inserted into the universe's dag. The user may not instantiate an AlClusterNode or an AlClusterMember directly.

There are two ways to delete a cluster object. When a cluster is deleted, its attached cluster node is deleted. Alternatively, when AlClusterNode::deleteObject() is used, its cluster is deleted. The dag nodes and control points in a cluster are not deleted, however the AlClusterMember objects that represented the "in a cluster" relation are invalidated.

Clusters don't have names. Any attempts to query for a name will return NULL.

Summary

AlCluster::AlCluster()

Description

Constructs an AlCluster wrapper object.

AlCluster::~AlCluster()

Description

Deletes an AlCluster wrapper object.

statusCode AlCluster::deleteObject()

Description

This function is responsible for deleting the associated cluster node and for removing the cluster from the universe. It also invalidates all of the AlClusterMember objects associated with this cluster.

A cluster can be deleted in two ways. If AlCluster::deleteObject() is called, it deletes the associated cluster node. If AlClusterNode::deleteObject() is called, it invalidates the associated AlCluster and AlClusterMembers.

Note that removing all members of a cluster will not destroy it. You must call the cluster deleteObject() to do this.

Return codes

sSuccess - the data for the cluster was successfully deleted.

sInvalidObject - the cluster was not valid

statusCode AlCluster::create()

Description

Creates a cluster and a cluster dag node. The cluster dag node is automatically added to the current universe. The cluster by default is given 'non-exclusive' status - this means that a particular item can be in more than one cluster at a time.

Return codes

sSuccess - if everything was successful

sInsufficientMemory - if not enough memory available

AlObjectType AlCluster::type() const

Description

Returns the class identifier 'kClusterType'.

AlCluster* AlCluster::asClusterPtr()

Description

This virtual function returns a non-null pointer to itself, indicating that it is safe to cast to an object of this class.

AlCluster* AlCluster::nextCluster() const

Description

This function returns a pointer to the cluster following this one in the global cluster list. If this is the last one then NULL is returned.

statusCode AlCluster::nextClusterD()

Description

This function destructively sets the object to point to the next cluster in the global cluster list, if the next cluster can be found. If not, the object is unaffected.

Return codes

sSuccess - the AlCluster was successfully updated.

sInvalidObject - the AlCluster was not valid

sFailure - the method failed.

AlCluster* AlCluster::prevCluster() const

Description

This function returns a pointer to the cluster preceding this one in the global cluster list. If this is the first one then NULL is returned.

statusCode AlCluster::prevClusterD()

Description

This function destructively sets the object to point to the next cluster in the global cluster list, if the next cluster can be found. If not, the object is unaffected.

Return codes

sSuccess - the AlCluster was successfully updated.

sInvalidObject - the AlCluster was not valid

sFailure - the method failed.

AlClusterNode *AlCluster::clusterNode() const

Description

Returns a pointer to the attached (parent) cluster node. The cluster node must exist.

boolean AlCluster::isEmpty() const

Description

Returns TRUE if this cluster is empty (i.e. doesn't have any members). If the call fails, TRUE is returned.

AlClusterMember* AlCluster::firstMember() const

Description

Returns the head of the list of members in this cluster.

int AlCluster::numberOfMembers() const

Description

Returns the number of members in this cluster. Zero is returned if the call fails.

statusCode AlCluster::applyIteratorToMembers( AlIterator* iter, int &rc ) const

Description

Apply the given iterator to each member of this cluster. See the documentation for AlIterator.

Return codes

sSuccess - the iterator completed successfully

sInvalidArgument - the iterator 'iter' was NULL.

sInvalidObject - the cluster was invalid

sFailure - the iterator completed abnormally.

statusCode AlCluster::clusterRestrict( AlClusterRestrict& restrict ) const

Description

Puts the type of the current cluster, kMultiCluster or kExclusiveCluster, into the argument.

Arguments

> restrict - value to return

Return codes

sSuccess - the cluster type was successfully set.

sInvalidObject - the cluster was invalid

sFailure - the cluster type could not be determined

statusCode AlCluster::setClusterRestrict( AlClusterRestrict newRestrict )

Description

Sets the type of the current cluster, kMultiCluster or kExclusiveCluster

Arguments

< newRestrict - new cluster type

Return codes

sSuccess - if everything successful

sInvalidObject - the cluster was not valid

sFailure - if cluster could not take on the given type

sInvalidArgument - the argument was neither kMultiCluster nor kExclusiveCluster

statusCode AlCluster::addMember( const AlClusterable* clustobj,double percentage /* = 1.0 */)

Description

Adds a clusterable object to a cluster. This means that all CV's under this dag are affected by the cluster. The percentage defines how much of the cluster's transformation is applied to the CVs under the dag node. A value of 1.0 means that the object's CVs are affected 100% by the cluster leaf transformations.

The method may fail if unable to create a cluster member object, or if the addition of the object would create a cycle of clusters, or if the object to be added is already in the cluster, or if the object to be added already has an ancestor in the same target cluster.

Arguments

< clustobj - is the object to add to the cluster

< percentage - the extent of the effect of the cluster on the object's CVs.

A value of 1.0 means 100%.

Return codes

sSuccess - if everything was successful

sInvalidArgument - 'clustobj' was NULL.

sFailure - failed for one of the reasons outlined above

sInvalidObject - the cluster was invalid

sInsufficientMemory - if not enough memory

statusCode AlCluster::removeMember( AlClusterable* clustobj )

Description

Removes the object from the cluster.

Arguments

< clustobj - the object to remove from the cluster.

Return codes

sSuccess - if everything successful

sInvalidObject - if the cluster is not valid

sInvalidArgument - clustobj was not valid

statusCode AlCluster::removeMember( AlClusterMember* clusterMember )

Description

Removes the cluster member from the cluster.

Arguments

< clusterMember - is the member to be removed

Return codes

sSuccess - if everything successful

sInvalidObject - if cluster is not valid

sInvalidArgument - clusterMember was not valid

AlClusterMember* AlCluster::hasMember( const AlClusterable* clustobj ) const

Description

Finds the AlClusterMember that corresponds to the relationship between the given object and the cluster object. NULL is returned if the object is not a member of the cluster or the cluster is not valid.

Arguments

< clustobj - is the object to be checked.

double AlCluster::percentEffect( AlClusterable* clustobj ) const

Description

Returns the percentage effect this cluster has on the given object. If the call fails, 0.0 is returned.

Arguments

< clustobj - is the object whose percentage is to be found

statusCode AlCluster::setPercentEffect( AlClusterable* clustobj, double percentage )

Description

Sets the percentage effect this cluster has on all things below the given object

Arguments

< clustobj - is the object whose children are to have their cluster percentage effects set

Return codes

sSuccess - if everything successful

sInvalidArgument - 'clustobj' was NULL.

sFailure - if the percentage effect setting failed

sInvalidObject - the cluster was not valid

statusCode AlCluster::removeFromAllClusters( AlClusterable* clustobj )

Description

Removes this object from all clusters in the universe that it may be in.

Arguments

< clustobj - the object to remove from all clusters

Return codes

sSuccess - the object was successfully removed from all clusters.

sInvalidArgument - the object was not valid.





aliasdocs@aw.sgi.com
Copyright © 1996, Alias|Wavefront, a Silicon Graphics Company. All rights reserved.