Structured meshes with mlab

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Structured meshes with mlab

Lionel-3
Hi,

I want to display several types of structured mesh in my application, using
mlab's features. I currently achieve this using the triangular_mesh() function,
but it produces unstructured datas, which means I cannot attach some widgets
like the cut_plane to it. And it's all kind of a patchwork.

For instance, let's say I have a mesh made of faces (2D elements).
Those faces are quads, and each quad is given a scalar value, which will
determine its color (the colormap does it well).

What I do is : for each quad, I build appropriates triangles, and assign the
scalar value of the quad to each vertex.

What I would like to do is : use some kind of quad_mesh() function that
allows me to assign a scalar value for a whole quad. Since this would be
structured data, it also might do scalar interpolation when faces are connected
to others.

I would need this kind of feature for 3D elements (cells) as well. Is there
something appropriate in the mlab's world for this ?

My knowledge of VTK is very limited, but I know it has some
Structured / Unstructured distinction. How may I pick this up into mlab ?
If there is nothing appropriate at the moment, I am absolutely ready to
implement this as an mlab module, if you agree with this (though I might
need some guidelines).

Lionel


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Structured meshes with mlab

Gael Varoquaux
On Thu, Feb 18, 2010 at 02:23:26PM +0000, Lionel wrote:
> I want to display several types of structured mesh in my application,
> using mlab's features. I currently achieve this using the
> triangular_mesh() function, but it produces unstructured datas, which
> means I cannot attach some widgets like the cut_plane to it. And it's
> all kind of a patchwork.

Correct, you will be creating PolyData with triangular_mesh.

> For instance, let's say I have a mesh made of faces (2D elements).
> Those faces are quads, and each quad is given a scalar value, which will
> determine its color (the colormap does it well).

> What I do is : for each quad, I build appropriates triangles, and assign the
> scalar value of the quad to each vertex.

> What I would like to do is : use some kind of quad_mesh() function that
> allows me to assign a scalar value for a whole quad. Since this would
> be structured data, it also might do scalar interpolation when faces
> are connected to others.

> I would need this kind of feature for 3D elements (cells) as well. Is there
> something appropriate in the mlab's world for this ?

What you are describing is indeed an UnstructuredGrid, in terms of VTK.

mlab doesn't expose this fonctionality, as IMHO it is intrinsicaly
complicated, no need to try and simplify it. However, you can easily
create such objects manually, and then use mlab on them.

See
http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/data.html
and in particular
http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/data.html#unstructuredgrid

> My knowledge of VTK is very limited, but I know it has some
> Structured / Unstructured distinction. How may I pick this up into mlab ?
> If there is nothing appropriate at the moment, I am absolutely ready to
> implement this as an mlab module, if you agree with this (though I might
> need some guidelines).

If you can come up with a simple and clear API, it might be interesting,
but I fail to find a function signature that would not make the code more
complex then creating the object by hand.

HTH,

Gaël
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Structured meshes with mlab

Lionel-3
Gael Varoquaux wrote:

> On Thu, Feb 18, 2010 at 02:23:26PM +0000, Lionel wrote:
>> I want to display several types of structured mesh in my application,
>> using mlab's features. I currently achieve this using the
>> triangular_mesh() function, but it produces unstructured datas, which
>> means I cannot attach some widgets like the cut_plane to it. And it's
>> all kind of a patchwork.
>
> Correct, you will be creating PolyData with triangular_mesh.
>
>> For instance, let's say I have a mesh made of faces (2D elements).
>> Those faces are quads, and each quad is given a scalar value, which will
>> determine its color (the colormap does it well).
>
>> What I do is : for each quad, I build appropriates triangles, and assign the
>> scalar value of the quad to each vertex.
>
>> What I would like to do is : use some kind of quad_mesh() function that
>> allows me to assign a scalar value for a whole quad. Since this would
>> be structured data, it also might do scalar interpolation when faces
>> are connected to others.
>
>> I would need this kind of feature for 3D elements (cells) as well. Is there
>> something appropriate in the mlab's world for this ?
>
> What you are describing is indeed an UnstructuredGrid, in terms of VTK.
>
> mlab doesn't expose this fonctionality, as IMHO it is intrinsicaly
> complicated, no need to try and simplify it. However, you can easily
> create such objects manually, and then use mlab on them.
>
> See
> http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/data.html
> and in particular
> http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/data.html#unstructuredgrid
>
>> My knowledge of VTK is very limited, but I know it has some
>> Structured / Unstructured distinction. How may I pick this up into mlab ?
>> If there is nothing appropriate at the moment, I am absolutely ready to
>> implement this as an mlab module, if you agree with this (though I might
>> need some guidelines).
>
> If you can come up with a simple and clear API, it might be interesting,
> but I fail to find a function signature that would not make the code more
> complex then creating the object by hand.
>
> HTH,
>
> Gaël

