Skip to content

Commit fa3c612

Browse files
committed
wrap concatenate to check for different shapes
1 parent 5521525 commit fa3c612

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ include-package-data = false
5656
[tool.setuptools.package-data]
5757
trimesh = [
5858
"resources/templates/*",
59-
"resources/*.json",
59+
"resources/*.json*",
6060
"resources/schema/*",
6161
"resources/schema/primitive/*.json",
6262
"resources/*.zip",

trimesh/util.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from .typed import ArrayLike, Dict, Iterable, NDArray, Optional, Set, Union, float64
2727

2828
# create a default logger
29-
log = logging.getLogger("trimesh")
29+
log = logging.getLogger(__name__)
3030

3131
ABC = abc.ABC
3232
now = time.time
@@ -1489,25 +1489,35 @@ def concatenate(
14891489
except BaseException:
14901490
pass
14911491

1492+
# concatenate vertex attributes that are valid for every mesh
14921493
vertex_attributes = {}
1493-
# concatenate vertex attributes
14941494
for key in is_mesh[0].vertex_attributes.keys():
1495-
# make sure every mesh has the attribute
1496-
# and that the attribute is valid for that mesh
1495+
# make sure every mesh has a valid attribute
14971496
if all(len(m.vertex_attributes.get(key, [])) == len(m.vertices) for m in is_mesh):
1498-
vertex_attributes[key] = np.concatenate(
1499-
[mesh.vertex_attributes.get(key, []) for mesh in is_mesh], axis=0
1500-
)
1497+
try:
1498+
vertex_attributes[key] = np.concatenate(
1499+
[mesh.vertex_attributes.get(key, []) for mesh in is_mesh], axis=0
1500+
)
1501+
except BaseException:
1502+
log.warning(
1503+
f"Failed to concatenate `vertex_attribute['{key}']`", exc_info=True
1504+
)
15011505

1506+
# concatenate face attributes that are valid for every mesh
15021507
face_attributes = {}
1503-
# concatenate valid face attributes
15041508
for key in is_mesh[0].face_attributes.keys():
1505-
# an attribute can only be concatenated if
1506-
# if is valid on every mesh we're concatenating
1509+
# an attribute can only be concatenated if it's valid for every mesh
15071510
if all(len(m.face_attributes.get(key, [])) == len(m.faces) for m in is_mesh):
1508-
face_attributes[key] = np.concatenate(
1509-
[mesh.face_attributes.get(key, []) for mesh in is_mesh], axis=0
1510-
)
1511+
try:
1512+
# stack along axis 0
1513+
face_attributes[key] = np.concatenate(
1514+
[mesh.face_attributes.get(key, []) for mesh in is_mesh], axis=0
1515+
)
1516+
except BaseException:
1517+
# could have failed because attribute had different shapes
1518+
log.warning(
1519+
f"Failed to concatenate `face_attribute['{key}']`", exc_info=True
1520+
)
15111521

15121522
# create the mesh object
15131523
result = trimesh_type(

0 commit comments

Comments
 (0)