Dear all,<br>Thinking that my question went unnoticed, i am sending it again. i would appreciate any tips, in particular for displaying tubes with varying diameter.<br>Thank you<br>Sreejith<br><br><div class="gmail_quote">
On Fri, Apr 10, 2009 at 9:46 AM, Sreejith Kuttanikkad <span dir="ltr"><<a href="mailto:sreejithpk@gmail.com">sreejithpk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="gmail_quote"><br>Dear paraview,<br><br>Following the examples given in paraview wiki, i have made a script to create a network of lines. After that I apply both tube and glyph(sphere) filter on it and the resulting<br>
view is attached in the figure. But what i would like to have is to be able to create varying tube radius and varying sphere radius. Ihave the radii of each tube and sphere in a file and i like to be able to get this into paraview. Any help in this regard is appreciated. <br>
<div><div></div><div class="h5">
here is a sample script. <br><br>##---------------------script-----------------##<br>#!/usr/bin/python<br>#This is intended as the script of a 'Programmable Source'<br>#Get a paraview.vtk.PolyData object for the output<br>
pdo = self.GetPolyDataOutput()<br>filename="network.dat"<br>#Allocate the number of 'cells' that will be added. We are just<br>#adding one vtkPolyLine 'cell' to the vtkPolyData object.<br>no_of_tubes=7<br>
pdo.Allocate(no_of_tubes, 1)<br>#This will store the points for the lines<br>newPts = vtk.vtkPoints()<br>offset=0<br>file=open(filename,'r')<br>lines=file.readlines()<br>for line in lines:<br> # skip lines starting comment char #<br>
point=0<br> if line[0]=='#':<br> pass<br> else:<br> #read x,y,z values<br> #check 3d or 2d network<br> #end points of tube (x1,y1,z1) & (x2,y2,z2)<br> if(len(line.split())==6):<br>
x1 = float(line.split()[0])<br> x2 = float(line.split()[3])<br> y1 = float(line.split()[1])<br> y2 = float(line.split()[4])<br> z1 = float( line.split()[2])<br> z2 = float( line.split()[5])<br>
else:<br> x1 = float(line.split()[0])<br> x2 = float(line.split()[2])<br> y1 = float(line.split()[1])<br> y2 = float(line.split()[3])<br> z1=0.0<br> z2=0.0<br> #Insert the Points into the vtkPoints object<br>
#The first parameter indicates the reference.<br> #value for the point. Here we add them sequentially.<br> #Note that the first point is at index 0 (not 1).<br> newPts.InsertPoint(point+offset, x1,y1,z1)<br>
point+=1<br> pdo.SetPoints(newPts)<br> #print x1,y1,z1<br> newPts.InsertPoint(point+offset, x2,y2,z2)<br> point+=1<br> pdo.SetPoints(newPts)<br> <br> #print x2,y2,z2<br> #Add the points to the vtkPolyData object<br>
#Right now the points are not associated with a line - <br> #it is just a set of unconnected points. We need to<br> #create a 'cell' object that ties points together<br> #to make a curve (in this case). This is done below.<br>
#A 'cell' is just an object that tells how points are<br> #connected to make a 1D, 2D, or 3D object.<br> <br> #Make a vtkPolyLine which holds the info necessary<br> #to create a curve composed of line segments. This<br>
#really just hold constructor data that will be passed<br> #to vtkPolyData to add a new line.<br> aPolyLine = vtk.vtkPolyLine()<br> #Indicate the number of points along the line<br> aPolyLine.GetPointIds().SetNumberOfIds(point)<br>
for i in range(0,point):<br> #Add the points to the line. The first value indicates<br> #the order of the point on the line. The second value<br> #is a reference to a point in a vtkPoints object. Depends<br>
#on the order that Points were added to vtkPoints object.<br> #Note that this will not be associated with actual points<br> #until it is added to a vtkPolyData object which holds a<br> #vtkPoints object.<br>
aPolyLine.GetPointIds().SetId(i, i+offset)<br> #Add the poly line 'cell' to the vtkPolyData object.<br> offset+=point<br> pdo.InsertNextCell(aPolyLine.GetCellType(), aPolyLine.GetPointIds())<br>
file.close()<br><br><br></div></div>##----------- sample input file network.dat--------##<br>#end1 end2 <br><div class="im">0 0 0 1 0 0 <br>1 0 0 1 1 0<br>1 1 0 0 1 0<br>0 1 0 0 0 0<br>1 0 0 2 0 0<br>
2 0 0 2 1 0<br>2 1 0 1 1 0<br>
<br></div></div></blockquote></div><br>