MItMeshVertex Class Reference

#include <MItMeshVertex.h>

Class Description

Polygon vertex iterator.

This class is the iterator for polygonal vertices.

The iterator functions in two modes depending on whether a component is specified. When a component is not given or is NULL the iteration will be over all vertices for the polygon. When a component is given this iterator will iterate over the vertices specified in the component. When iterating over components a DAG path to the surface must also be supplied.

+ Examples:

Public Member Functions

 MItMeshVertex (MObject &polyObject, MStatus *ReturnStatus=NULL)
 Constructor. More...
 
 MItMeshVertex (const MDagPath &polyObject, MObject &component=MObject::kNullObj, MStatus *ReturnStatus=NULL)
 Constructor. More...
 
virtual ~MItMeshVertex ()
 Destructor. More...
 
bool isDone (MStatus *ReturnStatus=NULL)
 Indicates if all of the vertices have been traversed yet. More...
 
MStatus next ()
 Advance to the next vertex in the iteration. More...
 
MStatus reset ()
 Reset the iterator to the first vertex. More...
 
MStatus reset (MObject &polyObject)
 Reset the iterator to the first vertex in the supplied polygon. More...
 
MStatus reset (const MDagPath &polyObject, MObject &component=MObject::kNullObj)
 Reset the iterator with the given polygon and component. More...
 
int count (MStatus *ReturnStatus=NULL)
 Return the number of vertices in the iteration. More...
 
int index (MStatus *ReturnStatus=NULL)
 Returns the index of the current vertex in the vertex list for this polygonal object. More...
 
MObject vertex (MStatus *ReturnStatus=NULL)
 This method is obsolete. More...
 
MObject currentItem (MStatus *ReturnStatus=NULL)
 Get the current vertex in the iteration as a component. More...
 
MPoint position (MSpace::Space space=MSpace::kObject, MStatus *ReturnStatus=NULL)
 Return the position of the current vertex in the specified space. More...
 
MStatus setPosition (const MPoint &point, MSpace::Space space=MSpace::kObject)
 Set the position of the current vertex in the given space. More...
 
MStatus translateBy (const MVector &vector, MSpace::Space space=MSpace::kObject)
 Translate the current vertex by the amount specified by the given vector. More...
 
MStatus getNormal (MVector &vector, MSpace::Space space=MSpace::kObject)
 Return the normal or averaged normal if unshared of the current vertex. More...
 
MStatus getNormal (MVector &vector, int faceIndex, MSpace::Space space=MSpace::kObject)
 Return the normal of the current vertex in the specified face. More...
 
MStatus getNormals (MVectorArray &vectorArray, MSpace::Space space=MSpace::kObject)
 Return the normals of the current vertex for all faces. More...
 
MStatus getNormalIndices (MIntArray &normalIndices) const
 This method returns the normal indices of the face/vertex associated with the current vertex. More...
 
MStatus numUVs (int &count, const MString *uvSet=NULL)
 This method returns the number of unique UVs mapped on this vertex. More...
 
MStatus setUV (float2 &uvPoint, const MString *uvSet=NULL)
 Set the shared UV value at this vertex. More...
 
MStatus getUV (float2 &uvPoint, const MString *uvSet=NULL)
 Get the shared UV value at this vertex. More...
 
MStatus setUV (int faceId, float2 &uvPoint, const MString *uvSet=NULL)
 Set the UV value for the given face at the current vertex. More...
 
MStatus getUV (int faceId, float2 &uvPoint, const MString *uvSet=NULL) const
 Get the UV value for the give facen at the current vertex. More...
 
MStatus setUVs (MFloatArray &uArray, MFloatArray &vArray, MIntArray &faceIds, const MString *uvSet=NULL)
 Set the UV value for the specified faces at the current vertex. More...
 
MStatus getUVs (MFloatArray &uArray, MFloatArray &vArray, MIntArray &faceIds, const MString *uvSet=NULL) const
 Get the UV values for all mapped faces at the current vertex. More...
 
MStatus getUVIndices (MIntArray &uvIndices, const MString *uvSet=NULL) const
 This method returns the uv indices into the normal array see MFnMesh::getUVs() of the current vertex. More...
 
MStatus updateSurface ()
 Signal that this polygonal surface has changed and needs to redraw itself. More...
 
MStatus geomChanged ()
 Reset the geom pointer in the MItMeshVertex. More...
 
MStatus setIndex (int index, int &prevIndex)
 This method sets the index of the current vertex to be accessed. More...
 
MStatus getConnectedFaces (MIntArray &faceList)
 This method gets the indices of the faces connected to the current vertex. More...
 
MStatus getConnectedEdges (MIntArray &edgeList)
 This method gets the indices of the edges connected to the current vertex. More...
 
