Ejemplo n.º 1
0
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)
        InputArrayChoiceMixin.__init__(self)
        
        self._config.scaleFactor = 1

        configList = [
            ('Scale factor:', 'scaleFactor', 'base:float', 'text',
             'The warping will be scaled by this factor'),
            ('Vectors selection:', 'vectorsSelection', 'base:str', 'choice',
             'The attribute that will be used as vectors for the warping.',
             (self._defaultVectorsSelectionString, self._userDefinedString))]

        self._warpVector = vtk.vtkWarpVector()

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkWarpVector' : self._warpVector})
        
        module_utils.setup_vtk_object_progress(self, self._warpVector,
                                           'Warping points.')
        

        self.sync_module_logic_with_config()
Ejemplo n.º 2
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        self._imageDilate = vtk.vtkImageContinuousDilate3D()
        self._imageErode = vtk.vtkImageContinuousErode3D()
        self._imageErode.SetInput(self._imageDilate.GetOutput())
        
        module_utils.setup_vtk_object_progress(self, self._imageDilate,
                                           'Performing greyscale 3D dilation')
        

        module_utils.setup_vtk_object_progress(self, self._imageErode,
                                           'Performing greyscale 3D erosion')
        

        self._config.kernelSize = (3, 3, 3)


        configList = [
            ('Kernel size:', 'kernelSize', 'tuple:int,3', 'text',
             'Size of the kernel in x,y,z dimensions.')]

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkImageContinuousDilate3D' : self._imageDilate,
             'vtkImageContinuousErode3D' : self._imageErode})
        
        self.sync_module_logic_with_config()
Ejemplo n.º 3
0
    def __init__(self, module_manager, contourFilterText):

        # call parent constructor
        ModuleBase.__init__(self, module_manager)

        self._contourFilterText = contourFilterText
        if contourFilterText == 'marchingCubes':
            self._contourFilter = vtk.vtkMarchingCubes()
        else: # contourFilter == 'contourFilter'
            self._contourFilter = vtk.vtkContourFilter()

        module_utils.setup_vtk_object_progress(self, self._contourFilter,
                                           'Extracting iso-surface')

        # now setup some defaults before our sync
        self._config.isoValue = 128;

        self._viewFrame = None
        self._createViewFrame()

        # transfer these defaults to the logic
        self.config_to_logic()

        # then make sure they come all the way back up via self._config
        self.logic_to_config()
        self.config_to_view()
Ejemplo n.º 4
0
    def __init__(self, module_manager):

        # call parent constructor
        ModuleBase.__init__(self, module_manager)

        # the decimator only works on triangle data, so we make sure
        # that it only gets triangle data
        self._triFilter = vtk.vtkTriangleFilter()
        self._decimate = vtk.vtkDecimatePro()
        self._decimate.PreserveTopologyOn()
        self._decimate.SetInput(self._triFilter.GetOutput())

        module_utils.setup_vtk_object_progress(self, self._triFilter,
                                           'Converting to triangles')
        
        module_utils.setup_vtk_object_progress(self, self._decimate,
                                           'Decimating mesh')
        
                                           
        # now setup some defaults before our sync
        self._config.target_reduction = self._decimate.GetTargetReduction() \
                                        * 100.0

        config_list = [
            ('Target reduction (%):', 'target_reduction', 'base:float', 'text',
             'Decimate algorithm will attempt to reduce by this much.')]

        ScriptedConfigModuleMixin.__init__(
            self, config_list,
            {'Module (self)' : self,
             'vtkDecimatePro' : self._decimate,
             'vtkTriangleFilter' : self._triFilter})

        self.sync_module_logic_with_config()
Ejemplo n.º 5
0
    def __init__(self, module_manager):

        # call parent constructor
        ModuleBase.__init__(self, module_manager)

        self._writer = vtk.vtkStructuredPointsWriter()

        module_utils.setup_vtk_object_progress(
            self, self._writer,
            'Writing vtk structured points data')

        

        # we do this to save space - if you're going to be transporting files
        # to other architectures, change this to ASCII
        # we've set this back to ASCII.  Seems the binary mode is screwed
        # for some files and manages to produce corrupt files that segfault
        # VTK on Windows.
        self._writer.SetFileTypeToASCII()
        
        # ctor for this specific mixin
        FilenameViewModuleMixin.__init__(
            self,
            'Select a filename',
            'VTK data (*.vtk)|*.vtk|All files (*)|*',
            {'vtkStructuredPointsWriter': self._writer},
            fileOpen=False)


        # set up some defaults
        self._config.filename = ''

        self.sync_module_logic_with_config()
Ejemplo n.º 6
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        self._implicitModeller = vtk.vtkImplicitModeller()

        module_utils.setup_vtk_object_progress(
            self, self._implicitModeller,
            'Converting surface to distance field')
                                           
        self._config.bounds = (-1, 1, -1, 1, -1, 1)
        self._config.dimensions = (64, 64, 64)
        self._config.maxDistance = 0.1
        
        configList = [
            ('Bounds:', 'bounds', 'tuple:float,6', 'text',
             'The physical location of the sampled volume in space '
             '(x0, x1, y0, y1, z0, z1)'),
            ('Dimensions:', 'dimensions', 'tuple:int,3', 'text',
             'The number of points that should be sampled in each dimension.'),
            ('Maximum distance:', 'maxDistance', 'base:float', 'text',
             'The distance will only be calculated up to this maximum.')]

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkImplicitModeller' : self._implicitModeller})

        self.sync_module_logic_with_config()
Ejemplo n.º 7
0
    def __init__(self, module_manager):

        # call parent constructor
        ModuleBase.__init__(self, module_manager)

        self._writer = vtk.vtkPolyDataWriter()
        # sorry about this, but the files get REALLY big if we write them
        # in ASCII - I'll make this a gui option later.
        self._writer.SetFileTypeToBinary()

        module_utils.setup_vtk_object_progress(
            self, self._writer,
            'Writing VTK Polygonal data')

        
        # ctor for this specific mixin
        FilenameViewModuleMixin.__init__(
            self,
            'Select a filename',
            'VTK data (*.vtk)|*.vtk|All files (*)|*',
            {'vtkPolyDataWriter': self._writer},
            fileOpen=False)

        # set up some defaults
        self._config.filename = ''

        self.sync_module_logic_with_config()
