Skip to content

Commit 2c20b49

Browse files
authored
Merge pull request #2265 from mikedh/feat/norm
Release: Fix Triangulation Option
2 parents e20de7e + b7609f1 commit 2c20b49

15 files changed

Lines changed: 114 additions & 98 deletions

Dockerfile

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,7 @@ COPY --chown=499 pyproject.toml /home/user/
2727
USER user
2828

2929
# install trimesh into .local
30-
# then delete any included test directories
31-
# and remove Cython after all the building is complete
32-
33-
34-
# TODO
35-
# remove mapbox-earcut fork when this is merged:
36-
# https://github.com/skogler/mapbox_earcut_python/pull/15
37-
RUN pip install --user /home/user[easy] && \
38-
pip install --user --force-reinstall git+https://github.com/mikedh/mapbox_earcut_python.git && \
39-
find /home/user/.local -type d -name tests -prune -exec rm -rf {} \;
30+
RUN pip install --user /home/user[easy]
4031

4132
####################################
4233
### Build output image most things should run on
@@ -73,7 +64,8 @@ RUN trimesh-setup --install=test,gmsh,gltf_validator,llvmpipe,binvox
7364
USER user
7465

7566
# install things like pytest and make sure we're on Numpy 2.X
76-
RUN pip install .[all] && \
67+
# todo : imagio is forcing a downgrade of numpy 2 in-place
68+
RUN pip install .[all] && pip install --force-reinstall --upgrade "numpy>2" && \
7769
python -c "import numpy as n; assert(n.__version__.startswith('2'))"
7870

7971
# check for lint problems

examples/colors.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"metadata": {},
2727
"outputs": [],
2828
"source": [
29-
"m = trimesh.load('../models/machinist.XAML',process=False)"
29+
"m = trimesh.load(\"../models/machinist.XAML\", process=False)"
3030
]
3131
},
3232
{

examples/curvature.ipynb

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@
1717
"metadata": {},
1818
"outputs": [],
1919
"source": [
20-
"import trimesh\n",
21-
"from trimesh.curvature import discrete_gaussian_curvature_measure, discrete_mean_curvature_measure, sphere_ball_intersection\n",
2220
"import matplotlib.pyplot as plt\n",
2321
"import numpy as np\n",
22+
"\n",
23+
"import trimesh\n",
24+
"from trimesh.curvature import (\n",
25+
" discrete_gaussian_curvature_measure,\n",
26+
" discrete_mean_curvature_measure,\n",
27+
" sphere_ball_intersection,\n",
28+
")\n",
29+
"\n",
2430
"%matplotlib inline\n",
2531
"\n",
2632
"mesh = trimesh.creation.icosphere()"
@@ -33,8 +39,20 @@
3339
"outputs": [],
3440
"source": [
3541
"radii = np.linspace(0.1, 2.0, 10)\n",
36-
"gauss = np.array([discrete_gaussian_curvature_measure(mesh, mesh.vertices, r)/sphere_ball_intersection(1, r) for r in radii])\n",
37-
"mean = np.array([discrete_mean_curvature_measure(mesh, mesh.vertices, r)/sphere_ball_intersection(1, r) for r in radii])"
42+
"gauss = np.array(\n",
43+
" [\n",
44+
" discrete_gaussian_curvature_measure(mesh, mesh.vertices, r)\n",
45+
" / sphere_ball_intersection(1, r)\n",
46+
" for r in radii\n",
47+
" ]\n",
48+
")\n",
49+
"mean = np.array(\n",
50+
" [\n",
51+
" discrete_mean_curvature_measure(mesh, mesh.vertices, r)\n",
52+
" / sphere_ball_intersection(1, r)\n",
53+
" for r in radii\n",
54+
" ]\n",
55+
")"
3856
]
3957
},
4058
{
@@ -45,11 +63,11 @@
4563
"source": [
4664
"plt.figure()\n",
4765
"plt.plot(radii, gauss.mean(axis=1))\n",
48-
"plt.title('Gaussian Curvature')\n",
66+
"plt.title(\"Gaussian Curvature\")\n",
4967
"plt.show()\n",
5068
"plt.figure()\n",
5169
"plt.plot(radii, mean.mean(axis=1))\n",
52-
"plt.title('Mean Curvature')\n",
70+
"plt.title(\"Mean Curvature\")\n",
5371
"plt.show();"
5472
]
5573
},

examples/nearest.ipynb

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
"metadata": {},
2020
"outputs": [],
2121
"source": [
22-
"import trimesh \n",
23-
"import numpy as np"
22+
"import numpy as np\n",
23+
"\n",
24+
"import trimesh"
2425
]
2526
},
2627
{
@@ -29,8 +30,8 @@
2930
"metadata": {},
3031
"outputs": [],
3132
"source": [
32-
"# load a large- ish PLY model with colors \n",
33-
"mesh = trimesh.load('../models/cycloidal.ply') "
33+
"# load a large- ish PLY model with colors\n",
34+
"mesh = trimesh.load(\"../models/cycloidal.ply\")"
3435
]
3536
},
3637
{
@@ -50,10 +51,8 @@
5051
"outputs": [],
5152
"source": [
5253
"# find the closest point on the mesh to each random point\n",
53-
"(closest_points,\n",
54-
" distances,\n",
55-
" triangle_id) = mesh.nearest.on_surface(points)\n",
56-
"# distance from point to surface of mesh", "distances"
54+
"(closest_points, distances, triangle_id) = mesh.nearest.on_surface(points)\n",
55+
"# distance from point to surface of meshdistances"
5756
]
5857
},
5958
{
@@ -64,21 +63,19 @@
6463
"source": [
6564
"# create a PointCloud object out of each (n,3) list of points\n",
6665
"cloud_original = trimesh.points.PointCloud(points)\n",
67-
"cloud_close = trimesh.points.PointCloud(closest_points)\n",
66+
"cloud_close = trimesh.points.PointCloud(closest_points)\n",
6867
"\n",
6968
"# create a unique color for each point\n",
7069
"cloud_colors = np.array([trimesh.visual.random_color() for i in points])\n",
7170
"\n",
7271
"# set the colors on the random point and its nearest point to be the same\n",
7372
"cloud_original.vertices_color = cloud_colors\n",
74-
"cloud_close.vertices_color = cloud_colors\n",
73+
"cloud_close.vertices_color = cloud_colors\n",
7574
"\n",
7675
"# create a scene containing the mesh and two sets of points\n",
77-
"scene = trimesh.Scene([mesh,\n",
78-
" cloud_original,\n",
79-
" cloud_close])\n",
76+
"scene = trimesh.Scene([mesh, cloud_original, cloud_close])\n",
8077
"\n",
81-
"# show the scene wusing \n",
78+
"# show the scene wusing\n",
8279
"scene.show()"
8380
]
8481
}

