hugoledoux / startin

A Delaunay triangulator for processing TINs
MIT License
34 stars 9 forks source link

pyo3_runtime.PanicException: called `Option::unwrap()` on a `None` value #23

Closed djdan7 closed 3 months ago

djdan7 commented 3 months ago

I get this error when using remove function and then inserting new one point. Do you know the reason, how to avoid it?

Error:

thread '<unnamed>' panicked at C:\Users\danie\.cargo\git\checkouts\startin-55c9cf214d22b2db\3a8c6f6\src\lib.rs:203:59:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "C:\DANE\Projects\DTM\test27.py", line 18, in <module>
    dt.insert_one_pt([12, 31, 4])
pyo3_runtime.PanicException: called `Option::unwrap()` on a `None` value

Code:

import startinpy

pts = [[1, 1, 1], [1, 2, 2], [2, 1, 3]]
dt = startinpy.DT()
dt.duplicates_handling = "Last"
dt.snap_tolerance = 0.1
dt.insert(pts)

print(dt)
print(dt.points)

ret = dt.insert_one_pt([1.09, 1, 1.5])
print(dt.points)

dt.remove(ret[0])
print(dt.points)

dt.insert_one_pt([12, 31, 4])
print(dt.points)
djdan7 commented 3 months ago

My guess is that this happens when there are less than 3 points left in the database. However, I have not done any extensive tests yet.

hugoledoux commented 3 months ago

Yes this happens because you have <3 points and the DT in invalid.

I'll prevent this from happening, thanks for reporting.