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

foufara foufara at yahoo.fr
Tue May 9 02:48:45 EDT 2017


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.


More information about the vtk-developers mailing list