examples/quick_start.ipynb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"outputs": [],
1919
"source": [
2020
"import numpy as np\n",
21+
"\n",
2122
"import trimesh"
2223
]
2324
},
@@ -28,9 +29,9 @@
2829
"outputs": [],
2930
"source": [
3031
"# load a file by name or from a buffer\n",
31-
"mesh = trimesh.load_mesh('../models/featuretype.STL')\n",
32+
"mesh = trimesh.load_mesh(\"../models/featuretype.STL\")\n",
3233
"# to keep the raw data intact, disable any automatic processing\n",
33-
"#mesh = trimesh.load_mesh('../models/featuretype.STL', process=False)"
34+
"# mesh = trimesh.load_mesh('../models/featuretype.STL', process=False)"
3435
]
3536
},
3637
{
@@ -180,7 +181,11 @@
180181
"# available, and will be the minimum volume version of each\n",
181182
"# except in certain degenerate cases, where they will be no worse\n",
182183
"# than a least squares fit version of the primitive.\n",
183-
"(mesh.bounding_box_oriented.volume, mesh.bounding_cylinder.volume, mesh.bounding_sphere.volume)"
184+
"(\n",
185+
" mesh.bounding_box_oriented.volume,\n",
186+
" mesh.bounding_cylinder.volume,\n",
187+
" mesh.bounding_sphere.volume,\n",
188+
")"
184189
]
185190
}
186191
],

examples/ray.ipynb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
"metadata": {},
1818
"outputs": [],
1919
"source": [
20-
"import trimesh\n",
21-
"import numpy as np"
20+
"import numpy as np\n",
21+
"\n",
22+
"import trimesh"
2223
]
2324
},
2425
{
@@ -38,10 +39,8 @@
3839
"outputs": [],
3940
"source": [
4041
"# create some rays\n",
41-
"ray_origins = np.array([[0, 0, -3],\n",
42-
" [2, 2, -3]])\n",
43-
"ray_directions = np.array([[0, 0, 1],\n",
44-
" [0, 0, 1]])"
42+
"ray_origins = np.array([[0, 0, -3], [2, 2, -3]])\n",
43+
"ray_directions = np.array([[0, 0, 1], [0, 0, 1]])"
4544
]
4645
},
4746
{
@@ -62,8 +61,8 @@
6261
"source": [
6362
"# run the mesh- ray query\n",
6463
"locations, index_ray, index_tri = mesh.ray.intersects_location(\n",
65-
" ray_origins=ray_origins,\n",
66-
" ray_directions=ray_directions)"
64+
" ray_origins=ray_origins, ray_directions=ray_directions\n",
65+
")"
6766
]
6867
},
6968
{
@@ -72,7 +71,7 @@
7271
"metadata": {},
7372
"outputs": [],
7473
"source": [
75-
"# the rays hit the mesh at coordinates", "locations"
74+
"# the rays hit the mesh at coordinateslocations"
7675
]
7776
},
7877
{
@@ -81,8 +80,7 @@
8180
"metadata": {},
8281
"outputs": [],
8382
"source": [
84-
"# the rays with index_ray hit the triangles stored at mesh.faces[index_tri]",
85-
"len(index_ray)"
83+
"# the rays with index_ray hit the triangles stored at mesh.faces[index_tri]len(index_ray)"
8684
]
8785
},
8886
{
@@ -92,8 +90,9 @@
9290
"outputs": [],
9391
"source": [
9492
"# stack rays into line segments for visualization as Path3D\n",
95-
"ray_visualize = trimesh.load_path(np.hstack((ray_origins,\n",
96-
" ray_origins + ray_directions*5.0)).reshape(-1, 2, 3))"
93+
"ray_visualize = trimesh.load_path(\n",
94+
" np.hstack((ray_origins, ray_origins + ray_directions * 5.0)).reshape(-1, 2, 3)\n",
95+
")"
9796
]
9897
},
9998
{
@@ -105,7 +104,7 @@
105104
"# unmerge so viewer doesn't smooth\n",
106105
"mesh.unmerge_vertices()\n",
107106
"# make mesh white- ish\n",
108-
"mesh.visual.face_colors = [255,255,255,255]\n",
107+
"mesh.visual.face_colors = [255, 255, 255, 255]\n",
109108
"mesh.visual.face_colors[index_tri] = [255, 0, 0, 255]"
110109
]
111110
},
@@ -116,8 +115,7 @@
116115
"outputs": [],
117116
"source": [
118117
"# create a visualization scene with rays, hits, and mesh\n",
119-
"scene = trimesh.Scene([mesh,\n",
120-
" ray_visualize])"
118+
"scene = trimesh.Scene([mesh, ray_visualize])"
121119
]
122120
},
123121
{

examples/save_image.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"metadata": {},
2020
"outputs": [],
2121
"source": [
22-
"import numpy as np\n",
23-
"import trimesh\n",
24-
"import math"
22+
"import math\n",
23+
"\n",
24+
"import trimesh"
2525
]
2626
},
2727
{
@@ -32,7 +32,7 @@
3232
"outputs": [],
3333
"source": [
3434
"# load a file by name\n",
35-
"mesh = trimesh.load_mesh('../models/featuretype.STL')"
35+
"mesh = trimesh.load_mesh(\"../models/featuretype.STL\")"
3636
]
3737
},
3838
{
@@ -92,7 +92,7 @@
9292
" math.radians(45),\n",
9393
" math.radians(45),\n",
9494
" \"ryxz\",\n",
95-
" )"
95+
")"
9696
]
9797
},
9898
{
@@ -102,7 +102,7 @@
102102
"metadata": {},
103103
"outputs": [],
104104
"source": [
105-
"# Get camera transform to look at geometry with isometric view \n",
105+
"# Get camera transform to look at geometry with isometric view\n",
106106
"t_r = scene.camera.look_at(corners, rotation=r_e)"
107107
]
108108
},
@@ -136,7 +136,7 @@
136136
"outputs": [],
137137
"source": [
138138
"# Write the bytes to file\n",
139-
"with open('../models/featuretype.png', \"wb\") as f:\n",
139+
"with open(\"../models/featuretype.png\", \"wb\") as f:\n",
140140
" f.write(png)\n",
141141
" f.close()"
142142
]

0 commit comments

Comments
 (0)