Ejemplo n.º 1
0
    def wrapOpImp(self):
        self.preMashCommand.data = self.mashData;
        self.mashData = self.preMashCommand.execute();
        
        self.transform_one.data = self.data;
        import vtkMeasure;
        data_one = self.transform_one.perform();
        measure_one = vtkMeasure.measure_factory(data_one);
        self.transform_two.data = self.mashData;
        data_two = self.transform_two.perform()
        measure_two = vtkMeasure.measure_factory(data_two);
        
        poly2Vops = Poly2ImageOp();
        poly2Vops.data = data_one;
        img_data_one = poly2Vops.perform();
        resoulation_one = poly2Vops.resoulation;
        poly2Vops.data = data_two;
        img_data_two = poly2Vops.perform();
        resoulation_two = poly2Vops.resoulation;

        resoulation = [min(resoulation_one[0],resoulation_two[0]),min(resoulation_one[1],resoulation_two[1]),min(resoulation_one[2],resoulation_two[2])];
        self.transform_one.data = data_one;
        self.transform_two.data = data_two;
        implicitV_One = vtk.vtkImplicitVolume();
        implicitV_One.SetVolume(img_data_one);
        transform_one = self.transform_one.getLinkedTransform();
        implicitV_One.SetTransform(transform_one.GetInverse());
        implicitV_One.SetOutValue(IMAGEOUT);

        implicitV_Two = vtk.vtkImplicitVolume();
        implicitV_Two.SetVolume(img_data_two);
        transform_two = self.transform_two.getLinkedTransform();
        implicitV_Two.SetTransform(transform_two.GetInverse());
        implicitV_Two.SetOutValue(IMAGEOUT);
        
        boolOp = vtk.vtkImplicitBoolean();
        boolOp.AddFunction(implicitV_One);
        boolOp.AddFunction(implicitV_Two);
        boolOp.SetOperationTypeToUnion();
        #boolOp.SetOperationTypeToDifference();
        #boolOp.SetOperationTypeToIntersection();
        
        implicit2Poly = Implicit2Poly();
        import vtk2Box;
        
        xMin = min(measure_one.xSize[0],measure_two.xSize[0]);
        xMax = max(measure_one.xSize[1],measure_two.xSize[1]);
        yMin = min(measure_one.ySize[0],measure_two.ySize[0]);
        yMax = max(measure_one.ySize[1],measure_two.ySize[1]);
        zMin = min(measure_one.zSize[0],measure_two.zSize[0]);
        zMax = max(measure_one.zSize[1],measure_two.zSize[1]);

        implicit2Poly.bbox = vtk2Box.BBox(xMin,xMax,yMin,yMax,zMin,zMax);
        implicit2Poly.resoulation = resoulation;
        implicit2Poly.data = boolOp;
        result = implicit2Poly.perform();
 
        return result;
Ejemplo n.º 2
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._distance = vtk.vtkImageEuclideanDistance()
        # this seems to yield more accurate results in this case
        # it would probably be better to calculate only 2d distance fields
        self._distance.ConsiderAnisotropyOff()

        self._xEndPoints = []
        self._noFlipXes = []
        self._pf1 = vtk.vtkProgrammableFilter()  # yeah
        self._pf1.SetInput(self._distance.GetOutput())
        self._pf1.SetExecuteMethod(self.pf1Execute)

        self._pf2 = vtk.vtkProgrammableFilter()
        self._pf2.SetInput(self._pf1.GetOutput())
        self._pf2.SetExecuteMethod(self.pf2Execute)

        self._mc = vtk.vtkMarchingCubes()
        self._mc.SetInput(self._pf1.GetOutput())
        self._mc.SetValue(0, 0.1)

        self._iv = vtk.vtkImplicitVolume()
        self._iv.SetVolume(self._pf2.GetOutput())

        self._cpd = vtk.vtkClipPolyData()
        self._cpd.SetClipFunction(self._iv)
        self._cpd.SetInput(self._mc.GetOutput())
        #self._cpd.InsideOutOn()

        module_utils.setup_vtk_object_progress(
            self, self._distance, 'Calculating distance field...')
        module_utils.setup_vtk_object_progress(self, self._pf1,
                                               'Signing distance field...')
        module_utils.setup_vtk_object_progress(self, self._pf2,
                                               'Creating implicit volume...')
        module_utils.setup_vtk_object_progress(self, self._mc,
                                               'Extracting isosurface...')
        module_utils.setup_vtk_object_progress(self, self._cpd,
                                               'Clipping isosurface...')

        self._iObj = self._distance
        self._oObj = self._cpd
        #self._oObj = self._pf2

        self._viewFrame = self._createViewFrame({
            'distance': self._distance,
            'pf1': self._pf1,
            'pf2': self._pf2,
            'mc': self._mc,
            'cpd': self._cpd
        })
