Skip to content

Commit cb0b986

Browse files
authored
Merge pull request #1084 from compas-dev/fix-halfedge-before-on-boundary
Fix bug in Mesh.halfedge_before
2 parents fb36991 + e02c3d7 commit cb0b986

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3636
* Fixed bug in `_core.tangent` where the Circle's Plane was accessed instead of the centre.
3737
* Fixed the `test_tangent` to work with a properly defined circle
3838
* `RhinoBrep` serialization works now with surface types other than NURBS.
39+
* Fixed bug in finding halfedge before a given halfedge if that halfedge is on the boundary (`Mesh.halfedge_before`).
3940

4041
### Removed
4142

src/compas/datastructures/halfedge/halfedge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2607,7 +2607,7 @@ def halfedge_after(self, u, v):
26072607
if face is not None:
26082608
w = self.face_vertex_after(face, v)
26092609
return v, w
2610-
nbrs = self.vertex_neighbors(u, ordered=True)
2610+
nbrs = self.vertex_neighbors(v, ordered=True)
26112611
w = nbrs[0]
26122612
return v, w
26132613

tests/compas/datastructures/test_halfedge.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,33 @@ def test_del_edge_attribute_in_view(mesh, edge_key):
269269
attrs["foo"]
270270

271271

272+
# ==============================================================================
273+
# Tests - Halfedges Before/After
274+
# ==============================================================================
275+
276+
277+
def test_halfedge_after_on_boundary(grid):
278+
corners = list(grid.vertices_where(vertex_degree=2))
279+
corner = corners[0]
280+
nbrs = grid.vertex_neighbors(corner, ordered=True)
281+
nbr = nbrs[-1]
282+
edge = grid.halfedge_after(nbr, corner)
283+
assert edge[0] == corner
284+
assert grid.is_edge_on_boundary(*edge)
285+
assert grid.halfedge_face(*edge) is None
286+
287+
288+
def test_halfedge_before_on_boundary(grid):
289+
corners = list(grid.vertices_where(vertex_degree=2))
290+
corner = corners[0]
291+
nbrs = grid.vertex_neighbors(corner, ordered=True)
292+
nbr = nbrs[0]
293+
edge = grid.halfedge_before(corner, nbr)
294+
assert edge[1] == corner
295+
assert grid.is_edge_on_boundary(*edge)
296+
assert grid.halfedge_face(*edge) is None
297+
298+
272299
# ==============================================================================
273300
# Tests - Loops & Strip
274301
# ==============================================================================

0 commit comments

Comments
 (0)