Mayavi: how to probe normal data?

10 messages
Open this post in threaded view
|

Mayavi: how to probe normal data?

 I need to know the normals to an isosurface at specified points.  Using my_contour.normals.filter.output.points.to_array() appears to return all the normals, but it is not clear how to identify which normal corresponds to which point.  In particular, the number of normals returned is generally different from the number of point or of polys. I tried a more direct approach using probe_data, but what is returned is the scalar only, not the normal, at the specified point.  How can I access the normal at a given point?Here is some sample code to show what I am trying to do: =========8<-------------------------from mayavi import mlabfrom numpy import mgrid, array, reshape N=5x, y, z = mgrid[-1.:1.:N*1j, -.5:.5:N*1j, -.2:.2:N*1j]t = x**2 + 4*y**2 + 25*z**2 cont = mlab.contour3d( x,y,z,t, contours=[0.9, ], opacity=.5 )xyz = array((.57735,0.28875,0.11547))xyz *= 0.94868xyz0 = (0,0,0)XYZ = zip(xyz0, xyz)mlab.plot3d(XYZ[0], XYZ[1], XYZ[2])a = cont.normals.filter.output # this returns the scalar (0.9) only:mlab.pipeline.probe_data(a, xyz[0], xyz[1], xyz[2])# normals data is not in 'vectors' either:# mlab.pipeline.probe_data(a, xyz[0], xyz[1], xyz[2], type='vectors') # the array of normals has different dimensions and points or polys:a1 = cont.normals.filter.output.points.to_array()print 'normals shape', a1.shapeb = cont.contour.contour_filter.output.polys.to_array() b = reshape(b, (b.size / 4., 4))[:, 1:]print 'polys shape', b.shapec = cont.contour.contour_filter.output.points.to_array()print 'points shape', c.shape _______________________________________________ Enthought-Dev mailing list [hidden email] https://mail.enthought.com/mailman/listinfo/enthought-dev
Open this post in threaded view
|

