CraGL / Decompose-Single-Image-Into-Layers

97 stars 22 forks source link

Error on apple example #5

Open alecjacobson opened 4 years ago

alecjacobson commented 4 years ago

I tried to run:

python ../ConvexHull_Simplification/SILD_convexhull_simplification.py apple

but I got this output

original vertices number: 85
Traceback (most recent call last):
  File "../ConvexHull_Simplification/SILD_convexhull_simplification.py", line 344, in <module>
    mesh=remove_one_edge_by_finding_smallest_adding_volume_with_test_conditions(mesh,option=2)
  File "../ConvexHull_Simplification/SILD_convexhull_simplification.py", line 151, in remove_one_edge_by_finding_smallest_adding_volume_with_test_conditions
    mesh.get_halfedges()
  File "/Users/ajx/Dropbox/Decompose-Single-Image-Into-Layers/ConvexHull_Simplification/trimesh.py", line 442, in get_halfedges
    if self.__halfedges is None: self.update_halfedges()
  File "/Users/ajx/Dropbox/Decompose-Single-Image-Into-Layers/ConvexHull_Simplification/trimesh.py", line 333, in update_halfedges
    he0index = len( self.__halfedges )
AttributeError: 'TriMesh' object has no attribute '_TriMesh__halfedges'
yig commented 4 years ago

What platform are you running on? What if you cd ../ConvexHull_Simplification and then

python SILD_convexhull_simplification.py ../examples/apple
alecjacobson commented 4 years ago

osx 10.13 with conda python2.7

Same error :-(

yig commented 4 years ago

This is a very mysterious error. The same error arose for someone else on Ubuntu: https://github.com/CraGL/Decompose-Single-Image-Into-Layers/issues/3 .

I was able to reproduce it with conda python (but not brew python). All the instance variables of the TriMesh object are being replaced with the instance variables of a different class (HalfEdge). I spent some time trying to debug it, but didn't succeed. It's as if something is trashing memory.

alecjacobson commented 4 years ago

How hard is it to convert this lib to py3 ? Maybe it will serendipitously also fix this error...

yig commented 4 years ago

Success. It looks like the GLPK solver was trashing memory. In SILD_convexhull_simplification.py, change line 204 from:

res = cvxopt.solvers.lp( cvxopt.matrix(c), cvxopt.matrix(A), cvxopt.matrix(b) ), solver='glpk' )

to

res = cvxopt.solvers.lp( cvxopt.matrix(c), cvxopt.matrix(A), cvxopt.matrix(b) ) )
yig commented 4 years ago

I updated it to work on Python 2 or 3

yig commented 4 years ago

The line number for disabling the GLPK solver has moved to 205.

alecjacobson commented 4 years ago

It works! Thanks so much debugging and fixing it.