40 vtkUnstructuredGrid *
const inputDiagram,
41 vtkUnstructuredGrid *
const outputDiagram) {
43 auto pointData = inputDiagram->GetPointData();
46 const auto critCoordinates = vtkFloatArray::SafeDownCast(
48 bool const embed = critCoordinates ==
nullptr;
54 if(critCoordinates ==
nullptr) {
55 this->
printErr(
"Missing `Coordinates' vtkPointData array");
58 if(critCoordinates->GetNumberOfComponents() != 3) {
59 this->
printErr(
"`Coordinates' array should have 3 components");
65 return ret == 0 ? 1 : 0;
69 vtkInformationVector **inputVector,
70 vtkInformationVector *outputVector) {
74 vtkPointSet *input = vtkPointSet::GetData(inputVector[0]);
75 vtkPointSet *output = vtkPointSet::GetData(outputVector, 0);
77 if(this->ProjectPersistenceDiagram) {
78 auto inputGrid = vtkUnstructuredGrid::SafeDownCast(input);
79 auto outputGrid = vtkUnstructuredGrid::SafeDownCast(output);
80 if(inputGrid !=
nullptr && outputGrid !=
nullptr) {
83 this->
printErr(
"Input should be a vtkUnstructuredGrid");
87 output->ShallowCopy(input);
89 vtkNew<vtkPoints> pointSet{};
90 pointSet->SetNumberOfPoints(input->GetNumberOfPoints());
92 if(UseTextureCoordinates) {
94 const auto textureCoordinates = input->GetPointData()->GetTCoords();
95 if(textureCoordinates ==
nullptr) {
98 printMsg(
"Starting computation with texture coordinates...");
100#ifdef TTK_ENABLE_OPENMP
101#pragma omp parallel for num_threads(threadNumber_)
103 for(
int i = 0; i < input->GetNumberOfPoints(); i++) {
104 std::array<double, 3> pt{};
105 textureCoordinates->GetTuple(i, pt.data());
106 pointSet->SetPoint(i, pt[0], pt[1], pt[2]);
109 }
else if(this->Use3DCoordinatesArray) {
111 const auto inputCoordsArray = this->GetInputArrayToProcess(2, inputVector);
112 if(inputCoordsArray ==
nullptr) {
115 printMsg(
"Starting computation...");
116 printMsg(std::vector<std::vector<std::string>>{
117 {
" Coordinates Array", inputCoordsArray->GetName()}});
119#ifdef TTK_ENABLE_OPENMP
120#pragma omp parallel for num_threads(threadNumber_)
122 for(
int i = 0; i < input->GetNumberOfPoints(); i++) {
123 std::array<double, 3> pt{};
124 inputCoordsArray->GetTuple(i, pt.data());
125 pointSet->SetPoint(i, pt[0], pt[1], pt[2]);
130 const auto inputScalarFieldU = this->GetInputArrayToProcess(0, inputVector);
131 const auto inputScalarFieldV = this->GetInputArrayToProcess(1, inputVector);
133 if(inputScalarFieldU ==
nullptr || inputScalarFieldV ==
nullptr) {
137 printMsg(
"Starting computation...");
138 printMsg({{
" U-component", inputScalarFieldU->GetName()},
139 {
" V-component", inputScalarFieldV->GetName()}});
141#ifdef TTK_ENABLE_OPENMP
142#pragma omp parallel for num_threads(threadNumber_)
144 for(
int i = 0; i < input->GetNumberOfPoints(); i++) {
145 pointSet->SetPoint(i, inputScalarFieldU->GetComponent(i, 0),
146 inputScalarFieldV->GetComponent(i, 0), 0);
150 output->SetPoints(pointSet);
152 printMsg(std::to_string(input->GetNumberOfPoints()) +
" points projected", 1,
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)