Re: Mayavi: how to probe normal data?

 On Wed, Nov 14, 2012 at 12:48:34PM -0800, Robert Stephenson wrote: > I need to know the normals to an isosurface at specified points.  Using > my_contour.normals.filter.output.points.to_array() appears to return all the > normals, but it is not clear how to identify which normal corresponds to which > point.  In particular, the number of normals returned is generally different > from the number of point or of polys. I would say (haven't checked), that if you do the following: normals = iso.normals.filter.output.points.to_array() pd = iso.contour.outputs[0] polys = pd.polys.to_array() polys is now the array of polygon points, in the format (n_pts, pts1, pts2, pt3s, ... n_pts, pts1, pts2, ...) as explained for lines on http://docs.enthought.com/mayavi/mayavi/data.html#extracting-linesi.e if the first number is '3', the next 3 are the point ids of a triangle, and again... The corresponding points are given in pd.points HTH, Gaël _______________________________________________ Enthought-Dev mailing list [hidden email] https://mail.enthought.com/mailman/listinfo/enthought-dev
Open this post in threaded view
|

Mayavi Over line plot

 In reply to this post by Robert Stephenson Dear all; I am new in Mayavi. I would like to extract data (scalar) from .vtu file. Is it possible to have a function like "PLOT OVER LINE" of Paraview? Thank in advance for your helps. Arouna
Open this post in threaded view
|

Re: Mayavi Over line plot

 On Mon, Nov 19, 2012 at 09:08:49AM -0800, adarga wrote: > Is it possible to have a function like "PLOT OVER LINE" of Paraview? I don't know what that does, sorry. Cheers, Gaël _______________________________________________ Enthought-Dev mailing list [hidden email] https://mail.enthought.com/mailman/listinfo/enthought-dev
Open this post in threaded view
|

Re: Mayavi Over line plot

 Thank you for your response. A detail about "Paraview plot over line " can be found here : http://www.paraview.org/Wiki/ParaView/Users_Guide/Plotting_and_Probing_DataIt consist of extraction of data over a straight line. For example, with a 2D or 3D figure, with "Plot over line ", I can extarct the data over one axis or profile of some quantity. Please excuse, if the explanation is not clear! I can provide some figures to illustrate my problem. Thank you in advance Arouna
Open this post in threaded view
|

Re: Mayavi Over line plot

 On Mon, Nov 19, 2012 at 09:26:10AM -0800, adarga wrote: > It consist of extraction of data over a straight line. For example, with a > 2D or 3D figure, with "Plot over line ", I can extarct the data over one > axis or profile of some quantity. OK. You can use probe_data for this purpose: http://docs.enthought.com/mayavi/mayavi/data.html#probing-data-at-given-positionsHope this helps, Gaël _______________________________________________ Enthought-Dev mailing list [hidden email] https://mail.enthought.com/mailman/listinfo/enthought-dev
Open this post in threaded view
|

Re: Mayavi: how to probe normal data?

 In reply to this post by Gael Varoquaux Thanks, Gael, for the reply.  What puzzles me is that the number of normals is not the same as the number of polys, both calculated as you suggest.  By playing with the pipeline viewer I discovered that the degree of this mismatch depends on the feature_angle property of the iso_surface.  Low feature_angles give very large numbers of normals and as the feature_angle increases the number of normals approaches the number of polys.  I haven't found much in the way of documentation on this -- perhaps I was looking in the wrong places? For my application, I need to know the surface normals at a handful of selected points on an iso-surface.  Any suggestions short of calculating them ab initio? If I explicitly  invoked the poly_data_normals filter on my surface would it behave more predictably, or is that what is used to generate the normals already? On Nov 17, 2012, at 6:26 AM, Gael Varoquaux wrote: > On Wed, Nov 14, 2012 at 12:48:34PM -0800, Robert Stephenson wrote: >> I need to know the normals to an isosurface at specified points.  Using >> my_contour.normals.filter.output.points.to_array() appears to return all the >> normals, but it is not clear how to identify which normal corresponds to which >> point.  In particular, the number of normals returned is generally different >> from the number of point or of polys. > > I would say (haven't checked), that if you do the following: > > normals = iso.normals.filter.output.points.to_array() > pd = iso.contour.outputs[0] > polys = pd.polys.to_array() > > polys is now the array of polygon points, in the format (n_pts, pts1, > pts2, pt3s, ... n_pts, pts1, pts2, ...) > as explained for lines on > http://docs.enthought.com/mayavi/mayavi/data.html#extracting-lines> i.e if the first number is '3', the next 3 are the point ids of a > triangle, and again... > > The corresponding points are given in pd.points > > HTH, > > Gaël > > _______________________________________________ > Enthought-Dev mailing list > [hidden email] > https://mail.enthought.com/mailman/listinfo/enthought-dev_______________________________________________ Enthought-Dev mailing list [hidden email] https://mail.enthought.com/mailman/listinfo/enthought-dev
Open this post in threaded view
|

Re: Mayavi: how to probe normal data?

 On Mon, Nov 19, 2012 at 11:48:35PM -0800, Robert S. Stephenson wrote: > Thanks, Gael, for the reply.  What puzzles me is that the number of > normals is not the same as the number of polys, both calculated as you > suggest.  By playing with the pipeline viewer I discovered that the > degree of this mismatch depends on the feature_angle property of the > iso_surface.  Low feature_angles give very large numbers of normals and > as the feature_angle increases the number of normals approaches the > number of polys. Indeed, you are right. The feature_angle is used to remove some triangles for which there is a large angle with the neighboring facets. > I haven't found much in the way of documentation on this -- perhaps I > was looking in the wrong places? For this level of technicity, you need to look in the VTK doc. It's kind of hairy. > For my application, I need to know the surface normals at a handful of > selected points on an iso-surface.  Any suggestions short of > calculating them ab initio? I am not sure. I have never done anything close to that. You might try increasing the feature_angle to the max and see if you can establish clear-cut correspondance. > If I explicitly  invoked the poly_data_normals filter on my surface > would it behave more predictably, or is that what is used to generate > the normals already? Indeed, it will not change anything. Sorry, you are going beyond anything I've tried. Gaël _______________________________________________ Enthought-Dev mailing list [hidden email] https://mail.enthought.com/mailman/listinfo/enthought-dev