[vtkusers] Trouble Applying Threshold filter to UnstructuredGrid

Amy Squillacote ahs at cfdrc.com
Mon Jun 2 12:44:57 EDT 2008


Hi Mike,

You could also try using the version of SetInputArrayToProcess with the 
following signature.

void SetInputArrayToProcess(int idx, int port, int connection, int 
fieldAssociation, const char *name);

For vtkThreshold, idx, port, and connection should all be 0 (from 
looking at the code for vtkThreshold's constructor).
Set fieldAssociation to vtkDataObject::FIELD_ASSOCIATION_POINTS (since 
you're using point data).
Set name to "Scalars 3".

- Amy

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
>
>
> _______________________________________________
> 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                    Phone: (256) 726-4839
Computer Scientist                 Fax: (256) 726-4806
CFD Research Corporation           Web: http://www.cfdrc.com
215 Wynn Drive, Suite 501
Huntsville, AL  35805





More information about the vtkusers mailing list