Example #1
0
 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkAssignAttribute(), 'Processing.',
         ('vtkDataSet',), ('vtkDataSet',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
def multi_con_h2(filename):
    # Creating contour for h2 fileld
    
    data = vtk.vtkXMLImageDataReader()
    data.SetFileName(filename)#"/Users/y1275963/Documents/homework/multifield.0060.vti")
    data.Update()
    #Getting highest value
    [low,high] = data.GetOutput().GetPointData().GetArray("H2").GetRange()

    data_h2 = vtk.vtkAssignAttribute()
    data_h2.SetInputConnection(data.GetOutputPort())
    data_h2.Assign('H2','SCALARS','POINT_DATA')
    
    
    
    # Create a filter to extract an isosurface from
    # the dataset.  Connect the input of this
    # filter to the output of the reader.  Set the
    # value for the (one) isosurface that we want
    # to extract, and tell the filter to compute
    # normal vectors for each triangle on the
    # output isosurface.
    
    iso = vtk.vtkContourFilter()
    iso.SetInputConnection(data_h2.GetOutputPort())
    iso.ComputeNormalsOn()
    iso.SetNumberOfContours(10)
    for i in range(10):
        iso.SetValue(i, (1.0-0.1*i)*high) #Chnge here to change the isovalue
    
    
    # Create a mapper to traverse the polydata and
    # generate graphics commands for drawing the
    # polygons onto the output device.
    
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(iso.GetOutputPort())
    mapper.ScalarVisibilityOff()
    
    # Output primitives (i.e. the triangles making
    # up the isosurface) are managed as an actor;
    # we specify that all outputs are coloured
    # red.
    
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    actor.GetProperty().SetColor(0, 0, 1)
    actor.GetProperty().SetOpacity(0.3)
    
    # Create a renderer which will output the
    # graphics commands onto a drawing surface within
    # a window.  By default the renderer will fill
    # all of the window.  We set the background
    # colour of the window to white.
    return actor
Example #3
0
def extract_contour(segmentation_path, contour_path, rgb_data=False):
    # build pipeline
    sys.stdout.write('Updating segmentation...'); sys.stdout.flush()
    segmentation = vtk.vtkMetaImageReader()
    segmentation.SetFileName(segmentation_path)
    segmentation.Update()
    print 'done.'
    
    if rgb_data:
        calculator_function = "mag(MetaImage)"
    else:
        calculator_function = "MetaImage * 255"
    
    sys.stdout.write('Updating calculator...'); sys.stdout.flush()
    calculator = vtk.vtkArrayCalculator()
    calculator.SetInputConnection(segmentation.GetOutputPort())
    # Working on point data
    calculator.SetAttributeModeToUsePointData()
    calculator.AddScalarArrayName("MetaImage")
    # magnitude of input
    calculator.SetFunction("mag(MetaImage)")
    # The output array will be called resArray
    calculator.SetResultArrayName("magnitude")
    
    # Use AssignAttribute to make resArray the active scalar field
    aa = vtk.vtkAssignAttribute()
    aa.SetInputConnection(calculator.GetOutputPort())
    aa.Assign("magnitude", "SCALARS", "POINT_DATA")
    aa.Update()
    print 'done.'
    
    # intensity is either (3 * 255^2)^0.5, or 1
    if rgb_data:
        magnitude = 420.0
    else:
        magnitude = 127
    
    sys.stdout.write('Updating contour...'); sys.stdout.flush()
    contour = vtk.vtkContourFilter()
    contour.SetInputConnection(calculator.GetOutputPort())
    contour.SetValue(0, magnitude)
    contour.Update()
    print 'done.'
    
    # write out data file in given format
    sys.stdout.write('Updating writer...'); sys.stdout.flush()
    writer = vtk.vtkXMLPolyDataWriter()
    writer.SetFileName(contour_path)
    writer.SetCompressorTypeToZLib()
    writer.SetInputConnection(contour.GetOutputPort())
    writer.Write()
    print 'done.'
Example #4
0
VTK_DATA_ROOT = vtkGetDataRoot()

# This test checks netCDF reader.  It uses the COARDS convention.
renWin = vtk.vtkRenderWindow()
renWin.SetSize(400, 400)
#############################################################################
# Case 1: Image type.
# Open the file.
reader_image = vtk.vtkNetCDFCFReader()
reader_image.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/tos_O1_2001-2002.nc")
reader_image.SetOutputTypeToImage()
# Set the arrays we want to load.
reader_image.UpdateMetaData()
reader_image.SetVariableArrayStatus("tos", 1)
reader_image.SphericalCoordinatesOff()
aa_image = vtk.vtkAssignAttribute()
aa_image.SetInputConnection(reader_image.GetOutputPort())
aa_image.Assign("tos", "SCALARS", "POINT_DATA")
thresh_image = vtk.vtkThreshold()
thresh_image.SetInputConnection(aa_image.GetOutputPort())
thresh_image.SetThresholdFunction(vtk.vtkThreshold.THRESHOLD_LOWER)
thresh_image.SetLowerThreshold(10000.0)
surface_image = vtk.vtkDataSetSurfaceFilter()
surface_image.SetInputConnection(thresh_image.GetOutputPort())
mapper_image = vtk.vtkPolyDataMapper()
mapper_image.SetInputConnection(surface_image.GetOutputPort())
mapper_image.SetScalarRange(270, 310)
actor_image = vtk.vtkActor()
actor_image.SetMapper(mapper_image)
ren_image = vtk.vtkRenderer()
ren_image.AddActor(actor_image)
Example #5
0
    def plot(self, struct):

        # creates self. data1, legend, filename, fieldname, dim, has_field, tracker, revision
        if not self.call_config(struct):
            return

        self.update_field_type('vector', True)
        self.update_legend_data()

        # creates self.src
        if not self.call_src():
            return

        self.ugrid = self.construct_data(self.src)
        self.src_vc = vtk.vtkAssignAttribute()
        #self.src_vc.Assign(aname, 0, pc) # 0 scalar 1 vector ; 0 point 1 cell
        if vtk.vtkVersion.GetVTKMajorVersion() < 6:
            self.src_vc.SetInput(self.ugrid)
        else:
            self.src_vc.SetInputData(self.ugrid)
        res = self.apply_data(self.lastmode)  # necesario, se non da erro vtk

        #        self.wireM = vtk.vtkDataSetMapper()
        #        self.wireM.SetInputConnection(self.src.GetOutputPort())

        #        print 'rango o:', self.src.GetOutput().GetScalarRange() #test
        #        print 'rango d:', self.src.GetOutputAsDataSet().GetScalarRange() #test #so para xml (vtu)
        #        self.wireM.SetScalarRange(self.src.GetOutput().GetScalarRange())

        # reverse rainbow [red->blue] -> [blue->red]
        #        look = self.wireM.GetLookupTable()
        #        self.add_scalarbar_2(look)

        self.add_outline_2(self.src_vc)

        if self.data1.get(
                'fielddomain'
        ) == 'cell':  # vtk does not seem to support cell vectors
            self.cellcenters = vtk.vtkCellCenters()
            self.cellcenters.SetInputConnection(self.src_vc.GetOutputPort())
            self.cellcenters_click = vtk.vtkCellCenters()  # ALPHA-vc
            self.cellcenters_click.SetInputConnection(
                self.src.GetOutputPort())  # ALPHA-vc

        if False:
            # vector
            self.gl = vtk.vtkArrowSource()
        else:
            # simple arrow
            self.gl = vtk.vtkGlyphSource2D()
            self.gl.SetGlyphTypeToArrow()
            self.gl.FilledOff()
            print 'arrow center', self.gl.GetCenter(), '->',
            self.gl.SetCenter(0.5, 0, 0)
            print self.gl.GetCenter()

#Prueba para representar flechas 3d (descomentar)
#        cyl = vtk.vtkCylinderSource()
#        cyl.SetResolution(6)
#        cyl.SetRadius(.05)
#        cyl.SetHeight(1)

#        cylTrans = vtk.vtkTransform()
#        cylTrans.Identity()
#        cylTrans.RotateZ(90)
#        cylTrans.Translate(0,-1,0)

#        cylTransFilter = vtk.vtkTransformPolyDataFilter()
#        cylTransFilter.SetInput(cyl.GetOutput())
#        cylTransFilter.SetTransform(cylTrans)
#        cone = vtk.vtkConeSource()
#        cone.SetResolution(6)
#        cone.SetCenter(2,0,0)
#        cone.SetAngle(15)

#        arrow = vtk.vtkAppendPolyData()
#        arrow.AddInput(cylTransFilter.GetOutput())
#        arrow.AddInput(cone.GetOutput())
#        arrow.Update()
#        self.gl = arrow
#Prueba para representar flechas 3d

        self.lin = vtk.vtkGlyph3D()
        if self.data1.get(
                'fielddomain'
        ) == 'cell':  # vtk does not seem to support cell vectors
            if vtk.vtkVersion.GetVTKMajorVersion() < 6:
                self.lin.SetInput(
                    self.cellcenters.GetOutput())  #amañar cambio new
            else:
                self.lin.SetInputConnection(
                    self.cellcenters.GetOutputPort())  #amañar cambio new
            #lutrange = self.src_vc.GetOutput().GetCellData().GetVectors().GetRange(-1)
        else:
            if vtk.vtkVersion.GetVTKMajorVersion() < 6:
                self.lin.SetInput(self.src_vc.GetOutput())
            else:
                self.lin.SetInputConnection(self.src_vc.GetOutputPort())
            #lutrange = self.src_vc.GetOutput().GetPointData().GetVectors().GetRange(-1)

        lut = vtk.vtkLookupTable()
        lut.SetRampToLinear()
        lut.SetScaleToLinear()
        # When using vector magnitude for coloring
        lut.SetVectorModeToMagnitude()
        lut.Build()
        # When using a vector component for coloring
        #lut.SetVectorModeToComponent()
        #lut.SetVectorComponent(1)

        if self.vectors is not None:
            lutrange = self.vectors.GetRange(-1)
            lut.SetTableRange(lutrange)

        self.lin.SetSourceConnection(self.gl.GetOutputPort())
        self.lin.SetScaleModeToScaleByVector()
        #        self.lin.SetScaleFactor(1.0)
        self.lin.SetColorModeToColorByVector()  # flechas de cores
        self.lin.OrientOn()
        self.lin.Update()

        self.pdM = vtk.vtkPolyDataMapper()
        self.pdM.SetInputConnection(self.lin.GetOutputPort())
        #coloreado de vectores
        #        self.pdM.SetScalarRange(lutrange)
        self.pdM.ScalarVisibilityOn()
        self.pdM.SetLookupTable(lut)
        self.pdM.InterpolateScalarsBeforeMappingOff()
        #        self.pdM.UseLookupTableScalarRangeOn()
        self.pdM.Update()

        self.linA = vtk.vtkActor()
        self.linA.SetMapper(self.pdM)
        #       self.linA.GetProperty().SetColor(Plot.arrow_color)

        #para mostrar surface e wireframe ao mesmo tempo
        self.wireM2 = vtk.vtkDataSetMapper()
        self.wireM2.SetInputConnection(self.src_vc.GetOutputPort())
        self.wireM2.ScalarVisibilityOff()
        self.wireA2 = vtk.vtkActor()
        self.wireA2.SetMapper(self.wireM2)
        self.wireA2.GetProperty().SetRepresentationToWireframe()
        self.wireA2.GetProperty().SetColor(Plot.edges_color)

        #        self.wireA = vtk.vtkActor()
        #        self.wireA.SetMapper(self.wireM)
        #        self.wireA.GetProperty().SetRepresentationToSurface()
        #        self.wireA.GetProperty().SetColor(Plot.edges_color)

        #        self.rens[0].AddActor(self.wireA)
        self.add_opacity_2([self.linA,
                            self.wireA2])  # Opacity: 100%/75%/50%/25%/0%
        self.rens[0].AddActor(self.wireA2)
        self.rens[0].AddActor(self.linA)

        if interactive:
            self.set_iren()
            if self.data1.get('fielddomain') == 'cell':
                self.clicker.set_point_cell('point')  # así ok
                self.clicker.set_objects(self.cellcenters_click, self.rens[0],
                                         self.iren, self.widget)  # ALPHA-vc
            else:
                self.clicker.set_point_cell(self.data1.get('fielddomain'))
                self.clicker.set_objects(self.src, self.rens[0], self.iren,
                                         self.widget)  # ALPHA-vc
            self.clicker.set_props([self.wireA2])
            self.clicker.setup()

        newlast = self.read_params(struct)  #####
        if newlast[0] is not None:
            self.lastscale = newlast[0]
        if newlast[1] is not None:
            self.lastmode = newlast[1]
        self.apply_params()

        for ren in self.rens:  # WORKAROUND (aparecia non centrada) // + outline
            ren.ResetCamera()

        if self.vectors is not None:
            self.scalarrange.local_set(lutrange)
            self.add_scalarbar_1()
            self.add_scalarbar_2(lut)

        self.done = True
Example #6
0
    def testFinancialField(self):

        """
            Demonstrate the use and manipulation of fields and use of
            vtkProgrammableDataObjectSource. This creates fields the hard way
            (as compared to reading a vtk field file), but shows you how to
            interface to your own raw data.

            The image should be the same as financialField.tcl
        """

        xAxis = "INTEREST_RATE"
        yAxis = "MONTHLY_PAYMENT"
        zAxis = "MONTHLY_INCOME"
        scalar = "TIME_LATE"

        # Parse an ascii file and manually create a field. Then construct a
        # dataset from the field.
        dos = vtk.vtkProgrammableDataObjectSource()

        def parseFile():
            f = open(VTK_DATA_ROOT + "/Data/financial.txt", "r")

            line = f.readline().split()
            # From the size calculate the number of lines.
            numPts = int(line[1])
            numLines = (numPts - 1) / 8 + 1

            # create the data object
            field = vtk.vtkFieldData()
            field.AllocateArrays(4)

            # read TIME_LATE - dependent variable
            while True:
                line = f.readline().split()
                if len(line) > 0:
                    break;
            timeLate = vtk.vtkFloatArray()
            timeLate.SetName(line[0])
            for i in range(0, numLines):
                line = f.readline().split()
                for j in line:
                    timeLate.InsertNextValue(float(j))
            field.AddArray(timeLate)

            # MONTHLY_PAYMENT - independent variable
            while True:
                line = f.readline().split()
                if len(line) > 0:
                    break;
            monthlyPayment = vtk.vtkFloatArray()
            monthlyPayment.SetName(line[0])
            for i in range(0, numLines):
                line = f.readline().split()
                for j in line:
                    monthlyPayment.InsertNextValue(float(j))
            field.AddArray(monthlyPayment)

            # UNPAID_PRINCIPLE - skip
            while True:
                line = f.readline().split()
                if len(line) > 0:
                    break;
            for i in range(0, numLines):
                line = f.readline()

            # LOAN_AMOUNT - skip
            while True:
                line = f.readline().split()
                if len(line) > 0:
                    break;
            for i in range(0, numLines):
                line = f.readline()

            # INTEREST_RATE - independent variable
            while True:
                line = f.readline().split()
                if len(line) > 0:
                    break;
            interestRate = vtk.vtkFloatArray()
            interestRate.SetName(line[0])
            for i in range(0, numLines):
                line = f.readline().split()
                for j in line:
                    interestRate.InsertNextValue(float(j))
            field.AddArray(interestRate)

            # MONTHLY_INCOME - independent variable
            while True:
                line = f.readline().split()
                if len(line) > 0:
                    break;
            monthlyIncome = vtk.vtkFloatArray()
            monthlyIncome.SetName(line[0])
            for i in range(0, numLines):
                line = f.readline().split()
                for j in line:
                    monthlyIncome.InsertNextValue(float(j))
            field.AddArray(monthlyIncome)

            dos.GetOutput().SetFieldData(field)

        dos.SetExecuteMethod(parseFile)


        # Create the dataset
        do2ds = vtk.vtkDataObjectToDataSetFilter()
        do2ds.SetInputConnection(dos.GetOutputPort())
        do2ds.SetDataSetTypeToPolyData()
        #format: component#, arrayname, arraycomp, minArrayId, maxArrayId, normalize
        do2ds.DefaultNormalizeOn()
        do2ds.SetPointComponent(0, xAxis, 0)
        do2ds.SetPointComponent(1, yAxis, 0)
        do2ds.SetPointComponent(2, zAxis, 0)
        do2ds.Update()

        rf = vtk.vtkRearrangeFields()
        rf.SetInputConnection(do2ds.GetOutputPort())
        rf.AddOperation("MOVE", scalar, "DATA_OBJECT", "POINT_DATA")
        rf.RemoveOperation("MOVE", scalar, "DATA_OBJECT", "POINT_DATA")
        rf.AddOperation("MOVE", scalar, "DATA_OBJECT", "POINT_DATA")
        rf.RemoveAllOperations()
        rf.AddOperation("MOVE", scalar, "DATA_OBJECT", "POINT_DATA")
        rf.Update()
        max = rf.GetOutput().GetPointData().GetArray(scalar).GetRange(0)[1]


        calc = vtk.vtkArrayCalculator()
        calc.SetInputConnection(rf.GetOutputPort())
        calc.SetAttributeModeToUsePointData()
        calc.SetFunction("s / %f" % max)
        calc.AddScalarVariable("s", scalar, 0)
        calc.SetResultArrayName("resArray")

        aa = vtk.vtkAssignAttribute()
        aa.SetInputConnection(calc.GetOutputPort())
        aa.Assign("resArray", "SCALARS", "POINT_DATA")
        aa.Update()

        rf2 = vtk.vtkRearrangeFields()
        rf2.SetInputConnection(aa.GetOutputPort())
        rf2.AddOperation("COPY", "SCALARS", "POINT_DATA", "DATA_OBJECT")

        # construct pipeline for original population
        popSplatter = vtk.vtkGaussianSplatter()
        popSplatter.SetInputConnection(rf2.GetOutputPort())
        popSplatter.SetSampleDimensions(50, 50, 50)
        popSplatter.SetRadius(0.05)
        popSplatter.ScalarWarpingOff()
        popSurface = vtk.vtkContourFilter()
        popSurface.SetInputConnection(popSplatter.GetOutputPort())
        popSurface.SetValue(0, 0.01)
        popMapper = vtk.vtkPolyDataMapper()
        popMapper.SetInputConnection(popSurface.GetOutputPort())
        popMapper.ScalarVisibilityOff()
        popMapper.ImmediateModeRenderingOn()
        popActor = vtk.vtkActor()
        popActor.SetMapper(popMapper)
        popActor.GetProperty().SetOpacity(0.3)
        popActor.GetProperty().SetColor(.9, .9, .9)

        # construct pipeline for delinquent population
        lateSplatter = vtk.vtkGaussianSplatter()
        lateSplatter.SetInputConnection(aa.GetOutputPort())
        lateSplatter.SetSampleDimensions(50, 50, 50)
        lateSplatter.SetRadius(0.05)
        lateSplatter.SetScaleFactor(0.05)
        lateSurface = vtk.vtkContourFilter()
        lateSurface.SetInputConnection(lateSplatter.GetOutputPort())
        lateSurface.SetValue(0, 0.01)
        lateMapper = vtk.vtkPolyDataMapper()
        lateMapper.SetInputConnection(lateSurface.GetOutputPort())
        lateMapper.ScalarVisibilityOff()
        lateActor = vtk.vtkActor()
        lateActor.SetMapper(lateMapper)
        lateActor.GetProperty().SetColor(1.0, 0.0, 0.0)

        # create axes
        popSplatter.Update()
        bounds = popSplatter.GetOutput().GetBounds()
        axes = vtk.vtkAxes()
        axes.SetOrigin(bounds[0], bounds[2], bounds[4])
        axes.SetScaleFactor(popSplatter.GetOutput().GetLength() / 5.0)
        axesTubes = vtk.vtkTubeFilter()
        axesTubes.SetInputConnection(axes.GetOutputPort())
        axesTubes.SetRadius(axes.GetScaleFactor() / 25.0)
        axesTubes.SetNumberOfSides(6)
        axesMapper = vtk.vtkPolyDataMapper()
        axesMapper.SetInputConnection(axesTubes.GetOutputPort())
        axesActor = vtk.vtkActor()
        axesActor.SetMapper(axesMapper)

        # label the axes
        XText = vtk.vtkVectorText()
        XText.SetText(xAxis)
        XTextMapper = vtk.vtkPolyDataMapper()
        XTextMapper.SetInputConnection(XText.GetOutputPort())
        XActor = vtk.vtkFollower()
        XActor.SetMapper(XTextMapper)
        XActor.SetScale(0.02, .02, .02)
        XActor.SetPosition(0.35, -0.05, -0.05)
        XActor.GetProperty().SetColor(0, 0, 0)

        YText = vtk.vtkVectorText()
        YText.SetText(yAxis)
        YTextMapper = vtk.vtkPolyDataMapper()
        YTextMapper.SetInputConnection(YText.GetOutputPort())
        YActor = vtk.vtkFollower()
        YActor.SetMapper(YTextMapper)
        YActor.SetScale(0.02, .02, .02)
        YActor.SetPosition(-0.05, 0.35, -0.05)
        YActor.GetProperty().SetColor(0, 0, 0)

        ZText = vtk.vtkVectorText()
        ZText.SetText(zAxis)
        ZTextMapper = vtk.vtkPolyDataMapper()
        ZTextMapper.SetInputConnection(ZText.GetOutputPort())
        ZActor = vtk.vtkFollower()
        ZActor.SetMapper(ZTextMapper)
        ZActor.SetScale(0.02, .02, .02)
        ZActor.SetPosition(-0.05, -0.05, 0.35)
        ZActor.GetProperty().SetColor(0, 0, 0)

        # Graphics stuff
        #
        ren = vtk.vtkRenderer()
        renWin = vtk.vtkRenderWindow()
        renWin.AddRenderer(ren)
        renWin.SetWindowName("vtk(-, Field.Data")
        renWin.SetSize(300, 300)

        # Add the actors to the renderer, set the background and size
        #
        ren.AddActor(axesActor)
        ren.AddActor(lateActor)
        ren.AddActor(XActor)
        ren.AddActor(YActor)
        ren.AddActor(ZActor)
        ren.AddActor(popActor) #it's last because its translucent)
        ren.SetBackground(1, 1, 1)

        camera = vtk.vtkCamera()
        camera.SetClippingRange(.274, 13.72)
        camera.SetFocalPoint(0.433816, 0.333131, 0.449)
        camera.SetPosition(-1.96987, 1.15145, 1.49053)
        camera.SetViewUp(0.378927, 0.911821, 0.158107)
        ren.SetActiveCamera(camera)
        XActor.SetCamera(camera)
        YActor.SetCamera(camera)
        ZActor.SetCamera(camera)

        # render and interact with data

        iRen = vtk.vtkRenderWindowInteractor()
        iRen.SetRenderWindow(renWin);
        renWin.Render()

        img_file = "financialField3.png"
        vtk.test.Testing.compareImage(iRen.GetRenderWindow(), vtk.test.Testing.getAbsImagePath(img_file), threshold=25)
        vtk.test.Testing.interact()
Example #7
0
    i += 1

Stream0 = vtk.vtkStreamTracer()
Stream0.SetInputData(mbds)
Stream0.SetSourceConnection(LineSourceWidget0.GetOutputPort())
Stream0.SetIntegrationStepUnit(2)
Stream0.SetMaximumPropagation(20)
Stream0.SetInitialIntegrationStep(0.5)
Stream0.SetIntegrationDirection(0)
Stream0.SetIntegratorType(0)
Stream0.SetMaximumNumberOfSteps(2000)
Stream0.SetTerminalSpeed(1e-12)

#del mbds

aa = vtk.vtkAssignAttribute()
aa.SetInputConnection(Stream0.GetOutputPort())
aa.Assign("Normals", "NORMALS", "POINT_DATA")

Ribbon0 = vtk.vtkRibbonFilter()
Ribbon0.SetInputConnection(aa.GetOutputPort())
Ribbon0.SetWidth(0.1)
Ribbon0.SetAngle(0)
Ribbon0.SetDefaultNormal(0, 0, 1)
Ribbon0.SetVaryWidth(0)

LookupTable1 = vtk.vtkLookupTable()
LookupTable1.SetNumberOfTableValues(256)
LookupTable1.SetHueRange(0, 0.66667)
LookupTable1.SetSaturationRange(1, 1)
LookupTable1.SetValueRange(1, 1)
# Import the VTK library bindings for Python

import vtk

# Create a reader to provide a source for data.
# This filter reads image datasets using VTK's
# XML-based file format.  The file contains
# information about the data format, data
# arrays and extent, so the only parameter that
# the filter needs is the file name.

data = vtk.vtkXMLImageDataReader()
data.SetFileName("/Users/y1275963/Documents/homework/multifield.0060.vti")

data_g = vtk.vtkAssignAttribute()
data_g.SetInputConnection(data.GetOutputPort())
data_g.Assign('G', 'SCALARS', 'POINT_DATA')

outline = vtk.vtkOutlineFilter()
outline.SetInputConnection(data_g.GetOutputPort())

outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())

outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
outlineActor.GetProperty().SetColor(0, 0, 0)

# Create a filter to extract an isosurface from
# the dataset.  Connect the input of this
Example #9
0
pl3d = vtk.vtkMultiBlockPLOT3DReader()
pl3d.SetXYZFileName("" + str(VTK_DATA_ROOT) + "/Data/combxyz.bin")
pl3d.SetQFileName("" + str(VTK_DATA_ROOT) + "/Data/combq.bin")
pl3d.SetScalarFunctionNumber(100)
pl3d.SetVectorFunctionNumber(202)
pl3d.Update()
output = pl3d.GetOutput().GetBlock(0)

sf = vtk.vtkSplitField()
sf.SetInputData(output)
sf.SetInputField("VECTORS", "POINT_DATA")
sf.Split(0, "vx")
sf.Split(1, "vy")
sf.Split(2, "vz")
#sf.Print()
aax = vtk.vtkAssignAttribute()
aax.SetInputConnection(sf.GetOutputPort())
aax.Assign("vx", "SCALARS", "POINT_DATA")
isoVx = vtk.vtkContourFilter()
isoVx.SetInputConnection(aax.GetOutputPort())
isoVx.SetValue(0, .38)
normalsVx = vtk.vtkPolyDataNormals()
normalsVx.SetInputConnection(isoVx.GetOutputPort())
normalsVx.SetFeatureAngle(45)
isoVxMapper = vtk.vtkPolyDataMapper()
isoVxMapper.SetInputConnection(normalsVx.GetOutputPort())
isoVxMapper.ScalarVisibilityOff()
isoVxMapper.ImmediateModeRenderingOn()
isoVxActor = vtk.vtkActor()
isoVxActor.SetMapper(isoVxMapper)
isoVxActor.GetProperty().SetColor(1, 0.7, 0.6)
Example #10
0
def doit(goodArguments):
    print("loading file: %s" % goodArguments.fileName)
    print("at group: %s" % goodArguments.grpName)

    f = h5py.File(goodArguments.fileName, 'r')
    g = f[goodArguments.grpName]
    pts = vtk.vtkPoints()

    pts.InsertNextPoint(0, 0, 0)
    pts.InsertNextPoint(20, 0, 0)
    pts.InsertNextPoint(60, 0, 0)

    radii = vtk.vtkFloatArray()
    radii.SetName("Radius")

    radii.InsertNextTuple([3.0])
    radii.InsertNextTuple([3.0])
    radii.InsertNextTuple([3.0])

    polyData = vtk.vtkPolyData()
    polyData.SetPoints(pts)
    polyData.GetPointData().AddArray(radii)

    #reader = vtkPolyDataReader()
    #reader.SetFileName(fn)
    #reader.Update();
    #dataset = reader.GetOutput()
    #del reader
    #dataset.ComputeBounds()
    #vesselbounds = vtkGetDataSetBounds(dataset)

    aa = vtk.vtkAssignAttribute()
    aa.SetInputData(polyData)
    aa.Assign('Radius', 'SCALARS', 'POINT_DATA')

    #assign_radius = vtk.assignedAttribute(polyData, 'Radius', 'SCALARS', 'POINT_DATA')

    tube = vtk.vtkTubeFilter()
    tube.SetVaryRadiusToVaryRadiusByAbsoluteScalar()
    tube.SetNumberOfSides(8)
    tube.CappingOff()
    tube.SetGenerateTCoordsToOff()
    tube.SetInputConnection(aa.GetOutputPort())

    #dataspec = ('pressure', 'SCALARS', 'POINT_DATA')

    #assign_final_attr = assignedAttribute(tube.GetOutputPort(), *dataspec)

    #bounds = getDataSetAttributeBounds(dataset, *dataspec)
    #bounds = dataset.GetPointData().GetArray(0).GetValueRange()
    mapper = vtk.vtkPolyDataMapper()
    #mapper.SetScalarRange(*bounds)
    mapper.CreateDefaultLookupTable()

    #mapper.SetInputConnection(assign_final_attr.GetOutputPort())
    mapper.SetInputConnection(tube.GetOutputPort())
    mapper.ImmediateModeRenderingOn()

    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    ren = vtk.vtkRenderer()
    ren.AddActor(actor)
    ren.ResetCamera()
    c = ren.GetActiveCamera()
    c.Dolly(1.4)
    c.SetClippingRange(c.GetPosition()[2] * 0.9, c.GetPosition()[2] * 1.1)

    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren)
    renWin.SetSize(1200, 1200)

    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)

    iren.Start()
