"vscode:/vscode.git/clone" did not exist on "aecf0c53bf69cd66fb8715119900cb54dd107598"
Commit 850efdf7 authored by Jiali Duan's avatar Jiali Duan Committed by Facebook GitHub Bot
Browse files

Python marching cubes improvements

Summary: Overhaul of marching_cubes_naive for better performance and to avoid relying on unstable hashing. In particular, instead of hashing vertex positions, we index each interpolated vertex with its corresponding edge in the 3d grid.

Reviewed By: kjchalup

Differential Revision: D39419642

fbshipit-source-id: b5fede3525c545d1d374198928dfb216262f0ec0
parent 6471893f
This diff is collapsed.
...@@ -4,284 +4,21 @@ ...@@ -4,284 +4,21 @@
# This source code is licensed under the BSD-style license found in the # This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. # LICENSE file in the root directory of this source tree.
# A length 256 list which maps a cubeindex to a number
# with the intersected edges' bits set to 1.
# Each cubeindex corresponds to a given cube configuration, where
# it is composed of a bitstring where the 0th bit is flipped if vertex 0
# is below the isosurface (i.e. 0x01), for each of the 8 vertices.
EDGE_TABLE = [
0x0,
0x109,
0x203,
0x30A,
0x406,
0x50F,
0x605,
0x70C,
0x80C,
0x905,
0xA0F,
0xB06,
0xC0A,
0xD03,
0xE09,
0xF00,
0x190,
0x99,
0x393,
0x29A,
0x596,
0x49F,
0x795,
0x69C,
0x99C,
0x895,
0xB9F,
0xA96,
0xD9A,
0xC93,
0xF99,
0xE90,
0x230,
0x339,
0x33,
0x13A,
0x636,
0x73F,
0x435,
0x53C,
0xA3C,
0xB35,
0x83F,
0x936,
0xE3A,
0xF33,
0xC39,
0xD30,
0x3A0,
0x2A9,
0x1A3,
0xAA,
0x7A6,
0x6AF,
0x5A5,
0x4AC,
0xBAC,
0xAA5,
0x9AF,
0x8A6,
0xFAA,
0xEA3,
0xDA9,
0xCA0,
0x460,
0x569,
0x663,
0x76A,
0x66,
0x16F,
0x265,
0x36C,
0xC6C,
0xD65,
0xE6F,
0xF66,
0x86A,
0x963,
0xA69,
0xB60,
0x5F0,
0x4F9,
0x7F3,
0x6FA,
0x1F6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
0x80C,
0x70C,
0x605,
0x50F,
0x406,
0x30A,
0x203,
0x109,
0x0,
]
# Maps each edge (by index) to the corresponding cube vertices # Maps each edge (by index) to the corresponding cube vertices
EDGE_TO_VERTICES = [ EDGE_TO_VERTICES = [
[0, 1], [0, 1],
[1, 2], [1, 5],
[3, 2],
[0, 3],
[4, 5], [4, 5],
[5, 6],
[7, 6],
[4, 7],
[0, 4], [0, 4],
[1, 5], [2, 3],
[2, 6],
[3, 7], [3, 7],
[6, 7],
[2, 6],
[0, 2],
[1, 3],
[5, 7],
[4, 6],
] ]
# A list of lists mapping a cube_index (a given configuration) # A list of lists mapping a cube_index (a given configuration)
...@@ -547,3 +284,6 @@ FACE_TABLE = [ ...@@ -547,3 +284,6 @@ FACE_TABLE = [
[0, 3, 8], [0, 3, 8],
[], [],
] ]
# mapping from 0-7 to v0-v7 in cube.vertices
INDEX = [0, 1, 5, 4, 2, 3, 7, 6]
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment