Tubes not showing up on protein demo #388

Closed
Yacoby opened this Issue May 27, 2016 · 13 comments

Comments

Projects
None yet
4 participants
@Yacoby

Yacoby commented May 27, 2016

Setup:

  • Mac OS X El Capitan 10.11.5
  • Python 2.7.11 (installed through homebrew)
  • VTK (installed through homebrew but using the head of master with the vtkNoPythonLink branch merged in. this is due to this bug)
  • Mayavi 4.4.4 (installed through pip)

I then ran the Protein example

Expected:
I would expect to see tubes between the proteins

Actual
I did not see tubes between proteins

@mdickinson

This comment has been minimized.

Show comment
Hide comment
@mdickinson

mdickinson Jun 28, 2016

Member

This appears to be a regression between Mayavi 4.4.0 and Mayavi 4.4.2.

Member

mdickinson commented Jun 28, 2016

This appears to be a regression between Mayavi 4.4.0 and Mayavi 4.4.2.

@rpep

This comment has been minimized.

Show comment
Hide comment
@rpep

rpep Jun 28, 2016

Contributor

I've just tried running it with
• the dev version of Mayavi
• El Capitan
• Python 2.7.11
• VTK from Conda

and got the error:

Volume rendering only works with StructuredPoints/ImageData/UnstructuredGrid datasets

and Mayavi then locks up completely - I had to force quit the program.

Contributor

rpep commented Jun 28, 2016

I've just tried running it with
• the dev version of Mayavi
• El Capitan
• Python 2.7.11
• VTK from Conda

and got the error:

Volume rendering only works with StructuredPoints/ImageData/UnstructuredGrid datasets

and Mayavi then locks up completely - I had to force quit the program.

@mdickinson

This comment has been minimized.

Show comment
Hide comment
@mdickinson

mdickinson Jun 28, 2016

Member

@ryanpepper: Thanks; confirmed here. That appears to be yet another regression between the last tagged release (4.4.4) and current master.

Member

mdickinson commented Jun 28, 2016

@ryanpepper: Thanks; confirmed here. That appears to be yet another regression between the last tagged release (4.4.4) and current master.

@mdickinson

This comment has been minimized.

Show comment
Hide comment
@mdickinson

mdickinson Jun 28, 2016

Member

4.4.4 with VTK 5.10.1 works, so this has to do with the VTK 5 -> VTK 6 change. It looks as though we're missing some VTK 6 compatibility somewhere.

Member

mdickinson commented Jun 28, 2016

4.4.4 with VTK 5.10.1 works, so this has to do with the VTK 5 -> VTK 6 change. It looks as though we're missing some VTK 6 compatibility somewhere.

@mdickinson

This comment has been minimized.

Show comment
Hide comment
@mdickinson

mdickinson Jul 6, 2016

Member

The following change fixes the missing tubes for me with VTK 6.x. It's obviously not the right fix, but it might point the way to the correct fix.

(Canopy 64bit) taniyama:mayavi mdickinson$ git diff
diff --git a/examples/mayavi/mlab/protein.py b/examples/mayavi/mlab/protein.py
index f6e0a2b..79b5e88 100644
--- a/examples/mayavi/mlab/protein.py
+++ b/examples/mayavi/mlab/protein.py
@@ -130,6 +130,7 @@ pts.mlab_source.dataset.lines = np.array(connections)
 tube = mlab.pipeline.tube(pts, tube_radius=0.15)
 tube.filter.radius_factor = 1.
 tube.filter.vary_radius = 'vary_radius_by_scalar'
+tube.filter.set_input_data(pts.mlab_source.dataset)
 mlab.pipeline.surface(tube, color=(0.8, 0.8, 0))

 # Visualize the local atomic density
Member

mdickinson commented Jul 6, 2016

The following change fixes the missing tubes for me with VTK 6.x. It's obviously not the right fix, but it might point the way to the correct fix.

(Canopy 64bit) taniyama:mayavi mdickinson$ git diff
diff --git a/examples/mayavi/mlab/protein.py b/examples/mayavi/mlab/protein.py
index f6e0a2b..79b5e88 100644
--- a/examples/mayavi/mlab/protein.py
+++ b/examples/mayavi/mlab/protein.py
@@ -130,6 +130,7 @@ pts.mlab_source.dataset.lines = np.array(connections)
 tube = mlab.pipeline.tube(pts, tube_radius=0.15)
 tube.filter.radius_factor = 1.
 tube.filter.vary_radius = 'vary_radius_by_scalar'