def contour_G(filename):
    # Creating contour for G fileld
    
    data = vtk.vtkXMLImageDataReader()
    data.SetFileName(filename)#"/Users/y1275963/Documents/homework/multifield.0060.vti")
    

    data_g = vtk.vtkAssignAttribute()
    data_g.SetInputConnection(data.GetOutputPort())
    data_g.Assign('G','SCALARS','POINT_DATA')
    

    outline = vtk.vtkOutlineFilter()
    outline.SetInputConnection(data_g.GetOutputPort())
    
    outlineMapper = vtk.vtkPolyDataMapper()
    outlineMapper.SetInputConnection(outline.GetOutputPort())
    
    outlineActor = vtk.vtkActor()
    outlineActor.SetMapper(outlineMapper)
    outlineActor.GetProperty().SetColor(0,0,1)
    
    
    # Create a filter to extract an isosurface from
    # the dataset.  Connect the input of this
    # filter to the output of the reader.  Set the
    # value for the (one) isosurface that we want
    # to extract, and tell the filter to compute
    # normal vectors for each triangle on the
    # output isosurface.
    
    iso = vtk.vtkContourFilter()
    iso.SetInputConnection(data_g.GetOutputPort())
    iso.ComputeNormalsOn()
    iso.SetNumberOfContours(1)
    iso.SetValue(0, 2500) #Chnge here to change the isovalue
    
    
    # Create a mapper to traverse the polydata and
    # generate graphics commands for drawing the
    # polygons onto the output device.
    
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(iso.GetOutputPort())
    mapper.ScalarVisibilityOff()
    
    # Output primitives (i.e. the triangles making
    # up the isosurface) are managed as an actor;
    # we specify that all outputs are coloured
    # red.
    
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    actor.GetProperty().SetColor(1, 0, 0)
    actor.GetProperty().SetOpacity(0.5)
    
    # Create a renderer which will output the
    # graphics commands onto a drawing surface within
    # a window.  By default the renderer will fill
    # all of the window.  We set the background
    # colour of the window to white.
    return (outlineActor,actor)
