Hello, and thanks for the incredibly useful project!
I have a class called TSurf() derived from vtkPolyData. Basically it is a standard PolyData, plus some simple attributes I use to store metadata. However, when I try to show one instance of the class in vtkplotter, I get a warning and nothing is shown:
Error: cannot build mesh from type:
<class 'pzero.objects_factory.TSurf'>
This is what I get if I do a print(MY_OBJECT), so it should be OK:
vtkPolyData (000001E67BDA2420)
Debug: Off
Modified Time: 17776
Reference Count: 2
Registered Events: (none)
Information: 000001E67BA1AA40
Data Released: False
Global Release Data: Off
UpdateTime: 0
Field Data:
Debug: Off
Modified Time: 64
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Number Of Points: 411
Number Of Cells: 632
Cell Data:
Debug: Off
Modified Time: 67
Reference Count: 1
Registered Events:
Registered Observers:
vtkObserver (000001E67BD94420)
Event: 33
EventName: ModifiedEvent
Command: 000001E67BA1A7C0
Priority: 0
Tag: 1
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
Scalars: (none)
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Point Data:
Debug: Off
Modified Time: 66
Reference Count: 1
Registered Events:
Registered Observers:
vtkObserver (000001E67BD946C0)
Event: 33
EventName: ModifiedEvent
Command: 000001E67BA1A7C0
Priority: 0
Tag: 1
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
Scalars: (none)
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Bounds:
Xmin,Xmax: (547500, 549046)
Ymin,Ymax: (5.06305e+06, 5.06477e+06)
Zmin,Zmax: (-86.6025, 2.28882e-05)
Compute Time: 53219
Number Of Points: 411
Point Coordinates: 000001E67BB609B0
Locator: 0000000000000000
Number Of Vertices: 0
Number Of Lines: 0
Number Of Polygons: 632
Number Of Triangle Strips: 0
Number Of Pieces: 1
Piece: -1
Ghost Level: 0
I guess the problem is inputtype = str(type(inputobj)) in mesh.py. Correct?
Based on a very quick test, a slight change to your code could solve the problem.
This test returns True also for subclasses of vtkPolyData:
isinstance(inputobj, vtk.vtkPolyData)
Thanks very much!
Hi @bistek thanks for the useful fix ! i'll include it in the next release.
let us know if you encounter any other problem :)
If you like I can do a commit, just changing line 120 in mesh.py:
elif "PolyData" in inputtype:
to
elif isinstance(inputobj, vtk.vtkPolyData):
sure thanks!
Mmmm... I tried but it looks like I cannot push to your repository. Anyway I'll test this solution locally.
yes.. well you should make pull request.. but no worries i can add that in my local!
In the meantime I was trying to use a local copy of the library, downloaded as a submodule, but it appears it conflicts with the one installed with pip, or that I am not able to implement the right import for functions in the submodule. Could you suggest a have a best practice for this? I suppose that the following should work, but it does not:
from .vtkplotter.vtkplotter import Plotter, Cone
The error when I try to push is:
remote: Permission to marcomusy/vtkplotter.git denied to bistek.
fatal: unable to access 'https://github.com/marcomusy/vtkplotter.git/': The requested URL returned error: 403
In the meantime I was trying to use a local copy of the library, downloaded as a submodule, but it appears it conflicts with the one installed with pip, or that I am not able to implement the right import for functions in the submodule. Could you suggest a have a best practice for this? I suppose that the following should work, but it does not:
what do you mean with "downloaded as a submodule"?
if you do
git clone https://github.com/marcomusy/vtkplotter.git
cd vtkplotter
you can modify the local copy, then type
pip install .
and it will become avalaible to all other modules
The error when I try to push is:
remote: Permission to marcomusy/vtkplotter.git denied to bistek. fatal: unable to access 'https://github.com/marcomusy/vtkplotter.git/': The requested URL returned error: 403yes , that's normal.. the typical procedure is that you make a fork then modify this fork and raise a pull request.
(you don't need to do it if you don't want to, i can change the line as you suggested)
Cool! I鈥檝e never thought using pip locally. Thanks very much!!
I鈥檒l try tomorrow and let you know if it id OK.
Hello, I have changed line 120 of mesh.py to:
elif isinstance(inputobj, vtk.vtkPolyData):
and line 129 to:
elif isinstance(inputobj, vtk.vtkStructuredGrid) or isinstance(inputobj, vtk.vtkRectilinearGrid):
It works perfectly.
Thanks for all!
Dear Marco, I have seen that you have not updated the main library as discussed above.
Thanks!
Hi @bistek they are both already on the master version!
https://github.com/marcomusy/vedo/blob/2689bd8360b0617f977f21b29aa637235c8ba232/vedo/mesh.py#L112
Is it possible they are not on the conda version?
..they will when the package is released.
OK, so I still have to install with pip from a local copy of the repository. Thanks!
just do
pip install -U git+https://github.com/marcomusy/vedo.git
Perfect! Thanks!