def test_from_complex_edge_path(self, edge_path): path = converter.from_hatch_edge_path(edge_path, ocs=OCS((0, 0, -1)), elevation=4) assert path.has_sub_paths is False assert len(path) == 19 assert all(math.isclose(v.z, -4) for v in path.control_vertices())
def test_edge_path_open_loop(): ep = EdgePath() # open segments do not create a path ep.add_line(A, B) ep.add_line(B, C) ep.add_line(C, D) path = converter.from_hatch_edge_path(ep) assert bool(path) is False, "expected an open loop"
def test_spline_edge(self): ep = EdgePath() ep.add_spline(fit_points=[(10, 5), (8, 5), (6, 8), (5, 10)]) ep.add_line((5, 10), (10, 5)) path = converter.from_hatch_edge_path(ep, ocs=OCS((0, 0, -1)), elevation=4) assert len(path) > 2 assert all(math.isclose(v.z, -4) for v in path.control_vertices())
def test_edge_path_closed_loop(e0, e1, e2, e3): ep = EdgePath() ep.add_line(e0[0], e0[1]) ep.add_line(e1[0], e1[1]) ep.add_line(e2[0], e2[1]) ep.add_line(e3[0], e3[1]) path = converter.from_hatch_edge_path(ep) assert len(list(path.sub_paths())) == 1, "expected one closed loop" assert len(list(path.control_vertices())) == 5 assert path.is_closed is True, "expected a closed loop"
def test_line_edge(self): ep = EdgePath() ep.add_line(A, B) ep.add_line(B, C) ep.add_line(C, D) ep.add_line(D, A) path = converter.from_hatch_edge_path(ep, ocs=OCS((0, 0, -1)), elevation=4) assert len(list(path.sub_paths())) == 1, "expected one closed loop" assert len(list(path.control_vertices())) == 5 assert all(math.isclose(v.z, -4) for v in path.control_vertices()) assert path.is_closed is True, "expected a closed loop"
def test_arc_edge(self): ep = EdgePath() ep.add_arc( center=(5.0, 5.0), radius=5.0, start_angle=0, end_angle=90, ccw=True, ) ep.add_line((5, 10), (10, 5)) path = converter.from_hatch_edge_path(ep, ocs=OCS((0, 0, -1)), elevation=4) assert len(path) == 2 assert all(math.isclose(v.z, -4) for v in path.control_vertices())
def test_from_edge_path_with_two_closed_loops(): ep = EdgePath() # 1st loop: closed segments ep.add_line((0, 0), (0, 1)) ep.add_line((0, 1), (1, 1)) ep.add_line((1, 1), (0, 1)) ep.add_line((0, 1), (0, 0)) # 2nd loop: closed segments ep.add_line((2, 0), (3, 0)) ep.add_line((3, 0), (3, 1)) ep.add_line((3, 1), (2, 1)) ep.add_line((2, 1), (2, 0)) path = converter.from_hatch_edge_path(ep) assert path.has_sub_paths is True, "should return a multi-path" assert len(list(path.sub_paths())) == 2, "expected two sub paths"
def test_from_edge_path(edge_path): path = converter.from_hatch_edge_path(edge_path) assert len(path) == 19
def test_from_edge_path(edge_path): path = converter.from_hatch_edge_path(edge_path) assert path.has_sub_paths is False assert len(path) == 19