Skip to content

Commit ec467e4

Browse files
committed
padding fix
1 parent 747b303 commit ec467e4

File tree

13 files changed

+211
-139
lines changed

13 files changed

+211
-139
lines changed

examples/basic/voronoi1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
points = np.random.random((500, 2))
66

77
pts = Points(points).subsample(0.02) # impose a min distance of 2%
8-
vor = voronoi(pts, pad=0.01)
8+
vor = voronoi(pts, padding=0.01)
99
vor.cmap('Set3', "VoronoiID", on='cells').wireframe(False)
1010

1111
lab = vor.labels("VoronoiID", cells=True, scale=0.01)

examples/notebooks/align1.ipynb

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": 4,
66
"metadata": {
77
"scrolled": true
88
},
@@ -11,31 +11,22 @@
1111
"name": "stdout",
1212
"output_type": "stream",
1313
"text": [
14-
"\u001b[1m\u001b[32;1mave. squared distance = 43.20515185350062\u001b[0m\n"
14+
"ave. squared distance = 43.20515185350062\n"
1515
]
1616
},
1717
{
1818
"data": {
19-
"application/vnd.jupyter.widget-view+json": {
20-
"model_id": "d0e95ecc66c24e2faaa347a292b971d8",
21-
"version_major": 2,
22-
"version_minor": 0
23-
},
2419
"text/plain": [
25-
"Plot(antialias=True, axes=['x', 'y', 'z'], axes_helper=1.0, background_color=16777215, camera=[2, -3, 0.2, 0.0…"
20+
"<vedo.plotter.Plotter at 0x7f3a5a98dfa0>"
2621
]
2722
},
23+
"execution_count": 4,
2824
"metadata": {},
29-
"output_type": "display_data"
25+
"output_type": "execute_result"
3026
}
3127
],
3228
"source": [
33-
"\"\"\"\n",
34-
"Align 2 shapes and for each vertex of the first draw\n",
35-
"and arrow to the closest point of the second.\n",
36-
"The source transformation is accessible with getTransform()\n",
37-
"rigid=True doesn't allow scaling\n",
38-
"\"\"\"\n",
29+
"\"\"\"Align 2 shapes: a simple line to a polygonal mesh\"\"\"\n",
3930
"from vedo import *\n",
4031
"\n",
4132
"limb = Mesh(dataurl + \"270.vtk\").alpha(0.5)\n",
@@ -44,7 +35,7 @@
4435
"# make a clone copy of the rim line and align it to the surface\n",
4536
"arim = rim.clone().alignTo(limb, rigid=True).c(\"g\").ps(20)\n",
4637
"\n",
47-
"plt = Plotter(backend='k3d') # or panel, k3d, itk, ipyvtk, or None\n",
38+
"plt = Plotter(backend=None) # or k3d, itk, ipyvtk, or None\n",
4839
"plt += [limb, rim, arim]\n",
4940
"\n",
5041
"# compute how well it fits\n",
@@ -59,7 +50,7 @@
5950
},
6051
{
6152
"cell_type": "code",
62-
"execution_count": null,
53+
"execution_count": 5,
6354
"metadata": {},
6455
"outputs": [],
6556
"source": [
@@ -83,7 +74,7 @@
8374
"name": "python",
8475
"nbconvert_exporter": "python",
8576
"pygments_lexer": "ipython3",
86-
"version": "3.9.10"
77+
"version": "3.9.7"
8778
}
8879
},
8980
"nbformat": 4,