+tube.filter.set_input_data(pts.mlab_source.dataset)
 mlab.pipeline.surface(tube, color=(0.8, 0.8, 0))

 # Visualize the local atomic density
@mdickinson

This comment has been minimized.

Show comment
Hide comment
@mdickinson

mdickinson Jul 6, 2016

Member

There's something interesting going on here. At the point where the Tube.update_pipeline method is called, we have len(self.inputs) = 1, and inputs[0].outputs[0] and inputs[0].mlab_source.dataset are two different but similar objects of type tvtk.tvtk_classes.poly_data.PolyData. The current code connects inputs[0].outputs[0] to the tube filter, and the tube is then invisible. If that code is changed to connect inputs[0].mlab_source.dataset to the tube filter instead, the tube becomes visible.

@prabhuramachandran: Can you comment on the two PolyData objects present here?

Some pdb output:

(Pdb) c
> /Users/mdickinson/Enthought/ETS/mayavi/mayavi/filters/tube.py(52)update_pipeline()
-> self.configure_input_data(
(Pdb) inputs[0].outputs[0]
<tvtk.tvtk_classes.poly_data.PolyData object at 0x1229ea230>
(Pdb) inputs[0].mlab_source.dataset
<tvtk.tvtk_classes.poly_data.PolyData object at 0x11de06830>
(Pdb) inputs[0].outputs[0].print_traits()
_in_set:                   0
_vtk_obj:                  (vtkPolyData)0x1229dc7e0
actual_memory_size:        159
bounds:                    (-6.261, 47.684, -1.498, 67.108, -10.161, 42.425)
cell_data:                 <tvtk.tvtk_classes.cell_d...a object at 0x127098410>
center:                    (20.711499999999997, 32.805, 16.131999999999998)
class_name:                'vtkPolyData'
data_object_type:          0
data_released:             0
debug:                     0
debug_:                    0
estimated_memory_size:     0
extent_translator:         <tvtk.tvtk_classes.extent...r object at 0x127098530>
extent_type:               0
field_data:                <tvtk.tvtk_classes.field_...a object at 0x127098530>
ghost_level:               0
global_release_data_flag:  0
global_release_data_flag_: 0
global_warning_display:    1
global_warning_display_:   1
information:               <tvtk.tvtk_classes.inform...n object at 0x127098ef0>
length:                    101.89275566496374
lines:                     <tvtk.tvtk_classes.cell_a...y object at 0x127098ef0>
m_time:                    885661
max_cell_size:             1
maximum_number_of_pieces:  -1
number_of_cells:           3346L
number_of_lines:           0L
number_of_pieces:          1
number_of_points:          3346L
number_of_polys:           3346L
number_of_strips:          0L
number_of_verts:           0L
piece:                     0
pipeline_information:      <tvtk.tvtk_classes.inform...n object at 0x127098ef0>
pipeline_m_time:           885600
point_data:                <tvtk.tvtk_classes.point_...a object at 0x127098ef0>
points:                    [(21.093, 56.492, 0.693),... 28.359)], length = 3346
polys:                     <tvtk.tvtk_classes.cell_a...y object at 0x10ff7b410>
producer_port:             <tvtk.tvtk_classes.algori...t object at 0x10ff7b410>
reference_count:           2
release_data_flag:         0
release_data_flag_:        0
request_exact_extent:      0
request_exact_extent_:     0
scalar_range:              (24.0, 72.0)
source:                    None
strips:                    <tvtk.tvtk_classes.cell_a...y object at 0x127098ef0>
update_extent:             array([ 0, -1,  0, -1,  0, -1])
update_ghost_level:        0
update_number_of_pieces:   1
update_piece:              0
update_time:               885662
verts:                     <tvtk.tvtk_classes.cell_a...y object at 0x10ff7b410>
whole_bounding_box:        array([ 0., -1.,  0., -1.,  0., -1.])
whole_extent:              array([ 0, -1,  0, -1,  0, -1])
(Pdb) inputs[0].mlab_source.dataset.print_traits()
_in_set:                   0
_vtk_obj:                  (vtkPolyData)0x108554208
actual_memory_size:        159
bounds:                    (-6.261, 47.684, -1.498, 67.108, -10.161, 42.425)
cell_data:                 <tvtk.tvtk_classes.cell_d...a object at 0x127098ef0>
center:                    (20.711499999999997, 32.805, 16.131999999999998)
class_name:                'vtkPolyData'
data_object_type:          0
data_released:             0
debug:                     0
debug_:                    0
estimated_memory_size:     0
extent_translator:         <tvtk.tvtk_classes.extent...r object at 0x127098ef0>
extent_type:               0
field_data:                <tvtk.tvtk_classes.field_...a object at 0x127098ef0>
ghost_level:               0
global_release_data_flag:  0
global_release_data_flag_: 0
global_warning_display:    1
global_warning_display_:   1
information:               <tvtk.tvtk_classes.inform...n object at 0x127098ef0>
length:                    101.89275566496374
lines:                     <tvtk.tvtk_classes.cell_a...y object at 0x127098ef0>
m_time:                    885599
max_cell_size:             1
maximum_number_of_pieces:  -1
number_of_cells:           3346L
number_of_lines:           0L
number_of_pieces:          1
number_of_points:          3346L
number_of_polys:           3346L
number_of_strips:          0L
number_of_verts:           0L
piece:                     0
pipeline_information:      <tvtk.tvtk_classes.inform...n object at 0x127098ef0>
pipeline_m_time:           885599
point_data:                <tvtk.tvtk_classes.point_...a object at 0x127098ef0>
points:                    [(21.093, 56.492, 0.693),... 28.359)], length = 3346
polys:                     <tvtk.tvtk_classes.cell_a...y object at 0x10ff7b410>
producer_port:             <tvtk.tvtk_classes.algori...t object at 0x10ff7b410>
reference_count:           3
release_data_flag:         0
release_data_flag_:        0
request_exact_extent:      0
request_exact_extent_:     0
scalar_range:              (24.0, 72.0)
source:                    None
strips:                    <tvtk.tvtk_classes.cell_a...y object at 0x127098ef0>
update_extent:             array([ 0, -1,  0, -1,  0, -1])
update_ghost_level:        0
update_number_of_pieces:   1
update_piece:              0
update_time:               885628
verts:                     <tvtk.tvtk_classes.cell_a...y object at 0x10ff7b410>
whole_bounding_box:        array([ 0., -1.,  0., -1.,  0., -1.])
whole_extent:              array([ 0, -1,  0, -1,  0, -1])
Member

