MeshFaceList

References
Provides access to the faces and Face related functionality of a Mesh.

Properties

Capacity

#Since v6.0
public int Capacity { get; set; }
Gets or sets the total number of mesh triangles and quads the internal data structure can hold without resizing.

Count

#Since v5.0
public int Count { get; set; }
Gets or sets the number of mesh faces. When getting this can includes invalid faces.
Count

QuadCount

#Since v5.0
public int QuadCount { get; }
Gets the number of faces that are valid quads (4 corners).
Explicit

ICollection<MeshFace>.IsReadOnly

#
Explicit

ICollection.IsSynchronized

#
bool ICollection.IsSynchronized
Explicit

ICollection.SyncRoot

#
Explicit

IList.IsFixedSize

#
bool IList.IsFixedSize
Explicit

IList.IsReadOnly

#
bool IList.IsReadOnly

TriangleCount

#Since v5.0
public int TriangleCount { get; }
Gets the number of faces that are valid triangles (3 corners).

Indexers

Explicit

IList.this[]

#
object IList.this[int index]
index (int)

this[]

#
public MeshFace this[int index] { get; set; }
Returns the mesh face at the given index.
index (int)Index of face to get. Must be larger than or equal to zero and smaller than the Face Count of the mesh.

Methods

AddFace

#ExampleSince v5.0
public int AddFace(int vertex1, int vertex2, int vertex3, int vertex4)
Appends a new quadrangular face to the end of the mesh face list.
vertex1 (int)Index of first face corner.
vertex2 (int)Index of second face corner.
vertex3 (int)Index of third face corner.
vertex4 (int)Index of fourth face corner.
The index of the newly added quad.

AddFace

#Since v5.0
public int AddFace(int vertex1, int vertex2, int vertex3)
Appends a new triangular face to the end of the mesh face list.
vertex1 (int)Index of first face corner.
vertex2 (int)Index of second face corner.
vertex3 (int)Index of third face corner.
The index of the newly added triangle.

AddFace

#Since v5.0
public int AddFace(MeshFace face)
Appends a new mesh face to the end of the mesh face list.
face (MeshFace)Face to add.
The index of the newly added face.

AddFaces

#Since v5.0
public int[] AddFaces(IEnumerable<MeshFace> faces)
Appends a list of faces to the end of the mesh face list.
faces (IEnumerable<MeshFace>)Faces to add.
Indices of the newly created faces

AdjacentFaces

#Since v5.0
public int[] AdjacentFaces(int faceIndex)
Gets all faces that share a topological edge with a given face.
faceIndex (int)A face index.
All indices that share an edge.

Clear

#Since v5.0
public void Clear()
Clears the Face list on the mesh.

ConvertNonPlanarQuadsToTriangles

#Since v6.0
public int ConvertNonPlanarQuadsToTriangles(double planarTolerance, double angleToleranceRadians, int splitMethod)
Splits non-planar quads into two triangles based on given parameters.
Remarks: If both planarTolerance = Rhino.RhinoMath.UnsetValue and angleToleranceRadians = Rhino.RhinoMath.UnsetValue, then all quads are split.
planarTolerance (double)If planarTolerance >= 0, then a quad is split if its vertices are not coplanar. If both planarTolerance = Rhino.RhinoMath.UnsetValue and angleToleranceRadians >= 0.0, then the planarity test is skipped.
angleToleranceRadians (double)If angleToleranceRadians >= 0.0, then a quad is split if the angle between opposite corner normals is > angleToleranceRadians. The corner normal is the normal to the triangle formed by two adjacent edges and the diagonal connecting their endpoints. A quad has four corner normals. If both angleToleranceRadians = Rhino.RhinoMath.UnsetValue and planarTolerance >= 0.0, then the corner normal angle test is skipped.
splitMethod (int)0 default Currently divides along the short diagonal. This may be changed as better methods are found or preferences change. By passing zero, you let the developers of this code decide what's best for you over time. 1 divide along the short diagonal 2 divide along the long diagonal 3 minimize resulting area 4 maximize resulting area 5 minimize angle between triangle normals 6 maximize angle between triangle normals
Number of quads that were converted to triangles.