Ejemplo n.º 8
0
    def __init__(self, module_manager):

        # call parent constructor
        ModuleBase.__init__(self, module_manager)

        self._writer = vtk.vtkIVWriter()
        # sorry about this, but the files get REALLY big if we write them
        # in ASCII - I'll make this a gui option later.
        #self._writer.SetFileTypeToBinary()

        # following is the standard way of connecting up the devide progress
        # callback to a VTK object; you should do this for all objects in
        module_utils.setup_vtk_object_progress(
            self, self._writer, 'Writing polydata to Inventor Viewer format')

        # ctor for this specific mixin
        FilenameViewModuleMixin.__init__(
            self,
            'Select a filename',
            'InventorViewer data (*.iv)|*.iv|All files (*)|*',
            {'vtkIVWriter': self._writer},
            fileOpen=False)
        
        # set up some defaults
        self._config.filename = ''
        self.sync_module_logic_with_config()
Ejemplo n.º 9
0
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        self._reader = vtkgdcm.vtkGDCMImageReader()
        # NB NB NB: for now we're SWITCHING off the VTK-compatible
        # Y-flip, until the X-mirror issues can be solved.
        self._reader.SetFileLowerLeft(1)
        self._ici = vtk.vtkImageChangeInformation()
        self._ici.SetInputConnection(0, self._reader.GetOutputPort(0))

        # create output MedicalMetaData and populate it with the
        # necessary bindings.
        mmd = MedicalMetaData()
        mmd.medical_image_properties = \
                self._reader.GetMedicalImageProperties()
        mmd.direction_cosines = \
                self._reader.GetDirectionCosines()
        self._output_mmd = mmd

        module_utils.setup_vtk_object_progress(self, self._reader,
                                           'Reading DICOM data')

        self._view_frame = None
        self._file_dialog = None
        self._config.dicom_filenames = []
        # if this is true, module will still try to load set even if
        # IPP sorting fails by sorting images alphabetically
        self._config.robust_spacing = False

        self.sync_module_logic_with_config()
Ejemplo n.º 10
0
    def __init__(self, module_manager):

        # call parent constructor
        ModuleBase.__init__(self, module_manager)
        

        self._imageInput = None
        self._meshInput = None

        
        self._flipper = vtk.vtkImageFlip()
        self._flipper.SetFilteredAxis(1)
        module_utils.setup_vtk_object_progress(
            self, self._flipper, 'Flipping Y axis.')

        self._config.cpt_driver_path = \
                'd:\\misc\\stuff\\driver.bat'
            #'/home/cpbotha/build/cpt/3d/driver/driver.exe'
        self._config.max_distance = 5

        config_list = [
                ('CPT driver path', 'cpt_driver_path',
                'base:str', 'filebrowser', 
                'Path to CPT driver executable',
                {'fileMode' : module_mixins.wx.OPEN,
                 'fileMask' : 'All files (*.*)|*.*'}), 
                ('Maximum distance', 'max_distance', 
                'base:float', 'text', 
                'The maximum (absolute) distance up to which the field is computed.')]

        ScriptedConfigModuleMixin.__init__(
            self, config_list,
            {'Module (self)' : self})
            
        self.sync_module_logic_with_config()
Ejemplo n.º 11
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        self._reslicer = vtk.vtkImageReslice()
        self._probefilter = vtk.vtkProbeFilter()

        self._config.paddingValue = 0.0

        #This is retarded - we (sometimes, see below) need the padder
        #to get the image extent big enough to satisfy the probe filter.
        #No apparent logical reason, but it throws an exception if we don't.
        self._padder = vtk.vtkImageConstantPad()

        configList = [(
            'Padding value:', 'paddingValue', 'base:float', 'text',
            'The value used to pad regions that are outside the supplied volume.'
        )]

        # initialise any mixins we might have
        ScriptedConfigModuleMixin.__init__(
            self, configList, {
                'Module (self)': self,
                'vtkImageReslice': self._reslicer,
                'vtkProbeFilter': self._probefilter,
                'vtkImageConstantPad': self._padder
            })

        module_utils.setup_vtk_object_progress(
            self, self._reslicer, 'Transforming image (Image Reslice)')
        module_utils.setup_vtk_object_progress(
            self, self._probefilter, 'Performing remapping (Probe Filter)')

        self.sync_module_logic_with_config()
Ejemplo n.º 12
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        # what a lame-assed filter, we have to make dummy inputs!
        # if we don't have a dummy input (but instead a None input) it
        # bitterly complains when we do a GetOutput() (it needs the input
        # to know the type of the output) - and GetPolyDataOutput() also
        # doesn't work.
        # NB: this does mean that our probeFilter NEEDS a PolyData as
        # probe geometry!
        ss = vtk.vtkSphereSource()
        ss.SetRadius(0)
        self._dummyInput = ss.GetOutput()

        #This is also retarded - we (sometimes, see below) need the "padder"
        #to get the image extent big enough to satisfy the probe filter. 
        #No apparent logical reason, but it throws an exception if we don't.
        self._padder = vtk.vtkImageConstantPad()
        self._source = None
        self._input = None
        
        self._probeFilter = vtk.vtkProbeFilter()
        self._probeFilter.SetInput(self._dummyInput)

        NoConfigModuleMixin.__init__(
            self,
            {'Module (self)' : self,
             'vtkProbeFilter' : self._probeFilter})

        module_utils.setup_vtk_object_progress(self, self._probeFilter,
                                           'Mapping source on input')
        
        self.sync_module_logic_with_config()
Ejemplo n.º 13
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        self._reslicer = vtk.vtkImageReslice()
        self._probefilter = vtk.vtkProbeFilter()

        self._config.paddingValue = 0.0
        
        #This is retarded - we (sometimes, see below) need the padder 
        #to get the image extent big enough to satisfy the probe filter. 
        #No apparent logical reason, but it throws an exception if we don't.
        self._padder = vtk.vtkImageConstantPad()

        configList = [
            ('Padding value:', 'paddingValue', 'base:float', 'text',
             'The value used to pad regions that are outside the supplied volume.')]        
        
        # initialise any mixins we might have
        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)': self,
             'vtkImageReslice': self._reslicer,
             'vtkProbeFilter': self._probefilter,
             'vtkImageConstantPad': self._padder})

        module_utils.setup_vtk_object_progress(self, self._reslicer,
                                               'Transforming image (Image Reslice)')
        module_utils.setup_vtk_object_progress(self, self._probefilter,
                                               'Performing remapping (Probe Filter)')

        self.sync_module_logic_with_config()
