Efficiently generating mesh for self-generated voxel grid

Trending 3 years ago

I'm moving connected an app that lets users conception a 3D house, pinch nan eventual extremity of it being 3D printable. I usage various materials successful nan shape of a tallness representation constructed from an image, for illustration this ceramic texture:

enter image explanation here

I representation nan brightness of each pixel to a height, for illustration so:

enter image explanation here

But erstwhile you commencement combining wall panels broadside by broadside and astatine different angles, it tin quickly get messy and you tin extremity up pinch a self-intersecting mesh, not to mention galore much polygons than are really necessary, each of which lend to thing which nan 3D Printer slicer can't header with. It looks for illustration this but nan geometry isn't cleanable capable to people it:

enter image explanation here

Now, presently everything successful nan app itself useful straight pinch polygons. Since each of this yet is generated from grid-like information (the root images) it seems to maine that immoderate benignant of voxel-based attack would beryllium very suitable, and could perchance output overmuch amended value results. I person tested nan attack of populating a grid straight from nan root images, and that spot tin beryllium done very efficiently. But I'm having a difficult clip uncovering nan correct algorithm to past move that grid information backmost into polygons fresh for 3D printing.

Most algorithms for turning voxel information into a polygon isosurface presume 2 things, arsenic acold arsenic I tin tell:

  1. That you person nary anterior knowledge of nan underlying geometry
  2. That nan geometry is simply a scalar field, alternatively than a "boolean" grid wherever nan grid lines genuinely do correspond to nan last geometry. There could beryllium good scaled specifications that autumn betwixt nan grid lines.

Whereas successful my case:

  1. I person immense quiet patches wrong nan building, but I tin easy disregard those because I person a database of bounding boxes of wherever each wall sheet exists
  2. I would for illustration to return advantage of nan truth that my information really is gridlike successful nature. Note that I tin person 'diagonals' - this elemental ceramic texture shown present is astir apt a small excessively simplistic, e.g. immoderate tile tile textures usage a batch much in-between heights:

enter image explanation here

Obviously thing arsenic elemental arsenic marching cubes could beryllium adapted to return advantage of constituent 1 easy capable (just skip complete sections of nan grid which aren't contained wrong immoderate of my bounding boxes) but I consciousness for illustration marching cubes will output WAY much polygons than necessary.

Can anybody urge immoderate circumstantial algorithms that mightiness suit this script (where we person anterior knowledge astir nan underlying geometry) aliases springiness maine immoderate hunt position that I tin usage to research? I've been searching algorithms for generating isosurfaces, but my small heart tells maine that what I'm moving pinch present is really subtly different because of nan grid-like quality of nan problem - e.g. are these moreover really "voxels" astatine all?