texture on mlab.surf #211

Closed
z--m-n opened this Issue Jul 7, 2015 · 7 comments

Comments

Projects
None yet
6 participants
@z--m-n

z--m-n commented Jul 7, 2015

I am trying to place a texture on a surface (mlab.surf). Instead, I see a surface with the mean pixel color of that texture image. I would appreciate a confirmation that this great feature (texture on mlab.surf) should still work as advertised and my installed system is to blame.

Similar code worked for me with mayavi 4.3 and vtk5 on a debian system. I did change the arguments passed to tvtk.Texture for it to work with mayavi 4.4.2 and vtk6 (via homebrew and virtenv+pip on OS X).

Thanks in advance!

EXAMPLE:

from tvtk.api import tvtk
from mayavi import mlab
import numpy as np

mlab.clf()

X,Y=np.mgrid[-1:1:20j,-1:1:20j]
Z = -np.cos(Y*X)+.5

img_filename='anyimage.jpg'
img=tvtk.JPEGReader(file_name=img_filename)
texture=tvtk.Texture(input_connection=img.output_port, interpolate=1)

# following produces a surface with a color that seems to be represent the mean img pixel.
s = mlab.surf(X,Y,Z,color=(1.,1.,1.))
s.actor.actor.mapper.scalar_visibility=False
s.actor.enable_texture=True
s.actor.tcoord_generator_mode='plane'
s.actor.actor.texture=texture

# but the texture itself works!
from mayavi.sources.api import BuiltinSurface
p = mlab.pipeline.surface( BuiltinSurface(source='plane') )
p.actor.actor.texture=texture```
@z--m-n

This comment has been minimized.

Show comment
Hide comment
@z--m-n

z--m-n Jul 10, 2015

The issue could be reproduced with the above example on a linux system (ubuntu 14.04, mayavi 4.4.2, vtk 6.0, wxpython 2.8).

z--m-n commented Jul 10, 2015

The issue could be reproduced with the above example on a linux system (ubuntu 14.04, mayavi 4.4.2, vtk 6.0, wxpython 2.8).

@itziakos itziakos added the bug label Jul 10, 2015

@itziakos itziakos added this to the Mayavi 4.4.4 milestone Aug 12, 2015

@andrewcollette

This comment has been minimized.

Show comment
Hide comment
@andrewcollette

andrewcollette Jan 22, 2016

Member

I can confirm this problem exists on Windows 7 (64-bit) as well. Textures seem to work on flat objects but I can't get them to work with objects generated using surf or mesh. Manually constructing a pipeline using mlab.pipeline.array2d_source and mlab.pipeline.scalar_field, as opposed to the BuiltinSurface, also don't work.

Any ideas for a workaround? I am trying to create a 3D terrain view for an Enthought customer demo next week...

Member

andrewcollette commented Jan 22, 2016

I can confirm this problem exists on Windows 7 (64-bit) as well. Textures seem to work on flat objects but I can't get them to work with objects generated using surf or mesh. Manually constructing a pipeline using mlab.pipeline.array2d_source and mlab.pipeline.scalar_field, as opposed to the BuiltinSurface, also don't work.

Any ideas for a workaround? I am trying to create a 3D terrain view for an Enthought customer demo next week...

@z--m-n

This comment has been minimized.

Show comment
Hide comment
@z--m-n

z--m-n Jan 26, 2016

I could also not get the mlab.pipeline methods to work. The issue may be related, and would explain why also the 'many lines' example is not working on affected systems (see other bug reports).

An elaborate workaround is to draw the terrain pixel by pixel, assuming your terrain map is a geoTIFF or similar 2d matrix source. For instance, as point3d (cubes with scale_factor set to the elevation map grid space, z reduced by half the scale_factor), or as triangular_mesh using two triangles per pixel.

z--m-n commented Jan 26, 2016

I could also not get the mlab.pipeline methods to work. The issue may be related, and would explain why also the 'many lines' example is not working on affected systems (see other bug reports).

An elaborate workaround is to draw the terrain pixel by pixel, assuming your terrain map is a geoTIFF or similar 2d matrix source. For instance, as point3d (cubes with scale_factor set to the elevation map grid space, z reduced by half the scale_factor), or as triangular_mesh using two triangles per pixel.

@farensheep

This comment has been minimized.

Show comment
Hide comment
@farensheep

farensheep Feb 1, 2016

Same for me : mean value data instead of RGB data. I work with Windows 7 and mayavi 4.4.0. I try to downgrade mayavi module to 3.3.1 and it works perfectly !

Same for me : mean value data instead of RGB data. I work with Windows 7 and mayavi 4.4.0. I try to downgrade mayavi module to 3.3.1 and it works perfectly !

@kitchoi kitchoi referenced this issue Apr 5, 2016

Merged

Fix texture #335

@kitchoi

This comment has been minimized.

Show comment
Hide comment
@kitchoi

kitchoi Apr 5, 2016

Member

#335 should fix the problem. As you can see here that a patch to your own build is quite simple.

Member

kitchoi commented Apr 5, 2016

#335 should fix the problem. As you can see here that a patch to your own build is quite simple.

@lmkli

This comment has been minimized.

Show comment
Hide comment
@lmkli

lmkli Jul 13, 2016

I don't think the problem is fixed.
I tried the script from #335 and can only get the correct texture on the ''cylinder" case, while the other two are both failed.

lmkli commented Jul 13, 2016

I don't think the problem is fixed.
I tried the script from #335 and can only get the correct texture on the ''cylinder" case, while the other two are both failed.

@lmkli

This comment has been minimized.

Show comment
Hide comment
@lmkli

lmkli Jul 13, 2016

updated:
I modified the actor.py file and got the three cases work well.
But the I still can not make it work for 'mesh' object ...

lmkli commented Jul 13, 2016

updated:
I modified the actor.py file and got the three cases work well.
But the I still can not make it work for 'mesh' object ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment