Skip to content

A first run

Isotropic remeshing of the Stanford bunny (35,947 vertices, 69,451 faces) to a uniform edge length of 2% of its bounding box diagonal, three ways. Run each from the repository root, after building with tests enabled (the meshes are in data/models).

wmtk_app reads a JSON file of options. application names the component; input paths are relative to the JSON file, and outputs are written to the working directory:

{
  "application": "isotropic_remeshing",
  "input": "bunny.obj",
  "output": "bunny_remeshed.obj",
  "length_rel": 0.02
}
mkdir -p first_run
cp data/models/bunny.obj docs/examples/json/first_run.json first_run/
cd first_run && ../build/app/wmtk_app -j first_run.json

It writes first_run/bunny_remeshed.obj.

The same options, as a dictionary. Without meshes, the component works on files:

# On files: the same options as the JSON file, with paths relative to the working directory.
wm.isotropic_remeshing({
    "input": str(DATA / "bunny.obj"),
    "output": "bunny_remeshed.obj",
    "length_rel": 0.02,
})

With meshes, it works in memory: the inputs are named, the result comes back as NumPy arrays, and nothing is written:

# In memory: inputs by name, NumPy arrays in and out, nothing written.
outputs, report = wm.isotropic_remeshing(
    {"input": "bunny", "length_rel": 0.02},
    {"bunny": wm.read_mesh(str(DATA / "bunny.obj"))},
)
mesh = outputs["mesh"]
print(len(mesh["V"]), "vertices,", len(mesh["cells"]["triangle"]["connectivity"]), "faces")
wm.write_mesh("bunny_remeshed.msh", mesh)

The memory interface, on wmtk::MeshData:

wmtk::MeshMap meshes{{"bunny", wmtk::io::read_mesh(data / "bunny.obj")}};
auto [outputs, report] = wmtk::components::isotropic_remeshing::isotropic_remeshing(
    {{"input", "bunny"}, {"length_rel", 0.02}},
    meshes);
wmtk::io::write_mesh("bunny_remeshed.msh", outputs.at("mesh"));

Link wmtk::isotropic_remeshing; see Installation.

All three give the same mesh: 2,034 vertices and 3,851 faces. In memory, the report holds what the command line logs: the edge lengths before and after, the valences, and the operations refused because they would fold the surface (136 here).

The options not given take their defaults. Every component lists its options:

./build/app/wmtk_app --options isotropic_remeshing
help(wm.isotropic_remeshing)

and the reference documents each one. A misspelled option is not an error: the component ignores it and logs a warning (isotropic_remeshing has no option ...). Editors can check option files before a run with the JSON Schemas.

Next