Skip to content
Snippets Groups Projects
Commit 59f430f0 authored by vr-group's avatar vr-group
Browse files

Added cell to point data conversion step.

parent cb960bfa
Branches develop
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
#include <iostream>
#include <string>
#include <vtkCellDataToPointData.h>
#include <vtkDataArraySelection.h>
#include <vtkDataObject.h>
#include <vtkImageData.h>
......@@ -17,7 +18,8 @@ std::int32_t main(std::int32_t argc, char** argv)
auto filepath = std::string(argv[1]);
auto reader = vtkSmartPointer<vtkXMLUnstructuredGridReader>::New();
auto converter = vtkSmartPointer<vtkResampleToImage> ::New();
auto converter = vtkSmartPointer<vtkCellDataToPointData> ::New();
auto resampler = vtkSmartPointer<vtkResampleToImage> ::New();
auto writer = vtkSmartPointer<vtkXMLImageDataWriter> ::New();
std::cout << "Reading unstructured grid.\n";
......@@ -28,15 +30,22 @@ std::int32_t main(std::int32_t argc, char** argv)
reader ->Update ();
auto input_data = reader->GetOutput();
std::cout << "Converting unstructured grid to structured grid.\n";
std::cout << "Converting cell data to point data.\n";
converter->SetInputDataObject (input_data);
converter->SetUseInputBounds (true);
converter->SetSamplingDimensions (std::stoi(argv[2]), std::stoi(argv[3]), std::stoi(argv[4]));
converter->SetPassCellData (false);
converter->SetContributingCellOption(vtkCellDataToPointData::ContributingCellEnum::All);
converter->Update ();
auto output_data = converter->GetOutput();
auto converted_data = converter->GetOutput();
std::cout << "Resampling unstructured grid to structured grid.\n";
resampler->SetInputDataObject (converted_data);
resampler->SetUseInputBounds (true);
resampler->SetSamplingDimensions (std::stoi(argv[2]), std::stoi(argv[3]), std::stoi(argv[4]));
resampler->Update ();
auto resampled_data = resampler->GetOutput();
std::cout << "Writing structured grid.\n";
writer ->SetInputData (output_data);
writer ->SetInputData (resampled_data);
writer ->SetFileName ((filepath.substr(0, filepath.size() - 3) + std::string("vti")).c_str());
writer ->Update ();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment