[vtkusers] More efficient way to present animation of multiple 3D surfaces?

Steve Chall stevec at renci.org
Fri May 25 16:39:30 EDT 2007


Amy, Thank you.  That works great.  I've extended your suggestion to an
animation showing a sequence of 3D surfaces, but I'm getting < 2 frames/sec
display rate and I'll bet I'm taking an inefficient path to my goal.  Here's
what I'm doing:  I have kMaxFrame (could be hundreds) of 2D arrays of
elevation values that I'm reading into a corresponding number of vtkPoints
objects according to your recommendations, then adding the points to each of
an array of vtkPolyData objects, then filtering each of those with its own
vtkDelaunay2D filter.  Then in an infinite loop I keep stepping through each
of the vtkDelauney2D objects, assigning it in turn as the mapper's input
connection.  But it's slow.  Should I somehow use
vtkAppendPolyData::SetInputByNumber()?

// Begin C++:
//
vtkPoints *points[kMaxFrames];
vtkPolyData *polyData[kMaxFrames];
vtkDelaunay2D *delaunay[kMaxFrames]'

for (int i = 0; i < kMaxFrames; i++)
{
  PopulatePointsFromOriginalData(i); 	// put data into points[i]
  BuildPolyDataFromPoints(i); 		// assign points[i] to polyData[i]
  BuildCellsFromPolyData(i); 	// run polyData[i] through filter
delaunay[i]
}

// ...set up the usual actor, mapper, renderer and render window stuff...

int frame = -1;

while(1) // Here's the part that's slow.  No problems with preceding code.
{
  frame++;
  frame %= kMaxFrames;
  mapper->SetInputConnection(delaunay[frame]->GetOutputPort());
  renWin->Render();
}

// End C++

Thank you for any further suggestions.

-Steve

-----Original Message-----
From: Amy Squillacote [mailto:amy.squillacote at kitware.com] 
Sent: Wednesday, May 23, 2007 4:24 PM
To: Steve Chall
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] How to generate a 3D surface from a regular 2D array
of elevations?

Hi Steve,

You could try the following. From your array of floating-point values 
(2D location + elevation), create a vtkPoints 
(http://www.vtk.org/doc/nightly/html/classvtkPoints.html). Set this as 
the points for a vtkPolyData object 
(http://www.vtk.org/doc/nightly/html/classvtkPolyData.html). Then pass 
the vtkPolyData object through a vtkDelaunay2D filter 
(http://www.vtk.org/doc/nightly/html/classvtkDelaunay2D.html). The 
output is a vtkPolyData, and this way you don't have to manually create 
the cells connecting the points.

- Amy

Steve Chall wrote:
>
> I've ordered the three books but in the meantime I'm subsisting on 
> online and the docs installed with vtk. Beginners' question: Is there 
> an example of the following? I want to read in a regular 2D array of 
> double float values and display it as a 3D surface, where the 2 
> indices for each array element represent a location on the earth's 
> surface and the value of each element represents an elevation. In 
> fact, I want to be able to display a sequence of surfaces 
> (representing a corresponding sequence of 2D arrays) of elevations as 
> an animation of interactively variable speed. From what I can see I 
> need to get the data into a vtkPolyData object, after which I can 
> display it and manipulate its visual representation just like in the 
> tutorials. But vtkPolyVertex, vtkTriangleStrip, and 
> vtkUnstructuredGrid are just a few of the candidates for an initial 
> intra-VTK format, and it's not clear to me which is most appropriate. 
> Thanks very much for any help you may be able to provide.
>
> -Steve C.
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>   

-- 
Amy Squillacote
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
Phone: (518) 371-3971 x106





More information about the vtkusers mailing list