How can i use the vtkStreamtracer to generate a streamline with my unstructured grid data(vtu)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How can i use the vtkStreamtracer to generate a streamline with my unstructured grid data(vtu)

stargazerrrrr
I`m using  VTK  to visualize data coming from xflow in vtu. When I use the
Paraview, it can generate the right streamline, but when I use the VTK to
visualize my data, it only displays the outline and the airplane model.
There is no streamline being generated.
This is my code:
//The background color
vtkSmartPointer<vtkNamedColors> namedColors =
vtkSmartPointer<vtkNamedColors>::New();

//The AirplaneModel file
std::string meshfilename =
"K:/Project/VTKproject/Airplane_Process/data/Mesh.vtp";
vtkSmartPointer<vtkXMLPolyDataReader> meshreader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
meshreader->SetFileName(meshfilename.c_str());
meshreader->Update();

   //The data file
std::string datafilename
="K:/Project/VTKproject/Airplane_Process/data/data.vtu";
vtkSmartPointer<vtkXMLUnstructuredGridReader> datareader =
vtkSmartPointer<vtkXMLUnstructuredGridReader>::New();
datareader->SetFileName(datafilename.c_str());
datareader->Update();

//The seed points
vtkSmartPointer<vtkPointSource> seeds =
vtkSmartPointer<vtkPointSource>::New();
seeds->SetCenter(0,0,0);
seeds->SetRadius(0.05);
seeds->SetNumberOfPoints(100);


//streamline generate

vtkSmartPointer<vtkStreamTracer> streamline =
vtkSmartPointer<vtkStreamTracer>::New();
datareader->Update();
streamline->SetInputConnection(datareader->GetOutputPort());
streamline->SetSourceConnection(seeds->GetOutputPort());
//streamline->SetIntegrationStepUnit(vtkStreamTracer::CELL_LENGTH_UNIT);
streamline->SetMaximumPropagation(500);
streamline->SetMaximumIntegrationStep(0.1);
streamline->SetMinimumIntegrationStep(0.01);
streamline->SetInitialIntegrationStep(0.05);
//streamline->SetIntegrationStepUnit(vtkStreamTracer::CELL_LENGTH_UNIT);
streamline->SetIntegrationDirectionToBoth();
streamline->SetIntegratorTypeToRungeKutta45();
streamline->Update();

vtkSmartPointer<vtkPolyDataMapper> streamLineMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
streamLineMapper->SetInputConnection(streamline->GetOutputPort());

vtkSmartPointer<vtkActor> streamLineActor =
vtkSmartPointer<vtkActor>::New();
streamLineActor->SetMapper(streamLineMapper);

//outlinefilter
vtkSmartPointer<vtkOutlineFilter> outline
=vtkSmartPointer<vtkOutlineFilter>::New();
outline->SetInputConnection(datareader->GetOutputPort());

vtkSmartPointer<vtkPolyDataMapper> outlineMapper
=vtkSmartPointer<vtkPolyDataMapper>::New();
outlineMapper->SetInputConnection(outline->GetOutputPort());

vtkSmartPointer<vtkActor> outlineActor =vtkSmartPointer<vtkActor>::New();
outlineActor->SetMapper(outlineMapper);
outlineActor->GetProperty()->SetColor(0,0,0);

//
vtkSmartPointer<vtkPolyDataMapper> meshmapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
meshmapper->SetInputConnection(meshreader->GetOutputPort());

vtkSmartPointer<vtkActor> meshactor = vtkSmartPointer<vtkActor>::New();
meshactor->SetMapper(meshmapper);

//rendering
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(meshactor);
renderer->AddActor(outlineActor);
renderer->AddActor(streamLineActor);
//renderer->AddActor(actor);
renderer->SetBackground(namedColors->GetColor3d("Cadet").GetData());
//window
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);

//interaction
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);

vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
    vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
renderWindowInteractor->SetInteractorStyle(style);
renderWindowInteractor->Initialize();
renderWindow->SetSize(300, 300);
renderWindow->Render();
renderWindowInteractor->Start();

This is the result in paraview:
<http://vtk.1045678.n5.nabble.com/file/t342734/paraview1.png>
This is the result of my code:
<http://vtk.1045678.n5.nabble.com/file/t342734/%E6%88%91%E7%9A%84%E6%95%88%E6%9E%9C.png>

Is there any problem in my code?



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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://vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: How can i use the vtkStreamtracer to generate a streamline with my unstructured grid data(vtu)

VTK - Users mailing list
Hi,

Would you mind posting your question to https://discourse.vtk.org? Community support for VTK has transitioned to that forum, and you are more likely to get an answer there.

Thanks,
Cory

On Thu, Apr 18, 2019 at 9:41 AM stargazerrrrr <[hidden email]> wrote:
I`m using  VTK  to visualize data coming from xflow in vtu. When I use the
Paraview, it can generate the right streamline, but when I use the VTK to
visualize my data, it only displays the outline and the airplane model.
There is no streamline being generated.
This is my code:
//The background color
vtkSmartPointer<vtkNamedColors> namedColors =
vtkSmartPointer<vtkNamedColors>::New();

