[vtkusers] PorgrammableAttributeDataFilters-Example in C++ Needed

Richard Strelitz strelitz at lanl.gov
Tue Oct 16 10:47:27 EDT 2001


I am trying to write a filter which adaptively classifies
data from a series of discrete files.  Although I could use
the look up table, I prefer for strategic reasons to use
the vtkProgrammableAttributeDataFilter, but have thus far been
unsuccessful in getting it to work in C++.  Can anyone provide me
with a sample or pointers in how to write one.
  I've provided the code I felt should work, and which did compile.
I get aq dsegment fault when I try to compute Npoints (line 3) which
I attribute to the code's failure to comprehend pFilter inside the
function categorize.
  Thank you,
  Richard Strelitz, Vis Team, LANL CCS-1
-----------------------------------

1	void categorize(void *ncats)
2	{ float tempVel; float category();    // category is a function that
returns index
3	 long Npoints =pFilter->GetInput()->GetNumberOfPoints();
4	 vtkScalars *vIn = vtkScalars::New();
4	  vIn->SetNumberOfScalars(Npoints);
6	 vIn =  pFilter->GetInput()->GetPointData()->GetScalars();
7	 for(long i=0; i<Npoints; i++)
8	  {tempVel =vIn->GetScalar(i);
9	   vIn->SetScalar(i,category(tempVel));
10	  }
11	 pFilter->GetOutput()->GetPointData()->SetScalars(vIn);
12	 vIn->Delete();
13	 }

1'	main()
2'	{...
3'		 vtkProgrammableFilter *pFilter = vtkProgrammableFilter::New();
4'	   pFilter->SetInput(pR->GetOutput());
5'	   pFilter->SetExecuteMethod(categorize,(void *)ncats);
6'	   pFilter->DebugOn();






More information about the vtkusers mailing list