Skip to content

Commit

Permalink
Fix bug with cell_to_point_data.
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhuramachandran committed Feb 18, 2022
1 parent c75bb7d commit 06ea7a5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
35 changes: 9 additions & 26 deletions mayavi/filters/cell_to_point_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class CellToPointData(FilterBase):

# The actual TVTK filter that this class manages.
filter = Instance(tvtk.CellDataToPointData,
args=(), kw={'pass_cell_data':1},
allow_none=False, record=True)
args=(), kw={'pass_cell_data':1},
allow_none=False, record=True)

# Information about what this object can consume/produce.
input_info = PipelineInfo(datasets=['any'],
Expand All @@ -36,27 +36,10 @@ class CellToPointData(FilterBase):
attribute_types=['any'],
attributes=['any'])

def update_pipeline(self):
# Do nothing if there is no input.
inputs = self.inputs
if len(inputs) == 0:
return

fil = self.filter
input = inputs[0].outputs[0]
self.configure_connection(fil, inputs[0])
fil.update()
dataset = self.inputs[0].get_output_dataset()
# This filter creates different outputs depending on the
# input.
out_map = {'vtkStructuredGrid': 'structured_grid_output',
'vtkRectilinearGrid': 'rectilinear_grid_output',
'vtkStructuredPoints': 'structured_points_output',
'vtkUnstructuredGrid': 'unstructured_grid_output',
'vtkPolyData': 'poly_data_output',
'vtkImageData': 'image_data_output'}
# Find the input data type and pass that to our output..
for type in out_map:
if dataset.is_a(type):
self._set_outputs([getattr(fil, out_map[type])])
break
def has_output_port(self):
""" The filter has an output port."""
return True

def get_output_object(self):
""" Return the output port."""
return self.filter.output_port
23 changes: 23 additions & 0 deletions mayavi/tests/test_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import unittest
from unittest.mock import patch
import os

from mayavi import mlab
from .test_engine_manager import patch_backend


def patch_pyface():
return patch("mayavi.core.common.pyface", None)


class TestFilters(unittest.TestCase):
@patch_pyface()
@patch_backend('test')
def test_cell_to_point_data(self):
src = mlab.pipeline.open(os.path.join('data', 'pyramid_ug.vtu'))
cd = mlab.pipeline.cell_derivatives(src)
cd.filter.vector_mode = 'compute_vorticity'
c2p = mlab.pipeline.cell_to_point_data(cd)
st = mlab.pipeline.streamline(c2p)
st.update_pipeline()
mlab.clf()

0 comments on commit 06ea7a5

Please sign in to comment.