Ondrej Certik | 20 Jul 03:16

show mesh in mayavi2, segfault

Hi,

I'd like to visualize a finite element mesh in mayavi2. I have it in
.vtk file. Is there a way to tell mayavi2 to show it? I didn't figure
it out.

So I adapted this script:

http://paste.debian.net/11654/

and it works fine, it shows 4 triangles. Now I'd like to import our
FEM package that can read the .vtk file and get the mesh data, but
mayavi2 segfaults, if I uncomment the line 15 in the above script...
How is that possible?

Here is the gdb trace:

$ gdb python
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
(gdb) run show_grid.py
Starting program: /usr/bin/python show_grid.py
[Thread debugging using libthread_db enabled]
[New Thread 0xb7d768c0 (LWP 30519)]

(Continue reading)

Prabhu Ramachandran | 20 Jul 04:46

Re: show mesh in mayavi2, segfault

Ondrej Certik wrote:
> Hi,
> 
> I'd like to visualize a finite element mesh in mayavi2. I have it in
> .vtk file. Is there a way to tell mayavi2 to show it? I didn't figure
> it out.

This should work:

$ mayavi2 -d foo.vtk -m Outline -m IsoSurface

BTW, which version of mayavi2 are you talking about?

$ mayavi2 -V

should help.

> So I adapted this script:
> 
> http://paste.debian.net/11654/
> 
> and it works fine, it shows 4 triangles. Now I'd like to import our
> FEM package that can read the .vtk file and get the mesh data, but
> mayavi2 segfaults, if I uncomment the line 15 in the above script...
> How is that possible?

Good question.  Can you run the script like so:

$ mayavi2 -x show_grid.py

(Continue reading)

Ondrej Certik | 21 Jul 02:15

Re: show mesh in mayavi2, segfault

On Sun, Jul 20, 2008 at 4:46 AM, Prabhu Ramachandran
<prabhu@...> wrote:
> Ondrej Certik wrote:
>> Hi,
>>
>> I'd like to visualize a finite element mesh in mayavi2. I have it in
>> .vtk file. Is there a way to tell mayavi2 to show it? I didn't figure
>> it out.
>
> This should work:
>
> $ mayavi2 -d foo.vtk -m Outline -m IsoSurface

It says:

ERROR|2008-07-21 02:04:30,892|Cannot contour: No scalars in input data!

paraview shows the mesh just fine. The mesh file is attached.

>
> BTW, which version of mayavi2 are you talking about?
>
> $ mayavi2 -V
>
> should help.

$ mayavi2 -V
MayaVi 2.2.0

>
(Continue reading)

Gael Varoquaux | 21 Jul 02:26

Re: show mesh in mayavi2, segfault

On Mon, Jul 21, 2008 at 02:15:37AM +0200, Ondrej Certik wrote:
> > This should work:

> > $ mayavi2 -d foo.vtk -m Outline -m IsoSurface

> It says:

> ERROR|2008-07-21 02:04:30,892|Cannot contour: No scalars in input data!

Isn't the error message clear (:->), it is trying to contour the surface,
but it cannot, because there are no scalars defined :). You can view your
file using

$ mayavi2 -d foo.vtk -m Outline -m Surface

I just tried, and it works. But that doesn't solve your main problem,
that is that what you tried first should work.

> $ mayavi2 -x show_grid.py
> bug-buddy: symbol lookup error: /usr/lib/libxml2.so.2: undefined
> symbol: gzopen64

> The same as before:

> $ python show_grid.py
> bug-buddy: symbol lookup error: /usr/lib/libxml2.so.2: undefined
> symbol: gzopen64

Damn. This works on my box (ubuntu hardy) both with mayavi2 from branches
and trunk. I suspect a distribution problem. This reference to an
(Continue reading)

Ondrej Certik | 21 Jul 11:05

Re: show mesh in mayavi2, segfault

On Mon, Jul 21, 2008 at 2:26 AM, Gael Varoquaux
<gael.varoquaux@...> wrote:
> On Mon, Jul 21, 2008 at 02:15:37AM +0200, Ondrej Certik wrote:
>> > This should work:
>
>> > $ mayavi2 -d foo.vtk -m Outline -m IsoSurface
>
>> It says:
>
>> ERROR|2008-07-21 02:04:30,892|Cannot contour: No scalars in input data!
>
> Isn't the error message clear (:->), it is trying to contour the surface,
> but it cannot, because there are no scalars defined :). You can view your
> file using
>
> $ mayavi2 -d foo.vtk -m Outline -m Surface
>
> I just tried, and it works. But that doesn't solve your main problem,
> that is that what you tried first should work.

