[vtkusers] Streamlines from scalars of structured points.Needing help!
stefano mininel
mininel.ml at gnbts.univ.trieste.it
Fri May 31 03:46:50 EDT 2002
Thank you very much for your help.
This solution is definitely something I wouldn't find easily or in a short time in a lonely
documentation/examples search.
I cannot say I've understood completely how it works, but it works perfectly!
As soon as I'll have some spare time I'll try to have a look at the source of this
vtkAssignAttribute and understand it better.
Meanwhile, a question, just to have a general idea: am I correct if I think of the
vtkAssignAttribute filter as a sort of necessary interface between vtk4.0 data structures and the
classes/filters that expect in their input data in the way of older vtk versions (to call upon
such data the now deprecated xx->GetPointData()->GetVectors() or GetScalars() ).
By the way, I'm amazed by the quickness of your help. I think that about 15 minutes between
sending my question and receiving the answer is a sort of record :-)
Stefano Mininel
Berk Geveci wrote:
> 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