|
| 1 | +import pytest |
| 2 | +import json |
| 3 | +import compas |
| 4 | +from random import random |
| 5 | +from compas.geometry import Point |
| 6 | +from compas.geometry import Polyhedron |
| 7 | +from compas.itertools import pairwise |
| 8 | + |
| 9 | + |
| 10 | +def test_polyhedron(): |
| 11 | + vertices = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]] |
| 12 | + faces = [[0, 1, 2, 3]] |
| 13 | + name = "Test Polyhedron" |
| 14 | + polyhedron = Polyhedron(vertices, faces, name) |
| 15 | + |
| 16 | + assert polyhedron.vertices == vertices |
| 17 | + assert polyhedron.faces == faces |
| 18 | + assert polyhedron.name == name |
| 19 | + assert polyhedron.points == vertices |
| 20 | + assert polyhedron.lines == [(a, b) for a, b in pairwise(vertices + vertices[:1])] |
| 21 | + assert polyhedron.points[0] == vertices[0] |
| 22 | + assert polyhedron.points[-1] != polyhedron.points[0] |
| 23 | + |
| 24 | + |
| 25 | +def test_polyhedron_str(): |
| 26 | + vertices = [[0, 0, 0], [1, 0, 0], [1, 1, 0]] |
| 27 | + faces = [[0, 1, 2]] |
| 28 | + polyhedron = Polyhedron(vertices, faces) |
| 29 | + |
| 30 | + assert str(polyhedron) == "Polyhedron(vertices=[['0.000', '0.000', '0.000'], ['1.000', '0.000', '0.000'], ['1.000', '1.000', '0.000']], faces=[[0, 1, 2]])" |
0 commit comments