[vtkusers] Trouble Applying Threshold filter to UnstructuredGrid

Mike Jackson imikejackson at gmail.com
Mon Jun 2 12:32:19 EDT 2008


yep, this is what I have currently..

   vtkSmartPointer<vtkThreshold> thr =  
vtkSmartPointer<vtkThreshold>::New();
   thr->SetDebug(true);
   int index = -2;
   grid->GetPointData()->GetAbstractArray 
(Dislocation::GlidePlaneID.c_str(), index);
   vtkInformation* infor = grid->GetInformation();
   thr->SetInput(grid);
   thr->ThresholdBetween( (double)(this->GlidePlaneIndex) - 0.5,  
(double)(this->GlidePlaneIndex) + 0.5 );
   thr->AllScalarsOff();
   thr->SetInputArrayToProcess(index, info);
   thr->Update(); // Force the filter to run
   vtkUnstructuredGrid* output = thr->GetOutput(0);

Still does not work. I know it _should_ work because I can use  
ParaView with the same limits on the same data set and get some data  
back.

-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On Jun 2, 2008, at 12:22 PM, John Platt wrote:

> Hi Mike,
>
> Have you tried getting the index of your scalars from the point data
>
> 	grid->GetPointData()->GetArray("Scalars 3", index);
>
> HTH
>
> John.
>
>
>
> -----Original Message-----
> From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On
> Behalf Of Mike Jackson
> Sent: 02 June 2008 16:45
> To: vtkusers at vtk.org
> Subject: [vtkusers] Trouble Applying Threshold filter to
> UnstructuredGrid
>
> I have a vtkUnstructuredGrid with 5 sets of Scalars attached to the
> point data. I would like to run a vtkThreshold filter on the grid
> selecting only points from the grid that have a scalar value between
> 1.5 and 2.5. I only want to use the 3rd scalar array as the
> determining factor.
>
> So lets say that I named my scalars "Scalars 1", "Scalars 2"...
>
> Here is what I have so far, which is not working.
>
> vtkSmartPointer<vtkThreshold> thr = vtkSmartPointer<vtkThreshold>::New
> ();
> vtkFieldData* fd = grid->GetFieldData();
> int index = -1;
> fd->GetArray("Scalars 3", index);
> thr->SetInput(grid);
> thr->ThresholdBetween( 1.5, 2.5 );
> thr->AllScalarsOff();
> thr->SetInputArrayToProcess(index, info);
> thr->Update(); // Force the filter to run
> vtkUnstructuredGrid* output = thr->GetOutput(0);
> output->Register(NULL);
>
> Note that I am using "info" variable which was retrieved from the
> RequestData(.. ) arguments in the usual fashion, which I don't think
> is correct.
>
> Also, the index of the Scalars array comes back as "-1" which means
> that my "Scalars 3" array could not be found. I know it is there. I
> can print the vtkUnstructuredGrid and "see" the named array.
>
> So I know this should be straight forward but I am just coming up  
> empty.
>
> Any help or hints would be appreciated.
> --
> Mike Jackson
> imikejackson & gmail * com
>
> _______________________________________________
> 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
>
>




More information about the vtkusers mailing list