[vtkusers] Problem with streamline

Mohammad Nazrul Islam int64380 at stud.uni-stuttgart.de
Fri Feb 15 05:46:46 EST 2008


Hi all,

I am trying to plot series of streamline from my x, y, z position vector file. and I have written the following code and i am getting the output from triangulaton but not from vtkstreamline. I am trying to solve but could not yet. could anybody help pls

def readpoints(filename):
 
 points=vtk.vtkPoints()
 
 file=open(filename,"r")
 line=file.readline()
 lines=0
 while file:
  line = file.readline()
  if line == "":
   break
  line = str.rstrip(line)
  cols =line.split('	')
  if len(cols)  <3:
   if line.find('-') == 0:
    print "Treating as options: ",line
    processOption(line)
   else: 
    print "Omitting line: ", line
    continue
 
  x=cols[0]
  y=cols[1]
  z=cols[2]

  points.SetNumberOfPoints(lines)
  points.InsertNextPoint(float(x),float(y), float(z))
  lines+=1
 
 
 scalars=vtk.vtkFloatArray()
 scalars.SetNumberOfTuples(lines)
  
 vector=vtk.vtkFloatArray()
 vector.SetNumberOfComponents(3)
 vector.SetNumberOfTuples(lines)
 
 slineGrid=vtk.vtkStructuredGrid()
 slineGrid.GetPointData().SetScalars(scalars)
 slineGrid.GetPointData().SetVectors(vector)
 slineGrid.GetPointData().AddArray
 slineGrid.SetPoints(points)
 
 
 
 delny = vtk.vtkDelaunay3D()
 delny.SetInput(slineGrid)
 delny.SetTolerance(1)
 delny.SetAlpha(5)
 delny.BoundingTriangulationOff()

 #Shrink the result to help see it better.
 shrink = vtk.vtkShrinkFilter()
 shrink.SetInputConnection(delny.GetOutputPort())
 shrink.SetShrinkFactor(0.9)

 
 map = vtk.vtkDataSetMapper()
 map.SetInputConnection(delny.GetOutputPort())

 triangulation = vtk.vtkActor()
 triangulation.SetMapper(map)
 triangulation.GetProperty().SetColor(1, 1, 1)
 	
 line=vtk.vtkLineSource()
 line.SetResolution(25)	
 
 integ=vtk.vtkRungeKutta4()
 
 streamline=vtk.vtkStreamLine()
 streamline.SetInput(delny.GetOutput()) 
 streamline.SetSource(line.GetOutput())
 streamline.SetMaximumPropagationTime(500)
 streamline.SetIntegrationStepLength(0.01)
 streamline.SetIntegrationDirectionToIntegrateBothDirections() 
 streamline.SetStepLength(0.001)
 streamline.SetIntegrator(integ)
 
 mapstreamline=vtk.vtkPolyDataMapper()
 mapstreamline.SetInputConnection(streamline.GetOutputPort())
 streamlineActor=vtk.vtkActor()
 streamlineActor.SetMapper(mapstreamline)
 return lines
and then the rendering staff. 




thanks in advance/


Nazrul



More information about the vtkusers mailing list