/usr/share/pyshared/mayavi/components/common.py is in mayavi2 4.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | """Common code used by different components.
"""
# Author: Prabhu Ramachandran <prabhu_r@users.sf.net>
# Copyright (c) 2005, Enthought, Inc.
# License: BSD Style.
# Enthought library imports.
from tvtk.api import tvtk
# Local imports.
from mayavi.core.component import Component
from mayavi.core.common import error
def get_module_source(obj):
"""Given an object (either a component or a module), return the
ModuleManager managing the module that contains this component.
"""
o = obj
while isinstance(o, Component):
o = o.inputs[0]
return o
def convert_to_poly_data(data):
"""Given a VTK dataset object, this returns the data as PolyData.
This is primarily used to convert the data suitably for filters
that only work for PolyData.
"""
if data.is_a('vtkPolyData'):
return data
conv = {'vtkStructuredPoints': tvtk.ImageDataGeometryFilter,
'vtkImageData': tvtk.ImageDataGeometryFilter,
'vtkRectilinearGrid': tvtk.RectilinearGridGeometryFilter,
'vtkStructuredGrid': tvtk.StructuredGridGeometryFilter,
'vtkUnstructuredGrid':tvtk.GeometryFilter}
fil = None
for name, fil_class in conv.items():
if data.is_a(name):
fil = fil_class()
break
if fil is not None:
fil.input = data
return fil.output
else:
error('Given object is not a VTK dataset: %s'%data.__class__.__name__)
|