ConvertQuadsToTriangles

#Since v5.0
public bool ConvertQuadsToTriangles()
Splits all quads along the short diagonal.
true on success, false on failure.

ConvertTrianglesToQuads

#Since v5.0
public bool ConvertTrianglesToQuads(double angleToleranceRadians, double minimumDiagonalLengthRatio)
Joins adjacent triangles into quads if the resulting quad is 'nice'.
angleToleranceRadians (double)Used to compare adjacent triangles' face normals. For two triangles to be considered, the angle between their face normals has to be <= angleToleranceRadians. When in doubt use RhinoMath.PI/90.0 (2 degrees).
minimumDiagonalLengthRatio (double)( <= 1.0) For two triangles to be considered the ratio of the resulting quad's diagonals (length of the shortest diagonal)/(length of longest diagonal). has to be >= minimumDiagonalLengthRatio. When in doubt us .875.
true on success, false on failure.

CullDegenerateFaces

#Since v5.0
public int CullDegenerateFaces()
Attempts to removes degenerate faces from the mesh.

Degenerate faces are faces that contains such a combination of indices, that their final shape collapsed in a line or point.

Before returning, this method also attempts to repair faces by juggling vertex indices.

The number of degenerate faces that were removed.

DeleteFaces

#Since v6.6
public int DeleteFaces(IEnumerable<int> faceIndexes, bool compact)
Removes a collection of faces from the mesh without affecting the remaining geometry.
faceIndexes (IEnumerable<int>)An array containing all the face indices to be removed.
compact (bool)If true, removes vertices that are no longer referenced.
The number of faces deleted on success.

DeleteFaces

#Since v5.0
public int DeleteFaces(IEnumerable<int> faceIndexes)
Removes a collection of faces from the mesh without affecting the remaining geometry.
faceIndexes (IEnumerable<int>)An array containing all the face indices to be removed.
The number of faces deleted on success.

Destroy

#Since v6.0
public void Destroy()
Releases all memory allocated to store faces. The list capacity will be 0 after this call.

Subsequent calls can add new items.

ExtractDuplicateFaces

#Since v6.0
public Mesh ExtractDuplicateFaces()
Extracts, or removes, duplicate faces.
A mesh containing the extracted duplicate faces if successful, null otherwise.

ExtractFaces

#Since v6.0
public Mesh ExtractFaces(IEnumerable<int> faceIndices)
Extracts, or removes, faces.
faceIndices (IEnumerable<int>)The face indices to be extracted.
A mesh containing the extracted faces if successful, null otherwise.

GetClashingFacePairs

#Since v6.0
public IndexPair[] GetClashingFacePairs(int maxPairCount)
Gets an array of pairs of mesh faces that clash.
maxPairCount (int)If >0, then at most this many pairs will be added to the output array. If <=0, then all clashing pairs will be added to the output array.
Array of pairs of mesh face indices.

GetConnectedFaces

#Since v5.6
public int[] GetConnectedFaces(int faceIndex, double angleRadians, bool greaterThanAngle)
Find all connected face indices where adjacent face normals meet the criteria of angleRadians and greaterThanAngle
faceIndex (int)face index to start from
angleRadians (double)angle to use for comparison of what is connected
greaterThanAngle (bool)If true angles greater than or equal to are considered connected. If false, angles less than or equal to are considered connected.
list of connected face indices

GetConnectedFaces

#Since v7.1
public int[] GetConnectedFaces(int faceIndex)
Find all connected face indices
faceIndex (int)face index to start from
list of connected face indices

GetConnectedFacesToEdges

#Since v5.6
public int[] GetConnectedFacesToEdges(int startFaceIndex, bool treatNonmanifoldLikeUnwelded)
Uses startFaceIndex and finds all connected face indexes up to unwelded or naked edges. If treatNonmanifoldLikeUnwelded is true then non-manifold edges will be considered as unwelded or naked
startFaceIndex (int)Initial face index
treatNonmanifoldLikeUnwelded (bool)True means non-manifold edges will be handled like unwelded edges, False means they aren't considered
Array of connected face indexes

