Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mesh Join Bugfix #4019

Merged
merged 1 commit into from
Apr 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions utils/mesh_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ def apply_matrices(meshes: Iterator[Mesh], matrices: Iterator[List[Matrix]], *,

yield from join_meshes(meshes_py(sub_vertices, sub_edges, sub_polygons))

def has_element(pol_edge):
if pol_edge is None:
return False
if len(pol_edge) > 0 and len(pol_edge[0]) > 0:
return True
return False


@pass_mesh_type
def join_meshes(meshes: Iterator[PyMesh], *, _mesh_type) -> Iterator[PyMesh]:
Expand All @@ -92,10 +99,16 @@ def join_meshes(meshes: Iterator[PyMesh], *, _mesh_type) -> Iterator[PyMesh]:
joined_polygons = []
vertexes_number = 0
for vertices, edges, polygons in meshes:
if edges:
joined_edges.extend([(e[0] + vertexes_number, e[1] + vertexes_number) for e in edges])
if polygons:
joined_polygons.extend([[i + vertexes_number for i in p] for p in polygons])
if has_element(edges):
if isinstance(edges, np.ndarray):
joined_edges.extend((edges + vertexes_number).tolist())
else:
joined_edges.extend([(e[0] + vertexes_number, e[1] + vertexes_number) for e in edges])
if has_element(polygons):
if isinstance(edges, np.ndarray):
joined_polygons.extend((polygons + vertexes_number).tolist())
else:
joined_polygons.extend([[i + vertexes_number for i in p] for p in polygons])
vertexes_number += len(vertices)
_vertices.append(vertices)
implementation = np.concatenate if _mesh_type == 'NP' else lambda vs: [v for _vs in vs for v in _vs]
Expand Down