Example #12
0
    def recalculateTime(self, time):

        if len(self.times) <= 0:
            return 'TimeManager: Error: .pvd file with 0 entries'

        if len(self.times) == 1:
            pi = pf = 0
        else:
            # posicion mayor tal que time >= t
            pi = 0
            while pi < len(self.times) and time >= self.times[pi].get('time'):
                pi += 1
            if pi > 0:
                pi -= 1

            # posicion menor tal que time <= t
            pf = 0
            while pf < len(self.times) and time > self.times[pf].get('time'):
                pf += 1
            if pf >= len(self.times):
                pf -= 1

        print 'pi, pf', pi, pf

        if pi == pf:
            return self.recalculate(pi)

        # para que non interpole tempo/frecuencia
        if self.interpolation is not True:
            return self.recalculate(pi)  # redondea cara á esquerda

        ti = self.times[pi].get('time')
        tf = self.times[pf].get('time')

        print 'ti, tf', ti, tf

        if ti == tf:
            return self.recalculate(pi)

        # [0,1]
        factor = (time - ti) / (tf - ti)

        print 'factor', factor

        # tambien posible reutilizar ficheros de mode == 1

        mnames = []

        # si ha cambiado el primer fichero ...
        if not (self.mode == 2 and self.index1 == pi):
            print '#1 si ha cambiado el primer fichero ..'
            tracker = self.tracker.get_tracker(pi)
            if isinstance(tracker, basestring):
                return tracker
            else:
                src = tracker.get_src(mnames)
                if isinstance(src, basestring):
                    return src
            self.tracker1 = tracker
            self.src1 = src

        # si ha cambiado el segundo fichero ...
        if not (self.mode == 2 and self.index2 == pf):
            print '#2 si ha cambiado el segundo fichero ...'
            tracker = self.tracker.get_tracker(pf)
            if isinstance(tracker, basestring):
                return tracker
            else:
                src = tracker.get_src(mnames)
                if isinstance(src, basestring):
                    return src
            self.tracker2 = tracker
            self.src2 = src

        # si ha cambiado algun fichero
        if not (self.mode == 2 and self.index1 == pi and self.index2 == pf):
            print '#3 si ha cambiado algun fichero'

            self.src = vtk.vtkInterpolateDataSetAttributes()

            #self.src.AddInput(self.src1.GetOutput())
            #self.src.AddInput(self.src2.GetOutput())

            #workaround: porque solo interpola atributos activos
            if self.attr_fn is not None and self.attr_sv is not None and self.attr_pc is not None:
                a1 = vtk.vtkAssignAttribute()
                a2 = vtk.vtkAssignAttribute()
                a1.Assign(self.attr_fn, self.attr_sv, self.attr_pc)
                a2.Assign(self.attr_fn, self.attr_sv, self.attr_pc)
                a1.SetInputConnection(self.src1.GetOutputPort())
                a2.SetInputConnection(self.src2.GetOutputPort())
                self.src.AddInputConnection(a1.GetOutputPort())
                self.src.AddInputConnection(a2.GetOutputPort())
            else:
                self.src.AddInputConnection(self.src1.GetOutputPort())
                self.src.AddInputConnection(self.src2.GetOutputPort())

            self.changes['new'] = True
            self.changes['changed'] = True

        # si aprendo como reutilizar self.src, [SetInput], no construye un self.src nuevo siempre

        self.src.SetT(factor)
        self.src.Update()

        self.mesh_names = mnames
        self.mode = 2
        self.time = time
        self.indexA = None
        self.index1 = pi
        self.index2 = pf
        self.changes['changed'] = True

        return True
Example #13
0
def getFreeSurfaceActor(vtk_r, scale=[1, 1, 1], fsRange=None):

    aa = vtk.vtkAssignAttribute()
    aa.SetInputConnection(vtk_r.GetOutputPort())
    aa.Assign('alpha.water', "SCALARS", "POINT_DATA")

    isoContour = vtk.vtkContourFilter()
    isoContour.SetInputConnection(aa.GetOutputPort())
    isoContour.SetValue(0, 0.5)
    # isoContour.SetGenerateTriangles(0)
    isoContour.SetNumberOfContours(1)

    isoContourDataFilter = vtk.vtkCompositeDataGeometryFilter()
    isoContourDataFilter.SetInputConnection(isoContour.GetOutputPort())

    transform = vtk.vtkTransform()
    transform.Scale(*scale)
    tf = vtk.vtkTransformPolyDataFilter()
    tf.SetInputConnection(isoContourDataFilter.GetOutputPort())
    tf.SetTransform(transform)

    # Use an ArrayCalculator to get the iso-contour elevation
    calc = vtk.vtkArrayCalculator()
    calc.SetInputConnection(tf.GetOutputPort())
    calc.SetAttributeModeToUsePointData()
    calc.AddCoordinateScalarVariable("coordsZ", 2)
    calc.SetFunction("coordsZ")
    calc.SetResultArrayName("coordsZ")

    #--- Map the data
    isoContourMapper = vtk.vtkDataSetMapper()
    isoContourMapper.SetInputConnection(calc.GetOutputPort())

    #---Select node property to display
    lutBlueRed = vtk.vtkLookupTable()
    lutBlueRed.SetHueRange(2. / 3., 0.)
    lutBlueRed.SetVectorModeToMagnitude()
    lutBlueRed.Build()

    scalarBar = vtk.vtkScalarBarActor()
    scalarBar.SetLookupTable(lutBlueRed)
    scalarBar.SetWidth(0.05)
    scalarBar.SetHeight(0.25)
    scalarBar.SetTitle("Z(m)")
    scalarBar.GetTitleTextProperty().SetColor(0., 0., 0.)
    scalarBar.GetLabelTextProperty().SetColor(0., 0., 0.)

    isoContourMapper.SelectColorArray("coordsZ")
    # isoContourMapper.SetScalarModeToUsePointData()
    isoContourMapper.SetScalarModeToUsePointFieldData()
    isoContourMapper.SetLookupTable(lutBlueRed)
    if fsRange is not None:
        isoContourMapper.SetScalarRange(*fsRange)
    isoContourMapper.SetUseLookupTableScalarRange(0)

    #---Add actor
    fsActor = vtk.vtkActor()
    fsActor.GetProperty().SetEdgeVisibility(0)
    fsActor.SetMapper(isoContourMapper)
    fsActor.GetProperty().SetOpacity(0.7)
    return fsActor, scalarBar
