/
test_visual_surface.py
81 lines (51 loc) · 1.72 KB
/
test_visual_surface.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import k3d
import numpy as np
import pytest
from .plot_compare import *
def test_surface():
prepare()
Nx = 240
Ny = 480
xmin, xmax = -3, 3
ymin, ymax = -0, 3
x = np.linspace(xmin, xmax, Nx)
y = np.linspace(ymin, ymax, Ny)
x, y = np.meshgrid(x, y)
heights = np.sin(x ** 2 + y ** 2).astype(np.float32)
surface = k3d.surface(heights, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax)
pytest.plot += surface
compare('surface')
surface.color = 0x00ffff
compare('surface_dynamic_color')
def test_surface_attribute():
prepare()
Nx = 240
Ny = 480
xmin, xmax = -3, 3
ymin, ymax = -0, 3
x = np.linspace(xmin, xmax, Nx)
y = np.linspace(ymin, ymax, Ny)
x, y = np.meshgrid(x, y)
heights = np.sin(x ** 2 + y ** 2).astype(np.float32)
surface = k3d.surface(heights, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, attribute=heights,
transform=k3d.transform(rotation=[np.pi / 4, 1, 0, 0]))
pytest.plot += surface
compare('surface_attribute')
def test_surface_attribute_low():
prepare()
Nx = 24
Ny = 48
xmin, xmax = -3, 3
ymin, ymax = -0, 3
x = np.linspace(xmin, xmax, Nx)
y = np.linspace(ymin, ymax, Ny)
x, y = np.meshgrid(x, y)
heights = np.sin(x ** 2 + y ** 2).astype(np.float32)
surface = k3d.surface(heights, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
attribute=heights, transform=k3d.transform(rotation=[np.pi / 4, 1, 0, 0]))
pytest.plot += surface
compare('surface_attribute_low')
surface.flat_shading = False
compare('surface_attribute_low_dynamic_smooth')
surface.wireframe = True
compare('surface_attribute_low_dynamic_wireframe')