Ejemplo n.º 3
0
    def onGradientInNewVolBtnClicked(self):
        # Result is not right!
        volumeNode = slicer.util.getNode("MRHead")
        ijkToRas = vtk.vtkMatrix4x4()
        volumeNode.GetIJKToRASMatrix(ijkToRas)
        imageData = volumeNode.GetImageData()
        extent = imageData.GetExtent()

        imageSize = imageData.GetDimensions()
        imageSpacing = imageData.GetSpacing()
        voxelType = vtk.VTK_FLOAT

        # Create empty image volume
        imageData_2 = vtk.vtkImageData()
        imageData_2.SetDimensions(imageSize[0] / 2, imageSize[1] / 2, imageSize[2] / 2)
        imageData_2.SetSpacing(imageSpacing)
        imageData_2.AllocateScalars(voxelType, 0)

        thresholder = vtk.vtkImageThreshold()
        thresholder.SetInputData(imageData_2)
        thresholder.SetInValue(0)
        thresholder.SetOutValue(0)

        volumeNode_2 = slicer.vtkMRMLScalarVolumeNode()
        volumeNode_2.SetSpacing(imageSpacing)
        volumeNode_2.SetImageDataConnection(thresholder.GetOutputPort())

        # Add volume to scene
        scene = slicer.mrmlScene
        scene.AddNode(volumeNode_2)
        displayNode = slicer.vtkMRMLScalarVolumeDisplayNode()
        scene.AddNode(displayNode)
        colorNode = slicer.util.getNode("Grey")
        displayNode.SetAndObserveColorNodeID(colorNode.GetID())
        volumeNode_2.SetAndObserveDisplayNodeID(displayNode.GetID())
        volumeNode_2.CreateDefaultStorageNode()

        # npData = slicer.util.array('MRHead')
        impVol = vtk.vtkImplicitVolume()
        impVol.SetVolume(imageData)

        for k in xrange(extent[4], extent[5] / 2 + 1):
            for j in xrange(extent[2], extent[3] / 2 + 1):
                for i in xrange(extent[0], extent[1] / 2 + 1):
                    g = impVol.FunctionGradient(i, j, k)
                    gradient = math.sqrt(g[0] ** 2 + g[1] ** 2 + g[2] ** 2)
                    imageData_2.SetScalarComponentFromFloat(i, j, k, 0, gradient)

        imageData_2.Modified()
Ejemplo n.º 4
0
    def onGradientBtnClicked(self):

        volumeNode = slicer.util.getNode("MRHead")
        ijkToRas = vtk.vtkMatrix4x4()
        volumeNode.GetIJKToRASMatrix(ijkToRas)
        imageData = volumeNode.GetImageData()
        extent = imageData.GetExtent()

        # npData = slicer.util.array('MRHead')
        impVol = vtk.vtkImplicitVolume()
        impVol.SetVolume(imageData)

        for k in xrange(extent[4], extent[5] / 2 + 1):
            for j in xrange(extent[2], extent[3] / 2 + 1):
                for i in xrange(extent[0], extent[1] / 2 + 1):
                    g = impVol.FunctionGradient(i, j, k)
                    gradient = math.sqrt(g[0] ** 2 + g[1] ** 2 + g[2] ** 2)
                    imageData.SetScalarComponentFromFloat(i, j, k, 0, gradient)

        imageData.Modified()
