Skip to content

Commit

Permalink
tests for the special cases: rectangle and square
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Elistratov committed Dec 11, 2020
1 parent 969cbb4 commit 7fd3618
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests_special/test_rectangle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import pytest
from mathutils import Vector
from bpypolyskel import bpypolyskel


verts = [
Vector((0.0, 10.0, 0.0)),
Vector((0.0, 0.0, 0.0)),
Vector((20.0, 0.0, 0.0)),
Vector((20.0, 10.0, 0.0))
]

unitVectors = None

holesInfo = None
firstVertIndex = 0
numPolygonVerts = 4
faces = []


@pytest.mark.dependency()
@pytest.mark.timeout(10)
def test_polygonize():
global faces
faces = bpypolyskel.polygonize(verts, firstVertIndex, numPolygonVerts, holesInfo, 0.0, 0.5, None, unitVectors)


@pytest.mark.dependency(depends=["test_polygonize"])
def test_numVertsInFace():
for face in faces:
assert len(face) >= 3


@pytest.mark.dependency(depends=["test_polygonize"])
def test_duplication():
for face in faces:
assert len(face) == len(set(face))


def plot_chart():
import matplotlib.pyplot as plt

global faces
faces = bpypolyskel.polygonize(verts, firstVertIndex, numPolygonVerts, holesInfo, 0.0, 0.5, faces, unitVectors)

# plot the hipped roof in 3D
fig = plt.figure()
ax = fig.gca(projection='3d')
for face in faces:
for edge in zip(face, face[1:] + face[:1]):
p1 = verts[edge[0]]
p2 = verts[edge[1]]
ax.plot([p1.x,p2.x],[p1.y,p2.y],[p1.z,p2.z],'k')
plt.show()

#plot_chart()
56 changes: 56 additions & 0 deletions tests_special/test_square.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import pytest
from mathutils import Vector
from bpypolyskel import bpypolyskel


verts = [
Vector((0.0, 10.0, 0.0)),
Vector((0.0, 0.0, 0.0)),
Vector((10.0, 0.0, 0.0)),
Vector((10.0, 10.0, 0.0))
]

unitVectors = None

holesInfo = None
firstVertIndex = 0
numPolygonVerts = 4
faces = []


@pytest.mark.dependency()
@pytest.mark.timeout(10)
def test_polygonize():
global faces
faces = bpypolyskel.polygonize(verts, firstVertIndex, numPolygonVerts, holesInfo, 0.0, 0.5, None, unitVectors)


@pytest.mark.dependency(depends=["test_polygonize"])
def test_numVertsInFace():
for face in faces:
assert len(face) >= 3


@pytest.mark.dependency(depends=["test_polygonize"])
def test_duplication():
for face in faces:
assert len(face) == len(set(face))


def plot_chart():
import matplotlib.pyplot as plt

global faces
faces = bpypolyskel.polygonize(verts, firstVertIndex, numPolygonVerts, holesInfo, 0.0, 0.5, faces, unitVectors)

# plot the hipped roof in 3D
fig = plt.figure()
ax = fig.gca(projection='3d')
for face in faces:
for edge in zip(face, face[1:] + face[:1]):
p1 = verts[edge[0]]
p2 = verts[edge[1]]
ax.plot([p1.x,p2.x],[p1.y,p2.y],[p1.z,p2.z],'k')
plt.show()

#plot_chart()

0 comments on commit 7fd3618

Please sign in to comment.