-
Notifications
You must be signed in to change notification settings - Fork 114
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
Changes from 16 commits
78aa12d
699c5b5
15d4f03
c87a0c2
ce730cd
41c5627
22a2170
fb087fd
fe82e1d
760c5c8
697665d
da4b248
e816686
b45e7ca
5e86329
b3f2f0e
7bf234c
246a7c1
bfea5c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -728,6 +728,32 @@ def add_cell(self, faces, ckey=None, attr_dict=None, **kwattr): | |
|
|
||
| return ckey | ||
|
|
||
|
|
||
| def add_mesh(self, input_mesh: Mesh): | ||
| if input_mesh.is_manifold(): | ||
| # mesh.unify_cycles() | ||
| unpacked_mesh = input_mesh.to_vertices_and_faces() | ||
|
||
|
|
||
| if self._max_vertex == -1: | ||
| vertex_diff = 0 | ||
| else: | ||
| vertex_diff = self._max_vertex + 1 | ||
|
||
|
|
||
| for vertex in unpacked_mesh[0]: | ||
| self.add_vertex(attr_dict = {"x": vertex[0], "y": vertex[1], "z":vertex[2]}) | ||
|
||
|
|
||
| faces_lst = [] | ||
|
|
||
| for face in unpacked_mesh[1]: | ||
| new_face = [vertex + vertex_diff for vertex in face] | ||
| self.add_face(new_face) | ||
|
||
| faces_lst.append(self._max_face) | ||
|
||
|
|
||
| self.add_cell(faces_lst) | ||
|
|
||
| else: | ||
| raise ValueError("Mesh is not manifold to be added as a cell") | ||
|
|
||
| # -------------------------------------------------------------------------- | ||
| # Modifiers | ||
| # -------------------------------------------------------------------------- | ||
|
|
@@ -4033,7 +4059,7 @@ def cell_face_neighbors(self, cell, face): | |
| return nbrs | ||
|
|
||
| def cell_neighbors(self, cell): | ||
| """Find the neighbors of a given cell. | ||
| """Find the neighbors of a given cell based on common vertices. | ||
|
||
|
|
||
| Parameters | ||
| ---------- | ||
|
|
@@ -4049,11 +4075,20 @@ def cell_neighbors(self, cell): | |
| -------- | ||
| :meth:`cell_face_neighbors` | ||
| """ | ||
|
|
||
| cells_vertices = {} | ||
| for cell_ in self.cells(): | ||
| vertices_of_a_cell = [] | ||
| for vertex in self.cell_vertices(cell_): | ||
| vertices_of_a_cell.append(tuple(self.vertex_coordinates(vertex))) | ||
|
|
||
| cells_vertices[cell_] = set(vertices_of_a_cell) | ||
|
|
||
| nbrs = [] | ||
| for face in self.cell_faces(cell): | ||
| for nbr in self.face_cells(face): | ||
| if nbr != cell: | ||
| nbrs.append(nbr) | ||
| for key in cells_vertices.keys(): | ||
| if key != cell and len((cells_vertices[cell] & cells_vertices[key])) > 2: | ||
| nbrs.append(key) | ||
|
|
||
| return list(set(nbrs)) | ||
|
|
||
| def is_cell_on_boundary(self, cell): | ||
|
|
||
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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