mdickinson commented Jul 6, 2016

There's something interesting going on here. At the point where the Tube.update_pipeline method is called, we have len(self.inputs) = 1, and inputs[0].outputs[0] and inputs[0].mlab_source.dataset are two different but similar objects of type tvtk.tvtk_classes.poly_data.PolyData. The current code connects inputs[0].outputs[0] to the tube filter, and the tube is then invisible. If that code is changed to connect inputs[0].mlab_source.dataset to the tube filter instead, the tube becomes visible.

@prabhuramachandran: Can you comment on the two PolyData objects present here?

Some pdb output:

(Pdb) c
> /Users/mdickinson/Enthought/ETS/mayavi/mayavi/filters/tube.py(52)update_pipeline()
-> self.configure_input_data(
(Pdb) inputs[0].outputs[0]
<tvtk.tvtk_classes.poly_data.PolyData object at 0x1229ea230>
(Pdb) inputs[0].mlab_source.dataset
<tvtk.tvtk_classes.poly_data.PolyData object at 0x11de06830>
(Pdb) inputs[0].outputs[0].print_traits()
_in_set:                   0
_vtk_obj:                  (vtkPolyData)0x1229dc7e0
actual_memory_size:        159
bounds:                    (-6.261, 47.684, -1.498, 67.108, -10.161, 42.425)
cell_data:                 <tvtk.tvtk_classes.cell_d...a object at 0x127098410>
center:                    (20.711499999999997, 32.805, 16.131999999999998)
class_name:                'vtkPolyData'
data_object_type:          0
data_released:             0
debug:                     0
debug_:                    0
estimated_memory_size:     0
extent_translator:         <tvtk.tvtk_classes.extent...r object at 0x127098530>
extent_type:               0
field_data:                <tvtk.tvtk_classes.field_...a object at 0x127098530>
ghost_level:               0
global_release_data_flag:  0
global_release_data_flag_: 0
global_warning_display:    1
global_warning_display_:   1
information:               <tvtk.tvtk_classes.inform...n object at 0x127098ef0>
length:                    101.89275566496374
lines:                     <tvtk.tvtk_classes.cell_a...y object at 0x127098ef0>
m_time:                    885661
max_cell_size:             1
maximum_number_of_pieces:  -1
number_of_cells:           3346L
number_of_lines:           0L
number_of_pieces:          1
number_of_points:          3346L
number_of_polys:           3346L
number_of_strips:          0L
number_of_verts:           0L
piece:                     0
pipeline_information:      <tvtk.tvtk_classes.inform...n object at 0x127098ef0>
pipeline_m_time:           885600
point_data:                <tvtk.tvtk_classes.point_...a object at 0x127098ef0>
points:                    [(21.093, 56.492, 0.693),... 28.359)], length = 3346
polys:                     <tvtk.tvtk_classes.cell_a...y object at 0x10ff7b410>
producer_port:             <tvtk.tvtk_classes.algori...t object at 0x10ff7b410>
reference_count:           2
release_data_flag:         0
release_data_flag_:        0
request_exact_extent:      0
request_exact_extent_:     0
scalar_range:              (24.0, 72.0)
source:                    None
strips:                    <tvtk.tvtk_classes.cell_a...y object at 0x127098ef0>
update_extent:             array([ 0, -1,  0, -1,  0, -1])
update_ghost_level:        0
update_number_of_pieces:   1
update_piece:              0
update_time:               885662
verts:                     <tvtk.tvtk_classes.cell_a...y object at 0x10ff7b410>
whole_bounding_box:        array([ 0., -1.,  0., -1.,  0., -1.])
whole_extent:              array([ 0, -1,  0, -1,  0, -1])
(Pdb) inputs[0].mlab_source.dataset.print_traits()
_in_set:                   0
_vtk_obj:                  (vtkPolyData)0x108554208
actual_memory_size:        159
bounds:                    (-6.261, 47.684, -1.498, 67.108, -10.161, 42.425)
cell_data:                 <tvtk.tvtk_classes.cell_d...a object at 0x127098ef0>
center:                    (20.711499999999997, 32.805, 16.131999999999998)
class_name:                'vtkPolyData'
data_object_type:          0
data_released:             0
debug:                     0
debug_:                    0
estimated_memory_size:     0
extent_translator:         <tvtk.tvtk_classes.extent...r object at 0x127098ef0>
extent_type:               0
field_data:                <tvtk.tvtk_classes.field_...a object at 0x127098ef0>
ghost_level:               0
global_release_data_flag:  0
global_release_data_flag_: 0
global_warning_display:    1
global_warning_display_:   1
information:               <tvtk.tvtk_classes.inform...n object at 0x127098ef0>
length:                    101.89275566496374
lines:                     <tvtk.tvtk_classes.cell_a...y object at 0x127098ef0>
m_time:                    885599
max_cell_size:             1
maximum_number_of_pieces:  -1
number_of_cells:           3346L
number_of_lines:           0L
number_of_pieces:          1
number_of_points:          3346L
number_of_polys:           3346L
number_of_strips:          0L
number_of_verts:           0L
piece:                     0
pipeline_information:      <tvtk.tvtk_classes.inform...n object at 0x127098ef0>
pipeline_m_time:           885599
point_data:                <tvtk.tvtk_classes.point_...a object at 0x127098ef0>
points:                    [(21.093, 56.492, 0.693),... 28.359)], length = 3346
polys:                     <tvtk.tvtk_classes.cell_a...y object at 0x10ff7b410>
producer_port:             <tvtk.tvtk_classes.algori...t object at 0x10ff7b410>
reference_count:           3
release_data_flag:         0
release_data_flag_:        0
request_exact_extent:      0
request_exact_extent_:     0
scalar_range:              (24.0, 72.0)
source:                    None
strips:                    <tvtk.tvtk_classes.cell_a...y object at 0x127098ef0>
update_extent:             array([ 0, -1,  0, -1,  0, -1])
update_ghost_level:        0
update_number_of_pieces:   1
update_piece:              0
update_time:               885628
verts:                     <tvtk.tvtk_classes.cell_a...y object at 0x10ff7b410>
whole_bounding_box:        array([ 0., -1.,  0., -1.,  0., -1.])
whole_extent:              array([ 0, -1,  0, -1,  0, -1])
@mdickinson