Ejemplo n.º 14
0
    def __init__(self, module_manager):

        # call parent constructor
        ModuleBase.__init__(self, module_manager)

        self._writer = vtk.vtkXMLPolyDataWriter()

        module_utils.setup_vtk_object_progress(
            self, self._writer,
            'Writing VTK PolyData')

        

        self._writer.SetDataModeToBinary()

        # ctor for this specific mixin
        FilenameViewModuleMixin.__init__(
            self,
            'Select a filename',
            'VTK PolyData (*.vtp)|*.vtp|All files (*)|*',
            {'vtkXMLPolyDataWriter': self._writer},
            fileOpen=False)
            

        # set up some defaults
        self._config.filename = ''

        self.sync_module_logic_with_config()
Ejemplo n.º 15
0
    def __init__(self, module_manager):

        # call parent constructor
        ModuleBase.__init__(self, module_manager)

        self._writer = vtk.vtkXMLImageDataWriter()
        
        # ctor for this specific mixin
        FilenameViewModuleMixin.__init__(
            self,
            'Select a filename',
            'VTK Image Data (*.vti)|*.vti|All files (*)|*',
            {'vtkXMLImageDataWriter': self._writer},
            fileOpen=False)



        module_utils.setup_vtk_object_progress(
            self, self._writer,
            'Writing VTK ImageData')

        self._writer.SetDataModeToBinary()

        # set up some defaults
        self._config.filename = ''
        self._module_manager.sync_module_logic_with_config(self)
Ejemplo n.º 16
0
    def __init__(self, module_manager):

        # call parent constructor
        ModuleBase.__init__(self, module_manager)

        self._writer = vtk.vtkStructuredPointsWriter()

        module_utils.setup_vtk_object_progress(
            self, self._writer, 'Writing vtk structured points data')

        # we do this to save space - if you're going to be transporting files
        # to other architectures, change this to ASCII
        # we've set this back to ASCII.  Seems the binary mode is screwed
        # for some files and manages to produce corrupt files that segfault
        # VTK on Windows.
        self._writer.SetFileTypeToASCII()

        # ctor for this specific mixin
        FilenameViewModuleMixin.__init__(
            self,
            'Select a filename',
            'VTK data (*.vtk)|*.vtk|All files (*)|*',
            {'vtkStructuredPointsWriter': self._writer},
            fileOpen=False)

        # set up some defaults
        self._config.filename = ''

        self.sync_module_logic_with_config()
Ejemplo n.º 17
0
    def _create_pipeline(self):
        # setup our pipeline

        self._otf = vtk.vtkPiecewiseFunction()
        self._ctf = vtk.vtkColorTransferFunction()

        self._volume_property = vtk.vtkVolumeProperty()
        self._volume_property.SetScalarOpacity(self._otf)
        self._volume_property.SetColor(self._ctf)
        self._volume_property.ShadeOn()
        self._volume_property.SetAmbient(0.1)
        self._volume_property.SetDiffuse(0.7)
        self._volume_property.SetSpecular(0.2)
        self._volume_property.SetSpecularPower(10)

        self._volume_raycast_function = vtk.vtkVolumeRayCastMIPFunction()
        self._volume_mapper = vtk.vtkVolumeRayCastMapper()

        # can also used FixedPoint, but then we have to use:
        # SetBlendModeToMaximumIntensity() and not SetVolumeRayCastFunction
        #self._volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper()
        
        self._volume_mapper.SetVolumeRayCastFunction(
            self._volume_raycast_function)

        
        module_utils.setup_vtk_object_progress(self, self._volume_mapper,
                                           'Preparing render.')

        self._volume = vtk.vtkVolume()
        self._volume.SetProperty(self._volume_property)
        self._volume.SetMapper(self._volume_mapper)
Ejemplo n.º 18
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        self._tubeFilter = vtk.vtkTubeFilter()

        module_utils.setup_vtk_object_progress(self, self._tubeFilter,
                                               'Generating tubes.')

        self._config.NumberOfSides = 3
        self._config.Radius = 0.01

        configList = [('Number of sides:', 'NumberOfSides', 'base:int', 'text',
                       'Number of sides that the tube should have.'),
                      ('Tube radius:', 'Radius', 'base:float', 'text',
                       'Radius of the generated tube.')]
        ScriptedConfigModuleMixin.__init__(self, configList)

        self._viewFrame = self._createWindow({
            'Module (self)': self,
            'vtkTubeFilter': self._tubeFilter
        })

        # pass the data down to the underlying logic
        self.config_to_logic()
        # and all the way up from logic -> config -> view to make sure
        self.syncViewWithLogic()
Ejemplo n.º 19
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)
        # initialise any mixins we might have
        NoConfigModuleMixin.__init__(self)

        self._imageReslice = vtk.vtkImageReslice()
        self._imageReslice.SetInterpolationModeToCubic()

        self._matrixToHT = vtk.vtkMatrixToHomogeneousTransform()
        self._matrixToHT.Inverse()

        module_utils.setup_vtk_object_progress(self, self._imageReslice,
                                               'Resampling volume')

        self._viewFrame = self._createViewFrame({
            'Module (self)':
            self,
            'vtkImageReslice':
            self._imageReslice
        })

        # pass the data down to the underlying logic
        self.config_to_logic()
        # and all the way up from logic -> config -> view to make sure
        self.syncViewWithLogic()
Ejemplo n.º 20
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        self._imageMath = vtk.vtkImageMathematics()
        self._imageMath.SetInput1(None)
        self._imageMath.SetInput2(None)

        module_utils.setup_vtk_object_progress(self, self._imageMath,
                                               'Performing image math')

        self._config.operation = 'subtract'
        self._config.constantC = 0.0
        self._config.constantK = 1.0

        configList = [('Operation:', 'operation', 'base:str', 'choice',
                       'The operation that should be performed.',
                       tuple(OPS_DICT.keys())),
                      ('Constant C:', 'constantC', 'base:float', 'text',
                       'The constant C used in some operations.'),
                      ('Constant K:', 'constantK', 'base:float', 'text',
                       'The constant C used in some operations.')]

        ScriptedConfigModuleMixin.__init__(
            self, configList, {
                'Module (self)': self,
                'vtkImageMathematics': self._imageMath
            })

        self.sync_module_logic_with_config()
