1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
# Copyright (c) 2018-2019 Manfred Moitzi
# License: MIT License
import pytest
import ezdxf
from ezdxf.render import R12Spline
CONTROL_POINTS = [
(8.55, 2.96),
(8.55, -0.03),
(2.75, -0.03),
(2.76, 3.05),
(4.29, 1.78),
(6.79, 3.05),
]
@pytest.fixture(scope="module")
def msp():
return ezdxf.new("R12").modelspace()
def test_r12_quadratic_spline(msp):
spline = R12Spline(CONTROL_POINTS, degree=2, closed=False)
polyline = spline.render(msp, segments=40)
assert polyline.dxftype() == "POLYLINE"
assert polyline.dxf.layer == "0"
assert len(polyline) == 41 + len(CONTROL_POINTS)
assert polyline.is_closed is False
def test_r12_cubic_spline(msp):
spline = R12Spline(CONTROL_POINTS, degree=3, closed=False)
polyline = spline.render(msp, segments=40)
assert polyline.dxftype() == "POLYLINE"
assert polyline.dxf.layer == "0"
assert len(polyline) == 41 + len(CONTROL_POINTS)
assert polyline.is_closed is False
def test_r12_cubic_spline_closed(msp):
spline = R12Spline(CONTROL_POINTS, degree=3, closed=True)
polyline = spline.render(msp, segments=40)
assert polyline.dxftype() == "POLYLINE"
assert polyline.dxf.layer == "0"
assert len(polyline) == 41 + len(CONTROL_POINTS)
assert polyline.is_closed is True
|