Ejemplo n.º 5
0
    def __init__(self):
        ActorFactory.ActorFactory.__init__(self)

        # whether to display the volume
        self._ShowVolume = 1
        self._StatusChange = 0

        # create a clipping cube to go with the volume
        self._ClippingCube = ClippingCubeFactory.ClippingCubeFactory()
        self.AddChild(self._ClippingCube)
        self._CubeClippingPlanes = vtk.vtkPlaneCollection()
        for i in range(6):
            self._CubeClippingPlanes.AddItem(vtk.vtkPlane())

        # for if we clip in with OrthoPlanes
        self._OrthoPlanes = None
        self._ShowOrthoPlanes = 1
        self._OrthoPlanesLookupTables = {}
        self._OrthoPickThreshold = 0.0025

        # corner clipping planes, in pairs with opposite normals
        self._CornerClippingPlanes = vtk.vtkPlaneCollection()
        for i in range(6):
            self._CornerClippingPlanes.AddItem(vtk.vtkPlane())

        # clipping planes for the volume, sorted for the
        # three chunks that will make up the final volume
        self._ClippingPlanes = [
            vtk.vtkPlaneCollection(),
            vtk.vtkPlaneCollection(),
            vtk.vtkPlaneCollection()
        ]

        for i in range(3):
            planes = self._ClippingPlanes[i]
            cplanes = self._CornerClippingPlanes
            bplanes = self._CubeClippingPlanes
            if i == 0:
                planes.AddItem(cplanes.GetItemAsObject(0))
                planes.AddItem(bplanes.GetItemAsObject(1))
                planes.AddItem(bplanes.GetItemAsObject(2))
                planes.AddItem(bplanes.GetItemAsObject(3))
                planes.AddItem(bplanes.GetItemAsObject(4))
                planes.AddItem(bplanes.GetItemAsObject(5))
            else:
                planes.AddItem(bplanes.GetItemAsObject(0))
                planes.AddItem(cplanes.GetItemAsObject(1))
                if i == 1:
                    planes.AddItem(cplanes.GetItemAsObject(2))
                    planes.AddItem(bplanes.GetItemAsObject(3))
                    planes.AddItem(bplanes.GetItemAsObject(4))
                    planes.AddItem(bplanes.GetItemAsObject(5))
                else:
                    planes.AddItem(bplanes.GetItemAsObject(2))
                    planes.AddItem(cplanes.GetItemAsObject(3))
                    if i == 2:
                        planes.AddItem(cplanes.GetItemAsObject(4))
                        planes.AddItem(bplanes.GetItemAsObject(5))
                    else:
                        planes.AddItem(bplanes.GetItemAsObject(4))
                        planes.AddItem(bplanes.GetItemAsObject(5))

        self._Input = None

        # generate the pipeline
        self._ImagePrefilter = vtk.vtkImageShrink3D()

        self._ImageReslice = vtk.vtkImageReslice()
        self._ImageReslice.SetInterpolationModeToLinear()

        self._ImageMapToColors = vtk.vtkImageMapToColors()
        self._ImageMapToColors.SetOutputFormatToRGBA()

        self._ImageToStructuredPoints = vtk.vtkImageToStructuredPoints()

        self._ImageClipsXY = []
        self._PlanesXY = []
        self._ActorsXY = []
        self._PropertyXY = vtk.vtkProperty()
        self._PropertyXY.SetDiffuse(0)
        self._PropertyXY.SetAmbient(1)

        self._ImageClipsYZ = []
        self._PlanesYZ = []
        self._ActorsYZ = []
        self._PropertyYZ = vtk.vtkProperty()
        self._PropertyYZ.SetDiffuse(0)
        self._PropertyYZ.SetAmbient(1)

        self._ImageClipsZX = []
        self._PlanesZX = []
        self._ActorsZX = []
        self._PropertyZX = vtk.vtkProperty()
        self._PropertyZX.SetDiffuse(0)
        self._PropertyZX.SetAmbient(1)

        # a list of the renderer info
        self._RendererCurrentIndex = {}
        self._RendererActorList = {}
        self._RendererObserverList = {}

        # a transform to apply to the image
        self._ImageTransform = None
        self._TransformToGrid = vtk.vtkTransformToGrid()

        # the alpha pick threshold for the volume
        self._PickThreshold = 0.25
        # the implicit volume for finding the gradient
        self._ImplicitVolume = vtk.vtkImplicitVolume()

        # the extent of the texture maps
        self._VolumeResolution = (64, 64, 64)

        # the bounds of the volume
        self._VolumeBounds = None