It only shows a white rectangle, for me. I would like to see the
actual mesh. If you do "paraview --data=mesh.vtk", click apply and
then set Display->Style->Representation->    Surface With Edges   (it
is a popup on the toolbar), it shows the mesh. 10x10 in this case.

I need it to debug my mesh generator, so I want to craft a little
python script that shows me the result immediately, without having to
point and click with a mouse. Also I want to customize the output for
my particular case (e.g. maybe put this option and code directly to
the mesh generator) and I think mayavi2 is perfectly suited for this.
(Continue reading)

fred | 21 Jul 11:33

Re: show mesh in mayavi2, segfault

Ondrej Certik a écrit :

> It only shows a white rectangle, for me. I would like to see the
> actual mesh. If you do "paraview --data=mesh.vtk", click apply and
> then set Display->Style->Representation->    Surface With Edges   (it
> is a popup on the toolbar), it shows the mesh. 10x10 in this case.
Ondrej,

Double-click on Surface module in the tree, then in Property,
select Representation: wireframe.

It does what you want.

> I need it to debug my mesh generator, so I want to craft a little
> python script that shows me the result immediately, without having to
> point and click with a mouse. Also I want to customize the output for
> my particular case (e.g. maybe put this option and code directly to
> the mesh generator) and I think mayavi2 is perfectly suited for this.
Absolutely ;-)

Please see the attached file.

Cheers,

--

-- 
Fred
Attachment (a.py): text/x-python, 608 bytes
_______________________________________________
(Continue reading)

Ondrej Certik | 21 Jul 13:49

Re: show mesh in mayavi2, segfault

On Mon, Jul 21, 2008 at 11:33 AM, fred <fredmfp <at> gmail.com> wrote:
> Ondrej Certik a écrit :
>
>> It only shows a white rectangle, for me. I would like to see the
>> actual mesh. If you do "paraview --data=mesh.vtk", click apply and
>> then set Display->Style->Representation->    Surface With Edges   (it
>> is a popup on the toolbar), it shows the mesh. 10x10 in this case.
>
> Ondrej,
>
> Double-click on Surface module in the tree, then in Property,
> select Representation: wireframe.
>
> It does what you want.

Yes! Thanks a lot, that's exactly what I wanted. Is there a way to see
the Representation popup in the mayavi2 window directly, without
having to call double click on the Surface module?

>
>> I need it to debug my mesh generator, so I want to craft a little
>> python script that shows me the result immediately, without having to
>> point and click with a mouse. Also I want to customize the output for
>> my particular case (e.g. maybe put this option and code directly to
>> the mesh generator) and I think mayavi2 is perfectly suited for this.
>
> Absolutely ;-)
>
> Please see the attached file.

(Continue reading)

fred | 21 Jul 14:31

Re: show mesh in mayavi2, segfault

