MeshViz.jl

Makie.jl recipes for visualization of Meshes.jl
Popularity
53 Stars
Updated Last
11 Months Ago
Started In
March 2021

MeshViz.jl

Makie.jl recipes for visualization of Meshes.jl.

Installation

Get the latest stable release with Julia's package manager:

] add MeshViz

Usage

using Meshes, MeshViz

# choose a Makie backend
import GLMakie as Mke

using PlyIO: load_ply

function loadply(fname)
  ply = load_ply(fname)
  x = ply["vertex"]["x"]
  y = ply["vertex"]["y"]
  z = ply["vertex"]["z"]
  I = ply["face"]["vertex_indices"]
  points = Point.(x, y, z)
  connec = [connect(Tuple(i.+1)) for i in I]
  SimpleMesh(points, connec)
end

mesh = loadply("beethoven.ply")

viz(mesh, showfacets = true)

beethoven

mesh = loadply("dragon.ply")

# for vertex coloring pass a vector of colors
# with the same length of the number of vertices
viz(mesh, color = 1:nvertices(mesh), colorscheme = :Spectral)

dragon

grid = CartesianGrid(10,10)

viz(grid, showfacets = true)

grid2d

# for element coloring pass a vector of colors
# with the same length of the number of elements
viz(grid, color = 1:nelements(grid))

grid2d-color

grid = CartesianGrid(10,10,10)

viz(grid, showfacets = true)

grid3d

viz(grid, color = 1:nelements(grid))

grid3d-color

using GeoTables

# Brazil states as Meshes.jl polygons
BRA = GeoTables.gadm("BRA", depth = 1)

viz(BRA.geometry, decimation = 0.02)

brazil

RIO = GeoTables.gadm("BRA", "Rio de Janeiro", depth = 1)

viz(RIO.geometry, decimation = 0.001)

rio

viz(BRA.geometry, color = 1:length(BRA.geometry))

brazil-color

Please check the docstring ?viz for available attributes.