conquer3d 0.7.3__tar.gz → 0.7.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. {conquer3d-0.7.3/conquer3d.egg-info → conquer3d-0.7.5}/PKG-INFO +21 -10
  2. {conquer3d-0.7.3 → conquer3d-0.7.5}/README.md +20 -9
  3. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/_C.so +0 -0
  4. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/ops/dc.cpp +21 -2
  5. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/ops/dmc.cpp +16 -2
  6. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/maths/qef.h +11 -4
  7. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/dc.cu +32 -4
  8. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/dc.h +3 -1
  9. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/dc_data.h +9 -2
  10. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/dmc.cu +36 -1
  11. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/dmc.h +3 -1
  12. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/dmc_data.h +2 -2
  13. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/mc.cu +13 -4
  14. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/mca.cu +2 -2
  15. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/mt_data.h +7 -7
  16. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/mtg_data.h +9 -9
  17. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/ops/__init__.py +4 -0
  18. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/ops/dual_contouring.py +28 -2
  19. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/ops/dual_marching_cubes.py +29 -2
  20. conquer3d-0.7.5/conquer3d/ops/hermite.py +263 -0
  21. {conquer3d-0.7.3 → conquer3d-0.7.5/conquer3d.egg-info}/PKG-INFO +21 -10
  22. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d.egg-info/SOURCES.txt +1 -0
  23. {conquer3d-0.7.3 → conquer3d-0.7.5}/pyproject.toml +1 -1
  24. {conquer3d-0.7.3 → conquer3d-0.7.5}/LICENSE +0 -0
  25. {conquer3d-0.7.3 → conquer3d-0.7.5}/MANIFEST.in +0 -0
  26. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/_C.pyi +0 -0
  27. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/__init__.py +0 -0
  28. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/conversion/__init__.py +0 -0
  29. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/conversion/grid.py +0 -0
  30. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/conversion/mesh.py +0 -0
  31. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/conversion/tmesh.py +0 -0
  32. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/creation/__init__.py +0 -0
  33. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/creation/triangle_creation.py +0 -0
  34. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/creation/triangle_creation.cpp +0 -0
  35. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/data_structure/bvh.cpp +0 -0
  36. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/data_structure/grid.cpp +0 -0
  37. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/data_structure/gs_bvh.cpp +0 -0
  38. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/data_structure/kdtree.cpp +0 -0
  39. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/data_structure/mesh_bvh.cpp +0 -0
  40. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/data_structure/pgs_bvh.cpp +0 -0
  41. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/data_structure/triangle_mesh.cpp +0 -0
  42. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/data_structure/zcurve.cpp +0 -0
  43. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/ops/chamfer.cpp +0 -0
  44. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/ops/flood_fill.cpp +0 -0
  45. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/ops/flood_fill_cf.cpp +0 -0
  46. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/ops/mc.cpp +0 -0
  47. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/ops/mca.cpp +0 -0
  48. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/ops/mt.cpp +0 -0
  49. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/ops/mtg.cpp +0 -0
  50. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/ops/volint.cpp +0 -0
  51. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/primitive/gs.cpp +0 -0
  52. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/primitive/pgs.cpp +0 -0
  53. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/primitive/ray.cpp +0 -0
  54. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/binds/primitive/triangle.cpp +0 -0
  55. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/check.h +0 -0
  56. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/constants.h +0 -0
  57. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/creation/triangle_creation.h +0 -0
  58. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/bvh.cu +0 -0
  59. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/bvh.h +0 -0
  60. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/grid.cu +0 -0
  61. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/grid.h +0 -0
  62. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/gs_bvh.h +0 -0
  63. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/kdtree.cu +0 -0
  64. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/kdtree.h +0 -0
  65. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/mesh_bvh.cu +0 -0
  66. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/mesh_bvh.h +0 -0
  67. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/pgs_bvh.h +0 -0
  68. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/triangle_mesh.cu +0 -0
  69. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/triangle_mesh.h +0 -0
  70. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/zcurve.cu +0 -0
  71. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/data_structure/zcurve.h +0 -0
  72. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/maths/f2x2.h +0 -0
  73. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/maths/f3x1.h +0 -0
  74. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/maths/f3x3.h +0 -0
  75. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/maths/f3x4.h +0 -0
  76. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/maths/f4x1.h +0 -0
  77. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/maths/f4x4.h +0 -0
  78. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/maths/maths.h +0 -0
  79. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/maths/ops.h +0 -0
  80. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/chamfer.cu +0 -0
  81. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/chamfer.h +0 -0
  82. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/flood_fill.cu +0 -0
  83. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/flood_fill.h +0 -0
  84. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/flood_fill_cf.cu +0 -0
  85. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/flood_fill_cf.h +0 -0
  86. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/mc.h +0 -0
  87. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/mc_data.h +0 -0
  88. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/mca.h +0 -0
  89. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/mca_data.h +0 -0
  90. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/mt.cu +0 -0
  91. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/mt.h +0 -0
  92. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/mtg.cu +0 -0
  93. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/mtg.h +0 -0
  94. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/volint.cu +0 -0
  95. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/ops/volint.h +0 -0
  96. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/primitive/aabb.h +0 -0
  97. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/primitive/edge.h +0 -0
  98. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/primitive/gs.cu +0 -0
  99. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/primitive/gs.h +0 -0
  100. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/primitive/gs_aabb.cu +0 -0
  101. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/primitive/gs_math.cuh +0 -0
  102. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/primitive/pgs.cu +0 -0
  103. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/primitive/pgs.h +0 -0
  104. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/primitive/pgs_aabb.cu +0 -0
  105. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/primitive/pgs_math.cuh +0 -0
  106. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/primitive/ray.h +0 -0
  107. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/primitive/triangle.h +0 -0
  108. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/csrc/pybind.cpp +0 -0
  109. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/__init__.py +0 -0
  110. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/assets/__init__.py +0 -0
  111. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/assets/common.py +0 -0
  112. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/assets/iphigenia.py +0 -0
  113. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/collate/__init__.py +0 -0
  114. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/collate/mesh.py +0 -0
  115. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/collate/sparse_tensor.py +0 -0
  116. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/dataset/__init__.py +0 -0
  117. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/dataset/base_mesh.py +0 -0
  118. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/dataset/digit3d.py +0 -0
  119. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/dataset/digit3dmv.py +0 -0
  120. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/dataset/mesh.py +0 -0
  121. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/dataset/redwood.py +0 -0
  122. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/transform/__init__.py +0 -0
  123. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/transform/base.py +0 -0
  124. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/transform/ops.py +0 -0
  125. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data/transform/vertex.py +0 -0
  126. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data_structure/__init__.py +0 -0
  127. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data_structure/bmesh.py +0 -0
  128. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data_structure/grid.py +0 -0
  129. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/data_structure/sort.py +0 -0
  130. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/io/__init__.py +0 -0
  131. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/io/obj.py +0 -0
  132. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/io/off.py +0 -0
  133. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/io/ply.py +0 -0
  134. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/ops/delaunay_triangulation.py +0 -0
  135. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/ops/diff_marching_cubes.py +0 -0
  136. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/ops/diff_marching_tetrahedra_grid.py +0 -0
  137. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/ops/distance.py +0 -0
  138. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/ops/dpsr.py +0 -0
  139. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/ops/marching_cubes.py +0 -0
  140. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/ops/marching_cubes_asymptotic.py +0 -0
  141. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/ops/marching_tetrahedra.py +0 -0
  142. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/ops/marching_tetrahedra_grid.py +0 -0
  143. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/ops/volint.py +0 -0
  144. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/primitive/__init__.py +0 -0
  145. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/primitive/gs.py +0 -0
  146. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d/primitive/pgs.py +0 -0
  147. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d.egg-info/dependency_links.txt +0 -0
  148. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d.egg-info/not-zip-safe +0 -0
  149. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d.egg-info/requires.txt +0 -0
  150. {conquer3d-0.7.3 → conquer3d-0.7.5}/conquer3d.egg-info/top_level.txt +0 -0
  151. {conquer3d-0.7.3 → conquer3d-0.7.5}/setup.cfg +0 -0
  152. {conquer3d-0.7.3 → conquer3d-0.7.5}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: conquer3d
