Skip to content

Components

This example illustrates the disconnected components of a given mesh.

Data

The data used in this example is from "Anatomic Human Foot & Lower Extremity Version 2.0" designed by DrGlassDPM on on Thingiverse. The components can be computed via Lagrange:

mesh = lagrange.io.load_mesh("data/foot.msh")
lagrange.compute_components(mesh, output_attribute_name="comp")

Code

#!/usr/bin/env python

import hakowan as hkw
import math

base = hkw.layer("data/foot.ply")
base = base.material(
    "Principled",
    color=hkw.texture.ScalarField("comp", colormap="set1", categories=True),
    roughness=0.2,
).transform(hkw.transform.Compute(component="comp"))

front_view = base.rotate(axis=[0, 1, 0], angle=math.pi)
top_view = base.rotate(axis=[1, 0, 0], angle=math.pi / 2)
side_view = base.rotate(axis=[0, 1, 0], angle=math.pi / 2)

config = hkw.config()
config.sensor.location = [0, 0, 3.5]

hkw.render(front_view, config, filename="results/foot_front.png")
hkw.render(top_view, config, filename="results/foot_top.png")
hkw.render(side_view, config, filename="results/foot_side.png")