pyvista / pymeshfix

Python Wrapper for MeshFix: easily repair holes in surface meshes
http://pymeshfix.pyvista.org
GNU General Public License v3.0
293 stars 29 forks source link

examples.native() AND examples.with_vtk() fail #10

Closed kayarre closed 5 years ago

kayarre commented 5 years ago

running pymeshfix after install with pip first error:

import pymeshfix
from pymeshfix import examples
examples.native()

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-0f795062c8aa> in <module>
----> 1 examples.native()

~/anaconda3/envs/test/lib/python3.7/site-packages/pymeshfix/examples/fix.py in native(outfile)
     12 def native(outfile='repaired.ply'):
     13     """ Repair Stanford Bunny Mesh """
---> 14     pymeshfix._meshfix.CleanFromFile(bunny_scan, outfile)

AttributeError: module 'pymeshfix._meshfix' has no attribute 'CleanFromFile'

The second error happens with examples.with_vtk() after closing the window that pops up

examples.with_vtk()                                                                                                                     
Plotting input mesh
Plotting repaired mesh
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-6-d930cf051638> in <module>
----> 1 examples.with_vtk()

~/anaconda3/envs/test/lib/python3.7/site-packages/pymeshfix/examples/fix.py in with_vtk(plot)
     25     if plot:
     26         print('Plotting repaired mesh')
---> 27         meshfix.plot()
     28 
     29     return meshfix.mesh

~/anaconda3/envs/test/lib/python3.7/site-packages/pymeshfix/meshfix.py in plot(self, show_holes, **kwargs)
    113             plotter = pv.Plotter()
    114             plotter.add_mesh(self.mesh, label='mesh')
--> 115             plotter.add_mesh(edges, 'r', label='edges')
    116             plotter.show()
    117 

~/anaconda3/envs/test/lib/python3.7/site-packages/pyvista/plotting/plotting.py in add_mesh(self, mesh, color, style, scalars, clim, show_edges, edge_color, point_size, line_width, opacity, flip_scalars, lighting, n_colors, interpolate_before_map, cmap, label, reset_camera, scalar_bar_args, show_scalar_bar, stitle, multi_colors, name, texture, render_points_as_spheres, render_lines_as_tubes, smooth_shading, ambient, diffuse, specular, specular_power, nan_color, nan_opacity, loc, backface_culling, rgb, categories, use_transparency, below_color, above_color, annotations, pickable, **kwargs)
    804 
    805         if mesh.n_points < 1:
--> 806             raise RuntimeError('Empty meshes cannot be plotted. Input mesh has zero points.')
    807 
    808         # Try to plot something if no preference given

RuntimeError: Empty meshes cannot be plotted. Input mesh has zero points.
~/anaconda3/envs/test/lib/python3.7/site-packages/pymeshfix/meshfix.py in plot(self, show_holes, **kwargs)
    113             plotter = pv.Plotter()
    114             plotter.add_mesh(self.mesh, label='mesh')
--> 115             plotter.add_mesh(edges, 'r', label='edges')
    116             plotter.show()
    117 

~/anaconda3/envs/test/lib/python3.7/site-packages/pyvista/plotting/plotting.py in add_mesh(self, mesh, color, style, scalars, clim, show_edges, edge_color, point_size, line_width, opacity, flip_scalars, lighting, n_colors, interpolate_before_map, cmap, label, reset_camera, scalar_bar_args, show_scalar_bar, stitle, multi_colors, name, texture, render_points_as_spheres, render_lines_as_tubes, smooth_shading, ambient, diffuse, specular, specular_power, nan_color, nan_opacity, loc, backface_culling, rgb, categories, use_transparency, below_color, above_color, annotations, pickable, **kwargs)
    804 
    805         if mesh.n_points < 1:
--> 806             raise RuntimeError('Empty meshes cannot be plotted. Input mesh has zero points.')
    807 
    808         # Try to plot something if no preference given

RuntimeError: Empty meshes cannot be plotted. Input mesh has zero points.

I have run this now on linux and osx and get the same errors

print(pv.Report('pymeshfix'))                                                                                                                                             

--------------------------------------------------------------------------------
  Date: Fri Sep 20 16:36:00 2019 CDT

             Linux : OS
                12 : CPU(s)
            x86_64 : Machine
             64bit : Architecture
           31.2 GB : RAM
           IPython : Environment

  Python 3.7.4 (default, Aug 13 2019, 20:35:49)  [GCC 7.3.0]

            0.13.2 : pymeshfix
            0.22.2 : pyvista
             8.1.2 : vtk
            1.16.5 : numpy
             2.5.0 : imageio
             1.4.3 : appdirs
             0.4.3 : scooby
             3.1.1 : matplotlib
             5.9.2 : PyQt5
             7.8.0 : IPython
             7.5.1 : ipywidgets

  Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for
  Intel(R) 64 architecture applications
--------------------------------------------------------------------------------
banesullivan commented 5 years ago

Can you also include the code that caused this Traceback?

banesullivan commented 5 years ago

The attribute error you mention isn't in that traceback...

kayarre commented 5 years ago

@banesullivan I apologize, there are two distinct issues in the examples I attempted to execute. updated the comment accordingly.

banesullivan commented 5 years ago

Okay, so I tracked down both of these issues. The first had to do with how much of this API was switched to camelcase (PEP8) and that example was forgotten to be changed from CleanFromFile to clean_from_file.

The second has to do with some upstream changes in PyVista where an error is thrown when plotting empty meshes - this routine would try to plot the edges and if there were none because the mesh was repaired, then there would be nothing to plot.

banesullivan commented 5 years ago

@kayarre, sorry this took a while to get around to fixing! All should be good on the master branch now and I'll try to tag a release soon when all the CIs look good

banesullivan commented 5 years ago

version 0.13.3 is deployed and this should be fixed now!