trimesh.path.exchange.misc

trimesh.path.exchange.misc.dict_to_path(as_dict)

Turn a pure dict into a dict containing entity objects that can be sent directly to a Path constructor.

Parameters:

as_dict (dict) – Has keys: ‘vertices’, ‘entities’

Returns:

kwargs – Has keys: ‘vertices’, ‘entities’

Return type:

dict

trimesh.path.exchange.misc.edges_to_path(edges, vertices, **kwargs)

Given an edge list of indices and associated vertices representing lines, generate kwargs for a Path object.

Parameters:
  • edges ((n, 2) int) – Vertex indices of line segments

  • vertices ((m, dimension) float) – Vertex positions where dimension is 2 or 3

Returns:

kwargs – Kwargs for Path constructor

Return type:

dict

trimesh.path.exchange.misc.faces_to_path(mesh, face_ids=None, **kwargs)

Given a mesh and face indices find the outline edges and turn them into a Path3D.

Parameters:
  • mesh (trimesh.Trimesh) – Triangulated surface in 3D

  • face_ids ((n,) int) – Indexes referencing mesh.faces

Returns:

kwargs – Kwargs for Path3D constructor

Return type:

dict

trimesh.path.exchange.misc.lines_to_path(lines)

Turn line segments into a Path2D or Path3D object.

Parameters:

lines ((n, 2, dimension) or (n, dimension) float) – Line segments or connected polyline curve in 2D or 3D

Returns:

kwargs – kwargs for Path constructor

Return type:

dict

trimesh.path.exchange.misc.linestrings_to_path(multi)

Load shapely LineString objects into a trimesh.path.Path2D object

Parameters:

multi (shapely.geometry.LineString or MultiLineString) – Input 2D geometry

Returns:

kwargs – Keyword arguments for Path2D constructor

Return type:

dict

trimesh.path.exchange.misc.polygon_to_path(polygon)

Load shapely Polygon objects into a trimesh.path.Path2D object

Parameters:

polygon (shapely.geometry.Polygon) – Input geometry

Returns:

kwargs – Keyword arguments for Path2D constructor

Return type:

dict