examples/notebooks/distance2mesh.ipynb

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,85 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 2,
66
"metadata": {},
7-
"outputs": [],
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"\u001b[32;1m_________________________________________________________________\u001b[0m\n",
13+
"\u001b[2m\u001b[7m\u001b[1m\u001b[32;1mMesh/Points\u001b[0m \n",
14+
"\u001b[1m\u001b[32;1m name: \u001b[0m\u001b[32;1mSphere\u001b[0m\n",
15+
"\u001b[1m\u001b[32;1m points: \u001b[0m\u001b[32;1m1058\u001b[0m\n",
16+
"\u001b[1m\u001b[32;1m cells: \u001b[0m\u001b[32;1m2112\u001b[0m\n",
17+
"\u001b[1m\u001b[32;1m polygons: \u001b[0m\u001b[32;1m2112\u001b[0m\n",
18+
"\u001b[1m\u001b[32;1m position: \u001b[0m\u001b[32;1m(0.0, 0.0, 0.0)\u001b[0m\n",
19+
"\u001b[1m\u001b[32;1m scale: \u001b[0m\u001b[32;1m(1.00, 1.00, 1.00)\u001b[0m\n",
20+
"\u001b[1m\u001b[32;1m center of mass: \u001b[0m\u001b[32;1m(0, 0, 0)\u001b[0m\n",
21+
"\u001b[1m\u001b[32;1m average size: \u001b[0m\u001b[32;1m1.00000\u001b[0m\n",
22+
"\u001b[1m\u001b[32;1m diagonal size: \u001b[0m\u001b[32;1m3.45872\u001b[0m\n",
23+
"\u001b[1m\u001b[32;1m bounds: \u001b[0m\u001b[32;1mx=(-0.998, 0.998)\u001b[0m\u001b[32;1m y=(-0.998, 0.998)\u001b[0m\u001b[32;1m z=(-1.00, 1.00)\u001b[0m\n",
24+
"\u001b[1m\u001b[32;1m scalar mode:\u001b[0m \u001b[32;1mDefault coloring = Default\u001b[0m\n",
25+
"\u001b[1m\u001b[32;1m active array: \u001b[0m\u001b[32;1mDistance (point data) \u001b[0m\n",
26+
"\u001b[1m\u001b[32;1m point data: \u001b[0m\u001b[32;1mname=Normals (3 FLOAT, np.float32),\u001b[0m\u001b[32;1m range=(-0.998,0.998)\u001b[0m\n",
27+
"\u001b[1m\u001b[32;1m point data: \u001b[0m\u001b[32;1mname=Distance (1 DOUBLE, np.float64),\u001b[0m\u001b[32;1m range=(1.50,3.50)\u001b[0m\n",
28+
"[2.54950976 2.54950976 2.41422468 ... 2.14595456 2.27999987 2.41536531]\n"
29+
]
30+
},
31+
{
32+
"data": {
33+
"application/vnd.jupyter.widget-view+json": {
34+
"model_id": "b796eb2c20d146398cdebb41c8ac8dae",
35+
"version_major": 2,
36+
"version_minor": 0
37+
},
38+
"text/plain": [
39+
"ViewInteractiveWidget(height=960, layout=Layout(height='auto', width='100%'), width=960)"
40+
]
41+
},
42+
"metadata": {},
43+
"output_type": "display_data"
44+
}
45+
],
846
"source": [
947
"\"\"\"Compute the (signed) distance from one mesh to another.\"\"\"\n",
1048
"\n",
1149
"from vedo import *\n",
1250
"\n",
1351
"s1 = Sphere().flat() # flat shading\n",
14-
"s2 = Cube(pos=(1,0,0), c='white', alpha=0.2)\n",
52+
"s2 = Cube(pos=(3,0,0), c='white', alpha=0.2)\n",
1553
"\n",
1654
"# add scalars to the sphere that correspond to their distance from the cube\n",
17-
"s1.distanceTo(s2, signed=True, invert=False)\n",
55+
"s1.distanceTo(s2, signed=True, invert=False).addScalarBar()\n",
1856
"\n",
19-
"#s1.printInfo()\n",
20-
"#print(s1.getPointArray(\"Distance\"))\n",
57+
"s1.print()\n",
58+
"print(s1.pointdata[\"Distance\"])\n",
2159
"\n",
2260
"plt = show(s1, s2, viewup='z', axes=1, backend='ipyvtk')\n",
2361
"plt"
2462
]
2563
},
2664
{
2765
"cell_type": "code",
28-
"execution_count": null,
66+
"execution_count": 3,
2967
"metadata": {},
3068
"outputs": [],
3169
"source": [
3270
"plt.close()"
3371
]
72+
},
73+
{
74+
"cell_type": "code",
75+
"execution_count": null,
76+
"metadata": {},
77+
"outputs": [],
78+
"source": []
3479
}
3580
],
3681
"metadata": {
3782
"kernelspec": {
38-
"display_name": "Python 3",
83+
"display_name": "Python 3 (ipykernel)",
3984
"language": "python",
4085
"name": "python3"
4186
},
@@ -49,7 +94,7 @@
4994
"name": "python",
5095
"nbconvert_exporter": "python",
5196
"pygments_lexer": "ipython3",
52-
"version": "3.8.8"
97+
"version": "3.9.7"
5398
}
5499
},
55100
"nbformat": 4,

examples/notebooks/legosurface.ipynb

Lines changed: 26 additions & 26 deletions
Large diffs are not rendered by default.

