Skip to content

Efficient Implementation of Marching Cubes' Cases with Topological Guarantees

License

Notifications You must be signed in to change notification settings

JuliaGeometry/MarchingCubes.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License CI PkgEval Coverage Status MarchingCubes Downloads

MarchingCubes

Julia port of Efficient Implementation of Marching Cubes' Cases with Topological Guarantees.

Public article available here.

Implementation

Adapted to Julia (1 based indexing) from the original c++ implementation (0 based indexing).

Tiny benchmark - visualization with ParaView

$ g++ -O3 ply.c main.cpp MarchingCubes.cpp
$ ./a.out
Marching Cubes ran in 0.007834 secs.
$ julia --check-bounds=no
julia> using BenchmarkTools, MarchingCubes
julia> mc = MarchingCubes.scenario();
julia> @btime march($mc)
  7.865 ms (0 allocations: 0 bytes)
julia> @btime march_legacy($mc)
  9.268 ms (0 allocations: 0 bytes)
julia> using PlyIO
julia> MarchingCubes.output(PlyIO, mc)  # writes "test.ply" (can be opened in a viewer, e.g. ParaView)

Test scenario output: ParaView Torus

MWE demonstrating visualization with MeshViz.jl

using MarchingCubes
using GLMakie
using MeshViz
using Meshes

mc = MarchingCubes.scenario()
march(mc)
msh = MarchingCubes.makemesh(Meshes, mc)
display(viz(msh))

Meshviz Mesh

MWE demonstrating visualization with GeometryBasics.jl and Makie.jl

using GeometryBasics
using MarchingCubes
using GLMakie

mc = MarchingCubes.scenario()
march(mc)
msh = MarchingCubes.makemesh(GeometryBasics, mc)

fap = mesh(msh; color = :gray)
display(fap)

Makie Mesh

Original BibTeX

@article{marching_cubes_jgt,
    author = {Thomas Lewiner and Hélio Lopes and Antônio Wilson Vieira and Geovan Tavares},
    title = {Efficient implementation of marching cubes cases with topological guarantees},
    year = {2003},
    month = {december},
    journal = {Journal of Graphics Tools},
    volume = {8},
    number = {2},
    pages = {1--15},
    publisher = {A.K.Peters},
    doi = {10.1080/10867651.2003.10487582},
    url = {\url{http://thomas.lewiner.org/pdfs/marching_cubes_jgt.pdf}}
}

License

This code is free to use under the terms of the MIT license.