[vtkusers] Streamlines from scalars of structured points. Needing help!

Berk Geveci berk.geveci at kitware.com
Thu May 30 10:26:00 EDT 2002


This is common problem. vtkImageGradient does not produce
any vectors. Instead it produces a scalar array with 3 components.
If you are using vtk, you can use the vtkAssignAttribute
filter to label the scalars as also vectors. Something like:
vtkAssignAttribute* aa = ...;
aa->SetInput(...);
aa->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS,
           vtkAssignAttribute::POINT_DATA);

bla->SetInput(aa->GetOutput());

If you are using an older version of VTK, you have to use 
vtkFieldDataToAttributeDataFilter and vtkAttributeDataToFieldDataFilter
to shuffle things around.

-Berk

On Thu, 2002-05-30 at 10:10, stefano mininel wrote:
> I know there should be an easy answer but right now I'm blocked.
> I've got a
> "vtkStructuredPoints *pPotGrid;"
> with its scalars containing electric potential values around a current
> dipole source (calculated from a previous PDE numerical solution and
> copied in this vtk object for visualization of the results).
> I want to show some current lines, so I tried with
> 
> "
> // using sphere source to have a bunch of points around the dipole
> position
> vtkSphereSource *pNearPoints = vtkSphereSource::New();
>     pNearPoints->SetCenter(xDipPos,yDipPos,zDipPos);
>     pNearPoints->... // other sphere settings
> 
> // setting the integrator for the streamlines
>  vtkRungeKutta4 *pIntegrator = vtkRungeKutta4::New();
> 
> vtkStreamLine *pStreamer = vtkStreamLine::New();
>   pStreamer->SetInput(pPotGrid);
>   pStreamer->SetSource(pNearPoints->GetOutput());
>   pStreamer->... // other streamline settings, quite standard and copied
> from vtk examples
> 
> ... // all the other things in visualization pipeline
> "
> 
> But upon rendering I receive the message "ERROR: in... No vector data
> defined!"
> True, I say! The structured points object contains only scalars. I need
> vectors.
> So I go with
> 
> "
> vtkImageGradient* grad = vtkImageGradient::New();
>     grad->SetDimensionality( 3 );
>     grad->SetInput(pPotGrid);
> "
> and put
> "pStreamer->SetInput(grad->GetOutput());"
> 
> But I receive the same error message.
> Probably I doing something very stupid but I'm lost in a maze, and I
> hope someone can enlighten me.
> Thanks in advance for any tip/help/suggestion/insult (erh ... not the
> last I hope!).
> 
>     Stefano Mininel
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers





More information about the vtkusers mailing list