This comment has been minimized.

Show comment
Hide comment
@mdickinson

mdickinson Jul 6, 2016

Member

The two PolyData objects are the input and output of the AssignAttribute object used in the VTKDataSource. At rendering time, the input has a nonzero number of lines, but the output has zero lines. It looks as though all that's missing is an update call on that object, though I have yet to figure out exactly when that update call should happen.

Member

mdickinson commented Jul 6, 2016

The two PolyData objects are the input and output of the AssignAttribute object used in the VTKDataSource. At rendering time, the input has a nonzero number of lines, but the output has zero lines. It looks as though all that's missing is an update call on that object, though I have yet to figure out exactly when that update call should happen.

@prabhuramachandran

This comment has been minimized.

Show comment
Hide comment
@prabhuramachandran

prabhuramachandran Jul 6, 2016

Member

@mdickinson -- I have a feeling this is all related to the changes made to work with the new VTK pipeline. I will have to take a closer look and get back.

Member

prabhuramachandran commented Jul 6, 2016

@mdickinson -- I have a feeling this is all related to the changes made to work with the new VTK pipeline. I will have to take a closer look and get back.

@prabhuramachandran

This comment has been minimized.

Show comment
Hide comment
@prabhuramachandran

prabhuramachandran Jul 6, 2016

