Model.morphfitfaces#

Model.morphfitfaces(fmark, ecollection, offset, nproj, p_vec, nhand, mode, method, smooth, regnodes)#

Fits the faces placed on the specified collection (using the Model.morphmanagefacemark() function) to the selected nodes or elements by sliding them, tilting them, or adjusting the curvature of the faces. The faces can be fit through the selected nodes or elements or just moved towards or away from the nodes or elements to meet a target buffer percentage (offset). The number of handles per edges of the fitted faces can be updated when using this function to get a more precise fit.

Parameters:
  • fmark (int) – The mark ID of the morph volume faces to be fitted. Valid values are 0, 1, 2 and 3.

  • ecollection (Collection) – The collection containing the entities to which the faces will be fit. Valid entities are nodes and elements

  • offset (double) – The target buffer zone value for the nodes or elements inside the morph volumes to be met during fitting. When fitting through nodes or elements this value is not used and can be set to 0.0.

  • nproj (int) –

    0 - Project faces along vector specified by p_vec.

    1 - Project faces normal to their current orientation

  • p_vec (hwTriple) – The hwTriple object defining the vector components to use for the projection direction. User can also supply a Python list of three doubles.

  • nhand (int) – Number of mid-handles per edge for each face to be fit. HyperMorph will update the number of mid-handles for each edge if necessary. No more than 5 mid-handles can be specified for an edge. To keep the existing number of handles per edge, set to -1.

  • mode (int) –

    0 - Fit using the buffer zone method (buffer zone is specified using offset).

    1 - Fit through the selected nodes or elements.

  • method (int) –

    0 - Slide faces

    1 - Tilt faces

    2 - Fit faces - smooth

    3 - Fit faces - wavy

    4 - Fit faces - approximate

  • smooth (int) – Amount of smoothness desired for the fitted face. The value of smooth must be between 0 and 10 inclusive with the higher numbers resulting in smoother faces. This value only applies for face fitting, not sliding or tilting.

  • regnodes (int) –

    0 - Do not register nodes to morph volumes after fitting faces.

    1 - Register nodes to morph volumes after fitting faces.

Examples#

Slide two faces normally to all the nodes displayed with a buffer of 10% and keeping the number of handles constant with a smoothness value of 6 and no registration of nodes#
import hm
import hm.entities as ent

model = hm.Model()

model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 1), face_id=0, mlist=0, mode=3
)

model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 2), face_id=2, mlist=0, mode=1
)

model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 1), face_id=2, mlist=0, mode=1
)

model.morphfitfaces(
  fmark=0,
  ecollection=hm.CollectionByDisplayed(model, ent.Node),
  offset=10.0,
  nproj=1,
  p_vec=[0.0, 0.0, 0.0],
  nhand=-1,
  mode=0,
  method=0,
  smooth=6,
  regnodes=0
)
Fit two faces smoothly along a vector through all the nodes displayed and enforcing three handles per edge with a smoothness value of 4 and registering the nodes#
import hm
import hm.entities as ent

model = hm.Model()

model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 1), face_id=0, mlist=0, mode=3
)

model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 2), face_id=5, mlist=0, mode=1
)

model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 1), face_id=5, mlist=0, mode=1
)

model.morphfitfaces(
  fmark=0,
  ecollection=hm.CollectionByDisplayed(model, ent.Node),
  offset=0.0,
  nproj=0,
  p_vec=[0.0, 1.0, 0.0],
  nhand=3,
  mode=1,
  method=2,
  smooth=4,
  regnodes=1
)