class MItGeometry

Jump to documentation

Iterator class for geometry data. (OpenMaya) (OpenMaya.py)

public members:

MItGeometry ( const MDagPath & dagPath, MStatus * ReturnStatus = NULL)
MItGeometry ( const MDagPath & dagPath, MObject & component , MStatus * ReturnStatus = NULL )
MItGeometry ( MObject & dagObject, MStatus * ReturnStatus = NULL )
MItGeometry ( MDataHandle & dataHandle, unsigned int groupId, bool readOnly = true, MStatus * ReturnStatus = NULL )
MItGeometry ( MDataHandle & dataHandle, bool readOnly = true, MStatus * ReturnStatus = NULL )
virtual ~MItGeometry ()
bool isDone ( MStatus * ReturnStatus = NULL ) const
MStatus next ()
MPoint position ( MSpace::Space space = MSpace::kObject , MStatus * ReturnStatus = NULL ) const
MStatus setPosition ( const MPoint & point, MSpace::Space space = MSpace::kObject )
int index ( MStatus * ReturnStatus = NULL ) const
MObject component ( MStatus * ReturnStatus = NULL ) const
OBSOLETE
MObject currentItem ( MStatus * ReturnStatus = NULL ) const
int count ( MStatus * ReturnStatus = NULL ) const
MStatus reset ( )

Documentation

Iterate over points/CV's/vertices of a geometry shape such as a mesh, nurbs surface, nurbs curve, subdivision surface or lattice.
Description

This class is the iterator class for geometry data, and can be used to loop over the CVs of NURBS, the points of subds & lattices, and the vertices of polygonal meshes.

Example: (of a simple traversal)

    MItGeometry iter( dagPath );
    for ( ; !iter.isDone(); iter.next() )
    {								
        MPoint pt = iter.position();
									
        // do something with it
    }						

Example: (of a traversal of a geometry group within a compute() method.)

    MStatus
    exampleIterator::compute(const MPlug& plug, MDataBlock& dataBlock)
    {
        MStatus status;
	
        if (plug.attribute() == oOutputGeometry) {
            // get the input geometry and input groupId
            MDataHandle hInputGeom = dataBlock.inputValue(inputGeomAttr);
            MDataHandle hGroupId = dataBlock.inputValue(inputGroupIdAttr);

            unsigned int groupId = hGroup.asLong();
            MDataHandle hOutput = dataBlock.outputValue(plug);
            hOutput.copy(hInputGeom);

            // do an iteration where we get each point and set it to a new value
            MItGeometry iter(hOutput,groupId,false);
            for ( ; !iter.isDone(); iter.next()) {
                MPoint pt = iter.position();

                // do something here to modify the point ... 

                iter.setPosition(pt);
            }
        } else {
            status = MS::kUnknownParameter;
        }        

        return status;
    }

Functions

MItGeometry:: MItGeometry ( const MDagPath & dagPath, MStatus * ReturnStatus )

Description

Constructor.
This constructor is used to iterate over all of the points/CV/vertices of a dag object given a particular dag path.

Arguments

  • dagPath The dag path to the object.
  • ReturnStatus Status code

Status Codes

  • MS::kSuccess The iterator was constructed successfully.
  • MS::kInsufficientMemory No memory available.
  • MS::kInvalidParameter An invalid object was given.

MItGeometry:: MItGeometry ( const MDagPath & dagPath, MObject & component , MStatus * ReturnStatus )

Description

Constructor.
This constructor is used to iterate over the points/CVs/vertices of a dag object given a particular dag path. The iteration will be over the points/CVs/Vertices specified by the component argument. If the component is null then the iteration will be over the entire object.

Arguments

  • dagPath The dag path to the object.
  • component The components of the object to iterate over. If this is null then the iteration will be over all components of the object.
  • ReturnStatus Status code

Status Codes

  • MS::kSuccess The iterator was constructed successfully.
  • MS::kInsufficientMemory No memory available.
  • MS::kInvalidParameter An invalid object was given.

MItGeometry:: MItGeometry ( MObject & dagObject, MStatus * ReturnStatus )

Description

Constructor.
This constructor is used to iterate over all of the points/CV/vertices of the given dag object. Since there is no path information passed into this constructor world space operations will not be possible.

Arguments

  • dagObject The DAG object to iterate.
  • ReturnStatus Status code

