Colouring a Surface from a set of Points
2012-08-06 10:27:49 GMT
I have an annoying problem that I can't seem to solve at all.
I am using a set of points (generated from ~50 streamlines) to generate a surface that supposedly follows my magnetic fieldlines. I am using the SurfaceReconstructionFilter to generate a ImageData set from which the isosurface is generated. Then once I have the isosurface I extract the PolyData for the surface and use the normals to generate a velocity perpendicular to the surface.
The problem comes when I want to then colour the isosurface with the values I have just calculated. I have tried to go back and find an attribute in the ImageData set to set some scalar point data and use that to colour the surface but nothing I try seems to work.
Here is the code snippet I am using:
#My magnetic field
bfield = mlab.pipeline.vector_field(f.w_sac['b3'][cube_slice] * 1e3,
f.w_sac['b2'][cube_slice] * 1e3,
f.w_sac['b1'][cube_slice] * 1e3,
#This uses a custom subclass of Streamline so I can manually set the seed points.
field_lines = sStreamline(seed_points = np.array(seeds))
#Get the points from the streamlines
f_lines = field_lines.outputs.points
f_points = tvtk.PolyData(points=f_lines)
#Create the surface
sr = tvtk.SurfaceReconstructionFilter(input=f_points,sample_spacing=spacing)
#Add the surface to Mayavi
tube = mlab.pipeline.surface(sr.output)
tube.contour.auto_contours = False
tube.contour.contours = [0.0]
#Get and compute the normals
tube_PD = tube.contour.outputs
norms = tvtk.PolyDataNormals()
norms.input = tube_PD
norms.compute_point_normals = True
norms.flip_normals = True
normals = np.array(norms.output.point_data.normals)
#Calculate the projection of V on the normal vector.
vperp = 
for i, perp in enumerate(normals):
vperp = np.array(vperp)
#Now I wish to colour tube with the vperp array.
Any suggestions would be greatly appreciated!
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________ MayaVi-users mailing list MayaVi-users <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mayavi-users