Colouring a Surface from a set of Points
2012-08-06 10:27:49 GMT
Hello,
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 fieldbfield = 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,
name="Magnetic Field")
#This uses a custom subclass of Streamline so I can manually set the seed points.
field_lines = sStreamline(seed_points = np.array(seeds))
bfield.add_child(field_lines)
#Get the points from the streamlines
f_lines = field_lines.outputs[0].points
f_points = tvtk.PolyData(points=f_lines)
#Create the surfacesr = tvtk.SurfaceReconstructionFilter(input=f_points,sample_spacing=spacing)
sr.update()
#Add the surface to Mayavitube = mlab.pipeline.surface(sr.output)
tube.enable_contours=True
tube.contour.auto_contours = False
tube.contour.contours = [0.0]
#Get and compute the normals
tube_PD = tube.contour.outputs[0]
norms = tvtk.PolyDataNormals()
norms.input = tube_PD
norms.compute_point_normals = True
norms.flip_normals = True
norms.update()
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.append(np.dot(perp, np.array([v3i[i],v2i[i],v1i[i]])))
vperp = np.array(vperp)
#Now I wish to colour tube with the vperp array.
Any suggestions would be greatly appreciated!
Thanks
Stuart
------------------------------------------------------------------------------ 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
RSS Feed