3
- Version: 0.7.3
3
+ Version: 0.7.5
4
4
  Summary: Geometric Cuda Tool Box
5
5
  Author-email: Do Hoang Khoi <khoido8899@gmail.com>
6
6
  License-Expression: MIT
@@ -60,9 +60,16 @@ Dynamic: license-file
60
60
 
61
61
  ---
62
62
 
63
+ > [!NOTE]
64
+ > The API documentation and the [documentation website](https://khoidoo.github.io/conquer3d/)
65
+ > were written with [Claude](https://claude.ai/code). The library itself — every CUDA kernel,
66
+ > data structure and operator — is the author's own work.
67
+
68
+ ---
69
+
63
70
  ## 🌟 Overview
64
71
 
65
- **Conquer3D** is an ultra-fast, GPU-native computational geometry and differentiable spatial computing library engineered in **PyTorch and CUDA**. Designed from the ground up for 3D computer vision, generative AI, neural surface reconstruction, and differentiable rendering, **Conquer3D** delivers up to **~1.0 Billion faces/second** isosurface extraction, exact CAD sharp crease preservation, and memory-efficient spatial acceleration structures.
72
+ **Conquer3D** is an ultra-fast, GPU-native computational geometry and differentiable spatial computing library engineered in **PyTorch and CUDA**. Designed from the ground up for 3D computer vision, generative AI, neural surface reconstruction, and differentiable rendering, **Conquer3D** delivers up to **~1.3 Billion faces/second** isosurface extraction, exact CAD sharp crease preservation, and memory-efficient spatial acceleration structures.
66
73
 
67
74
  Every operator consumes and produces PyTorch tensors **in place** — no host round-trip, no format conversion — so meshing a field is an operation *inside* a training step rather than a preprocessing stage around it.
68
75
 
@@ -115,14 +122,18 @@ The API reference does not stop at the Python surface. It descends through the p
115
122
 
116
123
  ## ⚡ Benchmarks
117
124
 
118
- *Empirical extraction performance on **NVIDIA GeForce RTX 4090** on the **Fandisk CAD model** at **$1024^3$ resolution** (6.86M sparse vertices, 5.15M active voxels):*
125
+ *Measured on **NVIDIA GeForce RTX 4090** (torch 2.8.0+cu128, CUDA 12.8) on the **Fandisk CAD model** at **$1024^3$ resolution** (5.15M active cells). Timed with CUDA events around the operator alone, median of 7 runs after 2 warm-ups:*
126
+
127
+ | Algorithm | Mesh Output | Extracted Vertices | Extracted Faces / Quads | Latency (ms) | Throughput |
128
+ | :--- | :--- | ---: | ---: | ---: | ---: |
129
+ | **DMC (pure quads)** | Pure Quads | 1,716,384 | 1,716,382 | **2.51 ms** | **684M faces/s** |
130
+ | **Dual Marching Cubes** | Triangles | 1,716,384 | 3,432,764 | **2.62 ms** | **1,311M faces/s** |
131
+ | MC Asymptotic | Triangles | 1,716,382 | 3,432,760 | 2.71 ms | 1,267M faces/s |
132
+ | Dual Contouring | Triangles | 1,716,384 | 3,432,764 | 3.88 ms | 884M faces/s |
133
+ | Marching Cubes | Triangles | 1,716,382 | 3,432,760 | 7.90 ms | 434M faces/s |
134
+ | Marching Tetrahedra | Triangles | 6,113,918 | 12,227,832 | 44.90 ms | 272M faces/s |
119
135
 
120
- | Algorithm | Mesh Output | Extracted Vertices | Extracted Faces / Quads | Latency (ms) | Throughput | Watertight |
121
- | :--- | :--- | :--- | :--- | :---: | :---: | :---: |
122
- | **Dual Marching Cubes (DMC)** | Triangles | **1,716,386** | **3,432,768** | **3.44 ms** | **~1.0B faces/s** | **Yes** |
123
- | **Dual Marching Cubes (DMC)** | Pure Quads | **1,716,386** | **1,716,384** | **3.22 ms** | **533M quads/s** | **Yes** |
124
- | **Dual Contouring (DC + Normals)** | Triangles | 1,716,386 | 3,432,768 | **4.79 ms** | **717M faces/s** | **Yes** |
125
- | **Marching Cubes Asymptotic (MCA)** | Triangles | 1,716,384 | 3,432,764 | 16.42 ms | **209M faces/s** | **Yes** |
136
+ All figures are produced by `docs/_figures/make_benchmarks.py` and can be reproduced. Sign-mode costs, pipeline setup breakdown and memory scaling are on the **[benchmarks page](https://khoidoo.github.io/conquer3d/benchmarks.html)**.
126
137
 
127
138
  ---
128
139
 
@@ -132,7 +143,7 @@ The API reference does not stop at the Python surface. It descends through the p
132
143
  <summary><b>🔷 1. Isosurface Extraction &amp; Meshing</b></summary>
133
144
  <br>
134
145
 
135
- - **Dual Marching Cubes (`dmc`)**: High-throughput manifold surface extraction with pure quad $(Q, 4)$ or triangle $(F, 3)$ outputs (~1.0B faces/s).
146
+ - **Dual Marching Cubes (`dmc`)**: High-throughput manifold surface extraction with pure quad $(Q, 4)$ or triangle $(F, 3)$ outputs (~1.3B faces/s measured).
136
147
  - **Dual Contouring (`dc`)**: Sharp CAD crease and mechanical corner preservation via GPU Quadratic Error Function (QEF) solving.
137
148
  - **Marching Cubes Asymptotic (`mca`)**: Decider-enhanced Marching Cubes resolving topological face ambiguities on-the-fly.
138
149
  - **Differentiable Poisson Surface Reconstruction (`dpsr`, `DPSR`)**: Differentiable spectral Fourier Poisson indicator field solving directly from oriented point clouds.
@@ -27,9 +27,16 @@
27
27
 
28
28
  ---
29
29
 
30
+ > [!NOTE]
31
+ > The API documentation and the [documentation website](https://khoidoo.github.io/conquer3d/)
32
+ > were written with [Claude](https://claude.ai/code). The library itself — every CUDA kernel,
33
+ > data structure and operator — is the author's own work.
34
+
35
+ ---
36
+
30
37
  ## 🌟 Overview
31
38
 
32
- **Conquer3D** is an ultra-fast, GPU-native computational geometry and differentiable spatial computing library engineered in **PyTorch and CUDA**. Designed from the ground up for 3D computer vision, generative AI, neural surface reconstruction, and differentiable rendering, **Conquer3D** delivers up to **~1.0 Billion faces/second** isosurface extraction, exact CAD sharp crease preservation, and memory-efficient spatial acceleration structures.
39
+ **Conquer3D** is an ultra-fast, GPU-native computational geometry and differentiable spatial computing library engineered in **PyTorch and CUDA**. Designed from the ground up for 3D computer vision, generative AI, neural surface reconstruction, and differentiable rendering, **Conquer3D** delivers up to **~1.3 Billion faces/second** isosurface extraction, exact CAD sharp crease preservation, and memory-efficient spatial acceleration structures.
33
40
 
34
41
  Every operator consumes and produces PyTorch tensors **in place** — no host round-trip, no format conversion — so meshing a field is an operation *inside* a training step rather than a preprocessing stage around it.
35
42
 
@@ -82,14 +89,18 @@ The API reference does not stop at the Python surface. It descends through the p
82
89
 
83
90
  ## ⚡ Benchmarks
84
91
 
85
- *Empirical extraction performance on **NVIDIA GeForce RTX 4090** on the **Fandisk CAD model** at **$1024^3$ resolution** (6.86M sparse vertices, 5.15M active voxels):*
92
+ *Measured on **NVIDIA GeForce RTX 4090** (torch 2.8.0+cu128, CUDA 12.8) on the **Fandisk CAD model** at **$1024^3$ resolution** (5.15M active cells). Timed with CUDA events around the operator alone, median of 7 runs after 2 warm-ups:*
93
+
94
+ | Algorithm | Mesh Output | Extracted Vertices | Extracted Faces / Quads | Latency (ms) | Throughput |
95
+ | :--- | :--- | ---: | ---: | ---: | ---: |
96
+ | **DMC (pure quads)** | Pure Quads | 1,716,384 | 1,716,382 | **2.51 ms** | **684M faces/s** |
97
+ | **Dual Marching Cubes** | Triangles | 1,716,384 | 3,432,764 | **2.62 ms** | **1,311M faces/s** |
98
+ | MC Asymptotic | Triangles | 1,716,382 | 3,432,760 | 2.71 ms | 1,267M faces/s |
99
+ | Dual Contouring | Triangles | 1,716,384 | 3,432,764 | 3.88 ms | 884M faces/s |
100
+ | Marching Cubes | Triangles | 1,716,382 | 3,432,760 | 7.90 ms | 434M faces/s |
101
+ | Marching Tetrahedra | Triangles | 6,113,918 | 12,227,832 | 44.90 ms | 272M faces/s |
86
102
 
87
- | Algorithm | Mesh Output | Extracted Vertices | Extracted Faces / Quads | Latency (ms) | Throughput | Watertight |
88
- | :--- | :--- | :--- | :--- | :---: | :---: | :---: |
89
- | **Dual Marching Cubes (DMC)** | Triangles | **1,716,386** | **3,432,768** | **3.44 ms** | **~1.0B faces/s** | **Yes** |
90
- | **Dual Marching Cubes (DMC)** | Pure Quads | **1,716,386** | **1,716,384** | **3.22 ms** | **533M quads/s** | **Yes** |
91
- | **Dual Contouring (DC + Normals)** | Triangles | 1,716,386 | 3,432,768 | **4.79 ms** | **717M faces/s** | **Yes** |
92
- | **Marching Cubes Asymptotic (MCA)** | Triangles | 1,716,384 | 3,432,764 | 16.42 ms | **209M faces/s** | **Yes** |
103
+ All figures are produced by `docs/_figures/make_benchmarks.py` and can be reproduced. Sign-mode costs, pipeline setup breakdown and memory scaling are on the **[benchmarks page](https://khoidoo.github.io/conquer3d/benchmarks.html)**.
93
104
 
94
105
  ---
95
106
 
@@ -99,7 +110,7 @@ The API reference does not stop at the Python surface. It descends through the p
99
110
  <summary><b>🔷 1. Isosurface Extraction &amp; Meshing</b></summary>
100
111
  <br>
101
112
 
102
- - **Dual Marching Cubes (`dmc`)**: High-throughput manifold surface extraction with pure quad $(Q, 4)$ or triangle $(F, 3)$ outputs (~1.0B faces/s).
113
+ - **Dual Marching Cubes (`dmc`)**: High-throughput manifold surface extraction with pure quad $(Q, 4)$ or triangle $(F, 3)$ outputs (~1.3B faces/s measured).
103
114
  - **Dual Contouring (`dc`)**: Sharp CAD crease and mechanical corner preservation via GPU Quadratic Error Function (QEF) solving.
104
115
  - **Marching Cubes Asymptotic (`mca`)**: Decider-enhanced Marching Cubes resolving topological face ambiguities on-the-fly.
105
116
  - **Differentiable Poisson Surface Reconstruction (`dpsr`, `DPSR`)**: Differentiable spectral Fourier Poisson indicator field solving directly from oriented point clouds.
@@ -21,7 +21,9 @@ std::tuple<torch::Tensor, torch::Tensor, std::optional<torch::Tensor>> dual_cont
21
21
  std::optional<torch::Tensor> colors,
22
22
  std::optional<torch::Tensor> voxel_vertices,
23
23
  float iso,
24
- bool quad_split
24
+ bool quad_split,
25
+ std::optional<torch::Tensor> edge_points,
26
+ std::optional<torch::Tensor> edge_normals
25
27
  ) {
26
28
  CHECK_INPUT(grid_vertices);
27
29
  CHECK_INPUT(voxels);
@@ -36,6 +38,20 @@ std::tuple<torch::Tensor, torch::Tensor, std::optional<torch::Tensor>> dual_cont
36
38
  if (voxel_vertices.has_value() && voxel_vertices.value().defined()) {
37
39
  CHECK_INPUT(voxel_vertices.value());
38
40
  }
41
+ if (edge_points.has_value() && edge_points.value().defined()) {
42
+ CHECK_INPUT(edge_points.value());
43
+ TORCH_CHECK(edge_points.value().dim() == 3 && edge_points.value().size(1) == 12 && edge_points.value().size(2) == 3,
44
+ "edge_points must have shape (M, 12, 3)");
45
+ TORCH_CHECK(edge_points.value().size(0) == voxels.size(0),
46
+ "edge_points must have one row per voxel");
47
+ }
48
+ if (edge_normals.has_value() && edge_normals.value().defined()) {
49
+ CHECK_INPUT(edge_normals.value());
50
+ TORCH_CHECK(edge_normals.value().dim() == 3 && edge_normals.value().size(1) == 12 && edge_normals.value().size(2) == 3,
51
+ "edge_normals must have shape (M, 12, 3)");
52
+ TORCH_CHECK(edge_normals.value().size(0) == voxels.size(0),
53
+ "edge_normals must have one row per voxel");
54
+ }
39
55
 
40
56
  return conquer3d::ops::dual_contouring(
41
57
  grid_vertices,
@@ -45,7 +61,9 @@ std::tuple<torch::Tensor, torch::Tensor, std::optional<torch::Tensor>> dual_cont
45
61
  colors,
46
62
  voxel_vertices,
47
63
  iso,
48
- quad_split
64
+ quad_split,
65
+ edge_points,
66
+ edge_normals
49
67
  );
50
68
  }
51
69
 
@@ -106,6 +124,7 @@ void bind_ops_dc(py::module &m) {
106
124
  py::arg("grid_normals") = py::none(), py::arg("colors") = py::none(),
107
125
  py::arg("voxel_vertices") = py::none(),
108
126
  py::arg("iso") = 0.0f, py::arg("quad_split") = true,
127
+ py::arg("edge_points") = py::none(), py::arg("edge_normals") = py::none(),
109
128
  R"pbdoc(
110
129
  Extracts a sharp-feature preserving surface mesh using Dual Contouring with GPU QEF solver (Ju et al. 2002) or precomputed voxel vertices.
111
130
 
@@ -21,7 +21,9 @@ std::tuple<torch::Tensor, torch::Tensor, std::optional<torch::Tensor>> dual_marc
21
21
  std::optional<torch::Tensor> voxel_vertices,
22
22
  float iso,
23
23
  bool quad_split,
24
- int project_iters
24
+ int project_iters,
25
+ std::optional<torch::Tensor> edge_points,
26
+ std::optional<torch::Tensor> edge_normals
25
27
  ) {
26
28
  CHECK_INPUT(grid_vertices);
27
29
  CHECK_INPUT(voxels);
@@ -33,6 +35,15 @@ std::tuple<torch::Tensor, torch::Tensor, std::optional<torch::Tensor>> dual_marc
33
35
  if (voxel_vertices.has_value() && voxel_vertices.value().defined()) {
34
36
  CHECK_INPUT(voxel_vertices.value());
35
37
  }
38
+ for (auto *t : {&edge_points, &edge_normals}) {
39
+ if (t->has_value() && t->value().defined()) {
40
+ CHECK_INPUT(t->value());
41
+ TORCH_CHECK(t->value().dim() == 3 && t->value().size(1) == 12 && t->value().size(2) == 3,
42
+ "edge_points/edge_normals must have shape (M, 12, 3)");
43
+ TORCH_CHECK(t->value().size(0) == voxels.size(0),
44
+ "edge_points/edge_normals must have one row per voxel");
45
+ }
46
+ }
36
47
 
37
48
  return conquer3d::ops::dual_marching_cubes(
38
49
  grid_vertices,
@@ -42,7 +53,9 @@ std::tuple<torch::Tensor, torch::Tensor, std::optional<torch::Tensor>> dual_marc
42
53
  voxel_vertices,
43
54
  iso,
44
55
  quad_split,
45
- project_iters
56
+ project_iters,
57
+ edge_points,
58
+ edge_normals
46
59
  );
47
60
  }
48
61
 
@@ -99,6 +112,7 @@ void bind_ops_dmc(py::module &m) {
99
112
  py::arg("grid_vertices"), py::arg("voxels"), py::arg("sdf"),
100
113
  py::arg("colors") = py::none(), py::arg("voxel_vertices") = py::none(),
101
114
  py::arg("iso") = 0.0f, py::arg("quad_split") = true, py::arg("project_iters") = 5,
115
+ py::arg("edge_points") = py::none(), py::arg("edge_normals") = py::none(),
102
116
  R"pbdoc(
103
117
  Extracts a watertight 2-manifold surface mesh using Differentiable Dual Marching Cubes (Schaefer & Warren 2004) or precomputed voxel vertices.
104
118
 
@@ -144,6 +144,7 @@ __host__ __device__ __forceinline__ void symmetric_eigen_3x3(
144
144
  * @param cell_min Minimum AABB coordinate of the voxel cell.
145
145
  * @param cell_max Maximum AABB coordinate of the voxel cell.
146
146
  * @param svd_tolerance Relative eigenvalue threshold for pseudoinverse (default: 0.01).
147
+ * @param cell_expand Scale applied to the cell half-extents before clamping (default: 2.0).
147
148
  * @return Optimal inner vertex position x*.
148
149
  */
149
150
  __host__ __device__ __forceinline__ float3 solve_qef(
@@ -152,12 +153,18 @@ __host__ __device__ __forceinline__ float3 solve_qef(
152
153
  int count,
153
154
  const float3 &cell_min,
154
155
  const float3 &cell_max,
155
- float svd_tolerance = 0.01f
156
+ float svd_tolerance = 0.01f,
157
+ float cell_expand = 2.0f
156
158
  ) {
157
159
  if (count <= 0) {
158
160
  return (cell_min + cell_max) * 0.5f;
159
161
  }
160
162
 
163
+ const float3 cell_centre = (cell_min + cell_max) * 0.5f;
164
+ const float3 cell_half = (cell_max - cell_min) * (0.5f * cell_expand);
165
+ const float3 clamp_min = cell_centre - cell_half;
166
+ const float3 clamp_max = cell_centre + cell_half;
167
+
161
168
  // 1. Compute Mass Point (Centroid)
162
169
  float3 mass_point = make_float3(0.0f, 0.0f, 0.0f);
163
170
  for (int i = 0; i < count; ++i) {
@@ -166,7 +173,7 @@ __host__ __device__ __forceinline__ float3 solve_qef(
166
173
  mass_point = mass_point * (1.0f / (float)count);
167
174
 
168
175
  if (count == 1) {
169
- return maths::clamp(pts[0], cell_min, cell_max);
176
+ return maths::clamp(pts[0], clamp_min, clamp_max);
170
177
  }
171
178
 
172
179
  // 2. Build Shifted Normal Equation System: (A^T A) y = b_tilde
@@ -224,9 +231,9 @@ __host__ __device__ __forceinline__ float3 solve_qef(
224
231
  y = y + v2 * proj;
225
232
  }
226
233
 
227
- // 5. Unshift and Clamp to Voxel AABB
234
+ // 5. Unshift and Clamp to the (optionally widened) Voxel AABB
228
235
  float3 x = mass_point + y;
229
- x = maths::clamp(x, cell_min, cell_max);
236
+ x = maths::clamp(x, clamp_min, clamp_max);
230
237
 
231
238
  return x;
232
239
  }
@@ -138,6 +138,8 @@ __global__ void compute_dual_vertices_kernel(
138
138
  const int *__restrict__ voxels,
139
139
  const float *__restrict__ sdf,
140
140
  const float3 *__restrict__ grid_normals,
141
+ const float3 *__restrict__ edge_points,
142
+ const float3 *__restrict__ edge_normals,
141
143
  float iso,
142
144
  int num_voxels,
143
145
  float3 *__restrict__ dual_vertices,
@@ -184,11 +186,27 @@ __global__ void compute_dual_vertices_kernel(
184
186
  float t = (iso - s0) / (s1 - s0);
185
187
  t = fmaxf(0.0f, fminf(1.0f, t));
186
188
 
187
- float3 pt = p[v0] + (p[v1] - p[v0]) * t;
189
+ float3 pt;
190
+ float3 n;
191
+ bool have_hermite = (edge_points != nullptr && edge_normals != nullptr);
192
+ if (have_hermite) {
193
+ pt = edge_points[m * 12 + e];
194
+ float3 hn = edge_normals[m * 12 + e];
195
+ float hlen = maths::norm(hn);
196
+ if (hlen > 1e-8f) {
197
+ n = hn * (1.0f / hlen);
198
+ } else {
199
+ have_hermite = false;
200
+ }
201
+ }
202
+ if (!have_hermite) {
203
+ pt = p[v0] + (p[v1] - p[v0]) * t;
204
+ }
188
205
  pts[count] = pt;
189
206
 
190
- float3 n;
191
- if (grid_normals != nullptr) {
207
+ if (have_hermite) {
208
+ // normal already set from the supplied Hermite data
209
+ } else if (grid_normals != nullptr) {
192
210
  float3 n0 = grid_normals[c_idx[v0]];
193
211
  float3 n1 = grid_normals[c_idx[v1]];
194
212
  float3 n_interp = n0 + (n1 - n0) * t;
@@ -665,7 +683,9 @@ std::tuple<at::Tensor, at::Tensor, c10::optional<at::Tensor>> dual_contouring(
665
683
  const c10::optional<at::Tensor> &colors,
666
684
  const c10::optional<at::Tensor> &voxel_vertices,
667
685
  float iso,
668
- bool quad_split
686
+ bool quad_split,
687
+ const c10::optional<at::Tensor> &edge_points,
688
+ const c10::optional<at::Tensor> &edge_normals
669
689
  ) {
670
690
  at::cuda::CUDAGuard device_guard(grid_vertices.device());
671
691
  auto allocator = at::cuda::ThrustAllocator();
@@ -705,12 +725,18 @@ std::tuple<at::Tensor, at::Tensor, c10::optional<at::Tensor>> dual_contouring(
705
725
  dual_vertices = at::empty({num_voxels, 3}, grid_vertices.options());
706
726
  source_dual_vertices_ptr = reinterpret_cast<const float3*>(dual_vertices.data_ptr<float>());
707
727
  const float3 *normals_ptr = grid_normals.has_value() ? reinterpret_cast<const float3*>(grid_normals.value().data_ptr<float>()) : nullptr;
728
+ const float3 *ep_ptr = (edge_points.has_value() && edge_points.value().defined() && edge_points.value().numel() > 0)
729
+ ? reinterpret_cast<const float3*>(edge_points.value().data_ptr<float>()) : nullptr;
730
+ const float3 *en_ptr = (edge_normals.has_value() && edge_normals.value().defined() && edge_normals.value().numel() > 0)
731
+ ? reinterpret_cast<const float3*>(edge_normals.value().data_ptr<float>()) : nullptr;
708
732
 
709
733
  compute_dual_vertices_kernel<<<blocks, threads, 0, at::cuda::getCurrentCUDAStream()>>>(
710
734
  reinterpret_cast<const float3*>(grid_vertices.data_ptr<float>()),
711
735
  voxels.data_ptr<int>(),
712
736
  sdf.data_ptr<float>(),
713
737
  normals_ptr,
738
+ ep_ptr,
739
+ en_ptr,
714
740
  iso,
715
741
  num_voxels,
716
742
  reinterpret_cast<float3*>(dual_vertices.data_ptr<float>()),
@@ -910,6 +936,8 @@ std::tuple<at::Tensor, c10::optional<at::Tensor>> dual_contouring_backward(
910
936
  voxels.data_ptr<int>(),
911
937
  sdf.data_ptr<float>(),
912
938
  normals_ptr,
939
+ nullptr,
940
+ nullptr,
913
941
  iso,
914
942
  num_voxels,
915
943
  reinterpret_cast<float3*>(dual_vertices.data_ptr<float>()),
@@ -30,7 +30,9 @@ std::tuple<at::Tensor, at::Tensor, c10::optional<at::Tensor>> dual_contouring(
30
30
  const c10::optional<at::Tensor> &colors = c10::nullopt,
31
31
  const c10::optional<at::Tensor> &voxel_vertices = c10::nullopt,
32
32
  float iso = 0.0f,
33
- bool quad_split = true
33
+ bool quad_split = true,
34
+ const c10::optional<at::Tensor> &edge_points = c10::nullopt,
35
+ const c10::optional<at::Tensor> &edge_normals = c10::nullopt
34
36
  );
35
37
 
36
38
  /**
@@ -59,13 +59,20 @@ static __constant__ float dc_corner_uvw[8][3] = {
59
59
  * deterministically to one of four quadrant slots. Because adjacent cells agree on this
60
60
  * mapping, the dual quad around a shared edge is assembled consistently from all four
61
61
  * incident cells.
62
+ *
63
+ * Slots 0-3 must walk the four incident cells **counter-clockwise about the edge's own
64
+ * positive axis**, and all three edge families must agree on that handedness -- otherwise
65
+ * the faces of one family are wound backwards relative to the rest and the extracted mesh
66
+ * has inconsistent normals. The right-handed plane perpendicular to each axis is $(Y, Z)$
67
+ * for $+X$, $(Z, X)$ for $+Y$ and $(X, Y)$ for $+Z$; note that $+Y$ pairs with $(Z, X)$ and
68
+ * not $(X, Z)$, which is the easy mistake here.
62
69
  */
63
70
  static __constant__ int dc_edge_quadrant[12] = {
64
71
  0, // e=0 (+X) -> slot 0
65
72
  3, // e=1 (+Y) -> slot 3
66
- 3, // e=2 (+X) -> slot 3
73
+ 1, // e=2 (+X) -> slot 1
67
74
  0, // e=3 (+Y) -> slot 0
68
- 1, // e=4 (+X) -> slot 1
75
+ 3, // e=4 (+X) -> slot 3
69
76
  2, // e=5 (+Y) -> slot 2
70
77
  2, // e=6 (+X) -> slot 2
71
78
  1, // e=7 (+Y) -> slot 1
@@ -368,6 +368,8 @@ __global__ void dmc_extract_dual_vertices_and_edges_kernel(
368
368
  const float *__restrict__ sdf,
369
369
  const float *__restrict__ colors,
370
370
  const float3 *__restrict__ precomputed_vertices,
371
+ const float3 *__restrict__ edge_points,
372
+ const float3 *__restrict__ edge_normals,
371
373
  int num_channels,
372
374
  const int *__restrict__ vert_offsets,
373
375
  const int *__restrict__ edge_offsets,
@@ -436,8 +438,22 @@ __global__ void dmc_extract_dual_vertices_and_edges_kernel(
436
438
  int dual_vert_idx = v_base + c;
437
439
  float u_sum = 0.0f, v_sum = 0.0f, w_sum = 0.0f;
438
440
 
441
+ const bool use_hermite = (edge_points != nullptr && edge_normals != nullptr);
442
+ float3 h_pts[12];
443
+ float3 h_nrm[12];
444
+ int h_count = 0;
445
+
439
446
  for (int i = 0; i < sz; ++i) {
440
447
  int e = c_edges[c][i];
448
+ if (use_hermite && h_count < 12) {
449
+ float3 hn = edge_normals[m * 12 + e];
450
+ float hlen = maths::norm(hn);
451
+ if (hlen > 1e-8f) {
452
+ h_pts[h_count] = edge_points[m * 12 + e];
453
+ h_nrm[h_count] = hn * (1.0f / hlen);
454
+ h_count++;
455
+ }
456
+ }
441
457
  int v0 = dmc_edge_corners[e][0];
442
458
  int v1 = dmc_edge_corners[e][1];
443
459
  float s0 = s[v0];
@@ -476,6 +492,16 @@ __global__ void dmc_extract_dual_vertices_and_edges_kernel(
476
492
  u = fmaxf(0.0f, fminf(1.0f, (pt.x - c_min.x) / dx));
477
493
  v = fmaxf(0.0f, fminf(1.0f, (pt.y - c_min.y) / dy));
478
494
  w = fmaxf(0.0f, fminf(1.0f, (pt.z - c_min.z) / dz));
495
+ } else if (use_hermite && h_count > 0) {
496
+ // Solve the quadratic error function over THIS contour's Hermite data.
497
+ // Restricting the solve to one contour is what keeps a cell that carries
498
+ // several contours emitting several distinct vertices, so the manifold
499
+ // guarantee survives while each vertex still lands on its own feature.
500
+ float3 pt = maths::solve_qef(h_pts, h_nrm, h_count, c_min, c_max, 0.01f);
501
+ out_vertices[dual_vert_idx] = pt;
502
+ u = fmaxf(0.0f, fminf(1.0f, (pt.x - c_min.x) / dx));
503
+ v = fmaxf(0.0f, fminf(1.0f, (pt.y - c_min.y) / dy));
504
+ w = fmaxf(0.0f, fminf(1.0f, (pt.z - c_min.z) / dz));
479
505
  } else {
480
506
  // Newton-Raphson Level-Set Projection
481
507
  for (int iter = 0; iter < project_iters; ++iter) {
@@ -802,7 +828,9 @@ std::tuple<at::Tensor, at::Tensor, c10::optional<at::Tensor>> dual_marching_cube
802
828
  const c10::optional<at::Tensor> &voxel_vertices,
803
829
  float iso,
804
830
  bool quad_split,
805
- int project_iters
831
+ int project_iters,
832
+ const c10::optional<at::Tensor> &edge_points,
833
+ const c10::optional<at::Tensor> &edge_normals
806
834
  ) {
807
835
  TORCH_CHECK(grid_vertices.is_cuda(), "grid_vertices must be a CUDA tensor");
808
836
  TORCH_CHECK(voxels.is_cuda(), "voxels must be a CUDA tensor");
@@ -889,12 +917,19 @@ std::tuple<at::Tensor, at::Tensor, c10::optional<at::Tensor>> dual_marching_cube
889
917
  ? reinterpret_cast<const float3*>(voxel_vertices->data_ptr<float>())
890
918
  : nullptr;
891
919
 
920
+ const float3 *dmc_ep_ptr = (edge_points.has_value() && edge_points->defined() && edge_points->numel() > 0)
921
+ ? reinterpret_cast<const float3*>(edge_points->data_ptr<float>()) : nullptr;
922
+ const float3 *dmc_en_ptr = (edge_normals.has_value() && edge_normals->defined() && edge_normals->numel() > 0)
923
+ ? reinterpret_cast<const float3*>(edge_normals->data_ptr<float>()) : nullptr;
924
+
892
925
  dmc_extract_dual_vertices_and_edges_kernel<<<grid, block, 0, stream>>>(
893
926
  reinterpret_cast<const float3*>(grid_vertices.data_ptr<float>()),
894
927
  voxels.data_ptr<int>(),
895
928
  sdf.data_ptr<float>(),
896
929
  colors_ptr,
897
930
  precomputed_ptr,
931
+ dmc_ep_ptr,
932
+ dmc_en_ptr,
898
933
  num_channels,
899
934
  vert_offsets.data_ptr<int>(),
900
935
  edge_offsets.data_ptr<int>(),
@@ -29,7 +29,9 @@ std::tuple<at::Tensor, at::Tensor, c10::optional<at::Tensor>> dual_marching_cube
29
29
  const c10::optional<at::Tensor> &voxel_vertices = c10::nullopt,
30
30
  float iso = 0.0f,
31
31
  bool quad_split = true,
32
- int project_iters = 5
32
+ int project_iters = 5,
33
+ const c10::optional<at::Tensor> &edge_points = c10::nullopt,
34
+ const c10::optional<at::Tensor> &edge_normals = c10::nullopt
33
35
  );
34
36
 
35
37
  /**
@@ -79,9 +79,9 @@ static __constant__ float dmc_corner_uvw[8][3] = {
79
79
  static __constant__ int dmc_edge_quadrant[12] = {
80
80
  0, // e=0 (+X) -> slot 0
81
81
  3, // e=1 (+Y) -> slot 3
82
- 3, // e=2 (+X) -> slot 3
82
+ 1, // e=2 (+X) -> slot 1
83
83
  0, // e=3 (+Y) -> slot 0
84
- 1, // e=4 (+X) -> slot 1
84
+ 3, // e=4 (+X) -> slot 3
85
85
  2, // e=5 (+Y) -> slot 2
86
86
  2, // e=6 (+X) -> slot 2
87
87
  1, // e=7 (+Y) -> slot 1
@@ -616,8 +616,15 @@ __global__ void interpolate_vertices_kernel(
616
616
  * @param[in] voxel_triangle_prefix_sums Device array of per-voxel output offsets.
617
617
  * @param[out] out_triangles Device array receiving triangle vertex index triples.
618
618
  * @note Launched with `NTHREADS` threads per block over a 1D grid.
619
- * @note Winding follows the table, giving outward-facing normals for a field that is
620
- * negative inside.
619
+ * @note The implementation is based on Bourke implementation at http://paulbourke.net/geometry/polygonise/.
620
+ * @note The adatation to CUDA at first is normal inconsistent where all normals are facing inwards.
621
+ * @note The canonical Lorensen-Cline / Bourke ::triTable is written for the convention
622
+ * that a corner bit is set when the corner is *below* the isolevel, and it winds each
623
+ * triangle so the right-hand normal points towards that below-isolevel region. For a
624
+ * signed distance field, below-isolevel is the *interior*, so emitting the table row
625
+ * verbatim yields inward-facing normals. The last two indices are therefore swapped on
626
+ * write, which reverses the winding and gives outward-facing normals for a field that is
627
+ * negative inside -- matching Dual Contouring and the rest of the library.
621
628
  */
622
629
  __global__ void assemble_triangles_kernel(
623
630
  const uint32_t num_active_voxels,
@@ -648,9 +655,11 @@ __global__ void assemble_triangles_kernel(
648
655
  uint32_t v1 = voxel_edge_to_vert_idx[active_voxel_idx * 12 + edge1];
649
656
  uint32_t v2 = voxel_edge_to_vert_idx[active_voxel_idx * 12 + edge2];
650
657
 
658
+ // Reversed winding: see the note above. The table's own order points the
659
+ // normal into the solid for a negative-inside field.
651
660
  out_triangles[(start_tri_idx + tri_count) * 3 + 0] = v0;
652
- out_triangles[(start_tri_idx + tri_count) * 3 + 1] = v1;
653
- out_triangles[(start_tri_idx + tri_count) * 3 + 2] = v2;
661
+ out_triangles[(start_tri_idx + tri_count) * 3 + 1] = v2;
662
+ out_triangles[(start_tri_idx + tri_count) * 3 + 2] = v1;
654
663
 
655
664
  tri_count++;
656
665
  }
@@ -310,8 +310,8 @@ __global__ void generate_edges_and_triangles_mca_kernel(
310
310
  for (int t = 0; t < 5 && tri_edges[t * 3] != -1; ++t) {
311
311
  int local_edges[3] = {
312
312
  tri_edges[t * 3 + 0],
313
- tri_edges[t * 3 + 1],
314
- tri_edges[t * 3 + 2]
313
+ tri_edges[t * 3 + 2],
314
+ tri_edges[t * 3 + 1]
315
315
  };
316
316
  #pragma unroll
317
317
  for (int e_idx = 0; e_idx < 3; ++e_idx) {
@@ -85,16 +85,16 @@ __constant__ int tetTriTable[16][7] = {
85
85
  {-1, -1, -1, -1, -1, -1, -1}, // 0x00
86
86
  { 0, 1, 2, -1, -1, -1, -1}, // 0x01
87
87
  { 0, 4, 3, -1, -1, -1, -1}, // 0x02
88
- { 2, 1, 4, 4, 3, 1, -1}, // 0x03
88
+ { 1, 2, 4, 1, 4, 3, -1}, // 0x03
89
89
  { 1, 3, 5, -1, -1, -1, -1}, // 0x04
90
90
  { 0, 5, 2, 0, 3, 5, -1}, // 0x05
91
- { 0, 4, 5, 0, 1, 5, -1}, // 0x06
92
- { 2, 5, 4, -1, -1, -1, -1}, // 0x07
93
- { 2, 4, 5, -1, -1, -1, -1}, // 0x08
94
- { 0, 5, 4, 0, 1, 5, -1}, // 0x09
95
- { 0, 2, 5, 0, 5, 3, -1}, // 0x0A
91
+ { 0, 4, 5, 0, 5, 1, -1}, // 0x06
92
+ { 2, 4, 5, -1, -1, -1, -1}, // 0x07
93
+ { 2, 5, 4, -1, -1, -1, -1}, // 0x08
94
+ { 0, 1, 5, 0, 5, 4, -1}, // 0x09
95
+ { 0, 5, 3, 0, 2, 5, -1}, // 0x0A
96
96
  { 1, 5, 3, -1, -1, -1, -1}, // 0x0B
97
- { 2, 4, 1, 4, 1, 3, -1}, // 0x0C
97
+ { 1, 3, 4, 1, 4, 2, -1}, // 0x0C
98
98
  { 0, 3, 4, -1, -1, -1, -1}, // 0x0D
99
99
  { 0, 2, 1, -1, -1, -1, -1}, // 0x0E
100
100
  {-1, -1, -1, -1, -1, -1, -1} // 0x0F
@@ -25,10 +25,10 @@ namespace mtg {
25
25
  */
26
26
  __constant__ int mtg_tets[6][4] = {
27
27
  {0, 2, 3, 7},
28
- {0, 2, 6, 7},
28
+ {0, 2, 7, 6},
29
29
  {0, 4, 6, 7},
30
30
  {0, 6, 1, 2},
31
- {0, 6, 1, 4},
31
+ {0, 6, 4, 1},
32
32
  {5, 6, 1, 4}
33
33
  };
34
34
 
@@ -60,16 +60,16 @@ __constant__ int mtg_triTable[16][7] = {
60
60
  {-1, -1, -1, -1, -1, -1, -1}, // 0x00
61
61
  { 0, 1, 2, -1, -1, -1, -1}, // 0x01
62
62
  { 0, 4, 3, -1, -1, -1, -1}, // 0x02
63
- { 2, 1, 4, 4, 3, 1, -1}, // 0x03
63
+ { 1, 2, 4, 1, 4, 3, -1}, // 0x03
64
64
  { 1, 3, 5, -1, -1, -1, -1}, // 0x04
65
65
  { 0, 5, 2, 0, 3, 5, -1}, // 0x05
66
- { 0, 4, 5, 0, 1, 5, -1}, // 0x06
67
- { 2, 5, 4, -1, -1, -1, -1}, // 0x07
68
- { 2, 4, 5, -1, -1, -1, -1}, // 0x08
69
- { 0, 5, 4, 0, 1, 5, -1}, // 0x09
70
- { 0, 2, 5, 0, 5, 3, -1}, // 0x0A
66
+ { 0, 4, 5, 0, 5, 1, -1}, // 0x06
67
+ { 2, 4, 5, -1, -1, -1, -1}, // 0x07
68
+ { 2, 5, 4, -1, -1, -1, -1}, // 0x08
69
+ { 0, 1, 5, 0, 5, 4, -1}, // 0x09
70
+ { 0, 5, 3, 0, 2, 5, -1}, // 0x0A
71
71
  { 1, 5, 3, -1, -1, -1, -1}, // 0x0B
72
- { 2, 4, 1, 4, 1, 3, -1}, // 0x0C
72
+ { 1, 3, 4, 1, 4, 2, -1}, // 0x0C
73
73
  { 0, 3, 4, -1, -1, -1, -1}, // 0x0D
74
74
  { 0, 2, 1, -1, -1, -1, -1}, // 0x0E
75
75
  {-1, -1, -1, -1, -1, -1, -1} // 0x0F
@@ -13,6 +13,7 @@ This package provides:
13
13
  from .marching_cubes import marching_cubes
14
14
  from .marching_cubes_asymptotic import marching_cubes_asymptotic, mca
15
15
  from .dual_contouring import dual_contouring, dc
16
+ from .hermite import compute_hermite_from_mesh, compute_hermite_from_field, DC_EDGE_CORNERS
16
17
  from .dual_marching_cubes import dual_marching_cubes, dmc
17
18
  from .diff_marching_cubes import diff_marching_cubes
18
19
 
@@ -31,6 +32,9 @@ __all__ = [
31
32
  "mca",
32
33
  "dual_contouring",
33
34
  "dc",
35
+ "compute_hermite_from_mesh",
36
+ "compute_hermite_from_field",
37
+ "DC_EDGE_CORNERS",
34
38
  "dual_marching_cubes",
35
39
  "dmc",
36
40
  "diff_marching_cubes",