Ejemplo n.º 21
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)


        self._imageMath = vtk.vtkImageMathematics()
        self._imageMath.SetInput1(None)
        self._imageMath.SetInput2(None)
        
        module_utils.setup_vtk_object_progress(self, self._imageMath,
                                           'Performing image math')
        
                                           
        self._config.operation = 'subtract'
        self._config.constantC = 0.0
        self._config.constantK = 1.0


        configList = [
            ('Operation:', 'operation', 'base:str', 'choice',
             'The operation that should be performed.',
             tuple(OPS_DICT.keys())),
            ('Constant C:', 'constantC', 'base:float', 'text',
             'The constant C used in some operations.'),
            ('Constant K:', 'constantK', 'base:float', 'text',
             'The constant C used in some operations.')]

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkImageMathematics' : self._imageMath})

        self.sync_module_logic_with_config()
Ejemplo n.º 22
0
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        self._reader = vtk.vtkMetaImageReader()

        module_utils.setup_vtk_object_progress(self, self._reader,
                                           'Reading MetaImage data.')
        

        self._config.filename = ''

        configList = [
            ('File name:', 'filename', 'base:str', 'filebrowser',
             'The name of the MetaImage file you want to load.',
             {'fileMode' : wx.OPEN,
              'fileMask' :
              'MetaImage single file (*.mha)|*.mha|MetaImage separate header '
              '(*.mhd)|*.mhd|All files (*.*)|*.*'})]

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkMetaImageReader' : self._reader})

        self.sync_module_logic_with_config()
Ejemplo n.º 23
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)


        self._imageDilate = vtk.vtkImageContinuousDilate3D()
        
        module_utils.setup_vtk_object_progress(self, self._imageDilate,
                                           'Performing greyscale 3D dilation')
        
                                           
        self._config.kernelSize = (3, 3, 3)


        configList = [
            ('Kernel size:', 'kernelSize', 'tuple:int,3', 'text',
             'Size of the kernel in x,y,z dimensions.')]
        ScriptedConfigModuleMixin.__init__(self, configList)        
        

        self._viewFrame = self._createWindow(
            {'Module (self)' : self,
             'vtkImageContinuousDilate3D' : self._imageDilate})

        # pass the data down to the underlying logic
        self.config_to_logic()
        # and all the way up from logic -> config -> view to make sure
        self.logic_to_config()
        self.config_to_view()
Ejemplo n.º 24
0
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)
        InputArrayChoiceMixin.__init__(self)

        self._config.scaleFactor = 1

        configList = [
            ('Scale factor:', 'scaleFactor', 'base:float', 'text',
             'The warping will be scaled by this factor'),
            ('Vectors selection:', 'vectorsSelection', 'base:str', 'choice',
             'The attribute that will be used as vectors for the warping.',
             (self._defaultVectorsSelectionString, self._userDefinedString))
        ]

        self._warpVector = vtk.vtkWarpVector()

        ScriptedConfigModuleMixin.__init__(self, configList, {
            'Module (self)': self,
            'vtkWarpVector': self._warpVector
        })

        module_utils.setup_vtk_object_progress(self, self._warpVector,
                                               'Warping points.')

        self.sync_module_logic_with_config()
Ejemplo n.º 25
0
    def __init__(self, module_manager):
        """Constructor (initialiser) for the PD reader.

        This is almost standard code for most of the modules making use of
        the FilenameViewModuleMixin mixin.
        """
        
        # call the constructor in the "base"
        ModuleBase.__init__(self, module_manager)

        # setup necessary VTK objects
	self._reader = vtk.vtkOBJReader()
        
        # ctor for this specific mixin
        FilenameViewModuleMixin.__init__(
            self,
            'Select a filename',
            'Wavefront OBJ data (*.obj)|*.obj|All files (*)|*',
            {'vtkOBJReader': self._reader})

        module_utils.setup_vtk_object_progress(self, self._reader,
                                           'Reading Wavefront OBJ data')

        # set up some defaults
        self._config.filename = ''

	self.sync_module_logic_with_config()
Ejemplo n.º 26
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)


        # we'll be playing around with some vtk objects, this could
        # be anything
        self._triangleFilter = vtk.vtkTriangleFilter()
        self._curvatures = vtk.vtkCurvatures()
        self._curvatures.SetCurvatureTypeToMaximum()
        self._curvatures.SetInput(self._triangleFilter.GetOutput())

        # initialise any mixins we might have
        NoConfigModuleMixin.__init__(self,
                {'Module (self)' : self,
                    'vtkTriangleFilter' : self._triangleFilter,
                    'vtkCurvatures' : self._curvatures})

        module_utils.setup_vtk_object_progress(self, self._triangleFilter,
                                           'Triangle filtering...')
        module_utils.setup_vtk_object_progress(self, self._curvatures,
                                           'Calculating curvatures...')
        
        
        self.sync_module_logic_with_config()
Ejemplo n.º 27
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)


        self._shepardFilter = vtk.vtkShepardMethod()
        
        module_utils.setup_vtk_object_progress(self, self._shepardFilter,
                                           'Applying Shepard Method.')
        
                                           
        self._config.maximum_distance = 1.0
        
                                           
                                           

        configList = [
            ('Kernel size:', 'kernelSize', 'tuple:int,3', 'text',
             'Size of the kernel in x,y,z dimensions.')]

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkImageContinuousDilate3D' : self._imageDilate})

        self.sync_module_logic_with_config()
Ejemplo n.º 28
0
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)
        InputArrayChoiceMixin.__init__(self)

        # 0 = RK2
        # 1 = RK4
        # 2 = RK45
        self._config.integrator = INTEG_TYPE.index('RK2')
        self._config.max_prop = 5.0
        self._config.integration_direction = INTEG_DIR.index('FORWARD')

        configList = [
            ('Vectors selection:', 'vectorsSelection', 'base:str', 'choice',
             'The attribute that will be used as vectors for the warping.',
             (input_array_choice_mixin.DEFAULT_SELECTION_STRING, )),
            ('Max propagation:', 'max_prop', 'base:float', 'text',
             'The streamline will propagate up to this lenth.'),
            ('Integration direction:', 'integration_direction', 'base:int',
             'choice', 'Select an integration direction.', INTEG_DIR_TEXTS),
            ('Integrator type:', 'integrator', 'base:int', 'choice',
             'Select an integrator for the streamlines.', INTEG_TYPE_TEXTS)
        ]

        self._streamTracer = vtk.vtkStreamTracer()

        ScriptedConfigModuleMixin.__init__(
            self, configList, {
                'Module (self)': self,
                'vtkStreamTracer': self._streamTracer
            })

        module_utils.setup_vtk_object_progress(self, self._streamTracer,
                                               'Tracing stream lines.')

        self.sync_module_logic_with_config()
Ejemplo n.º 29
0
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        self._reader = vtk.vtkMetaImageReader()

        module_utils.setup_vtk_object_progress(self, self._reader,
                                               'Reading MetaImage data.')

        self._config.filename = ''

        configList = [(
            'File name:', 'filename', 'base:str', 'filebrowser',
            'The name of the MetaImage file you want to load.', {
                'fileMode':
                wx.OPEN,
                'fileMask':
                'MetaImage single file (*.mha)|*.mha|MetaImage separate header '
                '(*.mhd)|*.mhd|All files (*.*)|*.*'
            })]

        ScriptedConfigModuleMixin.__init__(self, configList, {
            'Module (self)': self,
            'vtkMetaImageReader': self._reader
        })

        self.sync_module_logic_with_config()
Ejemplo n.º 30
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        # we'll be playing around with some vtk objects, this could
        # be anything
        self._triangleFilter = vtk.vtkTriangleFilter()
        self._curvatures = vtk.vtkCurvatures()
        self._curvatures.SetCurvatureTypeToMaximum()
        self._curvatures.SetInput(self._triangleFilter.GetOutput())

        # initialise any mixins we might have
        NoConfigModuleMixin.__init__(
            self, {
                'Module (self)': self,
                'vtkTriangleFilter': self._triangleFilter,
                'vtkCurvatures': self._curvatures
            })

        module_utils.setup_vtk_object_progress(self, self._triangleFilter,
                                               'Triangle filtering...')
        module_utils.setup_vtk_object_progress(self, self._curvatures,
                                               'Calculating curvatures...')

        self.sync_module_logic_with_config()
Ejemplo n.º 31
0
    def __init__(self, module_manager):

        # call parent constructor
        ModuleBase.__init__(self, module_manager)

        self._imageInput = None
        self._meshInput = None

        self._flipper = vtk.vtkImageFlip()
        self._flipper.SetFilteredAxis(1)
        module_utils.setup_vtk_object_progress(self, self._flipper,
                                               'Flipping Y axis.')

        self._config.cpt_driver_path = \
                'd:\\misc\\stuff\\driver.bat'
        #'/home/cpbotha/build/cpt/3d/driver/driver.exe'
        self._config.max_distance = 5

        config_list = [
            ('CPT driver path', 'cpt_driver_path', 'base:str', 'filebrowser',
             'Path to CPT driver executable', {
                 'fileMode': module_mixins.wx.OPEN,
                 'fileMask': 'All files (*.*)|*.*'
             }),
            ('Maximum distance', 'max_distance', 'base:float', 'text',
             'The maximum (absolute) distance up to which the field is computed.'
             )
        ]

        ScriptedConfigModuleMixin.__init__(self, config_list,
                                           {'Module (self)': self})

        self.sync_module_logic_with_config()
Ejemplo n.º 32
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)
        # initialise any mixins we might have
        NoConfigModuleMixin.__init__(self)


        self._imageReslice = vtk.vtkImageReslice()
        self._imageReslice.SetInterpolationModeToCubic()

        self._matrixToHT = vtk.vtkMatrixToHomogeneousTransform()
        self._matrixToHT.Inverse()


        module_utils.setup_vtk_object_progress(self, self._imageReslice,
                                           'Resampling volume')

        self._viewFrame = self._createViewFrame(
            {'Module (self)' : self,
             'vtkImageReslice' : self._imageReslice})

        # pass the data down to the underlying logic
        self.config_to_logic()
        # and all the way up from logic -> config -> view to make sure
        self.syncViewWithLogic()     
Ejemplo n.º 33
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)


        self._glyph3d = vtktud.vtkMyGlyph3D()
        
        module_utils.setup_vtk_object_progress(self, self._glyph3d,
                                           'Making 3D glyphs')
        
                                           
        self._config.scaling = 1.0
        self._config.scalemode = 1.0

        configList = [
            ('Scaling:', 'scaling', 'base:float', 'text',
             'Glyphs will be scaled by this factor.'),
            ('Scalemode:', 'scalemode', 'base:int', 'text',
             'Scaling will occur by scalar, vector direction or magnitude.')]
        ScriptedConfigModuleMixin.__init__(self, configList)        
        

        self._viewFrame = self._createWindow(
            {'Module (self)' : self,
             'vtkMyGlyph3D' : self._glyph3d})

        # pass the data down to the underlying logic
        self.config_to_logic()
        # and all the way up from logic -> config -> view to make sure
        self.logic_to_config()
        self.config_to_view()
Ejemplo n.º 34
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        self._tubeFilter = vtk.vtkTubeFilter()
        
        module_utils.setup_vtk_object_progress(self, self._tubeFilter,
                                           'Generating tubes.')
                                           
        self._config.NumberOfSides = 3
        self._config.Radius = 0.01

        configList = [
            ('Number of sides:', 'NumberOfSides', 'base:int', 'text',
             'Number of sides that the tube should have.'),
            ('Tube radius:', 'Radius', 'base:float', 'text',
             'Radius of the generated tube.')]
        ScriptedConfigModuleMixin.__init__(self, configList)        
        
        self._viewFrame = self._createWindow(
            {'Module (self)' : self,
             'vtkTubeFilter' : self._tubeFilter})

        # pass the data down to the underlying logic
        self.config_to_logic()
        # and all the way up from logic -> config -> view to make sure
        self.syncViewWithLogic()
Ejemplo n.º 35
0
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        self._extract = vtk.vtkImageExtractComponents()

        module_utils.setup_vtk_object_progress(self, self._extract,
                                           'Extracting components.')
        

        self._config.component1 = 0
        self._config.component2 = 1
        self._config.component3 = 2
        self._config.numberOfComponents = 1
        self._config.fileLowerLeft = False

        configList = [
            ('Component 1:', 'component1', 'base:int', 'text',
             'Zero-based index of first component to extract.'),
            ('Component 2:', 'component2', 'base:int', 'text',
             'Zero-based index of second component to extract.'),
            ('Component 3:', 'component3', 'base:int', 'text',
             'Zero-based index of third component to extract.'),
            ('Number of components:', 'numberOfComponents', 'base:int',
             'choice',
             'Number of components to extract.  Only this number of the '
             'above-specified component indices will be used.',
             ('1', '2', '3'))]

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkImageExtractComponents' : self._extract})

        self.sync_module_logic_with_config()
Ejemplo n.º 36
0
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        self._histogram = vtkdevide.vtkImageHistogram2D()
        module_utils.setup_vtk_object_progress(self, self._histogram,
                                           'Calculating 2D histogram')


        self._config.input1Bins = 256
        self._config.input2Bins = 256
        self._config.maxSamplesPerBin = 512

        configList = [
            ('Number of bins for input 1', 'input1Bins', 'base:int', 'text',
             'The full range of input 1 values will be divided into this many '
             'classes.'),
            ('Number of bins for input 2', 'input2Bins', 'base:int', 'text',
             'The full range of input 2 values will be divided into this many '
             'classes.'),
            ('Maximum samples per bin', 'maxSamplesPerBin', 'base:int', 'text',
             'The number of samples per 2D bin/class will be truncated to '
             'this value.')]

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkImageHistogram2D' : self._histogram})

        self.sync_module_logic_with_config()

        self._input0 = None
        self._input1 = None
Ejemplo n.º 37
0
    def __init__(self, module_manager):
        """Constructor (initialiser) for the PD reader.

        This is almost standard code for most of the modules making use of
        the FilenameViewModuleMixin mixin.
        """

        # call the constructor in the "base"
        ModuleBase.__init__(self, module_manager)

        # setup necessary VTK objects
        self._reader = vtk.vtkSTLReader()

        # ctor for this specific mixin
        FilenameViewModuleMixin.__init__(
            self, 'Select a filename',
            'STL data (*.stl)|*.stl|All files (*)|*',
            {'vtkSTLReader': self._reader})

        module_utils.setup_vtk_object_progress(self, self._reader,
                                               'Reading STL data')

        # set up some defaults
        self._config.filename = ''
        self.sync_module_logic_with_config()
Ejemplo n.º 38
0
    def _create_pipeline(self):
        # setup our pipeline

        self._otf = vtk.vtkPiecewiseFunction()
        self._ctf = vtk.vtkColorTransferFunction()

        self._volume_property = vtk.vtkVolumeProperty()
        self._volume_property.SetScalarOpacity(self._otf)
        self._volume_property.SetColor(self._ctf)
        self._volume_property.ShadeOn()
        self._volume_property.SetAmbient(0.1)
        self._volume_property.SetDiffuse(0.7)
        self._volume_property.SetSpecular(0.2)
        self._volume_property.SetSpecularPower(10)

        self._volume_raycast_function = vtk.vtkVolumeRayCastMIPFunction()
        self._volume_mapper = vtk.vtkVolumeRayCastMapper()

        # can also used FixedPoint, but then we have to use:
        # SetBlendModeToMaximumIntensity() and not SetVolumeRayCastFunction
        #self._volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper()

        self._volume_mapper.SetVolumeRayCastFunction(
            self._volume_raycast_function)

        module_utils.setup_vtk_object_progress(self, self._volume_mapper,
                                               'Preparing render.')

        self._volume = vtk.vtkVolume()
        self._volume.SetProperty(self._volume_property)
        self._volume.SetMapper(self._volume_mapper)
Ejemplo n.º 39
0
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        self._histogram = vtkdevide.vtkImageHistogram2D()
        module_utils.setup_vtk_object_progress(self, self._histogram,
                                               'Calculating 2D histogram')

        self._config.input1Bins = 256
        self._config.input2Bins = 256
        self._config.maxSamplesPerBin = 512

        configList = [
            ('Number of bins for input 1', 'input1Bins', 'base:int', 'text',
             'The full range of input 1 values will be divided into this many '
             'classes.'),
            ('Number of bins for input 2', 'input2Bins', 'base:int', 'text',
             'The full range of input 2 values will be divided into this many '
             'classes.'),
            ('Maximum samples per bin', 'maxSamplesPerBin', 'base:int', 'text',
             'The number of samples per 2D bin/class will be truncated to '
             'this value.')
        ]

        ScriptedConfigModuleMixin.__init__(
            self, configList, {
                'Module (self)': self,
                'vtkImageHistogram2D': self._histogram
            })

        self.sync_module_logic_with_config()

        self._input0 = None
        self._input1 = None
Ejemplo n.º 40
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        self._image_logic = vtk.vtkImageLogic()

        module_utils.setup_vtk_object_progress(self, self._image_logic,
                                               'Performing image logic')

        self._image_cast = vtk.vtkImageCast()
        module_utils.setup_vtk_object_progress(
            self, self._image_cast, 'Casting scalar type before image logic')

        self._config.operation = 0
        self._config.output_true_value = 1.0

        # 'choice' widget with 'base:int' type will automatically get cast
        # to index of selection that user makes.
        config_list = [
            ('Operation:', 'operation', 'base:int',
             'choice', 'The operation that should be performed.',
             tuple(self._operations)),
            ('Output true value:', 'output_true_value', 'base:float', 'text',
             'Output voxels that are TRUE will get this value.')
        ]

        ScriptedConfigModuleMixin.__init__(self, config_list, {
            'Module (self)': self,
            'vtkImageLogic': self._image_logic
        })

        self.sync_module_logic_with_config()
