# [vtkusers] merging multiple vtkStructuredGrid's?

Peter Schmitt pschmitt at gmail.com
Thu Jul 7 12:25:46 EDT 2005

Tom & vtk users,
Starting from a suggestion from a co-worker, I have a little work-around.

I load data as a vtkUnstructuredGrid...
1.  Load data into vtkPoints, vtkFloatArray, vtkIntArray, etc..
2.  create unstructured grid.
3.  step through all my point/data arrays.  Create a voxel to connect
the points in the proper orientation.  set each cell with appropriate
unstructured grid call

This makes life easier because I can add data in any arbitrary order,
as long as I keep my point ID's right.  In my case, I would get and
set data for one 20x20x129 grid.  Then I would append another
20x20x129 chunk of data.  Unstructured grids dont care how the points
are interconnected as long as you use vtkVoxel to connect the points
in the right orientation.

It may be less efficient (not sure--haven't done any testing) but it
makes my code a LOT nicer.  I think the data is stored more
efficiently as the a vtkUnstructuredGrid (vtu) file contains a list of
points followed by indices for each voxel... so my filesizes are
noticebly smaller.  (approximately by a factor of 2)

I'll keep you updated if I have any developments on this...

-Pete

On 6/16/05, Peter Schmitt <pschmitt at gmail.com> wrote:
> Thanks for the link to MergeFilter.  I poked through it a bit earlier,
> but the examples didn't seem to lead me down the right path.  I'll
> give it another more thorough look tomorrow.
>
> As far as performance is concerned, I will eventually be running all
> of this on a large Linux cluster using parallel vtk + MPI  Once I get
> rolling with this project, I'll try & post my results to vtkusers
> sometime in late July/early August.
>
> I have already written a small program that converts my data into the
> *.pvts (vtkXMLpStructuredGrid) format using a series of printf()
> statements.  I have verified that my data is okay by loading it into
> Paraview.   Translating from the *.pvts printf code to code that
> imports directly into vtk objects is a little confusing since I do not
> understand how to implement "pieces" of structured grids directly in
>
> Thanks again,
> Pete
>
>
> On 6/16/05, tom fogal <tfogal at apollo.sr.unh.edu> wrote:
> >  <a530bfb505061614571fbe2fa6 at mail.gmail.com>Peter Schmitt writes:
> > <snip>
> > >Does anyone have suggstions on how to merge the two StructuredGrids
> > >into one larger (40x20x20) structured grid?
> >
> > vtkMergeFilter sounds like it will do what you want. If you want more
> > control, it looks like vtkMergeDataObjectFilter might give you that.
> >
> > In the future, you could try a quick grep through:
> >
> > http://www.vtk.org/doc/nightly/html/classes.html
> >
> > sometimes just the name of a class is enough to clue you on what you'll
> > need to do.
> >
> > >(eventually I will need to merge 100's or 1000's of structuredgrids together).
> >
> > I don't know how well vtkMergeFilter scales, sorry...
> > Intuitively though, merging a thousand 40x20x20 grids sounds like it
> > will take a \emph{lot} of resources.
> >
> > >In the end, I hope to use vtkXMLPStructuredGridWriter to store one
> > >pvts file with one structuredgrid consiting of multiple pieces.
> >
> > I would be \emph{very} interested to hear how well that scales for you.
> >
> > -tom
> >
>

--
Pete