Ejemplo n.º 6
0
           (range_y[1] - range_y[0]) / (dim_y - 1.0),
           (range_z[1] - range_z[0]) / (dim_z - 1.0)]

# Convert vtkFloatArray to vtkImageData
vtk_image_data = vtk.vtkImageData()
vtk_image_data.SetDimensions(quadric_2.shape)
vtk_image_data.SetSpacing([0.1] * 3)  # How to set a correct spacing value??
vtk_image_data.GetPointData().SetScalars(vtk_array)
vtk_image_data.SetOrigin(-1, -1, -1)
vtk_image_data.SetSpacing(spacing)

dims = vtk_image_data.GetDimensions()
bounds = vtk_image_data.GetBounds()


implicit_volume = vtk.vtkImplicitVolume()
implicit_volume.SetVolume(vtk_image_data)

sample_2 = vtk.vtkSampleFunction()
sample_2.SetImplicitFunction(implicit_volume)
sample_2.SetModelBounds(bounds)
sample_2.ComputeNormalsOff()

contour_2 = vtk.vtkContourFilter()
contour_2.SetInputConnection(sample_2.GetOutputPort())
contour_2.SetValue(0, contour_value)

# ===========================================================================
# Rendering
renderer_1 = vtk.vtkRenderer()  # for vtkQuadric
renderer_2 = vtk.vtkRenderer()  # for meshgrid
    def __init__(self):
        ActorFactory.ActorFactory.__init__(self)

        # whether to display the volume
        self._ShowVolume = 1
        self._StatusChange = 0

        # create a clipping cube to go with the volume
        self._ClippingCube = ClippingCubeFactory.ClippingCubeFactory()
        self.AddChild(self._ClippingCube)
        self._CubeClippingPlanes = vtk.vtkPlaneCollection()
        for i in range(6):
            self._CubeClippingPlanes.AddItem(vtk.vtkPlane())

        # for if we clip in with OrthoPlanes
        self._OrthoPlanes = None
        self._ShowOrthoPlanes = 1
        self._OrthoPlanesLookupTables = {}
        self._OrthoPickThreshold = 0.0025

        # corner clipping planes, in pairs with opposite normals
        self._CornerClippingPlanes = vtk.vtkPlaneCollection()
        for i in range(6):
            self._CornerClippingPlanes.AddItem(vtk.vtkPlane())

        # clipping planes for the volume, sorted for the
        # three chunks that will make up the final volume
        self._ClippingPlanes = [vtk.vtkPlaneCollection(),
                                vtk.vtkPlaneCollection(),
                                vtk.vtkPlaneCollection()]

        for i in range(3):
            planes = self._ClippingPlanes[i]
            cplanes = self._CornerClippingPlanes
            bplanes = self._CubeClippingPlanes
            if i == 0:
                planes.AddItem(cplanes.GetItemAsObject(0))
                planes.AddItem(bplanes.GetItemAsObject(1))
                planes.AddItem(bplanes.GetItemAsObject(2))
                planes.AddItem(bplanes.GetItemAsObject(3))
                planes.AddItem(bplanes.GetItemAsObject(4))
                planes.AddItem(bplanes.GetItemAsObject(5))
            else:
                planes.AddItem(bplanes.GetItemAsObject(0))
                planes.AddItem(cplanes.GetItemAsObject(1))
                if i == 1:
                    planes.AddItem(cplanes.GetItemAsObject(2))
                    planes.AddItem(bplanes.GetItemAsObject(3))
                    planes.AddItem(bplanes.GetItemAsObject(4))
                    planes.AddItem(bplanes.GetItemAsObject(5))
                else:
                    planes.AddItem(bplanes.GetItemAsObject(2))
                    planes.AddItem(cplanes.GetItemAsObject(3))
                    if i == 2:
                        planes.AddItem(cplanes.GetItemAsObject(4))
                        planes.AddItem(bplanes.GetItemAsObject(5))
                    else:
                        planes.AddItem(bplanes.GetItemAsObject(4))
                        planes.AddItem(bplanes.GetItemAsObject(5))

        self._Input = None

        # generate the pipeline
        self._ImagePrefilter = vtk.vtkImageShrink3D()

        self._ImageReslice = vtk.vtkImageReslice()
        self._ImageReslice.SetInterpolationModeToLinear()

        self._ImageMapToColors = vtk.vtkImageMapToColors()
        self._ImageMapToColors.SetOutputFormatToRGBA()

        self._ImageToStructuredPoints = vtk.vtkImageToStructuredPoints()

        self._ImageClipsXY = []
        self._PlanesXY = []
        self._ActorsXY = []
        self._PropertyXY = vtk.vtkProperty()
        self._PropertyXY.SetDiffuse(0)
        self._PropertyXY.SetAmbient(1)

        self._ImageClipsYZ = []
        self._PlanesYZ = []
        self._ActorsYZ = []
        self._PropertyYZ = vtk.vtkProperty()
        self._PropertyYZ.SetDiffuse(0)
        self._PropertyYZ.SetAmbient(1)

        self._ImageClipsZX = []
        self._PlanesZX = []
        self._ActorsZX = []
        self._PropertyZX = vtk.vtkProperty()
        self._PropertyZX.SetDiffuse(0)
        self._PropertyZX.SetAmbient(1)

        # a list of the renderer info
        self._RendererCurrentIndex = {}
        self._RendererActorList = {}
        self._RendererObserverList = {}

        # a transform to apply to the image
        self._ImageTransform = None
        self._TransformToGrid = vtk.vtkTransformToGrid()

        # the alpha pick threshold for the volume
        self._PickThreshold = 0.25
        # the implicit volume for finding the gradient
        self._ImplicitVolume = vtk.vtkImplicitVolume()

        # the extent of the texture maps
        self._VolumeResolution = (64, 64, 64)

        # the bounds of the volume
        self._VolumeBounds = None