//The AirplaneModel file
std::string meshfilename =
"K:/Project/VTKproject/Airplane_Process/data/Mesh.vtp";
vtkSmartPointer<vtkXMLPolyDataReader> meshreader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
meshreader->SetFileName(meshfilename.c_str());
meshreader->Update();

   //The data file
std::string datafilename
="K:/Project/VTKproject/Airplane_Process/data/data.vtu";
vtkSmartPointer<vtkXMLUnstructuredGridReader> datareader =
vtkSmartPointer<vtkXMLUnstructuredGridReader>::New();
datareader->SetFileName(datafilename.c_str());
datareader->Update();

//The seed points
vtkSmartPointer<vtkPointSource> seeds =
vtkSmartPointer<vtkPointSource>::New();
seeds->SetCenter(0,0,0);
seeds->SetRadius(0.05);
seeds->SetNumberOfPoints(100);


//streamline generate

vtkSmartPointer<vtkStreamTracer> streamline =
vtkSmartPointer<vtkStreamTracer>::New();
datareader->Update();
streamline->SetInputConnection(datareader->GetOutputPort());
streamline->SetSourceConnection(seeds->GetOutputPort());
//streamline->SetIntegrationStepUnit(vtkStreamTracer::CELL_LENGTH_UNIT);
streamline->SetMaximumPropagation(500);
streamline->SetMaximumIntegrationStep(0.1);
streamline->SetMinimumIntegrationStep(0.01);
streamline->SetInitialIntegrationStep(0.05);
//streamline->SetIntegrationStepUnit(vtkStreamTracer::CELL_LENGTH_UNIT);
streamline->SetIntegrationDirectionToBoth();
streamline->SetIntegratorTypeToRungeKutta45();
streamline->Update();

vtkSmartPointer<vtkPolyDataMapper> streamLineMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
streamLineMapper->SetInputConnection(streamline->GetOutputPort());

vtkSmartPointer<vtkActor> streamLineActor =
vtkSmartPointer<vtkActor>::New();
streamLineActor->SetMapper(streamLineMapper);

//outlinefilter
vtkSmartPointer<vtkOutlineFilter> outline
=vtkSmartPointer<vtkOutlineFilter>::New();
outline->SetInputConnection(datareader->GetOutputPort());

vtkSmartPointer<vtkPolyDataMapper> outlineMapper
=vtkSmartPointer<vtkPolyDataMapper>::New();
outlineMapper->SetInputConnection(outline->GetOutputPort());

vtkSmartPointer<vtkActor> outlineActor =vtkSmartPointer<vtkActor>::New();
outlineActor->SetMapper(outlineMapper);
outlineActor->GetProperty()->SetColor(0,0,0);

//
vtkSmartPointer<vtkPolyDataMapper> meshmapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
meshmapper->SetInputConnection(meshreader->GetOutputPort());

vtkSmartPointer<vtkActor> meshactor = vtkSmartPointer<vtkActor>::New();
meshactor->SetMapper(meshmapper);

//rendering
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(meshactor);
renderer->AddActor(outlineActor);
renderer->AddActor(streamLineActor);
//renderer->AddActor(actor);
renderer->SetBackground(namedColors->GetColor3d("Cadet").GetData());
//window
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);

//interaction
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);

vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
    vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
renderWindowInteractor->SetInteractorStyle(style);
renderWindowInteractor->Initialize();
renderWindow->SetSize(300, 300);
renderWindow->Render();
renderWindowInteractor->Start();

This is the result in paraview:
<http://vtk.1045678.n5.nabble.com/file/t342734/paraview1.png>
This is the result of my code:
<http://vtk.1045678.n5.nabble.com/file/t342734/%E6%88%91%E7%9A%84%E6%95%88%E6%9E%9C.png>

Is there any problem in my code?



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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://vtk.org/mailman/listinfo/vtkusers


--
Cory Quammen
Staff R&D Engineer
Kitware, Inc.

_______________________________________________
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://vtk.org/mailman/listinfo/vtkusers