38 vtkInformationVector **inputVector,
39 vtkInformationVector *outputVector) {
41 const auto input = vtkDataSet::GetData(inputVector[0]);
42 auto output = vtkDataSet::GetData(outputVector);
46 output->ShallowCopy(input);
48 const auto inputScalarFieldU = this->GetInputArrayToProcess(0, input);
49 const auto inputScalarFieldV = this->GetInputArrayToProcess(1, input);
51 if(inputScalarFieldU ==
nullptr || inputScalarFieldV ==
nullptr) {
55 vtkNew<vtkFloatArray> textureCoordinates{};
56 textureCoordinates->SetNumberOfComponents(2);
57 textureCoordinates->SetName(
"UV coordinates from field");
59 if(textureCoordinates->GetNumberOfTuples() != output->GetNumberOfPoints()) {
60 textureCoordinates->SetNumberOfTuples(output->GetNumberOfPoints());
63 double uRange[2], vRange[2];
64 inputScalarFieldU->GetRange(uRange);
65 inputScalarFieldV->GetRange(vRange);
67 std::vector<std::array<double, 2>> coordinates(
threadNumber_);
69#ifdef TTK_ENABLE_OPENMP
70#pragma omp parallel for num_threads(threadNumber_)
72 for(
int i = 0; i < output->GetNumberOfPoints(); i++) {
76#ifdef TTK_ENABLE_OPENMP
77 threadId = omp_get_thread_num();
80 coordinates[threadId][0] = coordinates[threadId][1] = 0;
83 inputScalarFieldU->GetTuple(i, &(coordinates[threadId][0]));
85 coordinates[threadId][0]
86 = (coordinates[threadId][0] - uRange[0]) / (uRange[1] - uRange[0]);
91 inputScalarFieldV->GetTuple(i, &(coordinates[threadId][1]));
93 coordinates[threadId][1]
94 = (coordinates[threadId][1] - vRange[0]) / (vRange[1] - vRange[0]);
98 textureCoordinates->SetTuple(i, coordinates[threadId].data());
101 output->GetPointData()->SetTCoords(textureCoordinates);
104 "Computed texture map", 1.0, t.
getElapsedTime(), this->threadNumber_);
TTK VTK-filter which generates a texture map from one or two point data scalar fields.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
int FillOutputPortInformation(int port, vtkInformation *info) override
int FillInputPortInformation(int port, vtkInformation *info) override
vtkStandardNewMacro(ttkTextureMapFromField)
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)