Skip to content

CellNetwork.cell_neighbors() modification #1449

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed


## [2.10.1] 2025-03-24

### Added

* Added `add_mesh` to `compas.datastructures.CellNetwork`.

### Changed

* Fixed logic for method `CellNetwork.cell_neighbors` from common faces search to common 3+ vertices search.

### Removed

## [2.10.0] 2025-03-03

### Added
Expand Down
18 changes: 17 additions & 1 deletion src/compas/datastructures/cell_network/cell_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,22 @@ def add_cell(self, faces, ckey=None, attr_dict=None, **kwattr):

return ckey


def add_mesh(self, input_mesh: Mesh):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have the felling this already exists but under a different name, no @romanarust ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this does not yet exist

if input_mesh.is_manifold():
vertices, faces = input_mesh.to_vertices_and_faces()
vertex_offset = self._max_vertex + 1
for vertex in vertices:
self.add_vertex(x=vertex[0], y=vertex[1], z=vertex[2])
faces_lst = []
for face in faces:
new_face = [vertex + vertex_offset for vertex in face]
fkey = self.add_face(new_face)
faces_lst.append(fkey)
self.add_cell(faces_lst)
else:
raise ValueError("Mesh is not manifold to be added as a cell")

# --------------------------------------------------------------------------
# Modifiers
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -4306,4 +4322,4 @@ def cell_volume(self, cell):
# """
# points = transform_points(self.vertices_attributes("xyz"), T)
# for vertex, point in zip(self.vertices(), points):
# self.vertex_attributes(vertex, "xyz", point)
# self.vertex_attributes(vertex, "xyz", point)
Loading