Example #14
0
# -*- coding: utf-8 -*-
"""
    Created on Fri Mar  6 10:26:23 2015
    
    @author: y1275963
    """
#!/usr/bin/env vtkpython

import vtk

data = vtk.vtkXMLImageDataReader()
data.SetFileName("/Users/y1275963/Documents/homework/multifield.0135.vti")


data_g = vtk.vtkAssignAttribute()
data_g.SetInputConnection(data.GetOutputPort())
data_g.Assign('G','SCALARS','POINT_DATA')

opacityTransferFunction = vtk.vtkPiecewiseFunction()
opacityTransferFunction.AddPoint(10.0, 0.001)
opacityTransferFunction.AddPoint(1900.0,0.001 )
opacityTransferFunction.AddPoint(2000.0, 1.0)
opacityTransferFunction.AddPoint(2500.0, 1.0)
opacityTransferFunction.AddPoint(2600.0, 0.001)
opacityTransferFunction.AddPoint(22000.0, 0.001)
opacityTransferFunction.AddPoint(23000.0, 1.0)
opacityTransferFunction.AddPoint(27000.0, 1.0)

colorTransferFunction = vtk.vtkColorTransferFunction()
colorTransferFunction.AddHSVPoint(10.0, 0.1, 0.0, 0.0)
colorTransferFunction.AddHSVPoint(1900.0, 0.1, 0.0, 0.0)
Example #15
0
    def plot(self, struct):
        # Crea self. data1, legend, filename, fieldname, dim, has_field, tracker, revision
        if not self.call_config(struct):
            return

        # Actualiza campos
        self.update_field_type('vector', True)
        self.update_legend_data()

        # Crea self.src
        if not self.call_src():
            return

        # Obtenemos los vectores
        self.ugrid = self.construct_data(self.src)
        self.src_vc = vtk.vtkAssignAttribute()
        if vtk.vtkVersion.GetVTKMajorVersion() < 6:
            self.src_vc.SetInput(self.ugrid)
        else:
            self.src_vc.SetInputData(self.ugrid)

        # Segunda parte para incluir el visor
        # Pinta los elementos

        # Obtiene los centros de las celdas si se usa dicho tipo de elemento
        if self.data1.get(
                'fielddomain'
        ) == 'cell':  # vtk does not seem to support cell vectors
            self.cellcenters = vtk.vtkCellCenters()
            self.cellcenters.SetInputConnection(self.src_vc.GetOutputPort())
            self.cellcenters_click = vtk.vtkCellCenters()  # ALPHA-vc
            self.cellcenters_click.SetInputConnection(
                self.src.GetOutputPort())  # ALPHA-vc

        self.ini_params()
        #I##############################################################################
        ####### Inicializamos el dibujante #############################################
        # Create source for streamtubes
        self.seeds = vtk.vtkPointSource()
        self.seeds.SetRadius(
            self.lastradio)  # zona que abarca la salida de puntos
        self.seeds.SetCenter(self.lastcenter)
        print '====>plot ->> self.seeds.SetCenter', self.lastcenter[
            0], ',', self.lastcenter[1], ',', self.lastcenter[2]
        self.seeds.SetNumberOfPoints(self.lastnlin)

        self.lin = vtk.vtkStreamTracer()
        self.lin.SetInputConnection(self.src.GetOutputPort())
        if vtk.vtkVersion.GetVTKMajorVersion() < 6:
            self.lin.SetSource(self.seeds.GetOutput())
        else:
            self.lin.SetSourceConnection(self.seeds.GetOutputPort())

####### Configuramos el dibujante ##############################################
        self.lin.SetStartPosition(self.lastcenter)
        print '====>plot ->> self.lin.SetStartPosition', self.lastcenter[
            0], ',', self.lastcenter[1], ',', self.lastcenter[2]
        self.lin.SetMaximumPropagation(500)
        self.lin.SetInitialIntegrationStep(0.5)
        #self.lin.SetIntegrationStepUnit(2) # 2 = CELL_LENGTH_UNIT
        self.lin.SetIntegrationDirectionToBoth()

        integ = vtk.vtkRungeKutta4()
        self.lin.SetIntegrator(integ)

        ####### Configuramos el filtro #################################################
        self.streamTube = vtk.vtkTubeFilter()
        self.streamTube.SetInputConnection(self.lin.GetOutputPort())
        self.streamTube.SetInputArrayToProcess(1, 0, 0, 0, 1)
        self.streamTube.SetRadius(self.lastancho)
        self.streamTube.SetNumberOfSides(12)
        self.streamTube.SetVaryRadiusToVaryRadiusByVector()

        #F###### Configuramos la tabla de colores ######################################
        # Iniicializamos la tabla de asignacion de colores
        self.lut = vtk.vtkLookupTable()
        self.lut.SetRampToLinear()
        self.lut.SetScaleToLinear()
        self.lut.SetVectorModeToMagnitude(
        )  # When using vector magnitude for coloring
        self.lut.Build()

        if self.vectors is not None:
            self.lutrange = self.vectors.GetRange(-1)
            self.lut.SetTableRange(self.lutrange)

####### Configuramos el mapper #################################################
        self.pdM = vtk.vtkPolyDataMapper()
        self.pdM.SetInputConnection(self.streamTube.GetOutputPort())
        #Definicion del campo y el rango para colorear
        if self.vectors is not None:
            self.pdM.SelectColorArray(self.vectors.GetName())
            self.pdM.SetScalarRange(self.lutrange)
            if self.data1.get('fielddomain') == 'cell':
                self.pdM.SetScalarModeToUseCellFieldData()
            else:
                self.pdM.SetScalarModeToUsePointFieldData()
            self.pdM.SetColorModeToMapScalars()
            self.pdM.InterpolateScalarsBeforeMappingOff()
            self.pdM.ScalarVisibilityOn()
        self.pdM.SetLookupTable(self.lut)
        self.pdM.UseLookupTableScalarRangeOn()
        self.pdM.Update()

        ####### Configuramos el actor ##################################################
        self.linA = vtk.vtkActor()
        self.linA.SetMapper(self.pdM)
        self.linA.VisibilityOn()
        self.linA.GetProperty().SetAmbient(1.0)
        self.linA.GetProperty().SetDiffuse(0.0)
        self.linA.GetProperty().SetSpecular(0.0)

        #F##############################################################################

        #para mostrar surface e wireframe ao mesmo tempo
        self.wireM2 = vtk.vtkDataSetMapper()
        self.wireM2.SetInputConnection(self.src_vc.GetOutputPort())
        self.wireM2.ScalarVisibilityOff()
        self.wireA2 = vtk.vtkActor()
        self.wireA2.SetMapper(self.wireM2)
        self.wireA2.GetProperty().SetRepresentationToWireframe()
        self.wireA2.GetProperty().SetColor(Plot.edges_color)
        self.add_opacity_2([self.linA,
                            self.wireA2])  # Opacity: 100%/75%/50%/25%/0%
        # Incluimos los actores en el renderer
        self.rens[0].AddActor(self.wireA2)
        self.rens[0].AddActor(self.linA)

        # Si estamos en modo interactivo configuramos el clicker
        if interactive:
            self.set_iren()  # Configura el interactor
            if self.data1.get('fielddomain') == 'cell':
                self.clicker.set_point_cell('point')  # así ok
                self.clicker.set_objects(self.cellcenters_click, self.rens[0],
                                         self.iren, self.widget)  # ALPHA-vc
            else:
                self.clicker.set_point_cell(self.data1.get('fielddomain'))
                self.clicker.set_objects(self.src, self.rens[0], self.iren,
                                         self.widget)  # ALPHA-vc
            self.clicker.set_props([self.wireA2])
            self.clicker.setup()

        # Obtenemos los datos si los hay en el xml
        newlast = self.read_params(struct)
        changed = self.test_params(newlast)
        if changed:
            self.apply_params()

        # Reseteamos las camaras de todos los renderers
        for ren in self.rens:  # WORKAROUND (aparecia non centrada) // + outline
            ren.ResetCamera()

        # Incluye la barra de escala si tenemos vectores
        if self.vectors is not None:
            self.scalarrange.local_set(self.lutrange)
            self.add_scalarbar_1()
            self.add_scalarbar_2(self.lut)

        self.add_outline_2(self.src_vc)

        self.done = True