Member

@ryanpepper -- I've fixed the volume issue last week and that has been merged so ought to work now. I too am not seeing the tubes and will investigate this later.

Member

prabhuramachandran commented Jul 6, 2016

@ryanpepper -- I've fixed the volume issue last week and that has been merged so ought to work now. I too am not seeing the tubes and will investigate this later.

@mdickinson

This comment has been minimized.

Show comment
Hide comment
@mdickinson

mdickinson Jul 7, 2016

Member

@prabhuramachandran: Thanks.

An alternative quick fix for the protein demo: add the line pts.glyph.inputs[0].update() immediately after setting pts.mlab_source.dataset.lines.

Member

mdickinson commented Jul 7, 2016

@prabhuramachandran: Thanks.

An alternative quick fix for the protein demo: add the line pts.glyph.inputs[0].update() immediately after setting pts.mlab_source.dataset.lines.

@prabhuramachandran

This comment has been minimized.

Show comment
Hide comment
@prabhuramachandran

prabhuramachandran Jul 7, 2016

Member

I am sending a PR for this as it is a trivial fix (see #413). Basically, the example changes the dataset after it was added to the pipeline. So the only way to update things is to call pts.mlab_source.update().

Member

prabhuramachandran commented Jul 7, 2016

I am sending a PR for this as it is a trivial fix (see #413). Basically, the example changes the dataset after it was added to the pipeline. So the only way to update things is to call pts.mlab_source.update().

prabhuramachandran added a commit that referenced this issue Jul 8, 2016

@mdickinson

This comment has been minimized.

Show comment
Hide comment
@mdickinson

mdickinson Jul 8, 2016

Member

@prabhuramachandran: Thanks for the fix. I'm trying to debug a similar issue in some of our Mayavi-using code, and this may help. One thing's still puzzling me: why did this work with VTK 5?

Member

mdickinson commented Jul 8, 2016

@prabhuramachandran: Thanks for the fix. I'm trying to debug a similar issue in some of our Mayavi-using code, and this may help. One thing's still puzzling me: why did this work with VTK 5?

@prabhuramachandran

This comment has been minimized.

Show comment
Hide comment
@prabhuramachandran

prabhuramachandran Jul 8, 2016

Member

@mdickinson -- IIUC VTK changed the pipeline execution quite a bit and maintained backwards compatibility until VTK 5 and then dropped support for the old pipeline with VTK 6.x (http://www.vtk.org/Wiki/VTK/Tutorials/New_Pipeline). Now users are not supposed to directly manipulate the outputs and instead should setup input connections and output ports. I suspect that earlier when the lines was changed the dataset was internally modified and automatically fired an update but that this is no longer happening. Someone will need to go over the new pipeline document I cite above once again and do one more round of cleanup of the mayavi code to eliminate our old pipeline usage. There are also some convenient Python wrappers that VTK now provides which mayavi should start using (https://blog.kitware.com/improved-vtk-numpy-integration/) as this will cleanup a lot of the older code. The trouble of course is backwards compatibility but I guess it is safe to abandon 5.x now that VTK is at 7.x.

Member

prabhuramachandran commented Jul 8, 2016

@mdickinson -- IIUC VTK changed the pipeline execution quite a bit and maintained backwards compatibility until VTK 5 and then dropped support for the old pipeline with VTK 6.x (http://www.vtk.org/Wiki/VTK/Tutorials/New_Pipeline). Now users are not supposed to directly manipulate the outputs and instead should setup input connections and output ports. I suspect that earlier when the lines was changed the dataset was internally modified and automatically fired an update but that this is no longer happening. Someone will need to go over the new pipeline document I cite above once again and do one more round of cleanup of the mayavi code to eliminate our old pipeline usage. There are also some convenient Python wrappers that VTK now provides which mayavi should start using (https://blog.kitware.com/improved-vtk-numpy-integration/) as this will cleanup a lot of the older code. The trouble of course is backwards compatibility but I guess it is safe to abandon 5.x now that VTK is at 7.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment