Skip to content

Commit

Permalink
Update Meshing.jl examples for v0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
nhz2 committed Nov 21, 2024
1 parent 8ed2e8e commit 77baf71
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ Colors = "0.9, 0.10, 0.11, 0.12, 0.13"
CoordinateTransformations = "0.5, 0.6"
DocStringExtensions = "0.5, 0.6, 0.7, 0.8, 0.9"
FFMPEG = "0.2, 0.3, 0.4"
GeometryBasics = "0.3, 0.4, 0.5"
GeometryBasics = "0.3, 0.4"
HTTP = "1"
MeshIO = "0.4"
Meshing = "0.5, 0.6"
Meshing = "0.7"
MsgPack = "1"
Parameters = "0.10, 0.11, 0.12, 0.13"
PrecompileTools = "1"
Expand Down
14 changes: 10 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,17 @@ setobject!(vis, PointCloud(verts, colors))

```julia
# Visualize a mesh from the level set of a function
using Meshing: MarchingTetrahedra
using GeometryBasics: Mesh, HyperRectangle
using Meshing: MarchingTetrahedra, isosurface
using GeometryBasics:
Mesh,
TriangleFace,
Vec,
Point
xr,yr,zr = ntuple(_->LinRange(-1,1,50),3)
f = x -> sum(sin, 5 * x)
mesh = Mesh(f, HyperRectangle(Vec(-1, -1, -1), Vec(2, 2, 2)),
MarchingTetrahedra())
sdf = [f(Vec(x,y,z)) for x in xr, y in yr, z in zr]
vts, fcs = isosurface(sdf, MarchingTetrahedra(), xr, yr, zr)
mesh = Mesh(Point.(vts), TriangleFace.(fcs))
setobject!(vis, mesh,
MeshPhongMaterial(color=RGBA{Float32}(1, 0, 0, 0.5)))
```
Expand Down
4 changes: 2 additions & 2 deletions notebooks/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ MeshIO = "7269a6da-0436-5bbc-96c2-40638cbb6118"
Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc"

[compat]
Colors = "0.9, 0.10, 0.11, 0.12"
Colors = "0.9, 0.10, 0.11, 0.12, 0.13"
FileIO = "1"
GeometryBasics = "0.3, 0.4"
Meshing = "0.5, 0.6"
Meshing = "0.7"
MeshIO = "0.4"
10 changes: 6 additions & 4 deletions notebooks/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"using MeshCat\n",
"using CoordinateTransformations\n",
"using Rotations\n",
"using GeometryBasics: HyperRectangle, Vec, Point, Mesh\n",
"using GeometryBasics: HyperRectangle, Vec, Point, Mesh, TriangleFace\n",
"using Colors: RGBA, RGB"
]
},
Expand Down Expand Up @@ -384,10 +384,12 @@
"# Those two pieces of information are all we need to construct a mesh geometry.\n",
"\n",
"# Using `Meshing.jl`, we can construct a mesh directly from our function:\n",
"using Meshing: MarchingCubes\n",
"using Meshing: MarchingTetrahedra, isosurface\n",
"\n",
"bounds = HyperRectangle(lower_bound, upper_bound - lower_bound)\n",
"mesh = Mesh(f, bounds, MarchingCubes())\n",
"xr,yr,zr = ntuple(i->LinRange(lower_bound[i], upper_bound[i],50),3)\n",
"sdf = [f(Vec(x,y,z)) for x in xr, y in yr, z in zr]\n",
"vts, fcs = isosurface(sdf, MarchingTetrahedra(), xr, yr, zr)\n",
"mesh = Mesh(Point.(vts), TriangleFace.(fcs))\n",
"\n",
"# And now we can load that geometry into the visualizer\n",
"setobject!(vis, mesh)"
Expand Down

0 comments on commit 77baf71

Please sign in to comment.