[vtk-developers] Is vtkprobefilter working correctly ? Here is an example to test…

Ken Martin ken.martin at kitware.com
Tue May 9 08:34:53 EDT 2017


Unless I am missing something in your question, probing and locating cells
are two different things. I would expect them to have different results.
Probing interpolates, locators don't. From the documentation of the two
classes...

vtkProbeFilter is a filter that computes point attributes (e.g., scalars,
 * vectors, etc.) at specified point positions. The filter has two inputs:
 * the Input and Source. The Input geometric structure is passed through the
 * filter. The point attributes are computed at the Input point positions
 * by interpolating into the source data. For example, we can compute data
 * values on a plane (plane specified as Input) from a volume (Source).
 * The cell data of the source data is copied to the output based on in
 * which source cell each input point is. If an array of the same name
exists
 * both in source's point and cell data, only the one from the point data is
 * probed.
 *
 * This filter can be used to resample data, or convert one dataset form
into
 * another. For example, an unstructured grid (vtkUnstructuredGrid) can be
 * probed with a volume (three-dimensional vtkImageData), and then volume
 * rendering techniques can be used to visualize the results. Another
example:
 * a line or curve can be used to probe data to produce x-y plots along
 * that line or curve.

Versus

 * vtkCellLocator is a spatial search object to quickly locate cells in 3D.
 * vtkCellLocator uses a uniform-level octree subdivision, where each octant
 * (an octant is also referred to as a bucket) carries an indication of
 * whether it is empty or not, and each leaf octant carries a list of the
 * cells inside of it. (An octant is not empty if it has one or more cells
 * inside of it.)  Typical operations are intersection with a line to return
 * candidate cells, or intersection with another vtkCellLocator to return
 * candidate cells.



On Tue, May 9, 2017 at 2:48 AM, foufara via vtk-developers <
vtk-developers at vtk.org> wrote:

> Hi it's me again ! :-)
>
> No one can help me on that ?
>
> Here is this time a Cxx example.
>
> To sum it up, vtkprobefilter and vtkcelllocator do not give the same
> results
> on this example and that does not seem right to me…
>
> I'll be debugging it to see what happens.
> But if you already have the explanation, please et me know !
>
> Thanks
>
> Raphael
>
>
> #include "vtkPoints.h"
> #include "vtkPolyData.h"
> #include "vtkUnstructuredGrid.h"
> #include "vtkDataSet.h"
> #include "vtkPointData.h"
> #include "vtkDataArray.h"
> #include "vtkDataSetReader.h"
> #include "vtkProbeFilter.h"
> #include "vtkPointLocator.h"
> #include "vtkCellLocator.h"
> #include "vtkIdList.h"
> #include "vtkPolyDataWriter.h"
>
>
> int main()
> {
>
>     std::cout << "DEBUGRAPHA : Debug1" << "\n "<<std::endl;
>
>
>
>     double point1[3] = {-312.,-1407.,37.};
>     double point2[3] = {-312.,-1407.,57.};
>
>     // 2 Points to probe with
>     vtkPoints* points = vtkPoints::New();
>     vtkIdType nextPoint1 = points->InsertNextPoint(point1);
>     vtkIdType nextPoint2 = points->InsertNextPoint(point2);
>     vtkPolyData* polydata = vtkPolyData::New();
>     polydata->SetPoints(points);
>
>     std::cout << "Points" <<std::endl;
>     std::cout << "Point 1 : " << point1[0] <<
> " " << point1[1] << " " << point1[2]
> << std::endl;
>     std::cout << "Point 2 : " << point2[0] <<
> " " << point2[1] << " " << point2[2]
> << std::endl;
>     std::cout << "\n" << std::endl;
>
>     //Writing the points to vtk file
>     vtkPolyDataWriter* writer1 = vtkPolyDataWriter::New();
>     writer1->SetInputData(polydata);
>     writer1->SetFileName("polydata.vtk");
>     writer1->Write();
>
>     // 3D Data to probe
>     vtkDataSetReader *reader = vtkDataSetReader::New();
>     reader->SetFileName("extraction.vtk");
>     reader->Update();
>     vtkDataSet* data=reader->GetOutput();
>
>     // Probing
>     vtkProbeFilter* probe = vtkProbeFilter::New();
>     probe->SetInputData(polydata);
>     probe->SetSourceData(data);
>     probe->Update();
>     vtkDataSet* result=probe->GetOutput();
>
>     // Results probing
>     vtkPointData* pointData = result->GetPointData();
>     vtkDataArray* valid = pointData->GetArray("vtkValidPointMask");
>     vtkDataArray* cellid = pointData->GetArray("ID");
>
>     std::cout << "Probing" <<std::endl;
>     std::cout << "Valid : " << valid->GetTuple1(0) <<
> " " << valid->GetTuple1(1) << std::endl;
>     std::cout << "ID : " << cellid->GetTuple1(0) << " " <<
> cellid->GetTuple1(1) << std::endl;
>     std::cout << "\n" << std::endl;
>
>
>     // CellLocator
>     vtkIdType cellids[2];
>     vtkCellLocator* locator=vtkCellLocator::New();
>     locator->SetDataSet(data);
>     locator->BuildLocator();
>     for (int i=0; i<polydata->GetNumberOfPoints(); i++)
>     {
>         cellids[i]=locator->FindCell(polydata->GetPoint(i));
>     }
>     std::cout << "CellLocator" <<std::endl;
>     std::cout << "ID : " << cellids[0] << " " << cellids[1] << std::endl;
>
>     return 0;
> }
>
>
>
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.
> com/Is-vtkprobefilter-working-correctly-Here-is-an-example-
> to-test-tp5743104p5743147.html
> Sent from the VTK - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Search the list archives at: http://markmail.org/search/?q=vtk-developers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtk-developers
>
>


-- 
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065

This communication, including all attachments, contains confidential and
legally privileged information, and it is intended only for the use of the
addressee.  Access to this email by anyone else is unauthorized. If you are
not the intended recipient, any disclosure, copying, distribution or any
action taken in reliance on it is prohibited and may be unlawful. If you
received this communication in error please notify us immediately and
destroy the original message.  Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20170509/a519e6ad/attachment.html>


More information about the vtk-developers mailing list