Ejemplo n.º 8
0
def getImplicitVolume(image):
    implicitVolume = vtk.vtkImplicitVolume()
    implicitVolume.SetVolume(image)
    implicitVolume.SetOutValue(-1000)
    implicitVolume.SetOutGradient(0,0,0)  
    return implicitVolume
Ejemplo n.º 9
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._distance = vtk.vtkImageEuclideanDistance()
        # this seems to yield more accurate results in this case
        # it would probably be better to calculate only 2d distance fields
        self._distance.ConsiderAnisotropyOff()

        self._xEndPoints = []
        self._noFlipXes = []
        self._pf1 = vtk.vtkProgrammableFilter() # yeah
        self._pf1.SetInput(self._distance.GetOutput())
        self._pf1.SetExecuteMethod(self.pf1Execute)

        self._pf2 = vtk.vtkProgrammableFilter()
        self._pf2.SetInput(self._pf1.GetOutput())
        self._pf2.SetExecuteMethod(self.pf2Execute)

        self._mc = vtk.vtkMarchingCubes()
        self._mc.SetInput(self._pf1.GetOutput())
        self._mc.SetValue(0,0.1)

        self._iv = vtk.vtkImplicitVolume()
        self._iv.SetVolume(self._pf2.GetOutput())

        self._cpd = vtk.vtkClipPolyData()
        self._cpd.SetClipFunction(self._iv)
        self._cpd.SetInput(self._mc.GetOutput())
        #self._cpd.InsideOutOn()

        module_utils.setup_vtk_object_progress(self, self._distance,
                                           'Calculating distance field...')
        module_utils.setup_vtk_object_progress(self, self._pf1,
                                           'Signing distance field...')
        module_utils.setup_vtk_object_progress(self, self._pf2,
                                           'Creating implicit volume...')
        module_utils.setup_vtk_object_progress(self, self._mc,
                                           'Extracting isosurface...')
        module_utils.setup_vtk_object_progress(self, self._cpd,
                                           'Clipping isosurface...')
        
        
        
        

        self._iObj = self._distance
        self._oObj = self._cpd
        #self._oObj = self._pf2
        
        self._viewFrame = self._createViewFrame({'distance' :
                                                 self._distance,
                                                 'pf1' :
                                                 self._pf1,
                                                 'pf2' :
                                                 self._pf2,
                                                 'mc' :
                                                 self._mc,
                                                 'cpd' :
                                                 self._cpd})
