Streamlines using unstructered grid.

Hello,

I am quite new to VTK library.
I have a data which is unstructered grid. While paraview is able to visualize it in a second, I couldnt find a way to do it in c++.

Does any of you have experience with this ?

Best regards,

Here’s an example that should get you started with vtkStreamTracer: https://lorensen.github.io/VTKExamples/site/Cxx/VisualizationAlgorithms/Office/

Hello Cory,

Thank you for the reply. I found a solution long ago(The result is same with paraview).

It is ‘quite’ hard actually when it is unstructured grid.
The solution is : vtkCellDataToPointData

This nice class interpolates the cell data to point data, which is necessary for it. In short a code may be following, after seeds are set:

     vtkSmartPointer<vtkStreamTracer> streamer;
     vtkSmartPointer<vtkUnstructuredGrid> data;
     vtkSmartPointer<vtkUnstructuredGridReader> gridReader = vtkSmartPointer<vtkUnstructuredGridReader>::New();
    
    gridReader->SetFileName("myfile.vtk");
    gridReader->Update();
    
    data = gridReader->GetOutput();
    streamer = vtkStreamTracer::New();
    std::cout << "    Calculation of  streamlines are started." << std::endl;
    // Interpolate cell values to point values
    vtkSmartPointer<vtkCellDataToPointData> c2p = vtkSmartPointer<vtkCellDataToPointData>::New();
    c2p->SetInputData(data);
    c2p->Update();
    // Calculate streamline
    streamer->SetInputConnection(c2p->GetOutputPort());
    streamer->SetSourceConnection(seeds->GetOutputPort());
    streamer->SetInitialIntegrationStep(0.2);
    streamer->SetMinimumIntegrationStep(.01);
    streamer->SetMaximumIntegrationStep(.5);
    streamer->SetMaximumNumberOfSteps(2000);
    streamer->SetInterpolatorTypeToCellLocator();
    streamer->SetIntegrationDirectionToBoth();
    streamer->SetIntegratorTypeToRungeKutta4();
    //streamer->SetComputeVorticity(true);

    streamer->Update();

And rest is the mappers and actors. .