Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release: SVG Shapes #2363

Merged
merged 18 commits into from
Feb 27, 2025
Merged

Release: SVG Shapes #2363

merged 18 commits into from
Feb 27, 2025

Conversation

mikedh
Copy link
Owner

@mikedh mikedh commented Feb 26, 2025

nickeopti and others added 18 commits February 26, 2025 14:17
The current implementation of `trimesh.smoothing.laplacian_calculation`
relies on list comprehensions. The case of `equal_weight=True`, at
least, can be computed directly using sparse matrix operations. This PR
does that, which turns out to be nearly 20 times faster.

I have been unable to figure out a way of computing the
`equal_weight=False` case using sparse matrix operations, so I have let
the current implementation of that be. This implies quite a performance
difference between the two flag values. This is noted in the docstring,
which is now also more descriptive.

Correctness tests are added, which include a verbatim copy of the
original implementation to test against.

Performance characteristics:
```python
In [1]: import trimesh

In [2]: from tests import test_smoothing

In [3]: m = trimesh.creation.icosphere(8, 10)

In [4]: m.vertices.shape, m.faces.shape
Out[4]: ((655362, 3), (1310720, 3))

In [5]: %timeit trimesh.smoothing.laplacian_calculation(m, equal_weight=True)
44.4 ms ± 783 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)

In [6]: %timeit test_smoothing.explicit_laplacian_calculation(m, equal_weight=True)
790 ms ± 9.89 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

In [7]: %timeit trimesh.smoothing.laplacian_calculation(m, equal_weight=False)
2.87 s ± 31.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

In [8]: %timeit test_smoothing.explicit_laplacian_calculation(m, equal_weight=False)
2.91 s ± 34.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
```
where `test_smoothing.explicit_laplacian_calculation` is the original
implementation.
@mikedh mikedh merged commit 9667bc6 into main Feb 27, 2025
1 of 9 checks passed
@mikedh mikedh deleted the release/svg branch February 27, 2025 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loading shapes of svg not defined as <path d="
2 participants