Skip to content

Commit 1d0f548

Browse files
authored
Merge pull request #2104 from mikedh/release/removegeom
Release: Remove Geometries Fix And Pathlib
2 parents 7c90a94 + 9ed2aa0 commit 1d0f548

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ requires = ["setuptools >= 61.0", "wheel"]
55
[project]
66
name = "trimesh"
77
requires-python = ">=3.7"
8-
version = "4.0.7"
8+
version = "4.0.8"
99
authors = [{name = "Michael Dawson-Haggerty", email = "mikedh@kerfed.com"}]
1010
license = {file = "LICENSE.md"}
1111
description = "Import, export, process, analyze and view triangular meshes."

tests/test_scenegraph.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@ def test_nodes(self):
6565
# should have dumped the cache and removed the node
6666
assert node not in graph.nodes
6767

68+
def test_remove_geometries(self):
69+
# remove geometries from a scene graph
70+
scene = g.get_mesh("cycloidal.3DXML")
71+
72+
# only keep geometry instances of these
73+
keep = {"disc_cam_A", "disc_cam_B", "vxb-6800-2rs"}
74+
75+
assert len(scene.duplicate_nodes) == 12
76+
77+
# should remove instance references except `keep`
78+
scene.graph.remove_geometries(set(scene.geometry.keys()).difference(keep))
79+
80+
# there should now be three groups of duplicate nodes
81+
assert len(scene.duplicate_nodes) == len(keep)
82+
6883
def test_kwargs(self):
6984
# test the function that converts various
7085
# arguments into a homogeneous transformation

trimesh/scene/transforms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import collections
22
from copy import deepcopy
3+
from typing import Sequence
34

45
import numpy as np
56

@@ -473,7 +474,7 @@ def geometry_nodes(self):
473474
res[attr["geometry"]].append(node)
474475
return res
475476

476-
def remove_geometries(self, geometries):
477+
def remove_geometries(self, geometries: Sequence):
477478
"""
478479
Remove the reference for specified geometries
479480
from nodes without deleting the node.
@@ -498,6 +499,7 @@ def remove_geometries(self, geometries):
498499
# but the only property using the geometry should be
499500
# nodes_geometry: if this becomes not true change this to clear!
500501
self._cache.cache.pop("nodes_geometry", None)
502+
self.transforms._hash = None
501503

502504
def __contains__(self, key):
503505
return key in self.transforms.node_data

trimesh/typed.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from pathlib import Path
12
from typing import IO, Dict, List, Optional, Sequence, Tuple, Union
23

34
# our default integer and floating point types
@@ -11,7 +12,7 @@
1112

1213
# most loader routes take `file_obj` which can either be
1314
# a file-like object or a file path
14-
Loadable = Union[str, IO]
15+
Loadable = Union[str, Path, IO]
1516

1617
__all__ = [
1718
"NDArray",

0 commit comments

Comments
 (0)