Ondrej Certik a écrit :
>
> Yes! Thanks a lot, that's exactly what I wanted. Is there a way to see
> the Representation popup in the mayavi2 window directly, without
> having to call double click on the Surface module?
Dunno :-(

> Yes, it does exactly what I wanted. Thanks again. Is there a way to
> script mayavi from ipython? If I do the following, it breaks:
> 
> In [1]: from enthought.mayavi.scripts import mayavi2
> 
> In [2]: mayavi2.standalone(globals())
Yes, I think this is only meaningful in a script.

You can do what you want like this:

marsu[pts/3]:~/{6}/> ipython -wthread
Python 2.5.2 (r252:60911, Apr  7 2008, 01:11:55)
Type "copyright", "credits" or "license" for more information.

IPython 0.8.3.svn.r3001 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

marsu:~/{1}/> from enthought.mayavi.app import Mayavi

marsu:~/{2}/> from enthought.mayavi.sources.vtk_file_reader import 
(Continue reading)

Prabhu Ramachandran | 21 Jul 14:50

Re: show mesh in mayavi2, segfault

Ondrej Certik wrote:
>> Double-click on Surface module in the tree, then in Property,
>> select Representation: wireframe.
>>
>> It does what you want.
> 
> Yes! Thanks a lot, that's exactly what I wanted. Is there a way to see
> the Representation popup in the mayavi2 window directly, without
> having to call double click on the Surface module?

It should!  There should be a pane for mayavi object editor below the 
tree view that allows you to set the objects properties.  Don't you get 
that?  I'll admit that the UI For that can be a bit painful with funky 
scrollbars etc. but the pane should be there below the tree view. 
single clicking on a node should bring up the UI for that node there.

> Yes, it does exactly what I wanted. Thanks again. Is there a way to
> script mayavi from ipython? If I do the following, it breaks:
> 
> In [1]: from enthought.mayavi.scripts import mayavi2
> 
> In [2]: mayavi2.standalone(globals())

*NEVER* use that standalone line.  As the comment on the example states, 
this is only a hack to allow users to run the script as python script.py.

Fred has the right idea for scripting but even easier might be the mlab 
interface like this:

$ ipython -wthread
(Continue reading)

fred | 21 Jul 16:14

Re: show mesh in mayavi2, segfault

Prabhu Ramachandran a écrit :

> Fred has the right idea for scripting but even easier might be the mlab 
> interface like this:
Yep !

I should had wrote : "If I was Gaël, I would advice you to use mlab to 
do this trick." ;-))
because I don't know mlab so much.

Cheers,

--

-- 
Fred
Gael Varoquaux | 23 Jul 09:45

Re: show mesh in mayavi2, segfault

On Mon, Jul 21, 2008 at 01:49:56PM +0200, Ondrej Certik wrote:
> On Mon, Jul 21, 2008 at 11:33 AM, fred <fredmfp@...> wrote:
> > Ondrej Certik a écrit :

> >> It only shows a white rectangle, for me. I would like to see the
> >> actual mesh. If you do "paraview --data=mesh.vtk", click apply and
> >> then set Display->Style->Representation->    Surface With Edges   (it
> >> is a popup on the toolbar), it shows the mesh. 10x10 in this case.

> > Ondrej,

> > Double-click on Surface module in the tree, then in Property,
> > select Representation: wireframe.

> > It does what you want.

> Yes! Thanks a lot, that's exactly what I wanted. Is there a way to see
> the Representation popup in the mayavi2 window directly, without
> having to call double click on the Surface module?

Actually, when I want to display cool meshes, I use something like

In [1]: from enthought.mayavi import mlab

# Somecode to create a mesh, it could really be anything.    
In [2]: from numpy import mgrid, random

In [3]: x, y = mgrid[0:5, 0:5]

In [4]: z = random.random(x.shape)
(Continue reading)

Gael Varoquaux | 23 Jul 09:46

Re: show mesh in mayavi2, segfault

I forgot to attach a screenshot, so that people who do not have mayavi
installed can see what visualisation this creates.

On Wed, Jul 23, 2008 at 09:45:08AM +0200, Gael Varoquaux wrote:
> On Mon, Jul 21, 2008 at 01:49:56PM +0200, Ondrej Certik wrote:
> > On Mon, Jul 21, 2008 at 11:33 AM, fred <fredmfp@...> wrote:
> > > Ondrej Certik a écrit :

> > >> It only shows a white rectangle, for me. I would like to see the
> > >> actual mesh. If you do "paraview --data=mesh.vtk", click apply and
> > >> then set Display->Style->Representation->    Surface With Edges   (it
> > >> is a popup on the toolbar), it shows the mesh. 10x10 in this case.

> > > Ondrej,

> > > Double-click on Surface module in the tree, then in Property,
> > > select Representation: wireframe.

> > > It does what you want.

> > Yes! Thanks a lot, that's exactly what I wanted. Is there a way to see
> > the Representation popup in the mayavi2 window directly, without
> > having to call double click on the Surface module?

> Actually, when I want to display cool meshes, I use something like

> In [1]: from enthought.mayavi import mlab

> # Somecode to create a mesh, it could really be anything.    
> In [2]: from numpy import mgrid, random
(Continue reading)

Ondrej Certik | 23 Jul 11:27

Re: show mesh in mayavi2, segfault

On Wed, Jul 23, 2008 at 9:45 AM, Gael Varoquaux
<gael.varoquaux <at> normalesup.org> wrote:
> On Mon, Jul 21, 2008 at 01:49:56PM +0200, Ondrej Certik wrote:
>> On Mon, Jul 21, 2008 at 11:33 AM, fred <fredmfp <at> gmail.com> wrote:
>> > Ondrej Certik a écrit :
>
>> >> It only shows a white rectangle, for me. I would like to see the
>> >> actual mesh. If you do "paraview --data=mesh.vtk", click apply and
>> >> then set Display->Style->Representation->    Surface With Edges   (it
>> >> is a popup on the toolbar), it shows the mesh. 10x10 in this case.
>
>> > Ondrej,
>
>> > Double-click on Surface module in the tree, then in Property,
>> > select Representation: wireframe.
>
>> > It does what you want.
>
>> Yes! Thanks a lot, that's exactly what I wanted. Is there a way to see
>> the Representation popup in the mayavi2 window directly, without
>> having to call double click on the Surface module?
>
> Actually, when I want to display cool meshes, I use something like
>
> In [1]: from enthought.mayavi import mlab
>
> # Somecode to create a mesh, it could really be anything.
> In [2]: from numpy import mgrid, random
>
> In [3]: x, y = mgrid[0:5, 0:5]
(Continue reading)

Dave Peterson | 23 Jul 19:33

Re: show mesh in mayavi2, segfault

Ondrej Certik wrote:
> What are the ETS coding standards? Just
> Python Coding Style Guidelines?
>   

We have a coding standard document linked off the Enthought wiki in the 
developer section.  Yes, it is based on PEP8 / Python Coding Style 
Guidelines.

-- Dave
Ondrej Certik | 1 Aug 16:25

Re: show mesh in mayavi2, segfault

On Wed, Jul 23, 2008 at 7:33 PM, Dave Peterson <dpeterson@...> wrote:
> Ondrej Certik wrote:
>> What are the ETS coding standards? Just
>> Python Coding Style Guidelines?
>>
>
> We have a coding standard document linked off the Enthought wiki in the
> developer section.  Yes, it is based on PEP8 / Python Coding Style
> Guidelines.

I wasn't able to find it -- I google enthought wiki, I also went here:

http://www.scipy.org/Developer_Zone

but haven't found the coding style guidelines. I also tried

wiki.enthought.com
enthought.com
scipy.org, search for coding style,

but haven't found anything.  Could you please send me a link?

Thanks,
Ondrej
Janet Swisher | 1 Aug 17:23

Enthought coding standard

Ondrej Certik wrote:
> On Wed, Jul 23, 2008 at 7:33 PM, Dave Peterson <dpeterson@...> wrote:
>> Ondrej Certik wrote:
>>> What are the ETS coding standards? Just
>>> Python Coding Style Guidelines?
>>>
>> We have a coding standard document linked off the Enthought wiki in the
>> developer section.  Yes, it is based on PEP8 / Python Coding Style
>> Guidelines.
> 
> I wasn't able to find it -- I google enthought wiki, I also went here:
> 
> http://www.scipy.org/Developer_Zone
> 
> but haven't found the coding style guidelines. I also tried
> 
> wiki.enthought.com
> enthought.com
> scipy.org, search for coding style,
> 
> but haven't found anything.  Could you please send me a link?

It is linked off the Enthought Trac front page, but the location itself 
is obscure:

https://svn.enthought.com/enthought/browser/sandbox/docs/coding_standard.py

--

-- 
Janet Swisher, Sr. Technical Writer
Enthought, Inc., http://www.enthought.com
(Continue reading)

Robert Kern | 1 Aug 22:10

Re: show mesh in mayavi2, segfault

On Fri, Aug 1, 2008 at 09:25, Ondrej Certik <ondrej@...> wrote:
> On Wed, Jul 23, 2008 at 7:33 PM, Dave Peterson <dpeterson@...> wrote:
>> Ondrej Certik wrote:
>>> What are the ETS coding standards? Just
>>> Python Coding Style Guidelines?
>>>
>>
>> We have a coding standard document linked off the Enthought wiki in the
>> developer section.  Yes, it is based on PEP8 / Python Coding Style
>> Guidelines.
>
> I wasn't able to find it -- I google enthought wiki, I also went here:
>
> http://www.scipy.org/Developer_Zone
>
> but haven't found the coding style guidelines. I also tried
>
> wiki.enthought.com
> enthought.com
> scipy.org, search for coding style,
>
> but haven't found anything.  Could you please send me a link?

https://svn.enthought.com/enthought/

Under "Development Info".

--

-- 
Robert Kern

(Continue reading)

Ondrej Certik | 1 Aug 22:46

Re: show mesh in mayavi2, segfault

On Fri, Aug 1, 2008 at 10:10 PM, Robert Kern <robert.kern@...> wrote:
> On Fri, Aug 1, 2008 at 09:25, Ondrej Certik <ondrej@...> wrote:
>> On Wed, Jul 23, 2008 at 7:33 PM, Dave Peterson <dpeterson@...> wrote:
>>> Ondrej Certik wrote:
>>>> What are the ETS coding standards? Just
>>>> Python Coding Style Guidelines?
>>>>
>>>
>>> We have a coding standard document linked off the Enthought wiki in the
>>> developer section.  Yes, it is based on PEP8 / Python Coding Style
>>> Guidelines.
>>
>> I wasn't able to find it -- I google enthought wiki, I also went here:
>>
>> http://www.scipy.org/Developer_Zone
>>
>> but haven't found the coding style guidelines. I also tried
>>
>> wiki.enthought.com
>> enthought.com
>> scipy.org, search for coding style,
>>
>> but haven't found anything.  Could you please send me a link?
>
> https://svn.enthought.com/enthought/
>
> Under "Development Info".

Ah, here it is:

(Continue reading)

Prabhu Ramachandran | 21 Jul 14:38

Re: show mesh in mayavi2, segfault

Ondrej Certik wrote:
>>> $ mayavi2 -x show_grid.py
>>> bug-buddy: symbol lookup error: /usr/lib/libxml2.so.2: undefined
>>> symbol: gzopen64
[...]
> I got the same error when I was exporting LD_LIBRARY_PATH to Sage, so
> libxml2.so was using Sage's libz and that broke stuff. So I removed
> that LD_LIBRARY_PATH and all is ok.

Sorry, am confused.  Are you saying the issue is solved when you unset 
the LD_LIBRARY_PATH env var?

>> I am not too sure that the problem is in the Mayavi2 or TVTK code base.
> 
> Do you (or anyone) have time to fix it? If so, I'll create you an

I think this is really an issue with sfepy and what it links to and what 
vtk is linking to.  For some reason they are stepping on each other.  I 
can't see how mayavi and tvtk come into the picture.  My guess is if you 
take a simple VTK example and stick an import sfepy up front, you'll get 
the same error.  VTK uses libxml and libz (among various other things). 
  You can either build VTK with the ones on the system or have it use 
its own internal copies of the library.  I have no idea how your system 
is setup or how the debian build is setup for this.  Doing an ldd on the 
vtk libs and on sfepy may help.

> account on a box where it breaks, so that you can investigate.
> I prepared everything, I can reproduce it even over "ssh -X", it seems
> the bug is on any Debian sid, both i386 and amd64. Send me your public
> ssh key offlist.
(Continue reading)

Ondrej Certik | 21 Jul 15:07

Re: show mesh in mayavi2, segfault

On Mon, Jul 21, 2008 at 2:38 PM, Prabhu Ramachandran
<prabhu@...> wrote:
> Ondrej Certik wrote:
>>>> $ mayavi2 -x show_grid.py
>>>> bug-buddy: symbol lookup error: /usr/lib/libxml2.so.2: undefined
>>>> symbol: gzopen64
> [...]
>> I got the same error when I was exporting LD_LIBRARY_PATH to Sage, so
>> libxml2.so was using Sage's libz and that broke stuff. So I removed
>> that LD_LIBRARY_PATH and all is ok.
>
> Sorry, am confused.  Are you saying the issue is solved when you unset
> the LD_LIBRARY_PATH env var?

That solved the problem in the Sage case, but in mayavi2 case I
already had this LD_LIBRARY_PATH unset. So one can really
only use this trick once.

>
>>> I am not too sure that the problem is in the Mayavi2 or TVTK code base.
>>
>> Do you (or anyone) have time to fix it? If so, I'll create you an
>
> I think this is really an issue with sfepy and what it links to and what
> vtk is linking to.  For some reason they are stepping on each other.  I
> can't see how mayavi and tvtk come into the picture.  My guess is if you
> take a simple VTK example and stick an import sfepy up front, you'll get
> the same error.  VTK uses libxml and libz (among various other things).
>  You can either build VTK with the ones on the system or have it use
> its own internal copies of the library.  I have no idea how your system
(Continue reading)

Prabhu Ramachandran | 21 Jul 18:40

Re: show mesh in mayavi2, segfault

Ondrej Certik wrote:
> On Mon, Jul 21, 2008 at 2:38 PM, Prabhu Ramachandran
>> Sorry, am confused.  Are you saying the issue is solved when you unset
>> the LD_LIBRARY_PATH env var?
> 
> That solved the problem in the Sage case, but in mayavi2 case I
> already had this LD_LIBRARY_PATH unset. So one can really
> only use this trick once.

I see.

[...]

> apart from that it imports scipy + numpy + matplotlib. But importing
> scipy, numpy or matplotlib works. So I'll try to investigate
> and reduce the problem further.

The ldd output looks innocuous.  Could you try changing the order of the 
import?  Put the sfepy import after other mayavi imports. Can you do 
this on an IPython session for example?

> Thanks Fred and Prabhu for the tips, it works nice. This is much
> better, the mlab interface is what I wanted.

Cool!  I'm going to try and make the scripting interface a little easier 
if I can so we avoid a few imports.

> I think this brings a lot of new possibilities for 3D plots in SymPy.
> We should hook it in, so that one can use either pyglet or mayavi2.

(Continue reading)


Gmane