Example #16
0
# Use fixed radius
dens0 = vtk.vtkPointDensityFilter()
dens0.SetInputConnection(clipper.GetOutputPort())
dens0.SetSampleDimensions(res,res,res)
dens0.SetDensityEstimateToFixedRadius()
dens0.SetRadius(0.05)
#dens0.SetDensityEstimateToRelativeRadius()
dens0.SetRelativeRadius(2.5)
#dens0.SetDensityFormToVolumeNormalized()
dens0.SetDensityFormToNumberOfPoints()
dens0.ComputeGradientOn()
dens0.Update()
vrange = dens0.GetOutput().GetPointData().GetArray("Gradient Magnitude").GetRange()

# Show the gradient magnitude
assign0 = vtk.vtkAssignAttribute()
assign0.SetInputConnection(dens0.GetOutputPort())
assign0.Assign("Gradient Magnitude", "SCALARS", "POINT_DATA")

map0 = vtk.vtkImageSliceMapper()
map0.BorderOn()
map0.SliceAtFocalPointOn()
map0.SliceFacesCameraOn()
map0.SetInputConnection(assign0.GetOutputPort())

slice0 = vtk.vtkImageSlice()
slice0.SetMapper(map0)
slice0.GetProperty().SetColorWindow(vrange[1]-vrange[0])
slice0.GetProperty().SetColorLevel(0.5*(vrange[0]+vrange[1]))

# Show the region labels
Example #17
0
def main(filename):
    print("Loading", filename)
    reader = vtk.vtkUnstructuredGridReader()
    reader.SetFileName(filename)

    edges = vtk.vtkExtractEdges()
    edges.SetInputConnection(reader.GetOutputPort())

    tubes = vtk.vtkTubeFilter()
    tubes.SetInputConnection(edges.GetOutputPort())
    tubes.SetRadius(0.0625)
    tubes.SetVaryRadiusToVaryRadiusOff()
    tubes.SetNumberOfSides(32)

    tubesMapper = vtk.vtkPolyDataMapper()
    tubesMapper.SetInputConnection(tubes.GetOutputPort())
    tubesMapper.SetScalarRange(0.0, 26.0)

    tubesActor = vtk.vtkActor()
    tubesActor.SetMapper(tubesMapper)

    gradients = vtk.vtkGradientFilter()
    gradients.SetInputConnection(reader.GetOutputPort())

    vectors = vtk.vtkAssignAttribute()
    vectors.SetInputConnection(gradients.GetOutputPort())
    vectors.Assign("Gradients", vtk.vtkDataSetAttributes.VECTORS, \
        vtk.vtkAssignAttribute.POINT_DATA)

    arrow = vtk.vtkArrowSource()

    glyphs = vtk.vtkGlyph3D()
    glyphs.SetInputConnection(0, vectors.GetOutputPort())
    glyphs.SetInputConnection(1, arrow.GetOutputPort())
    glyphs.ScalingOn()
    glyphs.SetScaleModeToScaleByVector()
    glyphs.SetScaleFactor(0.25)
    glyphs.OrientOn()
    glyphs.ClampingOff()
    glyphs.SetVectorModeToUseVector()
    glyphs.SetIndexModeToOff()

    glyphMapper = vtk.vtkPolyDataMapper()
    glyphMapper.SetInputConnection(glyphs.GetOutputPort())
    glyphMapper.ScalarVisibilityOff()

    glyphActor = vtk.vtkActor()
    glyphActor.SetMapper(glyphMapper)

    renderer = vtk.vtkRenderer()
    renderer.AddActor(tubesActor)
    renderer.AddActor(glyphActor)
    renderer.SetBackground(0.328125, 0.347656, 0.425781)

    renwin = vtk.vtkRenderWindow()
    renwin.AddRenderer(renderer)
    renwin.SetSize(350, 500)

    renderer.ResetCamera()
    camera = renderer.GetActiveCamera()
    camera.Elevation(-80.0)
    camera.OrthogonalizeViewUp()
    camera.Azimuth(135.0)

    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renwin)
    iren.Initialize()
    iren.Start()
    return 1
VTK_DATA_ROOT = vtkGetDataRoot()

# This test checks netCDF CF reader for reading unstructured (p-sided) cells.
renWin = vtk.vtkRenderWindow()
renWin.SetSize(400,200)
#############################################################################
# Case 1: Spherical coordinates off.
# Open the file.
reader_cartesian = vtk.vtkNetCDFCFReader()
reader_cartesian.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/sampleGenGrid3.nc")
# Set the arrays we want to load.
reader_cartesian.UpdateMetaData()
reader_cartesian.SetVariableArrayStatus("sample",1)
reader_cartesian.SphericalCoordinatesOff()
# Assign the field to scalars.
aa_cartesian = vtk.vtkAssignAttribute()
aa_cartesian.SetInputConnection(reader_cartesian.GetOutputPort())
aa_cartesian.Assign("sample","SCALARS","CELL_DATA")
# Extract a surface that we can render.
surface_cartesian = vtk.vtkDataSetSurfaceFilter()
surface_cartesian.SetInputConnection(aa_cartesian.GetOutputPort())
mapper_cartesian = vtk.vtkPolyDataMapper()
mapper_cartesian.SetInputConnection(surface_cartesian.GetOutputPort())
mapper_cartesian.SetScalarRange(100,2500)
actor_cartesian = vtk.vtkActor()
actor_cartesian.SetMapper(mapper_cartesian)
ren_cartesian = vtk.vtkRenderer()
ren_cartesian.AddActor(actor_cartesian)
ren_cartesian.SetViewport(0.0,0.0,0.5,1.0)
renWin.AddRenderer(ren_cartesian)
#############################################################################
Example #19
0
VTK_DATA_ROOT = vtkGetDataRoot()

# This test checks netCDF reader.  It uses the COARDS convention.
renWin = vtk.vtkRenderWindow()
renWin.SetSize(400,400)
#############################################################################
# Case 1: Image type.
# Open the file.
reader_image = vtk.vtkNetCDFCFReader()
reader_image.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/tos_O1_2001-2002.nc")
reader_image.SetOutputTypeToImage()
# Set the arrays we want to load.
reader_image.UpdateMetaData()
reader_image.SetVariableArrayStatus("tos",1)
reader_image.SphericalCoordinatesOff()
aa_image = vtk.vtkAssignAttribute()
aa_image.SetInputConnection(reader_image.GetOutputPort())
aa_image.Assign("tos","SCALARS","POINT_DATA")
thresh_image = vtk.vtkThreshold()
thresh_image.SetInputConnection(aa_image.GetOutputPort())
thresh_image.ThresholdByLower(10000)
surface_image = vtk.vtkDataSetSurfaceFilter()
surface_image.SetInputConnection(thresh_image.GetOutputPort())
mapper_image = vtk.vtkPolyDataMapper()
mapper_image.SetInputConnection(surface_image.GetOutputPort())
mapper_image.SetScalarRange(270,310)
actor_image = vtk.vtkActor()
actor_image.SetMapper(mapper_image)
ren_image = vtk.vtkRenderer()
ren_image.AddActor(actor_image)
ren_image.SetViewport(0.0,0.0,0.5,0.5)
Example #20
0
bondMapper = vtk.vtkPolyDataMapper()
bondMapper.SetInputConnection(tube.GetOutputPort())
bondMapper.SetImmediateModeRendering(1)
bondMapper.UseLookupTableScalarRangeOff()
bondMapper.SetScalarVisibility(1)
bondMapper.SetScalarModeToDefault()

bondActor = vtk.vtkActor()
bondActor.SetMapper(bondMapper)

grad = vtk.vtkImageGradient()
grad.SetDimensionality(3)
grad.SetInputData(potential_cation.GetGridOutput())

attrib = vtk.vtkAssignAttribute()
attrib.SetInputConnection(grad.GetOutputPort())
attrib.Assign(vtk.vtkDataSetAttributes.SCALARS,
              vtk.vtkDataSetAttributes.VECTORS,
              vtk.vtkAssignAttribute.POINT_DATA)

center = potential_cation.GetOutput().GetPoint(0)

seeds = vtk.vtkPointSource()
seeds.SetRadius(3.0)
seeds.SetCenter(center)
seeds.SetNumberOfPoints(150)

integ = vtk.vtkRungeKutta4()
stream = vtk.vtkStreamTracer()
stream.SetInputConnection(attrib.GetOutputPort())
# This test checks netCDF CF reader for reading unstructured (p-sided) cells.
renWin = vtk.vtkRenderWindow()
renWin.SetSize(400, 200)
#############################################################################
# Case 1: Spherical coordinates off.
# Open the file.
reader_cartesian = vtk.vtkNetCDFCFReader()
reader_cartesian.SetFileName("" + str(VTK_DATA_ROOT) +
                             "/Data/sampleGenGrid3.nc")
