コード例 #1
0
def test_upright_polyline(factory):
    polyline = factory()
    p0 = path.make_path(polyline)
    assert p0.has_curves is True

    upright(polyline)
    assert polyline.dxf.extrusion.isclose(Z_AXIS)
    p1 = path.make_path(polyline)
    # vertex order do not change:
    assert path.have_close_control_vertices(p0, p1)
コード例 #2
0
def test_upright_hatch_with_edge_path(all_edge_types_hatch):
    hatch = all_edge_types_hatch
    hatch.dxf.elevation = Vec3(0, 0, 4)
    hatch.dxf.extrusion = Vec3(0, 0, -1)
    assert hatch.dxf.extrusion.isclose(-Z_AXIS)

    p0 = path.make_path(hatch)
    assert p0.has_curves is True

    upright(hatch)
    assert hatch.dxf.extrusion.isclose(Z_AXIS)
    p1 = path.make_path(hatch)
    assert path.have_close_control_vertices(p0, p1)
コード例 #3
0
def test_upright_hatch_with_polyline_path():
    hatch = Hatch.new(dxfattribs={
        "elevation": (0, 0, 4),
        "extrusion": (0, 0, -1),
    })
    hatch.paths.add_polyline_path([(x, y, b)
                                   for x, y, s, e, b in POLYLINE_POINTS])
    p0 = path.make_path(hatch)
    assert p0.has_curves is True

    upright(hatch)
    assert hatch.dxf.extrusion.isclose(Z_AXIS)
    p1 = path.make_path(hatch)
    assert path.have_close_control_vertices(p0, p1)
コード例 #4
0
def test_wcs_mirror_transformations_for_all_edge_types(
    sx, sy, all_edge_types_hatch
):
    hatch = all_edge_types_hatch
    src_path = make_path(hatch)
    assert len(src_path) > 1, "expected non empty path"

    m = Matrix44.scale(sx, sy, 1)
    transformed_hatch = transformed_copy(hatch, m)

    expected_path = src_path.transform(m)
    path_of_transformed_hatch = make_path(transformed_hatch)
    assert (
        have_close_control_vertices(path_of_transformed_hatch, expected_path)
        is True
    )
コード例 #5
0
def test_upright_quadrilaterals(cls):
    solid = cls.new(
        dxfattribs={
            "vtx0": (1, 1),
            "vtx1": (2, 1),
            "vtx2": (2, 2),
            "vtx3": (1, 2),
            "extrusion": (0, 0, -1),
        })
    p0 = path.make_path(solid)
    assert len(p0) == 4

    upright(solid)
    assert solid.dxf.extrusion.isclose(Z_AXIS)
    p1 = path.make_path(solid)
    # same vertex order as source entity
    assert path.have_close_control_vertices(p0, p1)
コード例 #6
0
def test_upright_ellipse():
    ellipse = Ellipse.new(
        dxfattribs={
            "center": (5, 5, 5),
            "major_axis": (5, 0, 0),
            "ratio": 0.5,
            "start_param": 0.5,
            "end_param": 1.5,
            "extrusion": (0, 0, -1),
        })
    p0 = path.make_path(ellipse)
    assert p0.has_curves is True

    upright(ellipse)
    assert ellipse.dxf.extrusion.isclose(Z_AXIS)
    p1 = path.make_path(ellipse)
    # has reversed vertex order of source entity:
    assert path.have_close_control_vertices(p0, p1.reversed())