コード例 #1
0
ファイル: vtkHedgeHog.py プロジェクト: fvpolpeta/devide
 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkHedgeHog(), 'Processing.',
         ('vtkDataSet',), ('vtkPolyData',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
コード例 #2
0
ファイル: HedgeHog.py プロジェクト: sldion/DNACC
 def __init__ (self, mod_m):
     debug ("In HedgeHog::__init__ ()")
     Common.state.busy ()
     Base.Objects.Module.__init__ (self, mod_m)
     self.root = None
     self.hhog = vtk.vtkHedgeHog ()
     self.mapper = self.map = vtk.vtkPolyDataMapper ()
     self.actor  = self.act = vtk.vtkActor ()
     self._initialize ()
     self.renwin.Render ()
     Common.state.idle ()
コード例 #3
0
    def initHedgeHog(self, scale=0.1):
        print "initializing HedgeHog object", scale
        # Create the HedgeHog object
        self.vtkHedgHog = vtk.vtkHedgeHog()
        self.vtkHedgHog.SetInputData(self.vtkStructuredGrid)
        self.vtkHedgHog.SetScaleFactor(scale)

        print "Making the HedgeHog mapper"
        # Now create its Actor and associated mapper
        mapper = vtk.vtkPolyDataMapper()
        print "mapper.SetInputConnection(self.vtkHedgHog.GetOutputPort())"
        mapper.SetInputConnection(self.vtkHedgHog.GetOutputPort())
        print "Setting color information"
        mapper.SetColorModeToDefault()
        mapper.SetScalarRange(self.dMin, self.dMax)
        mapper.SetScalarVisibility(1)
        print "Setting mapper to actor"
        self.vtkFlowActor.SetMapper(mapper)
コード例 #4
0
ファイル: Hogs.py プロジェクト: y1275963/Yingjie-s-Latex-repo
#         110 - pressure 
#         120 - temperature 
#         130 - enthalpy 
#         140 - internal energy 
#         144 - kinetic energy 
#         153 - velocity magnitude 
#         163 - stagnation energy 
#         170 - entropy 
#         184 - swirl
# vector: 
#         200 - velocity 
#         201 - vorticity 
#         202 - momentum 
#         210 - pressure gradient

hogs = vtk.vtkHedgeHog()
hogs.SetInputConnection(pl3d.GetOutputPort())
hogs.SetVectorModeToUseVector()
hogs.SetScaleFactor(0.001)

lut = vtk.vtkLookupTable()
lut.SetNumberOfColors(64)
lut.SetHueRange(0.66,0)
lut.SetValueRange(1,1)
lut.SetSaturationRange(1,1)
lut.Build()

map = vtk.vtkPolyDataMapper()
map.SetInputConnection(hogs.GetOutputPort())
map.SetScalarRange(lo, hi)
map.SetLookupTable(lut)
コード例 #5
0
warp_moment = vtk.vtkWarpVector()
warp_moment.SetInput(moment_reader.GetOutput())
warp_moment.SetScaleFactor(moment_scale)
warp_moment.Update()
warp_moment_mapper = vtk.vtkDataSetMapper()
warp_moment_mapper.SetInput(warp_moment.GetOutput())
warp_moment_actor = vtk.vtkActor()
warp_moment_actor.SetMapper(warp_moment_mapper)
warp_moment_actor.SetVisibility(0)

# ---------------------------------------------------
# HEDGEHOGS
# ---------------------------------------------------

# AXIAL
hedge_axial = vtk.vtkHedgeHog()
hedge_axial.SetInput(axial_reader.GetOutput())
hedge_axial.SetScaleFactor(axial_scale)
hedge_axial_mapper = vtk.vtkPolyDataMapper()
hedge_axial_mapper.SetInputConnection(hedge_axial.GetOutputPort())
hedge_axial_actor = vtk.vtkActor()
hedge_axial_actor.SetMapper(hedge_axial_mapper)
hedge_axial_actor.SetVisibility(0)
# SHEAR
hedge_shear = vtk.vtkHedgeHog()
hedge_shear.SetInput(shear_reader.GetOutput())
hedge_shear.SetScaleFactor(shear_scale)
hedge_shear_mapper = vtk.vtkPolyDataMapper()
hedge_shear_mapper.SetInputConnection(hedge_shear.GetOutputPort())
hedge_shear_actor = vtk.vtkActor()
hedge_shear_actor.SetMapper(hedge_shear_mapper)
コード例 #6
0
def main():
    colors = vtk.vtkNamedColors()

    rMin = 0.5
    rMax = 1.0
    dims = [13, 11, 11]

    # Create the structured grid.
    sgrid = vtk.vtkStructuredGrid()
    sgrid.SetDimensions(dims)

    # We also create the points and vectors. The points
    # form a hemi-cylinder of data.
    vectors = vtk.vtkDoubleArray()
    vectors.SetNumberOfComponents(3)
    vectors.SetNumberOfTuples(dims[0] * dims[1] * dims[2])
    points = vtk.vtkPoints()
    points.Allocate(dims[0] * dims[1] * dims[2])

    deltaZ = 2.0 / (dims[2] - 1)
    deltaRad = (rMax - rMin) / (dims[1] - 1)
    x = [0.0] * 3
    v = [0.0] * 3
    for k in range(0, dims[2]):
        x[2] = -1.0 + k * deltaZ
        kOffset = k * dims[0] * dims[1]
        for j in range(0, dims[1]):
            radius = rMin + j * deltaRad
            jOffset = j * dims[0]
            for i in range(0, dims[0]):
                theta = i * vtk.vtkMath.RadiansFromDegrees(15.0)
                x[0] = radius * math.cos(theta)
                x[1] = radius * math.sin(theta)
                v[0] = -x[1]
                v[1] = x[0]
                offset = i + jOffset + kOffset
                points.InsertPoint(offset, x)
                vectors.InsertTuple(offset, v)
    sgrid.SetPoints(points)
    sgrid.GetPointData().SetVectors(vectors)

    # We create a simple pipeline to display the data.
    hedgehog = vtk.vtkHedgeHog()
    hedgehog.SetInputData(sgrid)
    hedgehog.SetScaleFactor(0.1)

    sgridMapper = vtk.vtkPolyDataMapper()
    sgridMapper.SetInputConnection(hedgehog.GetOutputPort())
    sgridActor = vtk.vtkActor()
    sgridActor.SetMapper(sgridMapper)
    sgridActor.GetProperty().SetColor(colors.GetColor3d("Peacock"))

    # Create the usual rendering stuff
    renderer = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(renderer)

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

    renderer.AddActor(sgridActor)
    renderer.SetBackground(colors.GetColor3d("Beige"))
    renderer.ResetCamera()
    renderer.GetActiveCamera().Elevation(60.0)
    renderer.GetActiveCamera().Azimuth(30.0)
    renderer.GetActiveCamera().Dolly(1.25)
    renWin.SetSize(640, 480)

    # Interact with the data.
    renWin.Render()
    iren.Start()
コード例 #7
0
pl3d_v_output = pl3d_velocity.GetOutput().GetBlock(0)
# contour the scalar fields
contour = vtk.vtkContourFilter()
contour.SetInputData(pl3d_g_output)
contour.SetValue(0,0.225)
# probe the vector fields to get data at the contour surface
probe_gradient = vtk.vtkProbeFilter()
probe_gradient.SetInputConnection(contour.GetOutputPort())
probe_gradient.SetSourceData(pl3d_g_output)
probe_velocity = vtk.vtkProbeFilter()
probe_velocity.SetInputConnection(contour.GetOutputPort())
probe_velocity.SetSourceData(pl3d_v_output)
#
# To display the vector fields, we use vtkHedgeHog to create lines.
#
velocity = vtk.vtkHedgeHog()
velocity.SetInputConnection(probe_velocity.GetOutputPort())
velocity.SetScaleFactor(0.0015)
pressureGradient = vtk.vtkHedgeHog()
pressureGradient.SetInputConnection(probe_gradient.GetOutputPort())
pressureGradient.SetScaleFactor(0.00002)
def ExecuteDot (__vtk__temp0=0,__vtk__temp1=0):
    # proc for ProgrammableAttributeDataFilter.  Note the use of "double()"
    # in the calculations.  This protects us from Tcl using ints and
    # overflowing.
    inputs = dotProduct.GetInputList()
    input0 = inputs.GetDataSet(0)
    input1 = inputs.GetDataSet(1)
    numPts = input0.GetNumberOfPoints()
    vectors0 = input0.GetPointData().GetVectors()
    vectors1 = input1.GetPointData().GetVectors()
コード例 #8
0
cone = vtk.vtkConeSource()
cone.SetResolution(6)
cone.SetRadius(.1)

transform = vtk.vtkTransform()
transform.Translate(0.5, 0.0, 0.0)
transformF = vtk.vtkTransformPolyDataFilter()
transformF.SetInputConnection(cone.GetOutputPort())
transformF.SetTransform(transform)

# we just clean the normals for efficiency (keep down number of cones)
clean = vtk.vtkCleanPolyData()
clean.SetInputConnection(wavefront.GetOutputPort())
clean.PointMergingOff()

glyph = vtk.vtkHedgeHog()
glyph.SetInputConnection(clean.GetOutputPort())
glyph.SetVectorModeToUseNormal()
glyph.SetScaleFactor(0.4)

hairMapper = vtk.vtkPolyDataMapper()
hairMapper.SetInputConnection(glyph.GetOutputPort())

hair = vtk.vtkActor()
hair.SetMapper(hairMapper)

cowMapper = vtk.vtkPolyDataMapper()
cowMapper.SetInputConnection(wavefront.GetOutputPort())
cow = vtk.vtkActor()
cow.SetMapper(cowMapper)
コード例 #9
0
    _renderwindow = vtk.vtkRenderWindow()
    _renderer = vtk.vtkRenderer()
    _renderwindowinteractor = vtk.vtkRenderWindowInteractor()
    _background_color = [1,1,1]        
    _renderer.SetBackground(_background_color[0],_background_color[1], _background_color[2])
    _renderwindow.AddRenderer(_renderer)
    _renderwindowinteractor.SetRenderWindow(_renderwindow)
    _renderwindowinteractor.Initialize()
    _interactor_style_trackball = vtk.vtkInteractorStyleTrackballCamera()
    _renderwindowinteractor.SetInteractorStyle(_interactor_style_trackball)
    _mapper = vtk.vtkPolyDataMapper()
    
    #now create the vectors to display:
    _polydata = vtk.vtkPolyData()
    _hedgehog = vtk.vtkHedgeHog()
    _points = vtk.vtkPoints()
    _scalars = vtk.vtkFloatArray()
    _vectors = vtk.vtkFloatArray()
    _lut = vtk.vtkLookupTable()
    #_lut.SetTableRange(vis_min, vis_max) #this isn't working
    _lut.Build()
    #print _lut.GetRange()
    _vectors.SetNumberOfComponents(3) 
    
    
        
    counter=0
    for j in range(len(voxels[0])):  
        
コード例 #10
0
cutMapper = vtk.vtkPolyDataMapper()
cutMapper.SetInputConnection(cut.GetOutputPort())
cutMapper.SetScalarModeToUsePointFieldData()
cutMapper.SelectColorArray("Implicit scalars")

cutActor = vtk.vtkActor()
cutActor.SetMapper(cutMapper)
cutActor.GetProperty().SetColor(1,1,1)
cutActor.GetProperty().SetOpacity(1)

# Look at the vectors
ranPts = vtk.vtkMaskPoints()
ranPts.SetOnRatio(25)
ranPts.SetInputConnection(cut.GetOutputPort())

hhog = vtk.vtkHedgeHog()
hhog.SetInputConnection(ranPts.GetOutputPort())
hhog.SetVectorModeToUseVector()
hhog.SetScaleFactor(0.05)

hhogMapper = vtk.vtkPolyDataMapper()
hhogMapper.SetInputConnection(hhog.GetOutputPort())

hhogActor = vtk.vtkActor()
hhogActor.SetMapper(hhogMapper)
hhogActor.GetProperty().SetColor(1,1,1)
hhogActor.GetProperty().SetOpacity(1)

# Outline
outline = vtk.vtkOutlineFilter()
outline.SetInputConnection(sample.GetOutputPort())
コード例 #11
0
pl3d_v_output = pl3d_velocity.GetOutput().GetBlock(0)
# contour the scalar fields
contour = vtk.vtkContourFilter()
contour.SetInputData(pl3d_g_output)
contour.SetValue(0,0.225)
# probe the vector fields to get data at the contour surface
probe_gradient = vtk.vtkProbeFilter()
probe_gradient.SetInputConnection(contour.GetOutputPort())
probe_gradient.SetSourceData(pl3d_g_output)
probe_velocity = vtk.vtkProbeFilter()
probe_velocity.SetInputConnection(contour.GetOutputPort())
probe_velocity.SetSourceData(pl3d_v_output)
#
# To display the vector fields, we use vtkHedgeHog to create lines.
#
velocity = vtk.vtkHedgeHog()
velocity.SetInputConnection(probe_velocity.GetOutputPort())
velocity.SetScaleFactor(0.0015)
pressureGradient = vtk.vtkHedgeHog()
pressureGradient.SetInputConnection(probe_gradient.GetOutputPort())
pressureGradient.SetScaleFactor(0.00002)
def ExecuteDot (__vtk__temp0=0,__vtk__temp1=0):
    # proc for ProgrammableAttributeDataFilter.  Note the use of "double()"
    # in the calculations.  This protects us from Python using ints and
    # overflowing.
    inputs = dotProduct.GetInputList()
    input0 = inputs.GetDataSet(0)
    input1 = inputs.GetDataSet(1)
    numPts = input0.GetNumberOfPoints()
    vectors0 = input0.GetPointData().GetVectors()
    vectors1 = input1.GetPointData().GetVectors()
コード例 #12
0
# do not forget to call "Update()" at the end of the reader
rectGridReader.Update()
#----------------------------ALTERNATIVE---------------------------#
subset = vtk.vtkMaskPoints()
subset.SetOnRatio(10)
subset.RandomModeOn()
subset.SetInputConnection(rectGridReader.GetOutputPort())
#vtk.vtkColorTransferFunction()
#vtk.vtkLookupTable()
lut = vtk.vtkLookupTable()
lut.SetNumberOfColors(256)
lut.SetHueRange(0.667, 0.0)
lut.SetVectorModeToMagnitude()
lut.Build()

hh = vtk.vtkHedgeHog()
hh.SetInputConnection(subset.GetOutputPort())
hh.SetScaleFactor(0.001)

#------------------------------------FILTERS------------------------------------#
#----------------------------CHALLENGE1---------------------------#
rectGridOutline = vtk.vtkRectilinearGridOutlineFilter()
rectGridOutline.SetInputData(rectGridReader.GetOutput())
rectGridGeom = vtk.vtkRectilinearGridGeometryFilter()
rectGridGeom.SetInputData(rectGridReader.GetOutput())
rectGridGeom.SetExtent(0, 128, 0, 0, 0, 127)
#----------------------------CHALLENGE2---------------------------#
magnitudeCalcFilter = vtk.vtkArrayCalculator()
magnitudeCalcFilter.SetInputConnection(rectGridReader.GetOutputPort())
magnitudeCalcFilter.AddVectorArrayName('vectors')
# Set up here the array that is going to be used for the computation ('vectors')
コード例 #13
0
ファイル: Plot3DVectors.py プロジェクト: leo1978/berks-vtk
textProp = vtk.vtkTextProperty()
textProp.SetFontSize(10)
textProp.SetFontFamilyToArial()
textProp.SetColor(.3,1,1)
i = 0
for vectorFunction in vectorFunctions.split():
    locals()[get_variable_name("pl3d", vectorFunction, "")] = vtk.vtkMultiBlockPLOT3DReader()
    locals()[get_variable_name("pl3d", vectorFunction, "")].SetXYZFileName("" + str(VTK_DATA_ROOT) + "/Data/bluntfinxyz.bin")
    locals()[get_variable_name("pl3d", vectorFunction, "")].SetQFileName("" + str(VTK_DATA_ROOT) + "/Data/bluntfinq.bin")
    locals()[get_variable_name("pl3d", vectorFunction, "")].SetVectorFunctionNumber(expr.expr(globals(), locals(),["int","(","vectorFunction",")"]))
    locals()[get_variable_name("pl3d", vectorFunction, "")].Update()
    output = locals()[get_variable_name("pl3d", vectorFunction, "")].GetOutput().GetBlock(0)
    locals()[get_variable_name("plane", vectorFunction, "")] = vtk.vtkStructuredGridGeometryFilter()
    locals()[get_variable_name("plane", vectorFunction, "")].SetInputData(output)
    locals()[get_variable_name("plane", vectorFunction, "")].SetExtent(25,25,0,100,0,100)
    locals()[get_variable_name("hog", vectorFunction, "")] = vtk.vtkHedgeHog()
    locals()[get_variable_name("hog", vectorFunction, "")].SetInputConnection(locals()[get_variable_name("plane", vectorFunction, "")].GetOutputPort())
    maxnorm = output.GetPointData().GetVectors().GetMaxNorm()
    locals()[get_variable_name("hog", vectorFunction, "")].SetScaleFactor(expr.expr(globals(), locals(),["1.0","/","maxnorm"]))
    locals()[get_variable_name("mapper", vectorFunction, "")] = vtk.vtkPolyDataMapper()
    locals()[get_variable_name("mapper", vectorFunction, "")].SetInputConnection(locals()[get_variable_name("hog", vectorFunction, "")].GetOutputPort())
    locals()[get_variable_name("actor", vectorFunction, "")] = vtk.vtkActor()
    locals()[get_variable_name("actor", vectorFunction, "")].SetMapper(locals()[get_variable_name("mapper", vectorFunction, "")])
    locals()[get_variable_name("ren", vectorFunction, "")] = vtk.vtkRenderer()
    locals()[get_variable_name("ren", vectorFunction, "")].SetBackground(0.5,.5,.5)
    locals()[get_variable_name("ren", vectorFunction, "")].SetActiveCamera(camera)
    locals()[get_variable_name("ren", vectorFunction, "")].AddLight(light)
    renWin.AddRenderer(locals()[get_variable_name("ren", vectorFunction, "")])
    locals()[get_variable_name("ren", vectorFunction, "")].AddActor(locals()[get_variable_name("actor", vectorFunction, "")])
    locals()[get_variable_name("textMapper", vectorFunction, "")] = vtk.vtkTextMapper()
    locals()[get_variable_name("textMapper", vectorFunction, "")].SetInput(lindex(vectorLabels,i))
コード例 #14
0
def end_max(reader, scale, number_of_divisions=40):
    """ 
    Retrieve the end forces and the maximum force within the span
    (if exists) and produce the related hedgehogs
    """
    # Initialize text dictionary
    text_dict = {}
    #
    out = reader.GetOutput()
    points = out.GetPoints()
    point_data = out.GetPointData()
    vectors = point_data.GetVectors()

    # Get number of points
    number_of_points = points.GetNumberOfPoints()

    # Allocate arrays
    coordinates = np.zeros((number_of_points, 3))
    internal_force = np.zeros((number_of_points, 3))

    # Fill the coordinates array
    for i in range(number_of_points):
        coordinates[i,:] = points.GetPoint(i)
        internal_force[i,:] = vectors.GetTuple(i)

    # Prepare the lists
    force_ends = []
    force_maxs = []

    # Get the ends first
    i = 0
    while i < number_of_points:
        force_ends.append( (internal_force[i,:], coordinates[i,:]) )
        force_ends.append( (internal_force[i+40,:], coordinates[i+40,:]) )
        i = i + 41

    # Write the texts for end forces
    for i in range(len(force_ends)):
        tta = vtk.vtkTextActor()
        tta.SetVisibility(0)
        magn = np.sqrt(force_ends[i][0][0]**2 + force_ends[i][0][1]**2)
        text = "%.2f" %magn
        tta.SetInput(text)
        tp = tta.GetTextProperty()
        tp.SetFontSize(16)
        tp.SetBold(1)
        tta.GetPositionCoordinate().SetCoordinateSystemToWorld()
        tta.SetPosition(force_ends[i][1][0] 
                        + scale*force_ends[i][0][0], 
                        force_ends[i][1][1] 
                        + scale*force_ends[i][0][1])
        text_dict[tta] = force_ends[i]
    # Get the maximum values
    j = 0 
    max_force = 0
    for i in range(number_of_points):
        # Convert vectors to scalar (magnitude)
        current_force = np.sqrt(internal_force[i,0]**2 
                                + internal_force[i,1]**2 
                                + internal_force[i,2]**2)
        # Update maximum values
        if current_force >= max_force:
            max_force = current_force
            max_force_vector = [ internal_force[i,:], i ]

        # Add tuples to the lists and reset when the element ends
        # 0-40, 41-81, 82-122, ... >> j = 41, 82, 123, ...
        if ( (i != j) and ( (i-j) % number_of_divisions ) == 0):
            j = i+1
            force_maxs.append( (max_force_vector[0], 
                                coordinates[max_force_vector[1]]) )
            max_force = 0
            max_force_vector = 0

    # Max force text
    for i in range(len(force_maxs)):
        tta = vtk.vtkTextActor()
        tta.SetVisibility(0)
        magn = np.sqrt(force_maxs[i][0][0]**2 + force_maxs[i][0][1]**2)
        text = "%.2f" %magn
        tta.SetInput(text)
        tp = tta.GetTextProperty()
        tp.SetFontSize(16)
        tp.SetBold(1)
        tta.GetPositionCoordinate().SetCoordinateSystemToWorld()
        tta.SetPosition(force_maxs[i][1][0] 
                        + scale*force_maxs[i][0][0], 
                        force_maxs[i][1][1] 
                        + scale*force_maxs[i][0][1])
        text_dict[tta] = force_maxs[i]
    #
    # Write data to vtk file, then read from it (fix this)
    outfile = open("/tmp/tmp.vtk", 'w')
    outfile.write("# vtk DataFile Version 2.0\n")
    outfile.write("temporary_end output\n")
    outfile.write("ASCII\n")
    outfile.write("DATASET UNSTRUCTURED_GRID\n")
    npoints = len(force_ends)
    outfile.write("POINTS %d float\n" %npoints)
    for i in range(len(force_ends)):
        outfile.write("%24.16f %24.16f %24.16f\n"
                      %(force_ends[i][1][0], force_ends[i][1][1],
                        force_ends[i][1][2]) )
    outfile.write("\nCELLS %d %d\n" %(npoints-1, (npoints-1)*3) )
    for i in range(npoints-1):
        outfile.write("%d %d %d\n" %(2, i, i+1) )
    outfile.write("\nCELL_TYPES %d \n" %(npoints-1) )
    for i in range(npoints-1):
        outfile.write("%d\n" %(3) )
    outfile.write("\nPOINT_DATA %d\n" %npoints)
    outfile.write("VECTORS tmp float\n")
    for i in range(len(force_ends)):
        outfile.write("%24.16f %24.16f %24.16f\n"
                      %(force_ends[i][0][0], force_ends[i][0][1],
                        force_ends[i][0][2]))
    outfile.close()

    outfile = open("/tmp/tmp2.vtk", 'w')
    outfile.write("# vtk DataFile Version 2.0\n")
    outfile.write("temporary_max output\n")
    outfile.write("ASCII\n")
    outfile.write("DATASET UNSTRUCTURED_GRID\n")
    npoints = len(force_maxs)
    outfile.write("POINTS %d float\n" %npoints)
    for i in range(len(force_maxs)):
        outfile.write("%24.16f %24.16f %24.16f\n"
                      %(force_maxs[i][1][0], force_maxs[i][1][1],
                        force_maxs[i][1][2]))
    outfile.write("\nCELLS %d %d\n" %(npoints-1, (npoints-1)*3) )
    for i in range(npoints-1):
        outfile.write("%d %d %d\n" %(2, i, i+1) )
    outfile.write("\nCELL_TYPES %d \n" %(npoints-1) )
    for i in range(npoints-1):
        outfile.write("%d\n" %(3) )

    outfile.write("\nPOINT_DATA %d\n" %npoints)
    outfile.write("VECTORS tmp float\n")
    for i in range(len(force_maxs)):
        outfile.write("%24.16f %24.16f %24.16f\n"
                      %(force_maxs[i][0][0], force_maxs[i][0][1],
                        force_maxs[i][0][2]))

    outfile.close()
    # Create the end & maximum hedgehogs
    max_reader = vtk.vtkUnstructuredGridReader()
    max_reader.SetFileName("/tmp/tmp2.vtk")
    max_reader.ReadAllVectorsOn()
    max_reader.Update()
    maximum_hedgehog = vtk.vtkHedgeHog()
    maximum_hedgehog.SetInput(max_reader.GetOutput())
    maximum_hedgehog_mapper = vtk.vtkPolyDataMapper()
    maximum_hedgehog_mapper.SetInputConnection(maximum_hedgehog.GetOutputPort())
    max_actor = vtk.vtkActor()
    max_actor.SetMapper(maximum_hedgehog_mapper)

    end_reader = vtk.vtkUnstructuredGridReader()
    end_reader.SetFileName("/tmp/tmp.vtk")
    end_reader.ReadAllVectorsOn()
    end_reader.Update()
    end_hedgehog = vtk.vtkHedgeHog()
    end_hedgehog.SetInput(end_reader.GetOutput())
    end_hedgehog_mapper = vtk.vtkPolyDataMapper()
    end_hedgehog_mapper.SetInputConnection(end_hedgehog.GetOutputPort())
    end_actor = vtk.vtkActor()
    end_actor.SetMapper(end_hedgehog_mapper)

    return maximum_hedgehog, max_actor, end_hedgehog, end_actor, text_dict
コード例 #15
0
ファイル: cowHair.py プロジェクト: marwan-abdellah/VTK
#
wavefront = vtk.vtkOBJReader()
wavefront.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/Viewpoint/cow.obj")
wavefront.Update()
cone = vtk.vtkConeSource()
cone.SetResolution(6)
cone.SetRadius(0.1)
transform = vtk.vtkTransform()
transform.Translate(0.5, 0.0, 0.0)
transformF = vtk.vtkTransformPolyDataFilter()
transformF.SetInputConnection(cone.GetOutputPort())
transformF.SetTransform(transform)
# we just clean the normals for efficiency (keep down number of cones)
clean = vtk.vtkCleanPolyData()
clean.SetInputConnection(wavefront.GetOutputPort())
glyph = vtk.vtkHedgeHog()
glyph.SetInputConnection(clean.GetOutputPort())
glyph.SetVectorModeToUseNormal()
glyph.SetScaleFactor(0.4)
hairMapper = vtk.vtkPolyDataMapper()
hairMapper.SetInputConnection(glyph.GetOutputPort())
hair = vtk.vtkActor()
hair.SetMapper(hairMapper)
cowMapper = vtk.vtkPolyDataMapper()
cowMapper.SetInputConnection(wavefront.GetOutputPort())
cow = vtk.vtkActor()
cow.SetMapper(cowMapper)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor(cow)
ren1.AddActor(hair)
コード例 #16
0
#         110 - pressure
#         120 - temperature
#         130 - enthalpy
#         140 - internal energy
#         144 - kinetic energy
#         153 - velocity magnitude
#         163 - stagnation energy
#         170 - entropy
#         184 - swirl
# vector:
#         200 - velocity
#         201 - vorticity
#         202 - momentum
#         210 - pressure gradient

hogs = vtk.vtkHedgeHog()
hogs.SetInputConnection(pl3d.GetOutputPort())
hogs.SetVectorModeToUseVector()
hogs.SetScaleFactor(0.001)

lut = vtk.vtkLookupTable()
lut.SetNumberOfColors(64)
lut.SetHueRange(0.66, 0)
lut.SetValueRange(1, 1)
lut.SetSaturationRange(1, 1)
lut.Build()

map = vtk.vtkPolyDataMapper()
map.SetInputConnection(hogs.GetOutputPort())
map.SetScalarRange(lo, hi)
map.SetLookupTable(lut)
コード例 #17
0
ファイル: TestCellDerivs.py プロジェクト: 151706061/VTK
 FileName += ".vtk"
 # make sure the directory is writeable first
 if (catch.catch(globals(),"""channel = open("" + str(dir) + "/test.tmp", "w")""") == 0):
     channel.close()
     file.delete("-force", "" + str(dir) + "/test.tmp")
     locals()[get_variable_name("", cell, "Writer")] = vtk.vtkUnstructuredGridWriter()
     locals()[get_variable_name("", cell, "Writer")].SetInputConnection(locals()[get_variable_name("", cell, "derivs")].GetOutputPort())
     locals()[get_variable_name("", cell, "Writer")].SetFileName(FileName)
     locals()[get_variable_name("", cell, "Writer")].Write()
     # delete the file
     file.delete("-force", FileName)
     pass
 locals()[get_variable_name("", cell, "Centers")] = vtk.vtkCellCenters()
 locals()[get_variable_name("", cell, "Centers")].SetInputConnection(locals()[get_variable_name("", cell, "derivs")].GetOutputPort())
 locals()[get_variable_name("", cell, "Centers")].VertexCellsOn()
 locals()[get_variable_name("", cell, "hog")] = vtk.vtkHedgeHog()
 locals()[get_variable_name("", cell, "hog")].SetInputConnection(locals()[get_variable_name("", cell, "Centers")].GetOutputPort())
 locals()[get_variable_name("", cell, "mapHog")] = vtk.vtkPolyDataMapper()
 locals()[get_variable_name("", cell, "mapHog")].SetInputConnection(locals()[get_variable_name("", cell, "hog")].GetOutputPort())
 locals()[get_variable_name("", cell, "mapHog")].SetScalarModeToUseCellData()
 locals()[get_variable_name("", cell, "mapHog")].ScalarVisibilityOff()
 locals()[get_variable_name("", cell, "hogActor")] = vtk.vtkActor()
 locals()[get_variable_name("", cell, "hogActor")].SetMapper(locals()[get_variable_name("", cell, "mapHog")])
 locals()[get_variable_name("", cell, "hogActor")].GetProperty().SetColor(0,1,0)
 locals()[get_variable_name("", cell, "Glyph3D")] = vtk.vtkGlyph3D()
 locals()[get_variable_name("", cell, "Glyph3D")].SetInputConnection(locals()[get_variable_name("", cell, "Centers")].GetOutputPort())
 locals()[get_variable_name("", cell, "Glyph3D")].SetSourceData(ball.GetOutput())
 locals()[get_variable_name("", cell, "CentersMapper")] = vtk.vtkPolyDataMapper()
 locals()[get_variable_name("", cell, "CentersMapper")].SetInputConnection(locals()[get_variable_name("", cell, "Glyph3D")].GetOutputPort())
 locals()[get_variable_name("", cell, "CentersActor")] = vtk.vtkActor()
 locals()[get_variable_name("", cell, "CentersActor")].SetMapper(locals()[get_variable_name("", cell, "CentersMapper")])
コード例 #18
0
subMapper = vtk.vtkPointGaussianMapper()
subMapper.SetInputConnection(norms.GetOutputPort())
subMapper.EmissiveOff()
subMapper.SetScaleFactor(0.0)

subActor = vtk.vtkActor()
subActor.SetMapper(subMapper)

# Draw the normals
mask = vtk.vtkMaskPoints()
mask.SetInputConnection(norms.GetOutputPort())
mask.SetRandomModeType(1)
mask.SetMaximumNumberOfPoints(250)

hhog = vtk.vtkHedgeHog()
hhog.SetInputConnection(mask.GetOutputPort())
hhog.SetVectorModeToUseNormal()
hhog.SetScaleFactor(0.25)

hogMapper = vtk.vtkPolyDataMapper()
hogMapper.SetInputConnection(hhog.GetOutputPort())

hogActor = vtk.vtkActor()
hogActor.SetMapper(hogMapper)

# Create an outline
outline = vtk.vtkOutlineFilter()
outline.SetInputConnection(points.GetOutputPort())

outlineMapper = vtk.vtkPolyDataMapper()
コード例 #19
0
# Show the vectors (gradient)
assign2 = vtk.vtkAssignAttribute()
assign2.SetInputConnection(dens0.GetOutputPort())
assign2.Assign("Gradient", "VECTORS", "POINT_DATA")

plane = vtk.vtkPlane()
plane.SetNormal(0, 0, 1)
plane.SetOrigin(0.0701652, 0.172689, 0.27271)

cut = vtk.vtkFlyingEdgesPlaneCutter()
cut.SetInputConnection(assign2.GetOutputPort())
cut.SetPlane(plane)
cut.InterpolateAttributesOn()

v = vtk.vtkHedgeHog()
v.SetInputConnection(cut.GetOutputPort())
v.SetScaleFactor(0.0001)

vMapper = vtk.vtkPolyDataMapper()
vMapper.SetInputConnection(v.GetOutputPort())
vMapper.SetScalarRange(vrange)

vectors = vtk.vtkActor()
vectors.SetMapper(vMapper)

# Create the RenderWindow, Renderer and both Actors
#
ren0 = vtk.vtkRenderer()
ren0.SetViewport(0, 0, 0.333, 1)
ren1 = vtk.vtkRenderer()
コード例 #20
0
ファイル: TestCellDerivs.py プロジェクト: leo1978/berks-vtk
     channel.close()
     file.delete("-force", "" + str(dir) + "/test.tmp")
     locals()[get_variable_name(
         "", cell, "Writer")] = vtk.vtkUnstructuredGridWriter()
     locals()[get_variable_name("", cell, "Writer")].SetInputConnection(
         locals()[get_variable_name("", cell, "derivs")].GetOutputPort())
     locals()[get_variable_name("", cell, "Writer")].SetFileName(FileName)
     locals()[get_variable_name("", cell, "Writer")].Write()
     # delete the file
     file.delete("-force", FileName)
     pass
 locals()[get_variable_name("", cell, "Centers")] = vtk.vtkCellCenters()
 locals()[get_variable_name("", cell, "Centers")].SetInputConnection(
     locals()[get_variable_name("", cell, "derivs")].GetOutputPort())
 locals()[get_variable_name("", cell, "Centers")].VertexCellsOn()
 locals()[get_variable_name("", cell, "hog")] = vtk.vtkHedgeHog()
 locals()[get_variable_name("", cell, "hog")].SetInputConnection(
     locals()[get_variable_name("", cell, "Centers")].GetOutputPort())
 locals()[get_variable_name("", cell, "mapHog")] = vtk.vtkPolyDataMapper()
 locals()[get_variable_name("", cell, "mapHog")].SetInputConnection(
     locals()[get_variable_name("", cell, "hog")].GetOutputPort())
 locals()[get_variable_name("", cell,
                            "mapHog")].SetScalarModeToUseCellData()
 locals()[get_variable_name("", cell, "mapHog")].ScalarVisibilityOff()
 locals()[get_variable_name("", cell, "hogActor")] = vtk.vtkActor()
 locals()[get_variable_name("", cell, "hogActor")].SetMapper(
     locals()[get_variable_name("", cell, "mapHog")])
 locals()[get_variable_name("", cell,
                            "hogActor")].GetProperty().SetColor(0, 1, 0)
 locals()[get_variable_name("", cell, "Glyph3D")] = vtk.vtkGlyph3D()
 locals()[get_variable_name("", cell, "Glyph3D")].SetInputConnection(