MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / cut_mesh

Function cut_mesh

python/pymesh/meshutils/cut_mesh.py:6–32  ·  view source on GitHub ↗

Cut mesh into connected components based on ``comp_ids``. If ``comp_ids`` is ``None``, cut mesh based on UV discontinuity. Args: mesh (:class:`Mesh`): Input mesh. If ``comp_ids`` is ``None``, it must have uv coordinates stored as per-corner attribute named

(mesh, comp_ids=None)

Source from the content-addressed store, hash-verified

4import numpy as np
5
6def cut_mesh(mesh, comp_ids=None):
7 """ Cut mesh into connected components based on ``comp_ids``. If
8 ``comp_ids`` is ``None``, cut mesh based on UV discontinuity.
9
10 Args:
11 mesh (:class:`Mesh`): Input mesh. If ``comp_ids`` is ``None``, it must
12 have uv coordinates stored as per-corner attribute named
13 ``corner_texture``.
14 comp_ids (``numpy.ndarray``): Per-face label of how to group faces into
15 connected components.
16
17 Returns:
18 The cutted output mesh object.
19 """
20
21 cutter = MeshCutter(mesh.raw_mesh)
22 if comp_ids is not None:
23 comp_ids = np.array(comp_ids)
24 cutted_mesh = Mesh(cutter.cut_with_face_labels(comp_ids))
25 cutted_mesh.add_attribute("comp_ids")
26 cutted_mesh.set_attribute("comp_ids", comp_ids)
27 else:
28 cutted_mesh = Mesh(cutter.cut_at_uv_discontinuity())
29 cutted_mesh.add_attribute("corner_texture")
30 cutted_mesh.set_attribute("corner_texture",
31 mesh.get_attribute("corner_texture"))
32 return cutted_mesh
33

Callers 2

test_squareMethod · 0.90
test_square_2Method · 0.90

Calls 7

cut_with_face_labelsMethod · 0.95
add_attributeMethod · 0.95
set_attributeMethod · 0.95
MeshClass · 0.90
MeshCutterClass · 0.85
get_attributeMethod · 0.45

Tested by 2

test_squareMethod · 0.72
test_square_2Method · 0.72