# Set the arrays we want to load.
reader_cartesian.UpdateMetaData()
reader_cartesian.SetVariableArrayStatus("sample", 1)
reader_cartesian.SphericalCoordinatesOff()
# Assign the field to scalars.
aa_cartesian = vtk.vtkAssignAttribute()
aa_cartesian.SetInputConnection(reader_cartesian.GetOutputPort())
aa_cartesian.Assign("sample", "SCALARS", "CELL_DATA")
# Extract a surface that we can render.
surface_cartesian = vtk.vtkDataSetSurfaceFilter()
surface_cartesian.SetInputConnection(aa_cartesian.GetOutputPort())
mapper_cartesian = vtk.vtkPolyDataMapper()
mapper_cartesian.SetInputConnection(surface_cartesian.GetOutputPort())
mapper_cartesian.SetScalarRange(100, 2500)
actor_cartesian = vtk.vtkActor()
actor_cartesian.SetMapper(mapper_cartesian)
ren_cartesian = vtk.vtkRenderer()
ren_cartesian.AddActor(actor_cartesian)
ren_cartesian.SetViewport(0.0, 0.0, 0.5, 1.0)
renWin.AddRenderer(ren_cartesian)
#############################################################################
Example #22
0
#
pl3d = vtk.vtkMultiBlockPLOT3DReader()
pl3d.SetXYZFileName("" + str(VTK_DATA_ROOT) + "/Data/combxyz.bin")
pl3d.SetQFileName("" + str(VTK_DATA_ROOT) + "/Data/combq.bin")
pl3d.SetScalarFunctionNumber(100)
pl3d.SetVectorFunctionNumber(202)
pl3d.Update()
output = pl3d.GetOutput().GetBlock(0)
sf = vtk.vtkSplitField()
sf.SetInputData(output)
sf.SetInputField("VECTORS","POINT_DATA")
sf.Split(0,"vx")
sf.Split(1,"vy")
sf.Split(2,"vz")
#sf.Print()
aax = vtk.vtkAssignAttribute()
aax.SetInputConnection(sf.GetOutputPort())
aax.Assign("vx","SCALARS","POINT_DATA")
isoVx = vtk.vtkContourFilter()
isoVx.SetInputConnection(aax.GetOutputPort())
isoVx.SetValue(0,.38)
normalsVx = vtk.vtkPolyDataNormals()
normalsVx.SetInputConnection(isoVx.GetOutputPort())
normalsVx.SetFeatureAngle(45)
isoVxMapper = vtk.vtkPolyDataMapper()
isoVxMapper.SetInputConnection(normalsVx.GetOutputPort())
isoVxMapper.ScalarVisibilityOff()
isoVxMapper.ImmediateModeRenderingOn()
isoVxActor = vtk.vtkActor()
isoVxActor.SetMapper(isoVxMapper)
isoVxActor.GetProperty().SetColor(1,0.7,0.6)
Example #23
0
    def testFinancialField(self):
        """
            Demonstrate the use and manipulation of fields and use of
            vtkProgrammableDataObjectSource. This creates fields the hard way
            (as compared to reading a vtk field file), but shows you how to
            interface to your own raw data.

            The image should be the same as financialField.tcl
        """

        xAxis = "INTEREST_RATE"
        yAxis = "MONTHLY_PAYMENT"
        zAxis = "MONTHLY_INCOME"
        scalar = "TIME_LATE"

        # Parse an ascii file and manually create a field. Then construct a
        # dataset from the field.
        dos = vtk.vtkProgrammableDataObjectSource()

        def parseFile():
            f = open(VTK_DATA_ROOT + "/Data/financial.txt", "r")

            line = f.readline().split()
            # From the size calculate the number of lines.
            numPts = int(line[1])
            numLines = (numPts - 1) / 8 + 1

            # create the data object
            field = vtk.vtkFieldData()
            field.AllocateArrays(4)

            # read TIME_LATE - dependent variable
            while True:
                line = f.readline().split()
                if len(line) > 0:
                    break
            timeLate = vtk.vtkFloatArray()
            timeLate.SetName(line[0])
            for i in range(0, numLines):
                line = f.readline().split()
                for j in line:
                    timeLate.InsertNextValue(float(j))
            field.AddArray(timeLate)

            # MONTHLY_PAYMENT - independent variable
            while True:
                line = f.readline().split()
                if len(line) > 0:
                    break
            monthlyPayment = vtk.vtkFloatArray()
            monthlyPayment.SetName(line[0])
            for i in range(0, numLines):
                line = f.readline().split()
                for j in line:
                    monthlyPayment.InsertNextValue(float(j))
            field.AddArray(monthlyPayment)

            # UNPAID_PRINCIPLE - skip
            while True:
                line = f.readline().split()
                if len(line) > 0:
                    break
            for i in range(0, numLines):
                line = f.readline()

            # LOAN_AMOUNT - skip
            while True:
                line = f.readline().split()
                if len(line) > 0:
                    break
            for i in range(0, numLines):
                line = f.readline()

            # INTEREST_RATE - independent variable
            while True:
                line = f.readline().split()
                if len(line) > 0:
                    break
            interestRate = vtk.vtkFloatArray()
            interestRate.SetName(line[0])
            for i in range(0, numLines):
                line = f.readline().split()
                for j in line:
                    interestRate.InsertNextValue(float(j))
            field.AddArray(interestRate)

            # MONTHLY_INCOME - independent variable
            while True:
                line = f.readline().split()
                if len(line) > 0:
                    break
            monthlyIncome = vtk.vtkFloatArray()
            monthlyIncome.SetName(line[0])
            for i in range(0, numLines):
                line = f.readline().split()
                for j in line:
                    monthlyIncome.InsertNextValue(float(j))
            field.AddArray(monthlyIncome)

            dos.GetOutput().SetFieldData(field)

        dos.SetExecuteMethod(parseFile)

        # Create the dataset
        do2ds = vtk.vtkDataObjectToDataSetFilter()
        do2ds.SetInputConnection(dos.GetOutputPort())
        do2ds.SetDataSetTypeToPolyData()
        #format: component#, arrayname, arraycomp, minArrayId, maxArrayId, normalize
        do2ds.DefaultNormalizeOn()
        do2ds.SetPointComponent(0, xAxis, 0)
        do2ds.SetPointComponent(1, yAxis, 0)
        do2ds.SetPointComponent(2, zAxis, 0)
        do2ds.Update()

        rf = vtk.vtkRearrangeFields()
        rf.SetInputConnection(do2ds.GetOutputPort())
        rf.AddOperation("MOVE", scalar, "DATA_OBJECT", "POINT_DATA")
        rf.RemoveOperation("MOVE", scalar, "DATA_OBJECT", "POINT_DATA")
        rf.AddOperation("MOVE", scalar, "DATA_OBJECT", "POINT_DATA")
        rf.RemoveAllOperations()
        rf.AddOperation("MOVE", scalar, "DATA_OBJECT", "POINT_DATA")
        rf.Update()
        max = rf.GetOutput().GetPointData().GetArray(scalar).GetRange(0)[1]

        calc = vtk.vtkArrayCalculator()
        calc.SetInputConnection(rf.GetOutputPort())
        calc.SetAttributeTypeToPointData()
        calc.SetFunction("s / %f" % max)
        calc.AddScalarVariable("s", scalar, 0)
        calc.SetResultArrayName("resArray")

        aa = vtk.vtkAssignAttribute()
        aa.SetInputConnection(calc.GetOutputPort())
        aa.Assign("resArray", "SCALARS", "POINT_DATA")
        aa.Update()

        rf2 = vtk.vtkRearrangeFields()
        rf2.SetInputConnection(aa.GetOutputPort())
        rf2.AddOperation("COPY", "SCALARS", "POINT_DATA", "DATA_OBJECT")

        # construct pipeline for original population
        popSplatter = vtk.vtkGaussianSplatter()
        popSplatter.SetInputConnection(rf2.GetOutputPort())
        popSplatter.SetSampleDimensions(50, 50, 50)
        popSplatter.SetRadius(0.05)
        popSplatter.ScalarWarpingOff()
        popSurface = vtk.vtkContourFilter()
        popSurface.SetInputConnection(popSplatter.GetOutputPort())
        popSurface.SetValue(0, 0.01)
        popMapper = vtk.vtkPolyDataMapper()
        popMapper.SetInputConnection(popSurface.GetOutputPort())
        popMapper.ScalarVisibilityOff()
        popMapper.ImmediateModeRenderingOn()
        popActor = vtk.vtkActor()
        popActor.SetMapper(popMapper)
        popActor.GetProperty().SetOpacity(0.3)
        popActor.GetProperty().SetColor(.9, .9, .9)

        # construct pipeline for delinquent population
        lateSplatter = vtk.vtkGaussianSplatter()
        lateSplatter.SetInputConnection(aa.GetOutputPort())
        lateSplatter.SetSampleDimensions(50, 50, 50)
        lateSplatter.SetRadius(0.05)
        lateSplatter.SetScaleFactor(0.05)
        lateSurface = vtk.vtkContourFilter()
        lateSurface.SetInputConnection(lateSplatter.GetOutputPort())
        lateSurface.SetValue(0, 0.01)
        lateMapper = vtk.vtkPolyDataMapper()
        lateMapper.SetInputConnection(lateSurface.GetOutputPort())
        lateMapper.ScalarVisibilityOff()
        lateActor = vtk.vtkActor()
        lateActor.SetMapper(lateMapper)
        lateActor.GetProperty().SetColor(1.0, 0.0, 0.0)

        # create axes
        popSplatter.Update()
        bounds = popSplatter.GetOutput().GetBounds()
        axes = vtk.vtkAxes()
        axes.SetOrigin(bounds[0], bounds[2], bounds[4])
        axes.SetScaleFactor(popSplatter.GetOutput().GetLength() / 5.0)
        axesTubes = vtk.vtkTubeFilter()
        axesTubes.SetInputConnection(axes.GetOutputPort())
        axesTubes.SetRadius(axes.GetScaleFactor() / 25.0)
        axesTubes.SetNumberOfSides(6)
        axesMapper = vtk.vtkPolyDataMapper()
        axesMapper.SetInputConnection(axesTubes.GetOutputPort())
        axesActor = vtk.vtkActor()
        axesActor.SetMapper(axesMapper)

        # label the axes
        XText = vtk.vtkVectorText()
        XText.SetText(xAxis)
        XTextMapper = vtk.vtkPolyDataMapper()
        XTextMapper.SetInputConnection(XText.GetOutputPort())
        XActor = vtk.vtkFollower()
        XActor.SetMapper(XTextMapper)
        XActor.SetScale(0.02, .02, .02)
        XActor.SetPosition(0.35, -0.05, -0.05)
        XActor.GetProperty().SetColor(0, 0, 0)

        YText = vtk.vtkVectorText()
        YText.SetText(yAxis)
        YTextMapper = vtk.vtkPolyDataMapper()
        YTextMapper.SetInputConnection(YText.GetOutputPort())
        YActor = vtk.vtkFollower()
        YActor.SetMapper(YTextMapper)
        YActor.SetScale(0.02, .02, .02)
        YActor.SetPosition(-0.05, 0.35, -0.05)
        YActor.GetProperty().SetColor(0, 0, 0)

        ZText = vtk.vtkVectorText()
        ZText.SetText(zAxis)
        ZTextMapper = vtk.vtkPolyDataMapper()
        ZTextMapper.SetInputConnection(ZText.GetOutputPort())
        ZActor = vtk.vtkFollower()
        ZActor.SetMapper(ZTextMapper)
        ZActor.SetScale(0.02, .02, .02)
        ZActor.SetPosition(-0.05, -0.05, 0.35)
        ZActor.GetProperty().SetColor(0, 0, 0)

        # Graphics stuff
        #
        ren = vtk.vtkRenderer()
        renWin = vtk.vtkRenderWindow()
        renWin.AddRenderer(ren)
        renWin.SetWindowName("vtk(-, Field.Data")
        renWin.SetSize(300, 300)

        # Add the actors to the renderer, set the background and size
        #
        ren.AddActor(axesActor)
        ren.AddActor(lateActor)
        ren.AddActor(XActor)
        ren.AddActor(YActor)
        ren.AddActor(ZActor)
        ren.AddActor(popActor)  #it's last because its translucent)
        ren.SetBackground(1, 1, 1)

        camera = vtk.vtkCamera()
        camera.SetClippingRange(.274, 13.72)
        camera.SetFocalPoint(0.433816, 0.333131, 0.449)
        camera.SetPosition(-1.96987, 1.15145, 1.49053)
        camera.SetViewUp(0.378927, 0.911821, 0.158107)
        ren.SetActiveCamera(camera)
        XActor.SetCamera(camera)
        YActor.SetCamera(camera)
        ZActor.SetCamera(camera)

        # render and interact with data

        iRen = vtk.vtkRenderWindowInteractor()
        iRen.SetRenderWindow(renWin)
        renWin.Render()

        img_file = "financialField3.png"
        vtk.test.Testing.compareImage(
            iRen.GetRenderWindow(),
            vtk.test.Testing.getAbsImagePath(img_file),
            threshold=25)
        vtk.test.Testing.interact()
