Main Content

addFaces

Add faces to surface mesh

Since R2022b

    Description

    addFaces(mesh,faces) adds the specified faces to the surfaceMesh object, mesh.

    example

    addFaces(___,Name=Value) specifies options using one or more name-value arguments in addition to the previous syntax. For example, addFaces(mesh,faces,FaceNormals=[1 2 0; 1 1 1; 0 2 2; 4 3 0; 2 1 2; 5 5 0]) specifies the face normals for the surface mesh.

    Examples

    collapse all

    Define mesh vertices for a surface mesh.

    vertices = [1 -1  1; 1 1 1; -1 1 1; -1 -1 1; ...
                1 -1 -1; 1 1 -1; -1 1 -1; -1 -1 -1];

    Define the mesh faces using the vertices.

    faces = [6 2 1; 1 5 6; 8 4 3; 3 7 8; 6 7 3; 3 2 6; ...
             5 1 4; 4 8 5; 4 1 2; 2 3 4; 7 6 5; 5 8 7];

    Create and display the surface mesh.

    mesh = surfaceMesh(vertices,faces);
    surfaceMeshShow(mesh,Title="Original Mesh")

    Add a new vertex to the surface mesh.

    addVertices(mesh,[0 0 2])

    Add new faces to surface mesh and display the updated mesh.

    faces = [1 4 9; 2 3 9];
    addFaces(mesh,faces);
    surfaceMeshShow(mesh,Title="Modified Mesh")

    Input Arguments

    collapse all

    Surface mesh, specified as a surfaceMesh object.

    Mesh triangular faces, specified as an N-by-3 matrix. Each row of the array is in the form [V1 V2 V3], specifying the vertex IDs of the vertices which define the triangular face. N is the total number of faces to add to the mesh.

    Data Types: single | double

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: addFaces(mesh,faces,FaceNormals=[1 2 0; 1 1 1; 0 2 2; 4 3 0; 2 1 2; 5 5 0])

    Normal vectors for the mesh faces, specified as an N-by-3 matrix. Each row of the matrix of in the form [x y z], specifying the normal for a face. N is the total number of faces to add to the mesh.

    Data Types: single | double

    Color values for the mesh faces, specified as an N-by-3 matrix. Each row of the matrix is of the form [R G B], specifying the color value for a face. Each value must be in the range [0,1]. N is the total number of faces to add to the mesh.

    Data Types: single | double

    Version History

    Introduced in R2022b