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_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 edge_path(): ep = EdgePath() ep.add_line( (70.79594401862802, 38.81021154906707), (61.49705431814723, 38.81021154906707), ) ep.add_ellipse( center=(49.64089977339618, 36.43095770602131), major_axis=(16.69099826506408, 6.96203799241026), ratio=0.173450304570581, start_angle=348.7055398636587, end_angle=472.8737032507014, ccw=True, ) ep.add_line( (47.21845383585098, 38.81021154906707), (32.00406637283394, 38.81021154906707), ) ep.add_arc( center=(27.23255482392775, 37.32841621274949), radius=4.996302620946588, start_angle=17.25220809399113, end_angle=162.7477919060089, ccw=True, ) ep.add_line( (22.46104327502155, 38.81021154906707), (15.94617981131185, 38.81021154906707), ) ep.add_line( (15.94617981131185, 38.81021154906707), (15.94617981131185, 17.88970141145027), ) ep.add_line( (15.94617981131185, 17.88970141145027), (22.07965616927404, 17.88970141145026), ) ep.add_spline( control_points=[ (22.07965616927404, 17.88970141145027), (23.44151487263461, 19.56130038573538), (28.24116384863678, 24.26061858002495), (35.32501805918895, 14.41241846270862), (46.6153937930182, 11.75667640124574), (47.53794331191931, 23.11460620899234), (51.8076764251228, 12.06821526039212), (60.37405963053161, 14.60131364832752), (63.71393926002737, 20.24075830571701), (67.36423789268184, 19.07462271006858), (68.72358721334537, 17.88970141145026), ], knot_values=[ 2.825276861104652, 2.825276861104652, 2.825276861104652, 2.825276861104652, 8.585563484895022, 22.93271064560279, 29.77376253023298, 35.89697937194972, 41.26107011625705, 51.23489795733507, 54.82267350174899, 59.57512798605262, 59.57512798605262, 59.57512798605262, 59.57512798605262, ], degree=3, periodic=0, ) ep.add_line( (68.72358721334535, 17.88970141145027), (70.79594401862802, 17.88970141145027), ) ep.add_line( (70.79594401862802, 17.88970141145027), (70.79594401862802, 38.81021154906707), ) return ep