mesh2sdf2 2.1.1__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.
- mesh2sdf2-2.1.1/LICENSE +19 -0
- mesh2sdf2-2.1.1/MANIFEST.in +1 -0
- mesh2sdf2-2.1.1/PKG-INFO +118 -0
- mesh2sdf2-2.1.1/README.md +92 -0
- mesh2sdf2-2.1.1/csrc/array3.h +67 -0
- mesh2sdf2-2.1.1/csrc/makelevelset3.cpp +578 -0
- mesh2sdf2-2.1.1/csrc/makelevelset3.h +17 -0
- mesh2sdf2-2.1.1/csrc/pybind.cpp +68 -0
- mesh2sdf2-2.1.1/csrc/vec.h +63 -0
- mesh2sdf2-2.1.1/mesh2sdf/__init__.py +1 -0
- mesh2sdf2-2.1.1/mesh2sdf/compute.py +47 -0
- mesh2sdf2-2.1.1/mesh2sdf2.egg-info/PKG-INFO +118 -0
- mesh2sdf2-2.1.1/mesh2sdf2.egg-info/SOURCES.txt +19 -0
- mesh2sdf2-2.1.1/mesh2sdf2.egg-info/dependency_links.txt +1 -0
- mesh2sdf2-2.1.1/mesh2sdf2.egg-info/requires.txt +3 -0
- mesh2sdf2-2.1.1/mesh2sdf2.egg-info/top_level.txt +1 -0
- mesh2sdf2-2.1.1/pyproject.toml +56 -0
- mesh2sdf2-2.1.1/setup.cfg +4 -0
- mesh2sdf2-2.1.1/setup.py +30 -0
- mesh2sdf2-2.1.1/tests/test_mesh2sdf.py +231 -0
- mesh2sdf2-2.1.1/tests/test_sweep_equivalence.py +84 -0
mesh2sdf2-2.1.1/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2022 Peng-Shuai Wang <wangps@hotmail.com>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
graft csrc
|
mesh2sdf2-2.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mesh2sdf2
|
|
3
|
+
Version: 2.1.1
|
|
4
|
+
Summary: Compute the signed distance field from an input mesh
|
|
5
|
+
Author-email: Lucas Mosquera <25126199+LuckJMG@users.noreply.github.com>, Peng-Shuai Wang <wangps@hotmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/LuckJMG/mesh2sdf2
|
|
8
|
+
Project-URL: Source, https://github.com/LuckJMG/mesh2sdf2
|
|
9
|
+
Project-URL: Issues, https://github.com/LuckJMG/mesh2sdf2/issues
|
|
10
|
+
Project-URL: Upstream, https://github.com/wang-ps/mesh2sdf
|
|
11
|
+
Keywords: sdf,mesh,signed-distance-field,pybind11,3d
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: numpy
|
|
23
|
+
Requires-Dist: trimesh
|
|
24
|
+
Requires-Dist: scikit-image
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# Mesh2SDF2
|
|
28
|
+
|
|
29
|
+
[](https://pepy.tech/project/mesh2sdf2)
|
|
30
|
+
[](https://pepy.tech/project/mesh2sdf2/month)
|
|
31
|
+
[](https://pypi.org/project/mesh2sdf2/)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
> **This is a community-maintained fork** of
|
|
35
|
+
> [mesh2sdf](https://github.com/wang-ps/mesh2sdf) by Peng-Shuai Wang. It adds
|
|
36
|
+
> Python 3.10–3.14 support, modernizes the build (setuptools ≥68,
|
|
37
|
+
> pybind11 ≥2.13), and improve the compute speed. Original project, paper, and algorithm: see the
|
|
38
|
+
> [upstream repo](https://github.com/wang-ps/mesh2sdf). License: MIT.
|
|
39
|
+
|
|
40
|
+
Converts an input mesh to a signed distance field. It can work with arbitrary
|
|
41
|
+
meshes, even **non-watertight** meshes from ShapeNet.
|
|
42
|
+
|
|
43
|
+
`mesh2sdf` is used in their paper
|
|
44
|
+
[Dual Octree Graph Networks (SIGGRAPH 2022)](https://wang-ps.github.io/dualocnn)
|
|
45
|
+
to generate the training data.
|
|
46
|
+
Please cite their paper if you find the code useful for your research.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
`mesh2sdf2` depends on [pybind11](https://github.com/pybind/pybind11), and C++
|
|
52
|
+
compilers are needed to build the code. Supported compilers are listed
|
|
53
|
+
[here](https://github.com/pybind/pybind11#supported-compilers).
|
|
54
|
+
|
|
55
|
+
- Install via the following command:
|
|
56
|
+
``` shell
|
|
57
|
+
pip install mesh2sdf2
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- Alternatively, install from the source code via the following commands.
|
|
61
|
+
``` shell
|
|
62
|
+
git clone https://github.com/LuckJMG/mesh2sdf2.git
|
|
63
|
+
cd mesh2sdf2
|
|
64
|
+
pip install .
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- Alternatively, install from the source code via the following commands.
|
|
68
|
+
``` shell
|
|
69
|
+
git clone https://github.com/wang-ps/mesh2sdf.git
|
|
70
|
+
pip install ./mesh2sdf
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Example
|
|
74
|
+
|
|
75
|
+
After installing `mesh2sdf`, run the following command to process an input mesh
|
|
76
|
+
from ShapeNet:
|
|
77
|
+
|
|
78
|
+
```shell
|
|
79
|
+
python example/demo.py
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+

|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## How does it work?
|
|
86
|
+
|
|
87
|
+
- Given an input mesh, we first compute the **unsigned** distance field with the
|
|
88
|
+
fast sweeping algorithm implemented by
|
|
89
|
+
[Christopher Batty (SDFGen)](https://github.com/christopherbatty/SDFGen).
|
|
90
|
+
Note that the unsigned distance field can always be reliably and accurately
|
|
91
|
+
computed even though the input mesh is non-watertight.
|
|
92
|
+
|
|
93
|
+
- Then we extract the level sets with a small value **d** with the marching cube
|
|
94
|
+
algorithm. The extracted level sets are represented with triangle meshes and
|
|
95
|
+
are guaranteed to be manifold.
|
|
96
|
+
|
|
97
|
+
- There exist multiple connected components in the extracted meshes, and we only
|
|
98
|
+
keep the mesh with the largest bounding box.
|
|
99
|
+
|
|
100
|
+
- Compute the signed distance field again with the kept triangle mesh as the
|
|
101
|
+
final output. In this way, the signed distance field (SDF) is computed for a
|
|
102
|
+
non-watertight input mesh.
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
## Citation
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
@article {Wang-Sig2022,
|
|
109
|
+
title = {Dual Octree Graph Networks for Learning Adaptive Volumetric
|
|
110
|
+
Shape Representations},
|
|
111
|
+
author = {Wang, Peng-Shuai and Liu, Yang and Tong, Xin},
|
|
112
|
+
journal = {ACM Transactions on Graphics (SIGGRAPH)},
|
|
113
|
+
volume = {41},
|
|
114
|
+
number = {4},
|
|
115
|
+
year = {2022},
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
```
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Mesh2SDF2
|
|
2
|
+
|
|
3
|
+
[](https://pepy.tech/project/mesh2sdf2)
|
|
4
|
+
[](https://pepy.tech/project/mesh2sdf2/month)
|
|
5
|
+
[](https://pypi.org/project/mesh2sdf2/)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
> **This is a community-maintained fork** of
|
|
9
|
+
> [mesh2sdf](https://github.com/wang-ps/mesh2sdf) by Peng-Shuai Wang. It adds
|
|
10
|
+
> Python 3.10–3.14 support, modernizes the build (setuptools ≥68,
|
|
11
|
+
> pybind11 ≥2.13), and improve the compute speed. Original project, paper, and algorithm: see the
|
|
12
|
+
> [upstream repo](https://github.com/wang-ps/mesh2sdf). License: MIT.
|
|
13
|
+
|
|
14
|
+
Converts an input mesh to a signed distance field. It can work with arbitrary
|
|
15
|
+
meshes, even **non-watertight** meshes from ShapeNet.
|
|
16
|
+
|
|
17
|
+
`mesh2sdf` is used in their paper
|
|
18
|
+
[Dual Octree Graph Networks (SIGGRAPH 2022)](https://wang-ps.github.io/dualocnn)
|
|
19
|
+
to generate the training data.
|
|
20
|
+
Please cite their paper if you find the code useful for your research.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
`mesh2sdf2` depends on [pybind11](https://github.com/pybind/pybind11), and C++
|
|
26
|
+
compilers are needed to build the code. Supported compilers are listed
|
|
27
|
+
[here](https://github.com/pybind/pybind11#supported-compilers).
|
|
28
|
+
|
|
29
|
+
- Install via the following command:
|
|
30
|
+
``` shell
|
|
31
|
+
pip install mesh2sdf2
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- Alternatively, install from the source code via the following commands.
|
|
35
|
+
``` shell
|
|
36
|
+
git clone https://github.com/LuckJMG/mesh2sdf2.git
|
|
37
|
+
cd mesh2sdf2
|
|
38
|
+
pip install .
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- Alternatively, install from the source code via the following commands.
|
|
42
|
+
``` shell
|
|
43
|
+
git clone https://github.com/wang-ps/mesh2sdf.git
|
|
44
|
+
pip install ./mesh2sdf
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Example
|
|
48
|
+
|
|
49
|
+
After installing `mesh2sdf`, run the following command to process an input mesh
|
|
50
|
+
from ShapeNet:
|
|
51
|
+
|
|
52
|
+
```shell
|
|
53
|
+
python example/demo.py
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+

|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## How does it work?
|
|
60
|
+
|
|
61
|
+
- Given an input mesh, we first compute the **unsigned** distance field with the
|
|
62
|
+
fast sweeping algorithm implemented by
|
|
63
|
+
[Christopher Batty (SDFGen)](https://github.com/christopherbatty/SDFGen).
|
|
64
|
+
Note that the unsigned distance field can always be reliably and accurately
|
|
65
|
+
computed even though the input mesh is non-watertight.
|
|
66
|
+
|
|
67
|
+
- Then we extract the level sets with a small value **d** with the marching cube
|
|
68
|
+
algorithm. The extracted level sets are represented with triangle meshes and
|
|
69
|
+
are guaranteed to be manifold.
|
|
70
|
+
|
|
71
|
+
- There exist multiple connected components in the extracted meshes, and we only
|
|
72
|
+
keep the mesh with the largest bounding box.
|
|
73
|
+
|
|
74
|
+
- Compute the signed distance field again with the kept triangle mesh as the
|
|
75
|
+
final output. In this way, the signed distance field (SDF) is computed for a
|
|
76
|
+
non-watertight input mesh.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
## Citation
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
@article {Wang-Sig2022,
|
|
83
|
+
title = {Dual Octree Graph Networks for Learning Adaptive Volumetric
|
|
84
|
+
Shape Representations},
|
|
85
|
+
author = {Wang, Peng-Shuai and Liu, Yang and Tong, Xin},
|
|
86
|
+
journal = {ACM Transactions on Graphics (SIGGRAPH)},
|
|
87
|
+
volume = {41},
|
|
88
|
+
number = {4},
|
|
89
|
+
year = {2022},
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
```
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#ifndef ARRAY3_H
|
|
2
|
+
#define ARRAY3_H
|
|
3
|
+
|
|
4
|
+
#include <algorithm>
|
|
5
|
+
#include <cassert>
|
|
6
|
+
#include <cstddef>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
template <class T> struct Array3 {
|
|
10
|
+
int ni, nj, nk;
|
|
11
|
+
std::vector<T> a;
|
|
12
|
+
|
|
13
|
+
Array3(void) : ni(0), nj(0), nk(0) {}
|
|
14
|
+
|
|
15
|
+
Array3(int ni_, int nj_, int nk_)
|
|
16
|
+
: ni(ni_), nj(nj_), nk(nk_), a(static_cast<size_t>(ni_) * nj_ * nk_) {
|
|
17
|
+
assert(ni_ >= 0 && nj_ >= 0 && nk_ >= 0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Array3(int ni_, int nj_, int nk_, const T &value)
|
|
21
|
+
: ni(ni_), nj(nj_), nk(nk_),
|
|
22
|
+
a(static_cast<size_t>(ni_) * nj_ * nk_, value) {
|
|
23
|
+
assert(ni_ >= 0 && nj_ >= 0 && nk_ >= 0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
inline size_t index(int i, int j, int k) const {
|
|
27
|
+
return static_cast<size_t>(i) +
|
|
28
|
+
static_cast<size_t>(ni) *
|
|
29
|
+
(static_cast<size_t>(j) +
|
|
30
|
+
static_cast<size_t>(nj) * static_cast<size_t>(k));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const T &operator()(int i, int j, int k) const {
|
|
34
|
+
assert(i >= 0 && i < ni && j >= 0 && j < nj && k >= 0 && k < nk);
|
|
35
|
+
return a[index(i, j, k)];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
T &operator()(int i, int j, int k) {
|
|
39
|
+
assert(i >= 0 && i < ni && j >= 0 && j < nj && k >= 0 && k < nk);
|
|
40
|
+
return a[index(i, j, k)];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void assign(const T &value) { std::fill(a.begin(), a.end(), value); }
|
|
44
|
+
|
|
45
|
+
void resize(int ni_, int nj_, int nk_) {
|
|
46
|
+
assert(ni_ >= 0 && nj_ >= 0 && nk_ >= 0);
|
|
47
|
+
ni = ni_;
|
|
48
|
+
nj = nj_;
|
|
49
|
+
nk = nk_;
|
|
50
|
+
a.resize(static_cast<size_t>(ni) * nj * nk);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void resize(int ni_, int nj_, int nk_, const T &value) {
|
|
54
|
+
assert(ni_ >= 0 && nj_ >= 0 && nk_ >= 0);
|
|
55
|
+
ni = ni_;
|
|
56
|
+
nj = nj_;
|
|
57
|
+
nk = nk_;
|
|
58
|
+
a.assign(static_cast<size_t>(ni) * nj * nk, value);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
size_t size(void) const { return a.size(); }
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
typedef Array3<float> Array3f;
|
|
65
|
+
typedef Array3<int> Array3i;
|
|
66
|
+
|
|
67
|
+
#endif
|