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

signed_distance and barycentric_coordinates_tri crash kernel #33

Closed
celinede opened this issue Dec 5, 2019 · 8 comments
Closed

signed_distance and barycentric_coordinates_tri crash kernel #33

celinede opened this issue Dec 5, 2019 · 8 comments

Comments

@celinede
Copy link

celinede commented Dec 5, 2019

I have now a problem with signed_distance() which crashes my jupyter kernel for some points. I don't get any error message I only get "The kernel appears to have died. It will restart automatically".
And for barycentric_coordinates_tri() it always crashes the kernel, even for the points for which I could identify the closest point and triangle they belong to with signed_distance().
Do you have any idea about what could be the problem ?
Thanks for your help

@teseoch
Copy link
Collaborator

teseoch commented Dec 5, 2019

can you provide with the example and data?

@celinede
Copy link
Author

celinede commented Dec 5, 2019

So I try to find the triangle to closest point on the mesh (attached) for the following points:
p1 = [ 0.992596 0.065555 -0.0980209] (signed_distance works,
I get -0.0001638158094107626 5647 [ 0.99275841 0.06556438 -0.09804014])
p2 = [ 0.721779 -0.255626 0.642817] (signed_distance crashes)
in order to format my points I do as follow:

p = np.reshape(p1,(1,3))
S,I,C = igl.signed_distance(p,verts,tris)

Then for the barycentric coordinates of my point p1 on the mesh attached, I use the coordinates of the triangle I.
Coordinates of the nodes of triangle I:

t1 = [ 0.991791,  0.02708 , -0.124968]
t2 = [ 0.986896,  0.068604, -0.146047]
t3 = [ 0.993883,  0.066813, -0.087938]
igl.barycentric_coordinates_tri(p,t1,t2,t3)

mesh.sphere.ply.zip

@teseoch
Copy link
Collaborator

teseoch commented Dec 5, 2019

I tried and this works for me

import igl
import numpy as np

p1 = [0.992596, 0.065555, -0.0980209]
p = np.reshape(p1, (1, 3))


verts, tris = igl.read_triangle_mesh("mesh.sphere.ply")
S, I, C = igl.signed_distance(p, verts, tris)
print(S, I, C)

t1 = np.reshape([0.991791,  0.02708, -0.124968], (1, 3))
t2 = np.reshape([0.986896,  0.068604, -0.146047], (1, 3))
t3 = np.reshape([0.993883,  0.066813, -0.087938], (1, 3))
b = igl.barycentric_coordinates_tri(p, t1, t2, t3)

print(b)

@celinede
Copy link
Author

celinede commented Dec 5, 2019

ok so it seems like it had to do with the format of the data I input.
For the barycentric coordinates I was not doing the reshape of the coordinates of the nodes of the triangle.
And to avoid any crash I have to reshape with putting square brackets around the data to be reshaped otherwise the functions will crash for some values. I don't really understand what causes that.
p = np.reshape([p1], (1, 3))
It's a bit surprising to get a full crash instead of an error message for a problem of formatting of the data... Anyway, it's running now ! Thanks for your help !

@teseoch
Copy link
Collaborator

teseoch commented Dec 5, 2019

Yes, we are working on that.

The problem is that most igl function are designed for n x 3 but if you have only one point in python you will have 3 x 1

@fwilliams
Copy link
Collaborator

You are right that we should not crash with badly shaped inputs! Keep in mind that these python bindings are still in beta (we're still version 0.4!) so issues like this may arise. We really appreciate you reporting any problems we run into, and we'll do our best to resolve them :)

@teseoch teseoch closed this as completed Dec 5, 2019
@teseoch
Copy link
Collaborator

teseoch commented Dec 5, 2019

I just pushed a new version on conda 4.1.1. Now it should print an error in case of wrong sizes.

The new version is building and should take 1h for unix and 2h for windows

@celinede
Copy link
Author

celinede commented Dec 5, 2019

Nice! I'm very appreciative of your work.
I simply did not suspect that such a small mistake could crash the kernel so easily...
Thanks for the quick answers! :)

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

3 participants