Mesh Face Methods

The following methods provide basic access to the mesh faces.

For more face-related methods, see also

Face Methods (meshop struct)

 

For more mesh-related methods, see

Editable Mesh - Topics Index

Editable_Mesh : GeometryClass and TriMesh : Value

 

Methods:

getNumFaces <mesh>

Returns number of faces as an integer, equivalent to using <mesh>.numfaces

setNumFaces <mesh> <face_index_integer> [ <boolean> ]

Set the number of faces as specified. If the optional boolean argument is true, the existing topology remains intact. If it is false or left off, the topology is lost.

For all new faces, the following occurs:

getFace <mesh> <face_index_integer>

Returns the face vertex indexes for the indexed face as a point3. Each component of the point3 value contains a vertex index.

setFace <mesh> <face_index_integer> <vert_indices_point3>

Sets the face vertex indexes for the indexed face from a point3.

setFace <mesh> <face_index_integer> <vert_index_integer> \

<vert_index_integer> <vert_index_integer>

Sets the face vertex indexes for the indexed face from 3 vertex indexes.

deleteFace <mesh> <face_index_integer>

Deletes indexed face from the mesh. Renumbers faces accordingly.

collapseFace <mesh> <face_index_integer>

Deletes indexed face from the mesh, welding its 3 vertices together at the center of the original face. Renumbers faces accordingly.

getFaceNormal <mesh> <face_index_integer>

Returns the normal of the indexed face as a point3.

setFaceNormal <mesh> <face_index_integer> <point3>

Sets the indexed face's normal vector. As soon as you run update() on the mesh, this value is overwritten.

getFaceMatID <mesh> <face_index_integer>

Returns the indexed face's material ID as an integer.

setFaceMatID <mesh> <face_index_integer> <integer>

Sets the indexed face's material ID.

getFaceSmoothGroup <mesh> <face_index_integer>

Returns the indexed face's smoothing groups as a 32-bit integer. There are 32 possible smoothing groups. Each bit in the returned value corresponds to a smoothing group. If a bit is turned on, the face is part of that smoothing group. You can retrieve the list of smoothing groups for a face as a BitArray using the following function:

Script:

fn getFaceSmoothGroupB obj face =

(

local sgroup_val=getFaceSmoothGroup obj face

local sg_bitarray=#{}

if sgroup_val < 0 do

(

sg_bitarray[32]=true

sgroup_val -= 2^31

)

for i = 1 to 31 do

(

sg_bitarray[i]= (mod sgroup_val 2 > .5)

sgroup_val /= 2

)

sg_bitarray

)

setFaceSmoothGroup <mesh> <face_index_integer> <smoothing_group_integer>

Sets the indexed face's smoothing groups. If you have a face's desired smoothing groups as a BitArray, you could set the face's smoothing group data using the following function:

Script:

fn setFaceSmoothGroupB obj face sg_bitarray =

(

local sgroup_val=0

for i in sg_bitarray do sgroup_val += 2^(i-1)

setFaceSmoothGroup obj face sgroup_val

update obj

)

getFaceSelection <node> [ <modifier_or_index> ] [ name:<name> ]

 

getFaceSelection <mesh>

Retrieves the face selection set, or the specified named selection set if the optional name: parameter is specified, as a BitArray. See the getVertSelection() method for more information.

setFaceSelection <node> [ <modifier_or_index> ] \

( <sel_bitarray> | <sel_array> ) \

[ name:<name> ] [ keep:<boolean> ]

 

setFaceSelection <mesh> ( <sel_bitarray> | <sel_array> ) \

[ keep:<boolean> ]

Sets the face selections in an Editable Mesh base object, Mesh Select modifier, Edit Mesh modifier, or TriMesh. This mirrors the selection getting method above. See the setVertSelection() method for more information.

deselectHiddenFaces <mesh>

deselects the hidden faces in the mesh. This method is not applicable to TriMeshes.

extrudeFace <mesh> ( <index> | <bitarray> | <integer_array> | #selection )

<amount> <scale> [ dir:(<point3> | #common | #independent ) ]

Provides capabilities equivalent to the Extrude Face modifier. This function works only on Editable Mesh nodes. The second argument defines which faces to extrude, either a single face index, a BitArray of face indexes, an integer array of face indexes, or the name literal #selection meaning the current face selection in the Editable Mesh. The <amount> argument specifies the extrude distance and the <scale> specifies a % amount to scale each face cluster.

If the optional dir: keyword argument is not specified, face clusters are extruded by moving their vertices independently along the average normal at each vertex, as does the Extrude Face modifier. If it is specified, it can be a point3 giving a direction vector in which all vertices are moved, or it can be the value #independent which is the same as the default direction, or it can be the value #common which extrudes face clusters along the average normal of all the face normals in each cluster. #common is equivalent to the Group Normal option in EditableMesh, and #independent is equivalent to the Local Normal option.

Example:

s=sphere()

convertToMesh s

extrudeface s #{1..16} 10 100 dir:#independent

update s

emesh_extrudeFace.gif

See also:

Face Methods (meshop struct)

Mesh Methods (meshop struct)

 

For more mesh-related methods, see

Editable Mesh - Topics Index

Editable_Mesh : GeometryClass and TriMesh : Value