Ejemplo n.º 10
0
    def __init__(self):
        ActorFactory.ActorFactory.__init__(self)

        self._LookupTable = None  # lookup table is currently not used
        self._ColorTransferFunction = None
        self._OpacityTransferFunction = None
        self._RendererObserverList = {}

        # create a clipping cube to go with the volume
        self._ClippingCube = ClippingCubeFactory.ClippingCubeFactory()
        self.AddChild(self._ClippingCube)
        self._CubeClippingPlanes = vtk.vtkPlaneCollection()
        for i in range(6):
            self._CubeClippingPlanes.AddItem(vtk.vtkPlane())

        # corner clipping planes, in pairs with opposite normals
        self._CornerClippingPlanes = vtk.vtkPlaneCollection()
        for i in range(6):
            self._CornerClippingPlanes.AddItem(vtk.vtkPlane())

        # clipping planes for the volume, sorted for the
        # three chunks that will make up the final volume
        # (these are currently unused)
        self._ClippingPlanes = [vtk.vtkPlaneCollection(),
                                vtk.vtkPlaneCollection(),
                                vtk.vtkPlaneCollection()]

        for i in range(3):
            planes = self._ClippingPlanes[i]
            cplanes = self._CornerClippingPlanes
            bplanes = self._CubeClippingPlanes
            if i == 0:
                planes.AddItem(cplanes.GetItemAsObject(0))
                planes.AddItem(bplanes.GetItemAsObject(1))
                planes.AddItem(bplanes.GetItemAsObject(2))
                planes.AddItem(bplanes.GetItemAsObject(3))
                planes.AddItem(bplanes.GetItemAsObject(4))
                planes.AddItem(bplanes.GetItemAsObject(5))
            else:
                planes.AddItem(bplanes.GetItemAsObject(0))
                planes.AddItem(cplanes.GetItemAsObject(1))
                if i == 1:
                    planes.AddItem(cplanes.GetItemAsObject(2))
                    planes.AddItem(bplanes.GetItemAsObject(3))
                    planes.AddItem(bplanes.GetItemAsObject(4))
                    planes.AddItem(bplanes.GetItemAsObject(5))
                else:
                    planes.AddItem(bplanes.GetItemAsObject(2))
                    planes.AddItem(cplanes.GetItemAsObject(3))
                    if i == 2:
                        planes.AddItem(cplanes.GetItemAsObject(4))
                        planes.AddItem(bplanes.GetItemAsObject(5))
                    else:
                        planes.AddItem(bplanes.GetItemAsObject(4))
                        planes.AddItem(bplanes.GetItemAsObject(5))

        # generate the pipeline pieces
        self._Input = None

        # transform the full-resolution volume
        self._RayCastReslice = vtk.vtkImageReslice()
        self._RayCastReslice.SetInterpolationModeToLinear()

        # subsample the volume for low-res rendering
        self._ImagePrefilter1 = vtk.vtkImageShrink3D()

        self._ImagePrefilter2 = vtk.vtkImageShrink3D()

        # transform the subsampled volume
        self._ImageReslice1 = vtk.vtkImageReslice()
        self._ImageReslice1.SetInterpolationModeToLinear()

        self._ImageReslice2 = vtk.vtkImageReslice()
        self._ImageReslice2.SetInterpolationModeToLinear()

        # convert to RGBA for rendering (unused)
        self._ImageMapToColors = vtk.vtkImageMapToColors()
        self._ImageMapToColors.SetOutputFormatToRGBA()

        # strictly for VTK 3.2 compatibility
        self._ImageToStructuredPoints = vtk.vtkImageToStructuredPoints()

        # a transform to apply to the image
        self._ImageTransform = None
        self._TransformToGrid = vtk.vtkTransformToGrid()

        # the opacity pick threshold for the volume
        self._PickThreshold = 0.99
        # the implicit volume for finding the gradient
        self._ImplicitVolume = vtk.vtkImplicitVolume()

        # the texture dimensions (later this will be set automatically
        #    to provide the desired interactive rendering time)
        self._TextureSize = 128

        # the bounds of the volume
        self._VolumeBounds = None

        # vtkVolume specific stuff
        self._VolumeProperty = vtk.vtkVolumeProperty()
        self._VolumeProperty.SetInterpolationTypeToLinear()

        rayCastFunction = vtk.vtkVolumeRayCastCompositeFunction()
        self._VolumeRayCastMapper = vtk.vtkVolumeRayCastMapper()
        self._VolumeRayCastMapper.SetVolumeRayCastFunction(rayCastFunction)
        self._VolumeRayCastMapper.SetClippingPlanes(
            self._ClippingCube.GetClippingPlanes())
        try:  # vtk 3.2 does not contain this function call:
            self._VolumeRayCastMapper.AutoAdjustSampleDistancesOff()
        except:
            pass

        self._VolumeTextureMapper1 = vtk.vtkVolumeTextureMapper2D()
        self._VolumeTextureMapper1.SetTargetTextureSize(old_div(self._TextureSize, 4),
                                                        old_div(self._TextureSize, 4))
        self._VolumeTextureMapper1.SetMaximumNumberOfPlanes(
            old_div(self._TextureSize, 2))
        self._VolumeTextureMapper1.SetClippingPlanes(
            self._ClippingCube.GetClippingPlanes())
        try:  # vtk 3.2 does not contain this function call:
            # set to the amount of available texture memory (24MB is a good
            # start)
            self._VolumeTextureMapper1.SetMaximumStorageSize(24 * 1024 * 1024)
        except:
            pass

        self._VolumeTextureMapper2 = vtk.vtkVolumeTextureMapper2D()
        self._VolumeTextureMapper2.SetTargetTextureSize(self._TextureSize,
                                                        self._TextureSize)
        self._VolumeTextureMapper2.SetMaximumNumberOfPlanes(self._TextureSize)
        self._VolumeTextureMapper2.SetClippingPlanes(
            self._ClippingCube.GetClippingPlanes())

        try:  # vtk 3.2 does not contain this function call:
            # set to the amount of available texture memory (24MB is a good
            # start)
            self._VolumeTextureMapper2.SetMaximumStorageSize(24 * 1024 * 1024)
        except:
            pass

        # set two levels of detail: texture and ray-casting
        self._Volume = vtk.vtkLODProp3D()
        self._Volume.PickableOff()
        idT1 = self._Volume.AddLOD(self._VolumeTextureMapper1,
                                   self._VolumeProperty,
                                   0.02)
        idT2 = self._Volume.AddLOD(self._VolumeTextureMapper2,
                                   self._VolumeProperty,
                                   0.1)

        # remember these LOD id numbers
        self._lod = [idT1, idT2]

#        idRC = self._Volume.AddLOD(self._VolumeRayCastMapper,
#                                   self._VolumeProperty,
#                                   2.0)
        self._Volume.SetLODLevel(idT1, 2.0)
        self._Volume.SetLODLevel(idT2, 1.0)