[vtkusers] vtkProbeFilter inconsistency
Santosh Biradar
scbiradar at gmail.com
Fri Aug 17 09:39:08 EDT 2018
As you pointed out, the issue is with the tolerance. By setting the
tolerance I was able to get correct probed values.
However, my input dataset can keep changing and I am not sure I can really
set an optimum tolerance value each time.
Basically what I observed in the implementation of the Probe Filter is that
it picks a cell based on the tolerance set and then if it feels the cell is
actually "far" from the probe location, it returns the zero values in the
output point data.
I dont understand why does the probe filter pick the wrong cell in the
first place. I am doubting the FindCell call here. Why does it pick the
right or wrong cell arbitrarily on only ever so slight variation in the
input probe location is not clear to me.
I am inclining towards using a cell picker to get the "correct" cell id and
then doing interpolation myself to get the point data from the points of
the cell as you suggested.
Thanks Sujin for pointing me in the right direction.
Thanks,
Santosh
On Thu, Aug 16, 2018 at 7:34 PM, Sujin Philip <sujin.philip at kitware.com>
wrote:
> Hi Santosh,
>
>
>> If I understand correctly, the method you suggested will give the value
>> of the scalar from the cell data.
>>
> Correct.
>
> However, I want to get the interpolated value at any arbitrary position,
>> which is why I felt the probe filter is the correct choice(?).
>>
> Probe filter will do that for you. If it is just a few points you can also
> use the "weights" you get from the call to "FindCell" to do the
> interpolation yourself. There is an overloaded "FindCell" that will give
> you the "vtkCell". From there, you can get the ids of the cell's points.
>
>
>> Of what I understand, the probe filter returns interpolated point data or
>> it returns the cell data if the point data is not available.
>>
> Your understanding is correct.
>
>
>> On my data set, the probe filter's output has all the arrays of the point
>> data but the values are all zero. This happens on probing random positions
>> on the surface of the dataset. Do let me know if you need any further
>> information.
>>
> If the cells in your input dataset are 2D cells then the tolerance maybe
> the issue. Try setting ComputeTolerence to false and experiment with
> SetTolerance and see if that works.
>
> Thanks
> Sujin
>
>
> On Thu, Aug 16, 2018 at 8:53 AM, Santosh Biradar <scbiradar at gmail.com>
> wrote:
>
>> Thanks a lot Sujin.
>> If I understand correctly, the method you suggested will give the value
>> of the scalar from the cell data.
>> I am assuming I can use FindPoint to get the closest point and get the
>> point data from that point id.
>> However, I want to get the interpolated value at any arbitrary position,
>> which is why I felt the probe filter is the correct choice(?).
>> Of what I understand, the probe filter returns interpolated point data or
>> it returns the cell data if the point data is not available.
>> On my data set, the probe filter's output has all the arrays of the point
>> data but the values are all zero. This happens on probing random positions
>> on the surface of the dataset. Do let me know if you need any further
>> information.
>>
>> Thanks again,
>> Santosh
>>
>>
>>
>> On Tue, Aug 14, 2018 at 7:39 PM, Sujin Philip <sujin.philip at kitware.com>
>> wrote:
>>
>>> Hi Santosh,
>>>
>>> I cannot say for sure what is going wrong in the probe filter without
>>> more information. Looking at your code it looks like all you want to do is
>>> to find a cell that contains a given point and get its cell attribute. An
>>> easier way to achieve that would be:
>>>
>>> tol2 = 1e-6;
>>> double pcoords[3];
>>> double weights[8]; // size based on the max number of points in any of
>>> "input's" cells
>>> double pt[3] = { x, y, z };
>>> auto cellId = input->FindCell(pt, NULL, -1, tol2, 0, pcoords, weights);
>>> auto attr = vtkDataArray::SafeDownCast(input->GetCellData().GetAbstractA
>>> rray("T"));
>>> double val = 0.0;
>>> attr->GetTuple(cellId, &val);
>>>
>>> Hope this helps
>>>
>>> -Sujin
>>>
>>>
>>> On Tue, Aug 14, 2018 at 7:54 AM, Santosh Biradar <scbiradar at gmail.com>
>>> wrote:
>>>
>>>> Hi VTKers,
>>>>
>>>> I am trying to use the vtkProbeFilter on an unstructured data set. I am
>>>> using a cell to point filter on my input dataset and trying to probe the
>>>> output of the cell to point filter
>>>>
>>>> I have a snippet for what I am doing:
>>>>
>>>> #picker for getting the point
>>>> picker = vtk.vtkCellPicker()
>>>> picker.PickFromListOn()
>>>> picker.AddPickList(c2pactor)
>>>> picker.SetTolerance(0.000001*reader.GetOutput().GetLength())
>>>> picker.Pick(x, y, 0, renderer)
>>>> points = picker.GetPickedPositions()
>>>> numPoints = points.GetNumberOfPoints()
>>>> print numPoints
>>>> if numPoints < 1:
>>>> return
>>>> pnt = points.GetPoint(0)
>>>>
>>>> #probe filter
>>>> pt = vtk.vtkPoints()
>>>> pt.InsertPoint(0, x, y, z)
>>>> polydata = vtk.vtkPolyData()
>>>> polydata.SetPoints(pt)
>>>> probe = vtk.vtkProbeFilter()
>>>> probe.SetInputData(polydata)
>>>> probe.SetSourceData(c2p.GetOutput())
>>>>
>>>> probe.Update()
>>>>
>>>> val = probe.GetPolyDataOutput().GetPointData().GetScalars("T").Get
>>>> Range(0)[0]
>>>>
>>>> Now, I am getting inconsistent behavior of the probe filter.
>>>> Sometimes, I get the values of all the point data arrays as 0.0 for the
>>>> probed location.
>>>> I dont understand this behavior. It does work correctly but not always.
>>>>
>>>>
>>>> Alternately, I tried using the picker.GetCellId() and
>>>> picker.GetPointId() to directly fetch the value from the actor's input
>>>> dataset (in this case, output of cell to point filter). Again here, the
>>>> point id obtained always seems to be only a particular point in the cell
>>>> irresepctive of whether probed location is near that point or any other
>>>> point in that cell. So, I end up getting point data of a particular point
>>>> in that cell no matter where I probe in that cell.
>>>> Is using a vtkPointPicker the correct option here?
>>>>
>>>> Also, should I explore using vtkPointLocator/vtkCellLocator ?
>>>>
>>>> I hope the question is clear. I am using VTK-6.3 on Windows.
>>>>
>>>> Thanks,
>>>> Santosh
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>
>>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> https://public.kitware.com/mailman/listinfo/vtkusers
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180817/d623b255/attachment.html>
More information about the vtkusers
mailing list