Hello,

I have a question about masking in triangular meshes (I also posted this
question on stack overflow:
http://stackoverflow.com/questions/41948360/mayavi-mlab-masking-points-in-tr
iangular-mesh
but received no answers).
           
I need to generate an irregular triangular mesh with Mayavi, and mask some
of the points. If I use the mask option with a normal mesh, I get what I
want, but I'm currently unable to get the same with an irregular mesh.
The relevant piece of code I'm using (modified from an example in the
documentation) is:

import numpy
import mayavi.mlab as ml

def test_triangular_mesh():
    """An example of a cone, ie a non-regular mesh defined by its
        triangles.
    """
    n = 8
    t = numpy.linspace(-numpy.pi, numpy.pi, n)
    z = numpy.exp(1j * t)
    x = z.real.copy()
    y = z.imag.copy()
    z = numpy.zeros_like(x)

    triangles = [(0, i, i + 1) for i in range(1, n)]
    x = numpy.r_[0, x]
    y = numpy.r_[0, y]
    z = numpy.r_[1, z]
    t = numpy.r_[0, t]

    mask=numpy.array([True, False, True, True, False, False, False, False])

    return ml.triangular_mesh(x, y, z, triangles,
representation='wireframe', color=(0,0,0), mask=mask )

mesh = test_triangular_mesh()
ml.show()

By contrast, this code works:

import numpy as np
phi, theta = np.mgrid[0:np.pi:10j, 0:2 * np.pi:10j]
x = np.sin(phi) * np.cos(theta)
y = np.sin(phi) * np.sin(theta)
z = np.cos(phi)
mask = ( ( phi < 2*np.pi/3. ) & ( phi > np.pi/3. ) )

from mayavi import mlab
mlab.mesh(x, y, z, representation='wireframe', color=(0,0,0), mask=mask)

Can you please tell me how to obtain the same masking effect as the regular
mesh option with an irregular triangular mesh?

Thanks in advance!




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
MayaVi-users mailing list
MayaVi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to