That is exactly what I needed.
Is there a way to access the 'Capping' property for the tube filter? It
looks much better when activated.
-Tom
On Tue, Aug 25, 2009 at 06:03, Gael Varoquaux <[email protected]
> wrote:
> On Mon, Aug 24, 2009 at 11:54:20AM -0400, Tom Foutz wrote:
> > I have a number of lines which are all part of a single segment. When
> I
> > plot them all individually, it takes a long time, much longer than
> > plotting more complicated meshes. Is there a way I can display the
> lines
> > more efficiently? Is there a way I can make these one object in mlab,
> so
> > when I use the toolbar I don't get 30 different LineSource objects?
>
> First of all, here is an improved version of you demo script, simply
> coding thing a bit cleaner with Mayavi/numpy:
>
> from enthought.mayavi import mlab
> import numpy as np
>
> mlab.clf()
>
> # Number of lines
> n_lines = 200
> # Number of points per line
> n_points = 100
>
> # Create Example Coordinates
> xyz=[]
> for ii in xrange(n_lines):
> xyz.append(
> np.cumsum(np.random.random((n_points, 3)), axis=0)
> )
>
> fig = mlab.gcf()
> fig.scene.disable_render = True
> for this_xyz in xyz:
> x, y, z = this_xyz
> mlab.plot3d(x,
> y,
> z, tube_sides=7, tube_radius=0.1)
>
> fig.scene.disable_render = False
>
> Second, what you want is a graph: an object with a set of vertices
> connected in an arbitrary way. There are two examples of graphs in the
> Mayavi examples:
>
>
> http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/example_protein.html#example-protein
>
> http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/example_flight_graph.html#example-flight-graph
>
> The idea is that you specify the points and then their connections, as in
> index number of the flatten point array. This is a bit tedious, because
> it is easy to get it wrong, but of course, it is more powerful than the
> simple mlab.plot3d (that simply builds the connection array for you).
>
> Here is an example on your demo:
>
> from enthought.mayavi import mlab
> import numpy as np
>
> mlab.clf()
>
> # Number of lines
> n_lines = 200
> # Number of points per line
> n_points = 100
>
> # Create Example Coordinates
> xyz=[]
> for ii in xrange(n_lines):
> xyz.append(
> np.cumsum(np.random.random((n_points, 3)), axis=0)
> )
> xyz = np.array(xyz)
> x, y, z = xyz.T
> pts = mlab.pipeline.scalar_scatter(x.T, y.T, z.T)
>
> connections = []
> for i in range(n_lines):
> connections.append(np.c_[np.arange(i*n_points, (i+1)*n_points-1),
> np.arange(i*n_points+1, (i+1)*n_points)])
> pts.mlab_source.dataset.lines = np.vstack(connections)
> # First option: tubes
> if hasattr(mlab.pipeline, 'stripper'):
> lines = mlab.pipeline.surface(
> mlab.pipeline.tube(
> mlab.pipeline.stripper(
> pts,
> ),
> tube_sides=7, tube_radius=0.1,
> ),
> )
> else:
> lines = mlab.pipeline.surface(
> mlab.pipeline.tube(
> pts,
>
> ),
> tube_sides=7, tube_radius=0.1,
> ),
> )
>
> > (Also, as you can see in the demo below, each segment has a little
> space
> > between them. Is there any way I can connect them better so there is
> no
> > space between them? I was thinking about creating a sphere at each
> vertex
> > to fill the gap.)
>
> The right way to solve this is to use a stripper filter. It was added on
> August 3rd to Mayavi, and is used automatically by points3d, but is not
> in the released version. I added a check above to use it when available.
>
> HTH,
>
> Gaƫl
>
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
MayaVi-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mayavi-users