Status Codes

  • MS::kSuccess The iterator was constructed successfully.
  • MS::kInsufficientMemory No memory available.
  • MS::kInvalidParameter An invalid object was given.

MItGeometry:: MItGeometry ( MDataHandle & dataHandle, bool readOnly , MStatus * ReturnStatus )

Description

Constructor.
This constructor is used when iterating from within the compute() method of a node. The point/CV/vertex components of the geometry data pointed to by the dataHandle will be iterated. If readOnly mode is set to false, the setPosition method can be utilized.

Arguments

  • dataHandle The dataHandle pointing to the geometry data.
  • readOnly If false you will be allowed to modify the geometry position data during the iteration.
  • ReturnStatus Status code

Status Codes

  • MS::kSuccess The iterator was constructed successfully.
  • MS::kInsufficientMemory No memory available.
  • MS::kInvalidParameter An invalid object was given.

MItGeometry:: MItGeometry ( MDataHandle & dataHandle, unsigned int groupId, bool readOnly , MStatus * ReturnStatus )

Description

Constructor.
This constructor is used when iterating from within the compute() method of a node. The point/CV/vertex components of the specified group within the geometry data that is pointed to by the dataHandle will be iterated. If readOnly mode is set to false, the setPosition method can be utilized.

Arguments

  • dataHandle The dataHandle pointing to the geometry data.
  • groupId The id of the group whose components will be iterated.
  • readOnly If false you will be allowed to modify the geometry position data during the iteration.
  • ReturnStatus Status code

Status Codes

  • MS::kSuccess The iterator was constructed successfully.
  • MS::kInsufficientMemory No memory available.
  • MS::kInvalidParameter An invalid object was given.

MItGeometry:: ~MItGeometry ()

Description

Class destructor.
Deallocates memory used by this iterator.

bool MItGeometry:: isDone ( MStatus * ReturnStatus ) const

Description

Returns true if the iteration is finished, i.e. there are no more components to iterate on.

Arguments

  • ReturnStatus Status code

Return Value

  • true There are no more components to iterate on.
  • false There are more components in the iteration.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MStatus MItGeometry:: next ()

Description

Advance to the next component in the iteration. If the iterator is already at the last component then this method has no effect. Use isDone to determine if the iterator is at the last component.

Arguments

  • ReturnStatus Status code

Return Value

  • Status code

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MPoint MItGeometry:: position ( MSpace::Space space, MStatus * ReturnStatus ) const

Description

Return the position of the current point/CV/vertex component.

Arguments

  • space The transformation space in which the operation is done
  • ReturnStatus Status code

Return Value

  • Status code

Status Codes

  • MS::kSuccess The position of the current component was returned.
  • MS::kInvalidParameter Cannot do world space transform.
  • MS::kFailure An Object error has occurred.

MStatus MItGeometry:: setPosition ( const MPoint & pt, MSpace::Space space )

Description

Set the position of the current point/CV/vertex.

Arguments

  • space The transformation space in which the operation is done
  • ReturnStatus Status code

Return Value

  • Status code

Status Codes

  • MS::kSuccess The transformation was successful.
  • MS::kInvalidParameter Cannot do world space transform.
  • MS::kFailure The transformation was not successful because the data was read only.

int MItGeometry:: index ( MStatus * ReturnStatus ) const

Description

This method returns the index of the current point/CV/vertex component in the iteration.

Arguments

  • ReturnStatus Status code

Return Value

  • The index of the current point/CV/vertex.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MObject MItGeometry:: component ( MStatus *ReturnStatus) const

Description

This method is OBSOLETE, please use the currentItem method.

This method returns the current component in the iteration.

Arguments

  • ReturnStatus Status code

Return Value

  • The current component in the iteration.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MObject MItGeometry:: currentItem ( MStatus *ReturnStatus) const

Description

This method returns the current component in the iteration.

Arguments

  • ReturnStatus Status code

Return Value

  • The current component in the iteration.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

int MItGeometry:: count ( MStatus * ReturnStatus ) const

Description

Return the number of items in this iteration.

Arguments

  • ReturnStatus Status code

Return Value

  • The number of items that will be iterated

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MStatus MItGeometry:: reset ( )

Description

Reset the iterator to the first component.

Return Value

  • Status code

Status Codes

  • MS::kSuccess The iterator was successfully reset
  • MS::kFailure Error resetting iterator

This class has no child classes.


Autodesk® Maya® 2008 © 1997-2007 Autodesk, Inc. All rights reserved. doc++ Copyright