MStatus getConnectedVertices (MIntArray &vertexList)
 This method gets the indices of the vertices surrounding the current vertex. More...
 
MStatus numConnectedFaces (int &faceCount) const
 This Method checks for the number of Connected Faces. More...
 
MStatus numConnectedEdges (int &edgeCount) const
 This Method checks for the number of connected Edges on this vertex. More...
 
bool connectedToFace (int faceIndex, MStatus *ReturnStatus=NULL)
 This method determines whether the given face contains the current vertex. More...
 
bool connectedToEdge (int edgeIndex, MStatus *ReturnStatus=NULL)
 This method determines whether the given edge contains the current vertex. More...
 
MStatus getOppositeVertex (int &vertexId, int edgeId)
 This gets the other vertex of the given edge. More...
 
bool onBoundary (MStatus *ReturnStatus=NULL)
 This method determines whether the current vertex is on a Boundary. More...
 
bool hasColor (MStatus *ReturnStatus=NULL) const
 This method determines whether the current Vertex has a color set for one or more faces. More...
 
bool hasColor (int faceIndex, MStatus *ReturnStatus=NULL) const
 This method determines whether the given face has a color set for the current vertex. More...
 
MStatus getColor (MColor &color, int faceIndex, const MString *colorSetName=NULL) const
 This method gets the color of the current vertex in the specified face. More...
 
MStatus getColor (MColor &color, const MString *colorSetName=NULL) const
 This method gets the average color of the vertex. More...
 
MStatus getColors (MColorArray &colors, const MString *colorSetName=NULL) const
 This method gets the colors of the current vertex for each face it belongs to. More...
 
MStatus getColorIndices (MIntArray &colorIndex, const MString *colorSetName=NULL) const
 This method returns the colorIndices into the color array see MFnMesh::getColors() of the current vertex. More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 

Constructor & Destructor Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN MItMeshVertex ( MObject polyObject,
MStatus ReturnStatus = NULL 
)

Constructor.

Creates an iterator for all vertices of the given surface.

Parameters
[in]polyObjectThe surface to iterate over
[out]ReturnStatusStatus code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MItMeshVertex ( const MDagPath polyObject,
MObject component = MObject::kNullObj,
MStatus ReturnStatus = NULL 
)

Constructor.

Creates an iterator for the vertices of the given component. If no component is specified then the iteration will be for all vertices of the given polygon.

Parameters
[in]polyObjectThe surface to iterate over
[in]componentThe vertices of the polyObject to iterate over
[out]ReturnStatusStatus code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
~MItMeshVertex ( )
virtual

Destructor.

Frees up storage used by the iterator.

Member Function Documentation

bool isDone ( MStatus ReturnStatus = NULL)

Indicates if all of the vertices have been traversed yet.

Parameters
[out]ReturnStatusStatus code
Returns
Boolean value: true if all vertices have been traversed, false otherwise.
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
+ Examples:
MStatus next ( )

Advance to the next vertex in the iteration.

Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MStatus reset ( )

Reset the iterator to the first vertex.

Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MStatus reset ( MObject polyObject)

Reset the iterator to the first vertex in the supplied polygon.

Parameters
[in]polyObjectThe polygon for the iteration
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MStatus reset ( const MDagPath polyObject,
MObject component = MObject::kNullObj 
)

Reset the iterator with the given polygon and component.

If component is null then the iteration will be for all vertices in the given polygon.

Parameters
[in]polyObjectThe surface to iterate over
[in]componentThe vertices of the polyObject to iterate over
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
int count ( MStatus ReturnStatus = NULL)

Return the number of vertices in the iteration.

Parameters
[out]ReturnStatusStatus code
Returns
The number of vertices in the iteration
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
int index ( MStatus ReturnStatus = NULL)

Returns the index of the current vertex in the vertex list for this polygonal object.

Polygonal objects contain a list of vertices. Faces and edges are specified as indicies from this list, in this way vertices can be shared amoung faces and edges.

Parameters
[out]ReturnStatusStatus code
Returns
The index in the vertex list for the current vertex
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MObject vertex ( MStatus ReturnStatus = NULL)

This method is obsolete.

Deprecated:
Use the MItMeshVertex::currentItem method.

Get the current vertex in the iteration as a component.

Components are used to specify one or more vertices and are usefull in operating on groups of non-contiguous vertices for a surface. Components do not contain any information about the surface that they refer to so an MDagPath must be specified when dealing with components.

Parameters
[out]ReturnStatusStatus code
Returns
The current vertex in the interation
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kInsufficientMemory No memory available.
  • MS::kFailure An object error has occurred.
MObject currentItem ( MStatus ReturnStatus = NULL)

Get the current vertex in the iteration as a component.