GetDuplicateFaces

#Since v6.0
public int[] GetDuplicateFaces()
Finds all of the duplicate faces.
The indexes that are duplicates of other indexes if successful. If there are no duplicate, then an empty array is returned.

GetEnumerator

#Since v5.0
public IEnumerator<MeshFace> GetEnumerator()
Gets an enumerator that yields all faces in this collection.
The enumerator.

GetFace

#Since v5.0
public MeshFace GetFace(int index)
Returns the mesh face at the given index.
index (int)Index of face to get. Must be larger than or equal to zero and smaller than the Face Count of the mesh.
The mesh face at the given index on success or MeshFace.Unset if the index is out of range.

GetFaceAspectRatio

#Since v6.0
public double GetFaceAspectRatio(int index)
Returns the mesh face at the given index.
index (int)Index of face to get. Must be larger than or equal to zero and smaller than the Face Count of the mesh.
The mesh face at the given index on success or MeshFace.Unset if the index is out of range.

GetFaceBoundingBox

#Since v5.0
public BoundingBox GetFaceBoundingBox(int faceIndex)
Gets the bounding box of a face.
faceIndex (int)A face index.
A new bounding box, or BoundingBox.Empty on error.

GetFaceCenter

#Since v5.0
public Point3d GetFaceCenter(int faceIndex)
Gets the center point of a face.

For a triangular face, this is the centroid or barycenter.

For a quad, this is the average of four comer points.

faceIndex (int)A face index.
The center point.

GetFaceVertices

#Since v5.0
public bool GetFaceVertices(int faceIndex, out Point3f a, out Point3f b, out Point3f c, out Point3f d)
Gets the 3D location of the vertices forming a face.
faceIndex (int)A face index.
a (out Point3f)A first point. This out argument is assigned during the call.
b (out Point3f)A second point. This out argument is assigned during the call.
c (out Point3f)A third point. This out argument is assigned during the call.
d (out Point3f)A fourth point. This out argument is assigned during the call.
true if the operation succeeded, otherwise false.

GetTopologicalVertices

#Since v5.0
public int[] GetTopologicalVertices(int faceIndex)
Gets the topology vertex indices of a face.
faceIndex (int)A face index.
An array of integers.

GetZeroAreaFaces

#Since v6.0
public bool GetZeroAreaFaces(out int[] whollyDegenerateFaces, out int[] partiallyDegenerateFaces)
Examines and adds face indexes to whollyDegenerateFaces if the face is a triangle with zero area or a quad both triangles have zero area. Face indexes are added to partiallyDegenerateFaces when a quad has one triangle with zero area.
whollyDegenerateFaces (out int[])Array of indexes for faces, both triangles and quads, that have zero area.
partiallyDegenerateFaces (out int[])Array of indexes for quad faces, that have one triangle with zero area.
Returns true if the mesh has wholly or partially degenerate faces, false otherwise.

HasNakedEdges

#Since v5.0
public bool HasNakedEdges(int faceIndex)
Returns true if at least one of the face edges are not topologically connected to any other faces.
faceIndex (int)A face index.
true if that face makes the mesh open, otherwise false.

Insert

#Since v5.0
public void Insert(int index, MeshFace face)
Inserts a mesh face at a defined index in this list.
index (int)An index.
face (MeshFace)A face.
ArgumentOutOfRangeExceptionIf index is negative or >= Count.

IsHidden

#Since v5.0
public bool IsHidden(int faceIndex)
Gets a value indicating whether a face is hidden.

A face is hidden if, and only if, at least one of its vertices is hidden.

faceIndex (int)A face index.
true if hidden, false if fully visible.

MergeAdjacentFaces

#Since v7.6
public bool MergeAdjacentFaces(int edgeIndex)
Merges two triangular mesh faces that share an edge into one quadrangular face.
edgeIndex (int)The common topological edge index.
true if successful, false otherwise.

RemoveAt

