Note that there are some explanatory texts on larger screens.

plurals
  1. POAlgorithm to fit fewest rectangles to irregular shape
    primarykey
    data
    text
    <p>I have a rendering application that renders lots and lots of cubes in a 3-dimensional grid. This is inherently inefficient as each cube represents 4 vertices, and often the cubes are adjacent, creating one surface that could be represented by a single rectangle.</p> <p>To populate the area I use a 3-dimensional array, where a value of 0 denotes empty space and a non-0 value denotes a block.</p> <p>e.g. (where X denotes where a cube would be placed)</p> <pre><code>OOOXXXOOOO OOXXXXXXXO OOXXXXXXXO OOXXXXOOOO </code></pre> <p>would currently be represented as 21 cubes, or 252 triangles, whereas it could easily be represented as (where each letter denotes a part of a rectangle)</p> <pre><code>OOOAAAOOOO OOBAAACCCO OOBAAACCCO OOBAAAOOOO </code></pre> <p>which is a mere 3 rectangles, or 26 triangles.</p> <p>The typical size of these grids is 128x128x128, so it's clear I would benefit from a massive performance boost if I could efficiently reduce the shapes to the fewest rectangles possible in a reasonable amount of time, but I'm stuck for ideas for an algorithm.</p> <p>Using <a href="https://stackoverflow.com/questions/1726632/dynamic-programming-largest-square-block">Dynamic programming - Largest square block</a> would be one option, but it wouldn't result in an optimal answer, although if the solution is too complex to perform efficiently then this would have to be the way to go.</p> <p>Eventually I will have multiple types of cubes (e.g. green, brown, blue, referenced using different non-0 numbers in the array) so if possible a version that would work with multiple categories would be very helpful.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload