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

RecursionError for large number of objects #43

Closed
hweom opened this issue Dec 24, 2023 · 2 comments
Closed

RecursionError for large number of objects #43

hweom opened this issue Dec 24, 2023 · 2 comments

Comments

@hweom
Copy link

hweom commented Dec 24, 2023

import random
from sdf import *

part = box(1)
for i in range(0, 100):
    for j in range(0, 100):
        part |= box((10, 10, 2)).translate((i * 5, j * 5, random.uniform(0, 0.5)))

part.save('part.stl', samples=2**20)

results in

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    part.save('part.stl', samples=2**20)
  File "/usr/lib/python3.11/site-packages/sdf/d3.py", line 43, in save
    return mesh.save(path, self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sdf/mesh.py", line 152, in save
    points = generate(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sdf/mesh.py", line 92, in generate
    bounds = _estimate_bounds(sdf)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sdf/mesh.py", line 77, in _estimate_bounds
    volume = sdf(P).reshape((len(X), len(Y), len(Z)))
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/sdf/d3.py", line 25, in __call__
    return self.f(p).reshape((-1, 1))
...
  File "/usr/lib/python3.11/site-packages/sdf/d3.py", line 25, in __call__
    return self.f(p).reshape((-1, 1))
           ^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sdf/dn.py", line 9, in f
    d1 = a(p)
         ^^^^
  File "/usr/lib/python3.11/site-packages/sdf/d3.py", line 25, in __call__
    return self.f(p).reshape((-1, 1))
           ^^^^^^^^^
@nobodyinperson
Copy link

Duplicate of #23 and #40. Solution is here, which is to use union(...) instead of the |= operator.

@hweom
Copy link
Author

hweom commented Dec 26, 2023

Ah, thanks.

@hweom hweom closed this as not planned Won't fix, can't repro, duplicate, stale Dec 26, 2023
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

No branches or pull requests

2 participants