Components are used to specify one or more vertices and are usefull in operating on groups of non-contiguous vertices for a surface. Components do not contain any information about the surface that they refer to so an MDagPath must be specified when dealing with components.

Parameters
[out]ReturnStatusStatus code
Returns
The current vertex in the interation
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kInsufficientMemory No memory available.
  • MS::kFailure An object error has occurred.
MPoint position ( MSpace::Space  space = MSpace::kObject,
MStatus ReturnStatus = NULL 
)

Return the position of the current vertex in the specified space.

Object space ignores all transformations for the polygon, world space includes all such transformations.

Parameters
[in]spaceThe transformation space
[out]ReturnStatusStatus code
Returns
The position of the vertex in the specified space
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Unable to do world space transformation.
MStatus setPosition ( const MPoint point,
MSpace::Space  space = MSpace::kObject 
)

Set the position of the current vertex in the given space.

Parameters
[in]pointThe new position for the current vertex
[in]spaceTransformation space
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Unable to do world space transformation.
MStatus translateBy ( const MVector vector,
MSpace::Space  space = MSpace::kObject 
)

Translate the current vertex by the amount specified by the given vector.

Parameters
[in]vectorThe amount of translation
[in]spaceThe transformation space
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Unable to do world space transformation.
MStatus getNormal ( MVector vector,
MSpace::Space  space = MSpace::kObject 
)

Return the normal or averaged normal if unshared of the current vertex.

Parameters
[out]vectorThe normal.
[in]spaceThe transformation space.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Unable to do world space transformation.
MStatus getNormal ( MVector vector,
int  faceIndex,
MSpace::Space  space = MSpace::kObject 
)

Return the normal of the current vertex in the specified face.

Parameters
[out]vectorThe normal.
[in]faceIndexface index to get normal for
[in]spaceThe transformation space
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Unable to do world space transformation.
MStatus getNormals ( MVectorArray normalArray,
MSpace::Space  space = MSpace::kObject 
)

Return the normals of the current vertex for all faces.

Parameters
[out]normalArrayThe normals.
[in]spaceThe transformation space.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Unable to do world space transformation.
MStatus getNormalIndices ( MIntArray normalIndices) const

This method returns the normal indices of the face/vertex associated with the current vertex.

Parameters
[out]normalIndicesThe normal indices.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MStatus numUVs ( int &  uvCount,
const MString uvSet = NULL 
)

This method returns the number of unique UVs mapped on this vertex.

Parameters
[out]uvCountThe UV count
[in]uvSetName of the uv set to work with
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MStatus setUV ( float2 &  uvPoint,
const MString uvSet = NULL 
)

Set the shared UV value at this vertex.

Parameters
[in]uvPointThe UV value to set.
[in]uvSetName of the UV set to work with
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MStatus getUV ( float2 &  uvPoint,
const MString uvSet = NULL 
)

Get the shared UV value at this vertex.

Parameters
[out]uvPointUV value.
[in]uvSetName of the uv set to work with.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MStatus setUV ( int  faceId,
float2 &  uvPoint,
const MString uvSet = NULL 
)

Set the UV value for the given face at the current vertex.

Parameters
[in]faceIdIndex of required face
[in]uvPointValue of the UV point
[in]uvSetName of the uv set to work with
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
MStatus getUV ( int  faceId,
float2 &  uvPoint,
const MString uvSet = NULL 
) const

Get the UV value for the give facen at the current vertex.

Parameters
[in]faceIdIndex of the required face
[out]uvPointUV value.
[in]uvSetName of the uv set to work with
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
MStatus setUVs ( MFloatArray uArray,
MFloatArray vArray,
MIntArray faceIds,
const MString uvSet = NULL 
)

Set the UV value for the specified faces at the current vertex.

If the face is not already mapped, the value will not be set. If at least ne face was previously mapped, the method should succeed. If no faces were mapped, the method will fail.

Parameters
[in]uArrayAll the U values - in local face order
[in]vArrayThe corresponding V values
[in]faceIdsThe corresponding face Ids
[in]uvSetName of the uv set to work with
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MStatus getUVs ( MFloatArray uArray,
MFloatArray vArray,
MIntArray faceIds,
const MString uvSet = NULL 
) const

Get the UV values for all mapped faces at the current vertex.

If at least one face was mapped the method will succeed.

Parameters
[out]uArrayU values in local face order.
[out]vArrayV values in local face order.
[out]faceIdsThe corresponding face Ids
[in]uvSetName of the uv set to work with
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MStatus getUVIndices ( MIntArray uvIndices,
const MString uvSet = NULL 
) const

This method returns the uv indices into the normal array see MFnMesh::getUVs() of the current vertex.

