Skip to content

Commit 4b47f30

Browse files
committed
fix seg fault
1 parent 4aa3fae commit 4b47f30

File tree

5 files changed

+10
-1
lines changed

5 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4343
### Changed
4444

4545
* Fixed bug in propagation of linear and angular deflection between discretisation functions `OCCBrep.to_viewmesh` and `OCCBrep.to_tesselation`.
46+
* Fixed potential causes of segmentation fault (`OCCBrepVertex.is_same`, `OCCBrepEdge.is_same`, `OCCBrepLoop.is_same`, `OCCBrepFace.is_same`).
4647

4748
### Removed
4849

src/compas_occ/brep/brepedge.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ def is_same(self, other: "OCCBrepEdge") -> bool:
122122
``True`` if the edges are the same, ``False`` otherwise.
123123
124124
"""
125+
if not isinstance(other, OCCBrepEdge):
126+
return False
125127
return self.occ_edge.IsSame(other.occ_edge)
126128

127129
def is_equal(self, other: "OCCBrepEdge") -> bool:

src/compas_occ/brep/brepface.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ def is_same(self, other: "OCCBrepFace") -> bool:
183183
``True`` if the faces are the same, ``False`` otherwise.
184184
185185
"""
186+
if not isinstance(other, OCCBrepFace):
187+
return False
186188
return self.occ_face.IsSame(other.occ_face)
187189

188190
def is_equal(self, other: "OCCBrepFace") -> bool:

src/compas_occ/brep/breploop.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def is_same(self, other: "OCCBrepLoop") -> bool:
8181
``True`` if the loops are the same, ``False`` otherwise.
8282
8383
"""
84+
if not isinstance(other, OCCBrepLoop):
85+
return False
8486
return self.occ_wire.IsSame(other.occ_wire)
8587

8688
def is_equal(self, other: "OCCBrepLoop") -> bool:
@@ -206,7 +208,7 @@ def from_polygon(cls, polygon: Polygon) -> "OCCBrepLoop":
206208
207209
"""
208210
edges = []
209-
for a, b in pairwise(polygon.points):
211+
for a, b in pairwise(polygon.points + polygon.points[:1]):
210212
edge = OCCBrepEdge.from_point_point(a, b)
211213
edges.append(edge)
212214
return cls(wire_from_edges(edges))

src/compas_occ/brep/brepvertex.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def is_same(self, other: "OCCBrepVertex") -> bool:
5555
``True`` if the vertices are the same, ``False`` otherwise.
5656
5757
"""
58+
if not isinstance(other, OCCBrepVertex):
59+
return False
5860
return self.occ_vertex.IsSame(other.occ_vertex)
5961

6062
def is_equal(self, other: "OCCBrepVertex") -> bool:

0 commit comments

Comments
 (0)