This helped a lot Gaël, thanks.
However I did not manage to have an 'automatic' interpolation between
the cells of the grid, even a structured one.

I'm not sure if I make myself clear here, as I'm not too good with the
VTK vocabulary. The idea is to assign a scalar value to each cell of the
structured grid, then have VTK interpolate the actual scalar value for
each vertex of this cell, as if the original scalar was in the center of
the cell. For instance, if I had two adjacent cells with 2 values, say 0
and 1, with a blue -> red colormap, I would like to see the color going
progressively from blue to red on the face of the grid.

I also have a little problem with the mlab.pipeline.surface module. When
I apply such a module over an UnstructuredGrid, every volume will be
rendered with surfaces, which is what I want. However, when I apply it
to a StructuredGrid, it only makes faces for the whole grid, and not the
cells that are in it. Is there a way to reproduce the unstructured grid
behaviour ?

I thought that my needs are quite common, which is why I don't want to
code a toolbox for these functionalities before asking :)

Thanks,

Lionel

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Structured meshes with mlab

Gael Varoquaux
On Thu, Mar 04, 2010 at 10:21:18AM +0100, lionel wrote:
> Gael Varoquaux wrote:
> This helped a lot Gaël, thanks.
> However I did not manage to have an 'automatic' interpolation between
> the cells of the grid, even a structured one.

> I'm not sure if I make myself clear here, as I'm not too good with the
> VTK vocabulary. The idea is to assign a scalar value to each cell of the
> structured grid, then have VTK interpolate the actual scalar value for
> each vertex of this cell, as if the original scalar was in the center of
> the cell. For instance, if I had two adjacent cells with 2 values, say 0
> and 1, with a blue -> red colormap, I would like to see the color going
> progressively from blue to red on the face of the grid.

The VTK model is pretty much the opposite one: cell data is on all the
cell, and is not interpolated. What you are trying to do is what I would
call build the dual tessalation. You can use the VTK 'CellCenter' to
position points at the center of your cells, that inherit the cell data
as point data (apply it via the UserDefined filter,
http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/example_image_cursor_filter.html
). However as for the dual connectivity, I do not know what the best way
would be to build it. Worst case, you can always apply a Delaunay3D on
the output of 'CellCenter'.

> I thought that my needs are quite common, which is why I don't want to
> code a toolbox for these functionalities before asking :)

They may be in your field, but I believe that most people have grids that
are fairly dense, and thus don't try to render each cell separately.
Also, I believe that if they want some of the functionalities you want,
they simply hand to VTK the dual tessalation, and if they are doing
calculations on a continuous field defined by the cell centers, they need
this dual tessalation, and thus have it already computed.

HTH,

Gaël
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Structured meshes with mlab

Lionel-3
Gael Varoquaux wrote:

> On Thu, Mar 04, 2010 at 10:21:18AM +0100, lionel wrote:
>> Gael Varoquaux wrote:
>> This helped a lot Gaël, thanks.
>> However I did not manage to have an 'automatic' interpolation between
>> the cells of the grid, even a structured one.
>
>> I'm not sure if I make myself clear here, as I'm not too good with the
>> VTK vocabulary. The idea is to assign a scalar value to each cell of the
>> structured grid, then have VTK interpolate the actual scalar value for
>> each vertex of this cell, as if the original scalar was in the center of
>> the cell. For instance, if I had two adjacent cells with 2 values, say 0
>> and 1, with a blue -> red colormap, I would like to see the color going
>> progressively from blue to red on the face of the grid.
>
> The VTK model is pretty much the opposite one: cell data is on all the
> cell, and is not interpolated. What you are trying to do is what I would
> call build the dual tessalation. You can use the VTK 'CellCenter' to
> position points at the center of your cells, that inherit the cell data
> as point data (apply it via the UserDefined filter,
> http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/example_image_cursor_filter.html
> ). However as for the dual connectivity, I do not know what the best way
> would be to build it. Worst case, you can always apply a Delaunay3D on
> the output of 'CellCenter'.
>
>> I thought that my needs are quite common, which is why I don't want to
>> code a toolbox for these functionalities before asking :)
>
> They may be in your field, but I believe that most people have grids that
> are fairly dense, and thus don't try to render each cell separately.
> Also, I believe that if they want some of the functionalities you want,
> they simply hand to VTK the dual tessalation, and if they are doing
> calculations on a continuous field defined by the cell centers, they need
> this dual tessalation, and thus have it already computed.
>
> HTH,
>
> Gaël

Thanks for these exaplanations. I actually found the
mlab.pipeline.cell_to_point_data() filter, which does the trick pretty
well for the interpolation.
I still have a problem rendering each cell separately, but, for people
who are interested in this, we have another thread going on for it
("Rendering inner cells of a StructuredGrid". Doh, I miss Gnus to make
links to threads.)

Lionel

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev