meshpro / optimesh

:spider_web: Mesh optimization, mesh smoothing.
575 stars 56 forks source link

No edge has more than 2 cells. Are cells listed twice? #27

Closed encorechow closed 6 years ago

encorechow commented 6 years ago

Hi, I was using optimesh odt to do the smoothness and got a bug during call the function optimesh.odt.fixed_point_uniform:

Traceback (most recent call last):
  File "smoothing.py", line 31, in <module>
    X, cells = optimesh.odt.fixed_point_uniform(mesh.vertices, mesh.faces, 1.0e-2, 100)
  File "/root/anaconda3/lib/python3.6/site-packages/optimesh-0.4.3-py3.6.egg/optimesh/odt.py", line 91, in fixed_point_uniform
  File "/root/anaconda3/lib/python3.6/site-packages/optimesh-0.4.3-py3.6.egg/optimesh/helpers.py", line 71, in runner
  File "/root/anaconda3/lib/python3.6/site-packages/optimesh-0.4.3-py3.6.egg/optimesh/helpers.py", line 51, in <lambda>
  File "/root/anaconda3/lib/python3.6/site-packages/meshplex/mesh_tri.py", line 869, in flip_until_delaunay
    self.create_edges()
  File "/root/anaconda3/lib/python3.6/site-packages/meshplex/mesh_tri.py", line 344, in create_edges
    ), "No edge has more than 2 cells. Are cells listed twice?"
AssertionError: No edge has more than 2 cells. Are cells listed twice?

I checked the mesh and find there is definitely no duplicate faces. here is the mesh I used for input

stitching.zip

Does anyone have idea how this happened? btw, I used pymesh to load .obj file as numpy array. Thanks!

import pymesh
 import optimesh
 import numpy
 #mesh = pymesh.load_mesh("test_full.obj")
 mesh = pymesh.load_mesh("stitching.obj")
 print("before ", len(mesh.faces))
 mesh,_= pymesh.remove_duplicated_faces(mesh)
 print("after ", len(mesh.faces))
X, cells = optimesh.odt.fixed_point_uniform(mesh.vertices, mesh.faces, 1.0e-2, 100)
nschloe commented 6 years ago

I cannot run your code:

AttributeError: module 'pymesh' has no attribute 'load_mesh'

This is with pymesh 1.0.2.

encorechow commented 6 years ago

@nschloe you can follow the instruction on https://pymesh.readthedocs.io/en/latest/ to install pymesh. Thank you for the quick reply

nschloe commented 6 years ago

I did install it of course. Your code still doesn't work. Perhaps you're using an outdated version?

On Thu, Sep 20, 2018, 11:20 AM Zheng Zhou notifications@github.com wrote:

@nschloe https://github.com/nschloe you can follow the instruction on https://pymesh.readthedocs.io/en/latest/ to install pymesh. Thank you for the quick reply

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nschloe/optimesh/issues/27#issuecomment-423108256, or mute the thread https://github.com/notifications/unsubscribe-auth/AALFfPJuD2RXfreCmqHbQZtF2ARCQtQ8ks5uc13agaJpZM4WxraF .

encorechow commented 6 years ago

@nschloe I guess you installed pymesh by pip install pymesh right? It actually not what I was using, the website I provided above is the one that I used. They are difference. But this is not the problem. I just use pymesh to load obj as numpy array. I think you can use any other apis to load obj file as numpy array. The point is the smooth function didn't work when I pass the vertices and faces from my obj file. I am not sure if it is the problem of my mesh or the code. I will be very appreciated if you can help me figure it out. Thanks!

encorechow commented 6 years ago

if you use pip install pymesh, I think you should be able to load obj by following code:

from pymesh import obj
m = obj.Obj("sample.obj")
nschloe commented 6 years ago

I guess you installed pymesh by pip install pymesh right?

Correct.

This

from pymesh import obj
m = obj.Obj("sample.obj")

gives

Traceback (most recent call last):
  File "/home/nschloe/.local/lib/python3.6/site-packages/pymesh/obj.py", line 52, in __read
    elif line.lstrip().startswith("vn"):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "a.py", line 8, in <module>
    mesh = obj.Obj("stitching.obj")
  File "/home/nschloe/.local/lib/python3.6/site-packages/pymesh/obj.py", line 30, in __init__
    data = Obj.__load(fh)
  File "/home/nschloe/.local/lib/python3.6/site-packages/pymesh/obj.py", line 39, in __load
    return numpy.fromiter(Obj.__read(fh), dtype=Obj.obj_dtype)
  File "/home/nschloe/.local/lib/python3.6/site-packages/pymesh/obj.py", line 73, in __read
    raise RuntimeError("Failed to load OBJ file.")
RuntimeError: Failed to load OBJ file.

Feel free to reopen once you have a reproducible example.