Skip to content

Commit

Permalink
add unit test for edge split method
Browse files Browse the repository at this point in the history
  • Loading branch information
tomate44 authored and wwmayer committed May 1, 2024
1 parent 2a07bce commit c7c07f2
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/Mod/Part/parttests/BRep_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def testProject(self):
This is a unit test for PR #13507
"""
num = 18
alt = [0,1] * num
alt = [0, 1] * num
pts = [App.Vector(i, alt[i], 0) for i in range(num)]

bsc = Part.BSplineCurve()
Expand All @@ -24,3 +24,26 @@ def testProject(self):
self.assertFalse(proj.isNull())
self.assertEqual(len(proj.Edges), 1)

def testEdgeSplitFace(self):
coords2d = [(0.5, -0.5), (1.0, -0.5), (1.0, 0.5), (0.5, 0.5)]
pts2d = [App.Base.Vector2d(u, v) for u, v in coords2d]
pts2d.append(pts2d[0])

sphere = Part.Sphere()
edges = []
for i in range(1, len(pts2d)):
ls = Part.Geom2d.Line2dSegment(pts2d[i - 1], pts2d[i])
edges.append(ls.toShape(sphere))

split = edges[0].split(0.25)
new_edges = split.Edges + edges[1:]
wire = Part.Wire(new_edges)
face = Part.Face(wire, "Part::FaceMakerSimple")
self.assertTrue(face.isValid())

def testEdgeSplitReplace(self):
cyl = Part.makeCylinder(2, 5)
e1 = cyl.Edge3
split = e1.split([1.0, 2.0])
newcyl = cyl.replaceShape([(e1, split), (cyl.Vertex2, split.Vertex1)])
self.assertTrue(newcyl.isValid())

0 comments on commit c7c07f2

Please sign in to comment.