{"id":17222814,"url":"https://github.com/cheind/sdftoolbox","last_synced_at":"2025-04-14T00:17:28.692Z","repository":{"id":51275285,"uuid":"498233483","full_name":"cheind/sdftoolbox","owner":"cheind","description":"Vectorized Python methods for creating, manipulating and tessellating signed distance fields.","archived":false,"fork":false,"pushed_at":"2023-09-01T08:39:00.000Z","size":18895,"stargazers_count":52,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T14:21:16.926Z","etag":null,"topics":["dual-method","isosurface","isosurface-extraction","signed-distance-fields","surfacenets"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cheind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-31T07:34:57.000Z","updated_at":"2025-03-17T21:42:58.000Z","dependencies_parsed_at":"2022-08-25T14:30:51.268Z","dependency_job_id":null,"html_url":"https://github.com/cheind/sdftoolbox","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Fsdftoolbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Fsdftoolbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Fsdftoolbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Fsdftoolbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cheind","download_url":"https://codeload.github.com/cheind/sdftoolbox/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799960,"owners_count":21163404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dual-method","isosurface","isosurface-extraction","signed-distance-fields","surfacenets"],"created_at":"2024-10-15T04:06:25.395Z","updated_at":"2025-04-14T00:17:28.668Z","avatar_url":"https://github.com/cheind.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](https://github.com/cheind/sdftoolbox/actions/workflows/python-package.yml/badge.svg)\n\n# sdftoolbox\n\nThis repository provides vectorized Python methods for creating, manipulating and tessellating signed distance fields (SDFs). This library was started to investigate variants of dual isosurface extraction methods, but has since evolved into a useful toolbox around SDFs.\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"doc/surfacenets.svg\"\u003e\n\u003c/div\u003e\n\nThe image above shows two reconstructions of a sphere displaced by waves. The reconstruction on the left uses (dual) SurfaceNets from this library, the right side shows the result of applying (primal) Marching Cubes algorithm from scikit-image.\n\nSee [examples/compare.py](examples/compare.py) for details and [doc/SDF.md](doc/SDF.md) for an in-depth documentation.\n\n## Features\n\n-   A generic blueprint algorithm for dual iso-surface generation from SDFs\n    -   providing the following vertex placement strategies\n        -   (Naive) SurfaceNets\n        -   Dual Contouring\n        -   Midpoint to generate Minecraft like reconstructions\n    -   providing the following edge/surface boundary intersection strategies\n        -   Linear (single step)\n        -   Newton (iterative)\n        -   Bisection (iterative)\n-   Mesh postprocessing\n    -   Vertex reprojection onto SDFs\n    -   Quad/Triangle topology support\n    -   Vertex/Face normal support\n-   Tools for programmatically creating and modifying SDFs\n-   Importing volumetric SDFs from NeRF tools such as [instant-ngp](https://www.google.com/search?channel=fs\u0026client=ubuntu-sn\u0026q=instant-ngp) and [NeuS2](https://github.com/19reborn/NeuS2)\n-   Inline plotting support for reconstructed meshes using matplotlib\n-   Exporting (STL) of tesselated isosurfaces\n\n## Documentation\n\nAlgorithmic ideas, mathematical details and results are discussed in [doc/SDF.md](doc/SDF.md).\n\n## Example Code\n\n```python\n# Main import\nimport sdftoolbox\n\n# Setup a snowman-scene\nsnowman = sdftoolbox.sdfs.Union(\n    [\n        sdftoolbox.sdfs.Sphere.create(center=(0, 0, 0), radius=0.4),\n        sdftoolbox.sdfs.Sphere.create(center=(0, 0, 0.45), radius=0.3),\n        sdftoolbox.sdfs.Sphere.create(center=(0, 0, 0.8), radius=0.2),\n    ],\n)\nfamily = sdftoolbox.sdfs.Union(\n    [\n        snowman.transform(trans=(-0.75, 0.0, 0.0)),\n        snowman.transform(trans=(0.0, -0.3, 0.0), scale=0.8),\n        snowman.transform(trans=(0.75, 0.0, 0.0), scale=0.6),\n    ]\n)\nscene = sdftoolbox.sdfs.Difference(\n    [\n        family,\n        sdftoolbox.sdfs.Plane().transform(trans=(0, 0, -0.2)),\n    ]\n)\n\n# Generate the sampling locations. Here we use the default params\ngrid = sdftoolbox.Grid(\n    res=(65, 65, 65),\n    min_corner=(-1.5, -1.5, -1.5),\n    max_corner=(1.5, 1.5, 1.5),\n)\n\n# Extract the surface using dual contouring\nverts, faces = sdftoolbox.dual_isosurface(\n    scene,\n    grid,\n    vertex_strategy=sdftoolbox.NaiveSurfaceNetVertexStrategy(),\n    triangulate=False,\n)\n```\n\ngenerates\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"doc/hello_surfacenets.svg\" width=\"30%\"\u003e\n\u003c/div\u003e\n\nSee [examples/hello_dualiso.py](examples/hello_dualiso.py) for details.\n\n## Install\n\nInstall with development extras to run all the examples.\n\n```\npip install git+https://github.com/cheind/sdf-surfacenets#egg=sdf-surfacenets[dev]\n```\n\n## Examples\n\nThe examples can be found in [./examples/](./examples/). Each example can be invoked as a module\n\n```\npython -m examples.\u003cname\u003e\n```\n\n### Mesh from NeRF\n\nThis library supports loading SDFs from density fields provided by various NeRF implementations (instant-ngp and NeuS2). These discretized SDF fields can then be manipulated/triangulated using **sdftoolbox** routines.\n\nThe following image shows the resulting triangulated mesh from the Lego scene generated by **sdftoolbox** from an instant-ngp density image atlas.\n\n![](doc/nerf/naive25600.png)\n\nCommand\n\n```shell\npython -m examples.nerf2mesh        \\\n    -r 256 -t 4.0 -o -1.5 -s 0.0117 \\\n    --sdf-flip                      \\\n    doc/nerf/density.png\n\n# Use 'python -m examples.nerf2mesh --help' for more options.\n```\n\nNote, meshes generated by **sdftoolbox** seem to be of better quality than those generated by the respective NeRF tools. The following compares a low-res reconstruction (res=64,drange=1) of the same scene\n\n|        sdftoolbox         |           NeuS2           |\n| :-----------------------: | :-----------------------: |\n| ![](doc/nerf/naive01.png) | ![](doc/nerf/neus200.png) |\n\nSee https://github.com/19reborn/NeuS2/issues/22 for a discussion\n\n### Gallery\n\nHere are some additional plots from various examples\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"doc/normals.gif\" width=\"50%\"\u003e\n\u003c/div\u003e\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"doc/lods.svg\" width=\"50%\"\u003e\n\u003c/div\u003e\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"doc/bool.svg\" width=\"50%\"\u003e\n\u003c/div\u003e\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"doc/edge_strategies_sphere.svg\" width=\"50%\"\u003e\n\u003c/div\u003e\n\n## References\n\nSee [doc/SDF.md](doc/SDF.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheind%2Fsdftoolbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheind%2Fsdftoolbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheind%2Fsdftoolbox/lists"}