Giter VIP home page Giter VIP logo

marching-cubes's Introduction

Marching Cubes

This is a C++ implementation of the Marching Cubes algorithm [1] adapted from [2].

The Marching Cubes algorithm is a computer graphics algorithm to extract a polygonal mesh (in this implementation, a triangular mesh) of an isosurface from a three-dimensional discrete scalar field.

A three-dimensional scalar field can be specified as a txt file in the format specified below and the triangular mesh is obtained in the Stanford PLY file format [3] which can be visualized using any mesh visualizer such as Paraview, Blender, etc.

Usage

The driver file is main_march.cpp. To run main_march.cpp, run the following commands:

make main_march
./main_march <inp_file_path> <out_file_path> <float_isovalue>

This command will read the scalar field specified in <inp_file_path> and extract an isosurface with functional value <float_isovalue> as a PLY file to <out_file_path>.

Example Usage
make main_march
./main_march data/txt_in/healthy_brain.txt data/ply_out/healthy_brain_72.ply 72.0
Input File Format

The input scalar field can be specified as a grid in a text file. The text file contains as many lines as there are number of points in the 3D grid. Each line of the text file is of the following format:

x y z value

where x,y,z specify the location in the grid and value assigns a functional value to that location.

Demo

The following images are obtained by running this implementation on a scalar field obtained from the MRI scan of the human brain.

References

[1] Lorensen, William E., and Harvey E. Cline. “Marching Cubes: A High Resolution 3D Surface Construction Algorithm.” Proceedings of the 14th Annual Conference on Computer Graphics and Interactive Techniques - SIGGRAPH '87, 1987, doi:10.1145/37401.37422.

[2] Brooke, Paul. “Polygonising a Scalar Field.” Polygonising a Scalar Field (Marching Cubes), paulbourke.net/geometry/polygonise/.

[3] Brooke, Paul. PLY - Polygon File Format, paulbourke.net/dataformats/ply/.

marching-cubes's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.