The **mmgs** application allows to discretize and optimize an implicitly defined line (which means a line defined by a level-set function). It takes a 3D surface mesh (*i.e. *a set of triangles) and the values of the level-set function at the mesh nodes and returns another 3D surface mesh (that represents the same underlying geometry) with the explicit discretization of the wanted isovalue and the two new domains defined by this isovalue (conformingly connected).

### Example

We start from the teapot.mesh mesh and the distance function to a cube discretized at the mesh nodes (cube-distance.sol file). The input mesh and the distance function are displayed figure 1.

To split the domain on the 0 value of the level-set function:

mmgs_O3 teapot -sol cube-distance.sol -ls

- we specify the name of the .sol file, that contains here the level-set function values at mesh nodes, using the -sol option (more infos about the -sol option).
- The -ls option states that the input
*.sol*file is in fact a level-set file and that we want to discretize the implicit line defined by the 0 level of the level-set. You can specifiy another value than 0 by providing it as argument of the -ls argument.

We obtain two domains conformingly connected and separated by a line that is a discretization of the initial 0 level-set (see figure 2).

**Note that by default Mmg imposes the reference (=color) of the isosurface and of the domains :**

- The isoline is created with the ref 10;
- Triangles in the negative part of the distance function have the ref 3;
- Triangles in the positive part of the distance function have the ref 2.

### Preservation of input references (colors)

By default, Mmgs resets the references (colors) of the input mesh. In the previous example, the input teapot has multiple colors (see figure 3).

It is possible to ask Mmgs to preserve its:

mmgs_O3 teapot -sol cube-distance.sol -ls -keep-ref

The result is displayed figure 4.

Note that the way to preserve input references is not the same for mmgs than for mmg2d and mmg3d (where a parameter file must be used). It will probably be homogenized in the future so the *-keep-ref *option will be removed to be replaced by the parameter file compatibility (more generic).

##### Associated pages

Isovalue discretization algorithm, Documentation