#Since v6.6
public void RemoveAt(int index, bool compact)
Removes a face from the mesh.
index (int)The index of the face that will be removed.
compact (bool)If true, removes vertices that are no longer referenced.
ArgumentOutOfRangeExceptionIf index is < 0 or >= Count.

RemoveAt

#Since v5.0
public void RemoveAt(int index)
Removes a face from the mesh.
index (int)The index of the face that will be removed.
ArgumentOutOfRangeExceptionIf index is < 0 or >= Count.

RemoveZeroAreaFaces

#Since v6.0
public int RemoveZeroAreaFaces(ref int fixedFaceCount)
Deletes or fixes mesh faces that have zero area.
fixedFaceCount (ref int)Number of fixed partially degenerate faces.
Number of removed wholly degenerate faces.

SetFace

#Since v5.0
public bool SetFace(int index, int vertex1, int vertex2, int vertex3, int vertex4)
Sets a quadrangular face at a specific index of the mesh.
index (int)A position in the list.
vertex1 (int)The first vertex index.
vertex2 (int)The second vertex index.
vertex3 (int)The third vertex index.
vertex4 (int)The fourth vertex index.
true if the operation succeeded, otherwise false.

SetFace

#Since v5.0
public bool SetFace(int index, int vertex1, int vertex2, int vertex3)
Sets a triangular face at a specific index of the mesh.
index (int)A position in the list.
vertex1 (int)The first vertex index.
vertex2 (int)The second vertex index.
vertex3 (int)The third vertex index.
true if the operation succeeded, otherwise false.

SetFace

#Since v5.0
public bool SetFace(int index, MeshFace face)
Sets a face at a specific index of the mesh.
index (int)A position in the list.
face (MeshFace)A face.
true if the operation succeeded, otherwise false.
Explicit

ICollection<MeshFace>.Add

#
void ICollection<MeshFace>.Add(MeshFace item)
item (MeshFace)
Explicit

ICollection<MeshFace>.Contains

#
item (MeshFace)
Explicit

ICollection<MeshFace>.CopyTo

#
void ICollection<MeshFace>.CopyTo(MeshFace[] array, int arrayIndex)
array (MeshFace[])
arrayIndex (int)
Explicit

ICollection<MeshFace>.Remove

#
item (MeshFace)
Explicit

IList<MeshFace>.IndexOf

#
int IList<MeshFace>.IndexOf(MeshFace item)
item (MeshFace)
Explicit

IList<MeshFace>.Insert

#Since v5.0
void IList<MeshFace>.Insert(int index, MeshFace item)
index (int)
item (MeshFace)
Explicit

IList<MeshFace>.RemoveAt

#Since v5.0
void IList<MeshFace>.RemoveAt(int index)
index (int)
Explicit

ICollection.CopyTo

#
void ICollection.CopyTo(Array array, int index)
array (Array)
index (int)
Explicit

IEnumerable.GetEnumerator

#Since v5.0
IEnumerator IEnumerable.GetEnumerator()
Explicit

IList.Add

#
int IList.Add(object value)
value (object)
Explicit

IList.Contains

#
bool IList.Contains(object value)
value (object)
Explicit

IList.IndexOf

#
int IList.IndexOf(object value)
value (object)
Explicit

IList.Insert

#
void IList.Insert(int index, object value)
index (int)
value (object)
Explicit

IList.Remove

#
void IList.Remove(object value)
value (object)
Explicit

IList.RemoveAt

#Since v5.0
void IList.RemoveAt(int index)
index (int)

ToIntArray

#
public int[] ToIntArray(bool asTriangles, ref List<int> replacedIndices)
Copies all of the faces to a linear array of indices. Clean-up of vertex indices if replacedIndices is a valid List<int> ///
asTriangles (bool)If set to true as triangles.
replacedIndices (ref List<int>)List is populated with vertex indices that were replaced with 0. If replacedIndices is null there will be no cleanup
The int array. This method never returns null.

ToIntArray

#Since v5.9
public int[] ToIntArray(bool asTriangles)
Copies all of the face indices to a linear array of indices per face. Note that this includes indices from invalid faces too.
asTriangles (bool)If set to true as triangles.
The int array. This method never returns null.