Giter Club home page Giter Club logo

dualmc's Introduction

Introduction

This project provides a simple C++ implementation of the dual marching cubes algorithm described in the paper Dual Marching Cubes from Gregory M. Nielson. It is a byproduct of some work I did as a student assistent back in 2009. Though there are other implementations out there it might still be helpfull to someone.

Unfortunately, under rare circumstances the original algorithm can create non-manifold meshes. See the remarks of the original paper on this problem. In chapter 3.3.5 of his book "Isosurfaces: Geometry, Topology, and Algorithms" Rephael Wenger proposed the manifold dual marching cubes algorithm as a possible solution, which is also included in this implementation.

Requirements

  • C++11
  • No other dependencies

Implementation

The algorithm is implemented in the files dualmc.h, dualmc.tpp, and dualmc_tables.tpp. A simple example command-line application which demonstrates basic usage is provided as well. An application for generating the (manifold) dual marching cubes tables is implemented in apps/gentables.

Dual point computation could be improved using Hermite data or at least first derivatives as described in Dual Contouring of Hermite Data. So feel free to contribute :)

Example Application

To build the example and see the available options in a Linux environment type:

$ make
$ ./dmc -help

A basic CMAKE file is provided as well. If this still does not suit you under Windows or OS X the adept programmer should have no problems setting up a small project.

RAW Files

The example application can only read 8-bit and 16-bit volume data sets in the very limited RAW format (i.e. only stores raw data, no further information such as the volume grid dimension is included). A classic source for RAW files is http://www.volvis.org/ . Currently, the site does not seem to be available. The OpenQVis project also provides some data sets in RAW format. Another source is The Volume Library from Stefan Roettger. This site provides files in the more versatile PMV format but also code which can convert these files to RAW.

The example application provides a small cube data set (32^3)and can also generate a caffeine molecule. To extract a surface from the cube volume type:

$ ./dmc -raw data/cube.raw 32 32 32 -iso 0.5

The iso value of 0.5 is mapped to a middle density w.r.t. the bit-depth of the data set. For the caffeine data set type:

$ ./dmc -caffeine -iso 0.5

caffeine

For code simplicity the example outputs surfaces in the Wavefront OBJ format.

License

BSD 3-Clause License

dualmc's People

Contributors

dominikwodniok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dualmc's Issues

Hmm

Your screenshot looks like surface nets?!

Can output mesh be updated in parallel Chunks?

This is a really great Manifold Dual Marching Cubes implementation!

How would you extend buildSharedVerticesQuads to update only a subsection of its quad&vertex output instead of exporting everything at once?

I want to use dualmc to make an editable Voxel terrain system that updates small parts of a large terrain in realtime.

For example, a data set of 512^3 would be divided into 8x8x8 chunks, and editing the iso of a voxel at location (0,0,0) only updates the mesh output for (0,0,0) to (7,7,7).

Some pseudocode for chunk processing:

int32_t chunkx = 0;
int32_t chunky = 0;
int32_t chunkz = 0;

int32_t chunksize = 8;

....

void DualMC<T>::buildSharedVerticesQuads(
        VolumeDataType const iso,
        std::vector<Vertex> & vertices,
        std::vector<Quad> & quads
        )

....

for(int32_t cz = 0; cz < reducedZ; ++cz) // iterate voxels
		{
			for(int32_t cy = 0; cy < reducedY; ++cy)
			{
				for(int32_t cx = 0; cx < reducedX; ++cx)
				{
					int32_t x = cx+chunkx; // offset chunk size
					int32_t y = cy+chunky;
					int32_t z = cz+chunkz;
					
					x = CLAMP(x,chunkx,chunkx+chunksize);
					y = CLAMP(y,chunky,chunky+chunksize);
					z = CLAMP(z,chunkz,chunkz+chunksize);
					
					x = CLAMP(x,0,reducedX-1);
					y = CLAMP(y,0,reducedY-1);
					z = CLAMP(z,0,reducedZ-1);
					
					// is this parallelizable?
					// can each voxel be processed separately?
					CalcDualPoint(x,y,z,
								  iso,
								  vertices, quads);
				}
			}
		}

How would you allocate the vertices&quads output vectors once, to the max mesh size needed for a given resolution, then later reuse those same vectors, quickly updating only a small chunk of the mesh output at a time?

Any help would be appreciated, thank you again for the awesome library!

Generates non-manifold output, LUT might be off

Hi, this is a brilliant Dual MC implementation, thanks for sharing it!

According to the original paper, Dual Marching Cubes should have two-manifold output, but running the caffeine example non-manifold output is generated. (T junctions can be found around the side molecules)

I suspect that the table could have some value(s) off, how was it generated? I'd like to have a go at adjusting the table values to make it generate clean meshes ;)

Seamless tiles

Hi, I really like this marching cubes. Especially that it outputs quads rather than triangles.
But I am having trouble with using this library to generate tiled output. I always get holes in between tiles (or overlapping triangles on seams). Could you please help me? I have prepared a simplified example app.
https://github.com/malytomas/dualmc-tiles-test/tree/master
dualmc-tiles

Problem with dimX != dimY != dimZ != 2^n

For my 261x131x137 volume the result exhibits strange distortions:
Every second z-voxel-layer is empty and the y-voxels seem to be duplicated.
If i scale the grid up to 261x261x261 it works flawlessly.
Do you have any idea what may cause this?

Missing gentables.h

It seems that the gentables.h file is missing in the repository.
Can you maybe check this?

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.