# Now generate normals from resulting points
curv = vtk.vtkPCACurvatureEstimation()
curv.SetInputConnection(pts.GetOutputPort())
curv.SetSampleSize(20)

# Time execution
timer = vtk.vtkTimerLog()
timer.StartTimer()
curv.Update()
timer.StopTimer()
time = timer.GetElapsedTime()
print("Points processed: {0}".format(pts.GetOutput().GetNumberOfPoints()))
print("   Time to generate curvature: {0}".format(time))

# Break out the curvature into three separate arrays
assign = vtk.vtkAssignAttribute()
assign.SetInputConnection(curv.GetOutputPort())
assign.Assign("PCACurvature", "VECTORS", "POINT_DATA")

extract = vtk.vtkExtractVectorComponents()
extract.SetInputConnection(assign.GetOutputPort())
extract.Update()
print(extract.GetOutput(0).GetScalarRange())
print(extract.GetOutput(1).GetScalarRange())
print(extract.GetOutput(2).GetScalarRange())

# Three different outputs for different curvatures
subMapper = vtk.vtkPointGaussianMapper()
subMapper.SetInputConnection(extract.GetOutputPort(0))
subMapper.EmissiveOff()
subMapper.SetScaleFactor(0.0)
    def plot(self, struct):

        # creates self. data1, legend, filename, fieldname, dim, has_field, tracker, revision
        if not self.call_config(struct):
            return

        self.update_field_type('vector', True)
        self.update_legend_data()

        # creates self.src
        if not self.call_src():
            return

        self.ugrid = self.construct_data(self.src)

        self.src_vc = vtk.vtkAssignAttribute()
        #self.src_vc.Assign(aname, 0, pc) # 0 scalar 1 vector ; 0 point 1 cell
        if vtk.vtkVersion.GetVTKMajorVersion() < 6:
            self.src_vc.SetInput(self.ugrid)
        else:
            self.src_vc.SetInputData(self.ugrid)

        self.lastmode = self.get_selected(struct)
        self.apply_data(self.lastmode)

        self.add_outline_2(self.src_vc)

        # test nrc. es visible con este cambio:
        #        self.refsT = vtk.vtkThreshold()
        #        self.refsT.SetInputConnection(self.src.GetOutputPort())
        #        self.refsT.ThresholdByUpper(1.0)

        self.wireM = vtk.vtkDataSetMapper()
        #        self.wireM.SetInputConnection(self.src.GetOutputPort())
        self.wireM.SetInputConnection(self.src_vc.GetOutputPort())

        # test
        if self.data1.get('fielddomain') == 'cell':
            self.wireM.SetScalarModeToUseCellData()
        elif self.data1.get('fielddomain') == 'point':
            self.wireM.SetScalarModeToUsePointData()

#        self.wireM.SetInputConnection(self.refsT.GetOutputPort()) # test nrc.

        self.scalarrange.local_set(self.src_vc.GetOutput().GetScalarRange())

        # reverse rainbow [red->blue] -> [blue->red]
        look = self.wireM.GetLookupTable()

        #para mostrar surface e wireframe ao mesmo tempo
        self.wireA = vtk.vtkActor()
        self.wireA.SetMapper(self.wireM)
        self.wireA.GetProperty().SetRepresentationToSurface()
        self.wireA.GetProperty().SetColor(Plot.edges_color)
        self.wireA.GetProperty().SetEdgeColor(Plot.edges_color)

        self.add_swe_2(self.wireA)  # wireframe/surface/surface+edges
        self.add_opacity_2([self.wireA])  # Opacity: 100%/75%/50%/25%/0%
        self.rens[0].AddActor(self.wireA)  # malla con cores

        if interactive:
            self.set_iren()
            self.clicker = clicker = ClickLabel.ClickLabel()
            clicker.set_point_cell(self.data1.get('fielddomain'))
            clicker.set_objects(self.src_vc, self.rens[0], self.iren,
                                self.widget)
            clicker.set_props([self.wireA])
            clicker.setup()

        self.add_scalarbar_2(look)

        self.done = True
# Use fixed radius
dens0 = vtk.vtkPointDensityFilter()
dens0.SetInputConnection(clipper.GetOutputPort())
dens0.SetSampleDimensions(res, res, res)
dens0.SetDensityEstimateToFixedRadius()
dens0.SetRadius(0.05)
# dens0.SetDensityEstimateToRelativeRadius()
dens0.SetRelativeRadius(2.5)
# dens0.SetDensityFormToVolumeNormalized()
dens0.SetDensityFormToNumberOfPoints()
dens0.ComputeGradientOn()
dens0.Update()
vrange = dens0.GetOutput().GetPointData().GetArray("Gradient Magnitude").GetRange()

# Show the gradient magnitude
assign0 = vtk.vtkAssignAttribute()
assign0.SetInputConnection(dens0.GetOutputPort())
assign0.Assign("Gradient Magnitude", "SCALARS", "POINT_DATA")

map0 = vtk.vtkImageSliceMapper()
map0.BorderOn()
map0.SliceAtFocalPointOn()
map0.SliceFacesCameraOn()
map0.SetInputConnection(assign0.GetOutputPort())

slice0 = vtk.vtkImageSlice()
slice0.SetMapper(map0)
slice0.GetProperty().SetColorWindow(vrange[1] - vrange[0])
slice0.GetProperty().SetColorLevel(0.5 * (vrange[0] + vrange[1]))

# Show the region labels
Example #27
0

ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetWindowName("Phi field")
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

for i in range(numHalos):
  ren.AddActor(sphereactorlist[i])


#==============================================================================

assv = vtk.vtkAssignAttribute()
assv.SetInputConnection(hr.GetOutputPort())
assv.Assign("velocity", "VECTORS", "POINT_DATA")

print "running hogs"


hogs = vtk.vtkHedgeHog()
hogs.SetInputConnection(assv.GetOutputPort())
hogs.SetVectorModeToUseVector()
hogs.SetScaleFactor(10)

lut1 = vtk.vtkLookupTable()
lut1.SetNumberOfColors(64)
lut1.SetHueRange(0.66,0)
lut1.SetValueRange(1,1)