Ejemplo n.º 41
0
    def __init__(self, module_manager, contourFilterText):

        # call parent constructor
        ModuleBase.__init__(self, module_manager)

        self._contourFilterText = contourFilterText
        if contourFilterText == 'marchingCubes':
            self._contourFilter = vtk.vtkMarchingCubes()
        else:  # contourFilter == 'contourFilter'
            self._contourFilter = vtk.vtkContourFilter()

        module_utils.setup_vtk_object_progress(self, self._contourFilter,
                                               'Extracting iso-surface')

        # now setup some defaults before our sync
        self._config.isoValue = 128

        self._viewFrame = None
        self._createViewFrame()

        # transfer these defaults to the logic
        self.config_to_logic()

        # then make sure they come all the way back up via self._config
        self.logic_to_config()
        self.config_to_view()
Ejemplo n.º 42
0
    def __init__(self, module_manager):

        # call parent constructor
        ModuleBase.__init__(self, module_manager)

        self._writer = vtk.vtkMetaImageWriter()

        module_utils.setup_vtk_object_progress(
            self, self._writer,
            'Writing VTK ImageData')

        # set up some defaults
        self._config.filename = ''
        self._config.compression = True

        config_list = [
                ('Filename:', 'filename', 'base:str', 'filebrowser',
                    'Output filename for MetaImage file.',
                    {'fileMode' : wx.SAVE,
                     'fileMask' : 'MetaImage single file (*.mha)|*.mha|MetaImage separate header/(z)raw files (*.mhd)|*.mhd|All files (*)|*',
                     'defaultExt' : '.mha'}
                    ),
                ('Compression:', 'compression', 'base:bool', 'checkbox',
                    'Compress the image / volume data')
                ]

        ScriptedConfigModuleMixin.__init__(self, config_list,
                {'Module (self)' : self})
Ejemplo n.º 43
0
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        # setup config
        self._config.toroidal = True
        self._config.thickness = 0.3333
        self._config.phiRoundness = 0.2
        self._config.thetaRoundness = 0.8
        self._config.size = 0.5

        self._config.center = (0, 0, 0)
        self._config.scale = (1, 1, 1)

        self._config.thetaResolution = 64
        self._config.phiResolution = 64

        # and then our scripted config
        configList = [
            ('Toroidal: ', 'toroidal', 'base:bool', 'checkbox',
             'Should the quadric be toroidal.'),
            ('Thickness: ', 'thickness', 'base:float', 'text',
             'Thickness of the toroid, scaled between 0 and 1'),
            ('Phi Roundness: ', 'phiRoundness', 'base:float', 'text',
             'Controls shape of superquadric'),
            ('Theta Roundness: ', 'thetaRoundness', 'base:float', 'text',
             'Controls shape of superquadric'),
            ('Size: ', 'size', 'base:float', 'text',
             'The size of the superquadric.'),
            ('Centre: ', 'center', 'tuple:float,3', 'text',
             'The translation transform of the resultant superquadric.'),
            ('Scale: ', 'scale', 'tuple:float,3', 'text',
             'The scale transformof the resultant superquadric.'),
            ('Theta resolution: ', 'thetaResolution', 'base:int', 'text',
             'The resolution of the output polydata'),
            ('Phi resolution: ', 'phiResolution', 'base:int', 'text',
             'The resolution of the output polydata')
        ]

        # now create the necessary VTK modules
        self._superquadric = vtk.vtkSuperquadric()
        self._superquadricSource = vtk.vtkSuperquadricSource()

        # we need these temporary outputs
        self._outputs = [self._superquadric, vtk.vtkPolyData()]

        # setup progress for the processObject
        module_utils.setup_vtk_object_progress(self, self._superquadricSource,
                                               "Synthesizing polydata.")

        # mixin ctor
        ScriptedConfigModuleMixin.__init__(
            self, configList, {
                'Module (self)': self,
                'vtkSuperquadric': self._superquadric,
                'vtkSuperquadricSource': self._superquadricSource
            })

        self.sync_module_logic_with_config()
Ejemplo n.º 44
0
    def _setup_for_shell_splatting(self):
        self._volume_mapper = vtkdevide.vtkOpenGLVolumeShellSplatMapper()
        self._volume_mapper.SetOmegaL(0.9)
        self._volume_mapper.SetOmegaH(0.9)
        # high-quality rendermode
        self._volume_mapper.SetRenderMode(0)

        module_utils.setup_vtk_object_progress(self, self._volume_mapper,
                                           'Preparing render.')
Ejemplo n.º 45
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        # main morph gradient
        self._imageDilate = vtk.vtkImageContinuousDilate3D()
        self._imageErode = vtk.vtkImageContinuousErode3D()
        self._imageMath = vtk.vtkImageMathematics()
        self._imageMath.SetOperationToSubtract()

        self._imageMath.SetInput1(self._imageDilate.GetOutput())
        self._imageMath.SetInput2(self._imageErode.GetOutput())

        # inner gradient
        self._innerImageMath = vtk.vtkImageMathematics()
        self._innerImageMath.SetOperationToSubtract()
        self._innerImageMath.SetInput1(None)  # has to take image
        self._innerImageMath.SetInput2(self._imageErode.GetOutput())

        # outer gradient
        self._outerImageMath = vtk.vtkImageMathematics()
        self._outerImageMath.SetOperationToSubtract()
        self._outerImageMath.SetInput1(self._imageDilate.GetOutput())
        self._outerImageMath.SetInput2(None)  # has to take image

        module_utils.setup_vtk_object_progress(
            self, self._imageDilate, 'Performing greyscale 3D dilation')

        module_utils.setup_vtk_object_progress(
            self, self._imageErode, 'Performing greyscale 3D erosion')

        module_utils.setup_vtk_object_progress(
            self, self._imageMath, 'Subtracting erosion from '
            'dilation')

        module_utils.setup_vtk_object_progress(
            self, self._innerImageMath, 'Subtracting erosion from '
            'image (inner)')

        module_utils.setup_vtk_object_progress(
            self, self._outerImageMath, 'Subtracting image from '
            'dilation (outer)')

        self._config.kernelSize = (3, 3, 3)

        configList = [('Kernel size:', 'kernelSize', 'tuple:int,3', 'text',
                       'Size of the kernel in x,y,z dimensions.')]
        ScriptedConfigModuleMixin.__init__(
            self, configList, {
                'Module (self)': self,
                'vtkImageContinuousDilate3D': self._imageDilate,
                'vtkImageContinuousErode3D': self._imageErode,
                'vtkImageMathematics': self._imageMath
            })

        self.sync_module_logic_with_config()
