File: test_544_revcloud.py

package info (click to toggle)
ezdxf 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 104,528 kB
  • sloc: python: 182,341; makefile: 116; lisp: 20; ansic: 4
file content (43 lines) | stat: -rw-r--r-- 1,221 bytes parent folder | download
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
# Copyright (c) 2024, Manfred Moitzi
# License: MIT License
import pytest

import ezdxf
from ezdxf import revcloud


def test_create_revcloud():
    points = [(0, 0), (1, 0), (1, 1), (0, 1)]
    lw_points = revcloud.points(points, segment_length=0.1, bulge=0.5)
    assert len(lw_points) == 40


@pytest.mark.parametrize(
    "points", [[], [(0, 0)], [(0, 0), (0, 0)], [(0, 0), (1, 0), (0, 0)]]
)
def test_too_few_points_raises_exception(points):
    with pytest.raises(ValueError):
        revcloud.points(points, segment_length=0.1)


def test_too_small_segment_length_raises_exception():
    with pytest.raises(ValueError):
        revcloud.points([(0, 0), (1, 0), (1, 1), (0, 1)], segment_length=0)


def test_add_entity():
    doc = ezdxf.new()
    msp = doc.modelspace()
    # counter-clockwise oriented revision cloud:
    lwp = revcloud.add_entity(msp, [(0, 0), (1, 0), (1, 1), (0, 1)], 0.1)

    assert doc.appids.has_entry(revcloud.REVCLOUD_PROPS)
    assert revcloud.is_revcloud(lwp) is True

    # clockwise oriented revision cloud:
    lwp = revcloud.add_entity(msp, [(0, 0), (0, 1), (1, 1), (1, 0)], 0.1)
    assert revcloud.is_revcloud(lwp) is True


if __name__ == "__main__":
    pytest.main([__file__])