Parameters
[out]uvIndicesUV indices.
[in]uvSetName of the uv set.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MStatus updateSurface ( )

Signal that this polygonal surface has changed and needs to redraw itself.

Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MStatus geomChanged ( )

Reset the geom pointer in the MItMeshVertex.

If you're using MFnMesh to update Normals or Color per vertex while iterating, you must call geomChanged on the iteratior immediately after the MFnMesh call to make sure that your geometry is up to date. A crash may result if this method is not called. A similar approach must be taken for updating upstream vertex tweaks with an MPlug. After the update, call this method.

Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MStatus setIndex ( int  index,
int &  prevIndex 
)

This method sets the index of the current vertex to be accessed.

The current vertex will no longer be in sync with any previous iteration.

Parameters
[in]indexIndex of desired vertex to access.
[out]prevIndexIndex of vertex which was current before the change.
Returns
The index of the vertex that was previously current
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
MStatus getConnectedFaces ( MIntArray faces)

This method gets the indices of the faces connected to the current vertex.

Parameters
[out]facesFace indices.
Returns
Status Code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
MStatus getConnectedEdges ( MIntArray edges)

This method gets the indices of the edges connected to the current vertex.

Parameters
[out]edgesEdge indices.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
MStatus getConnectedVertices ( MIntArray vertices)

This method gets the indices of the vertices surrounding the current vertex.

Parameters
[out]verticesIndices of connected vertices.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
MStatus numConnectedFaces ( int &  faceCount) const

This Method checks for the number of Connected Faces.

Parameters
[in]faceCountThe number of connected faces.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MStatus numConnectedEdges ( int &  edgeCount) const

This Method checks for the number of connected Edges on this vertex.

Parameters
[in]edgeCountThe number of connected edges.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
bool connectedToFace ( int  index,
MStatus ReturnStatus = NULL 
)

This method determines whether the given face contains the current vertex.

Parameters
[in]indexIndex of face to check.
[out]ReturnStatusStatus code
Returns
Boolean value: true if contained, false otherwise.
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
bool connectedToEdge ( int  index,
MStatus ReturnStatus = NULL 
)

This method determines whether the given edge contains the current vertex.

Parameters
[in]indexIndex of edge to check.
[out]ReturnStatusStatus code
Returns
Boolean value: true if contained, false otherwise.
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
MStatus getOppositeVertex ( int &  vertexId,
int  edgeId 
)

This gets the other vertex of the given edge.

Parameters
[out]vertexIdId of the given edge's opposite vertex.
[in]edgeIdThe edge to get the other vertex for
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
bool onBoundary ( MStatus ReturnStatus = NULL)

This method determines whether the current vertex is on a Boundary.

Parameters
[out]ReturnStatusStatus code
Returns
Boolean value: true if contained, false otherwise.
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
bool hasColor ( MStatus ReturnStatus = NULL) const

This method determines whether the current Vertex has a color set for one or more faces.

Parameters
[out]ReturnStatusStatus code
Returns
Boolean value: true if a color is set for at least one face, false otherwise.
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
bool hasColor ( int  index,
MStatus ReturnStatus = NULL 
) const

This method determines whether the given face has a color set for the current vertex.

Parameters
[in]indexIndex of face to check.
[out]ReturnStatusStatus code
Returns
Boolean value: true if a color has been set, false otherwise.
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
MStatus getColor ( MColor color,
int  faceIndex,
const MString colorSetName = NULL 
) const

This method gets the color of the current vertex in the specified face.

Parameters
[out]colorColor.
[in]faceIndexThe face to get the color for this vertex for
[in]colorSetNameName of the color set.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
MStatus getColor ( MColor color,
const MString colorSetName = NULL 
) const

This method gets the average color of the vertex.

Parameters
[out]colorThe average color
[in]colorSetNameName of the color set.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
MStatus getColors ( MColorArray colors,
const MString colorSetName = NULL 
) const

This method gets the colors of the current vertex for each face it belongs to.

If no colors are assigned to the vertex at all, the return values will be (-1 -1 -1 1). If some but not all of the vertex/face colors have been explicitly set, the ones that have not been set will be (0, 0, 0, 1).

Parameters
[out]colorsColors.
[in]colorSetNameName of the color set.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
  • MS::kInvalidParameter Invalid index given.
MStatus getColorIndices ( MIntArray colorIndices,
const MString colorSetName = NULL 
) const

This method returns the colorIndices into the color array see MFnMesh::getColors() of the current vertex.

Parameters
[out]colorIndicesColor indices.
[in]colorSetNameName of the color set.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
const char * className ( )
static

Returns the name of this class.

Returns
The name of this class.

The documentation for this class was generated from the following files:
  • MItMeshVertex.h
  • MItMeshVertex.cpp