examples/notebooks/numpy2volume.ipynb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,35 @@
1414
},
1515
{
1616
"data": {
17+
"application/vnd.jupyter.widget-view+json": {
18+
"model_id": "485788b1c34a4c9a9fb0f4a6b0633217",
19+
"version_major": 2,
20+
"version_minor": 0
21+
},
1722
"text/plain": [
18-
"<vedo.plotter.Plotter at 0x7f459c235850>"
23+
"ViewInteractiveWidget(height=960, layout=Layout(height='auto', width='100%'), width=960)"
1924
]
2025
},
21-
"execution_count": 1,
2226
"metadata": {},
23-
"output_type": "execute_result"
27+
"output_type": "display_data"
2428
}
2529
],
2630
"source": [
2731
"# Make a Volume from a numpy object\n",
2832
"#\n",
2933
"import numpy as np\n",
3034
"from vedo import *\n",
31-
"#embedWindow('itkwidgets') # backends are: itkwidgets, k3d or False\n",
3235
"\n",
3336
"X, Y, Z = np.mgrid[:30, :30, :30]\n",
37+
"\n",
3438
"# scaled distance from the center at (15, 15, 15)\n",
3539
"scalar_field = ((X-15)**2 + (Y-15)**2 + (Z-15)**2)/225/3\n",
3640
"print('scalar min, max =', np.min(scalar_field), np.max(scalar_field))\n",
3741
"\n",
3842
"vol = Volume(scalar_field)\n",
3943
"lego = vol.legosurface(vmin=.3, vmax=.6)\n",
4044
"\n",
41-
"plt = show(lego, axes=1, backend=None)\n",
45+
"plt = show(lego, axes=1, backend='ipyvtk')\n",
4246
"plt"
4347
]
4448
},
@@ -61,7 +65,7 @@
6165
],
6266
"metadata": {
6367
"kernelspec": {
64-
"display_name": "Python 3",
68+
"display_name": "Python 3 (ipykernel)",
6569
"language": "python",
6670
"name": "python3"
6771
},
@@ -75,7 +79,7 @@
7579
"name": "python",
7680
"nbconvert_exporter": "python",
7781
"pygments_lexer": "ipython3",
78-
"version": "3.8.8"
82+
"version": "3.9.7"
7983
}
8084
},
8185
"nbformat": 4,

examples/notebooks/pca.ipynb

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,44 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 1,
66
"metadata": {},
7-
"outputs": [],
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"\u001b[1m\u001b[32;1minside points # 2502\u001b[0m\n",
13+
"\u001b[1m\u001b[31;1moutside points # 2498\u001b[0m\n",
14+
"\u001b[1masphericity: 0.5282829679821651\u001b[0m\n"
15+
]
16+
},
17+
{
18+
"data": {
19+
"application/vnd.jupyter.widget-view+json": {
20+
"model_id": "518be2799b674814b33da00638af9079",
21+
"version_major": 2,
22+
"version_minor": 0
23+
},
24+
"text/plain": [
25+
"ViewInteractiveWidget(layout=Layout(height='auto', width='100%'), width=1000)"
26+
]
27+
},
28+
"metadata": {},
29+
"output_type": "display_data"
30+
}
31+
],
832
"source": [
933
"\"\"\"\n",
1034
"Draw the PCA (Principal Component Analysis) ellipsoid that contains\n",
11-
"50% of a cloud of Points, then check if points are inside the surface.\n",
12-
"Extra info is stored in object.info['sphericity'], 'va', 'vb', 'vc'.\n",
35+
"50% of a cloud of a pointcloud, then check how many points are inside the surface.\n",
1336
"\"\"\"\n",
1437
"from vedo import *\n",
1538
"import numpy as np\n",
1639
"\n",
17-
"plt = Plotter(backend='ipyvtk')\n",
40+
"plt = Plotter(backend='ipyvtk', size=(1000,500))\n",
1841
"\n",
19-
"pts = np.random.randn(500, 3) # random gaussian point cloud\n",
42+
"pts = np.random.randn(5000, 3) * [3,2,1]# random gaussian point cloud\n",
2043
"\n",
2144
"elli = pcaEllipsoid(pts, pvalue=0.5) # group of [ellipse, 3 axes]\n",
2245
"plt += elli\n",
@@ -28,13 +51,13 @@
2851
"\n",
2952
"printc(\"inside points #\", ipts.N(), c='g')\n",
3053
"printc(\"outside points #\", opts.N(), c='r')\n",
31-
"printc(\"a-sphericity:\", elli.asphericity())\n",
54+
"printc(\"asphericity:\", elli.asphericity())\n",
3255
"plt.show(axes=1)"
3356
]
3457
},
3558
{
3659
"cell_type": "code",
37-
"execution_count": null,
60+
"execution_count": 2,
3861
"metadata": {},
3962
"outputs": [],
4063
"source": [
@@ -51,7 +74,7 @@
5174
],
5275
"metadata": {
5376
"kernelspec": {
54-
"display_name": "Python 3",
77+
"display_name": "Python 3 (ipykernel)",
5578
"language": "python",
5679
"name": "python3"
5780
},
@@ -65,7 +88,7 @@
6588
"name": "python",
6689
"nbconvert_exporter": "python",
6790
"pygments_lexer": "ipython3",
68-
"version": "3.8.8"
91+
"version": "3.9.7"
6992
}
7093
},
7194
"nbformat": 4,

examples/other/export_x3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
txt = Text3D(__doc__, font='Bongas', s=350, c='red2', depth=0.05)
1212
txt.pos(2500, 300, 500)
1313

14-
plt.show(embryo, txt, txt.box(pad=250), axes=1, viewup='z', zoom=1.2)
14+
plt.show(embryo, txt, txt.box(padding=250), axes=1, viewup='z', zoom=1.2)
1515

1616
# This exports the scene and generates 2 files:
1717
# embryo.x3d and an example embryo.html to inspect in the browser

0 commit comments

Comments
 (0)