[vtkusers] Not getting to use the vtkThreshold with a vtkRectilinearGrid

David Doria daviddoria+vtk at gmail.com
Fri Jan 8 18:21:32 EST 2010


On Fri, Dec 18, 2009 at 1:21 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
> On Fri, Dec 18, 2009 at 12:51 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>> From vtkThreshold:
>> // vtkThreshold is a filter that EXTRACTS CELLS from any dataset type that
>> // satisfy a threshold criterion. A cell satisfies the criterion if the
>> // scalar value of (every or any) point satisfies the criterion. The
>> // criterion can take three forms: 1) greater than a particular value; 2)
>> // less than a particular value; or 3) between two values. The output of this
>> // filter is an unstructured grid.
>>
>> I don't think you have defined any cells have you?
>>
>> On Fri, Dec 18, 2009 at 12:38 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
>>> 2009/12/18 Adriano Gonçalves <adriano at esss.com.br>
>>>>
>>>> Hi David, I've gotten to solve the problem using the method SetInputArrayToProcess thus:
>>>>
>>>> thresh.SetInputArrayToProcess(0, 0, 0, 1, 'test')
>>>>
>>>> (this "1" at the 4th parameter is the same of the vtkDataObject::FIELD_ASSOCIATION_CELLS  constant)
>>>>
>>>> Thank you so much for your help!
>>>>
>>>> Adriano
>>>>
>>>
>>> Adriano,
>>>
>>> I'm glad you got it to work, but I'm not sure you used it correctly.
>>>
>>> In my example:
>>> http://www.cmake.org/Wiki/VTK/Examples/Thresholding
>>>
>>> Since I set the array to the PointData, I used
>>>
>>> threshold->SetInputArrayToProcess(0, 0, 0,
>>> vtkDataObject::FIELD_ASSOCIATION_POINTS,
>>> vtkDataSetAttributes::SCALARS);
>>>
>>> These first three parameters (idx, port, connection) should all be 0
>>> because I only have one array and input data set, right? The last two
>>> params seem reasonable.
>>>
>>> Anyone know why this still wouldn't work? Is there no way to set the
>>> array to process by it's name as is done with many other filters?
>>>
>>> Thanks,
>>>
>>> David
>
> As bill pointed out, vtkThreshold only thresholds cells, even though
> you have to specify that you want to threshold cells (very odd).
>
> You can use vtkThresholdPoints to threshold points (this works as expected):
> http://www.cmake.org/Wiki/VTK/Examples/Thresholding_Points
>
> I tried to add some triangles and then threshold the values on the
> cells, but it is still producing 0 points and cells. I added the array
> to the cellData (polydata->GetCellData()->AddArray(index);), changed
> one of the parameters to vtkDataObject::FIELD_ASSOCIATION_CELLS, and
> changed vtkThresholdPoints to vtkThreshold.
> http://www.cmake.org/Wiki/VTK/Examples/Thresholding_Cells
>
> I don't have time to look into this further right now - it's on my
> to-do list unless someone gets to it first. Adriano - would you mind
> looking into it?
>
> Thanks,
>
> David
>

Bryn fixed this - it works now:
http://www.cmake.org/Wiki/VTK/Examples/Thresholding_Cells

Thanks Bryn!

David



More information about the vtkusers mailing list