Ejemplo n.º 46
0
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        # setup config
        self._config.toroidal = True
        self._config.thickness = 0.3333
        self._config.phiRoundness = 0.2
        self._config.thetaRoundness = 0.8
        self._config.size = 0.5

        self._config.center = (0,0,0)
        self._config.scale = (1,1,1)

        self._config.thetaResolution = 64
        self._config.phiResolution = 64

        # and then our scripted config
        configList = [
            ('Toroidal: ', 'toroidal', 'base:bool', 'checkbox',
             'Should the quadric be toroidal.'),
            ('Thickness: ', 'thickness', 'base:float', 'text',
             'Thickness of the toroid, scaled between 0 and 1'),
            ('Phi Roundness: ', 'phiRoundness', 'base:float', 'text',
             'Controls shape of superquadric'),
            ('Theta Roundness: ', 'thetaRoundness', 'base:float', 'text',
             'Controls shape of superquadric'),
            ('Size: ', 'size', 'base:float', 'text',
             'The size of the superquadric.'),
            ('Centre: ', 'center', 'tuple:float,3', 'text',
             'The translation transform of the resultant superquadric.'),
            ('Scale: ', 'scale', 'tuple:float,3', 'text',
             'The scale transformof the resultant superquadric.'),
            ('Theta resolution: ', 'thetaResolution', 'base:int', 'text',
             'The resolution of the output polydata'),
            ('Phi resolution: ', 'phiResolution', 'base:int', 'text',
             'The resolution of the output polydata')]

        # now create the necessary VTK modules
        self._superquadric = vtk.vtkSuperquadric()
        self._superquadricSource = vtk.vtkSuperquadricSource()

        # we need these temporary outputs
        self._outputs = [self._superquadric, vtk.vtkPolyData()]
        
        # setup progress for the processObject
        module_utils.setup_vtk_object_progress(self, self._superquadricSource,
                                           "Synthesizing polydata.")

        # mixin ctor
        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkSuperquadric' : self._superquadric,
             'vtkSuperquadricSource' : self._superquadricSource})

        self.sync_module_logic_with_config()
Ejemplo n.º 47
0
 def _setup_for_raycast(self):
     self._volume_raycast_function = \
                                   vtk.vtkVolumeRayCastCompositeFunction()
     
     self._volume_mapper = vtk.vtkVolumeRayCastMapper()
     self._volume_mapper.SetVolumeRayCastFunction(
         self._volume_raycast_function)
     
     module_utils.setup_vtk_object_progress(self, self._volume_mapper,
                                        'Preparing render.')
Ejemplo n.º 48
0
    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)
        InputArrayChoiceMixin.__init__(self)

        self._config.scaling = True
        self._config.scaleFactor = 1
        self._config.scaleMode = glyphScaleMode.index('SCALE_BY_VECTOR')
        self._config.colourMode = glyphColourMode.index('COLOUR_BY_VECTOR')
        self._config.vectorMode = glyphVectorMode.index('USE_VECTOR')
        self._config.mask_on_ratio = 5
        self._config.mask_random = True


        configList = [
            ('Scale glyphs:', 'scaling', 'base:bool', 'checkbox',
             'Should the size of the glyphs be scaled?'),
            ('Scale factor:', 'scaleFactor', 'base:float', 'text',
             'By how much should the glyph size be scaled if scaling is '
             'active?'),
            ('Scale mode:', 'scaleMode', 'base:int', 'choice',
             'Should scaling be performed by vector, scalar or only factor?',
             glyphScaleModeTexts),
            ('Colour mode:', 'colourMode', 'base:int', 'choice',
             'Colour is determined based on scalar or vector magnitude.',
             glyphColourModeTexts),
            ('Vector mode:', 'vectorMode', 'base:int', 'choice',
             'Should vectors or normals be used for scaling and orientation?',
             glyphVectorModeTexts),
            ('Vectors selection:', 'vectorsSelection', 'base:str', 'choice',
             'The attribute that will be used as vectors for the warping.',
             (input_array_choice_mixin.DEFAULT_SELECTION_STRING,)),
            ('Mask on ratio:', 'mask_on_ratio', 'base:int', 'text',
             'Every Nth point will be glyphed.'),
            ('Random masking:', 'mask_random', 'base:bool', 'checkbox',
             'Pick random distribution of Nth points.')]

        self._mask_points = vtk.vtkMaskPoints()
        module_utils.setup_vtk_object_progress(self,
                self._mask_points, 'Masking points.')

        self._glyphFilter = vtk.vtkGlyph3D()
        asrc = vtk.vtkArrowSource()
        self._glyphFilter.SetSource(0, asrc.GetOutput())

        self._glyphFilter.SetInput(self._mask_points.GetOutput())
        
        module_utils.setup_vtk_object_progress(self, self._glyphFilter,
                                           'Creating glyphs.')

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkGlyph3D' : self._glyphFilter})

        self.sync_module_logic_with_config()
Ejemplo n.º 49
0
    def _setup_for_fixed_point(self):
        """This doesn't seem to work.  After processing is complete,
        it stalls on actually rendering the volume.  No idea.
        """
        import vtktudoss 
        self._volume_mapper = vtktudoss.vtkCVFixedPointVolumeRayCastMapper()
        self._volume_mapper.SetBlendModeToComposite()
        #self._volume_mapper.SetBlendModeToMaximumIntensity()

        module_utils.setup_vtk_object_progress(self, self._volume_mapper,
                                           'Preparing render.')
Ejemplo n.º 50
0
    def _setup_for_gpu_raycasting(self):
        """This doesn't seem to work.  After processing is complete,
        it stalls on actually rendering the volume.  No idea.
        """
        
        self._volume_mapper = vtk.vtkGPUVolumeRayCastMapper()
        self._volume_mapper.SetBlendModeToComposite()
        #self._volume_mapper.SetBlendModeToMaximumIntensity()

        module_utils.setup_vtk_object_progress(self, self._volume_mapper,
                                           'Preparing render.')