TTK
Loading...
Searching...
No Matches
ttkDataSetInterpolator.cpp
Go to the documentation of this file.
2
3#include <vtkDataSet.h>
4#include <vtkInformation.h>
5#include <vtkObjectFactory.h>
6
7#include <vtkPointData.h>
8#include <vtkProbeFilter.h>
9
11
13 this->setDebugMsgPrefix("DataSetInterpolator");
14 this->SetNumberOfInputPorts(2);
15 this->SetNumberOfOutputPorts(1);
16
17 vtkWarningMacro("`TTK DataSetInterpolator' is now deprecated. Please use "
18 "`ResampleWithDataset' instead.");
19}
21
23 vtkInformation *info) {
24 if(port == 0 || port == 1) {
25 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
26 return 1;
27 }
28 return 0;
29}
30
32 vtkInformation *info) {
33 if(port == 0) {
35 return 1;
36 }
37 return 0;
38}
39
41 vtkInformationVector **inputVector,
42 vtkInformationVector *outputVector) {
43 ttk::Timer t;
44
45 auto target = vtkDataSet::GetData(inputVector[0]);
46 auto source = vtkDataSet::GetData(inputVector[1]);
47
48 this->printMsg(
49 "Computing " + std::to_string(target->GetNumberOfPoints()) + " locations",
51
52 auto output = vtkDataSet::GetData(outputVector);
53
55 probe->SetInputData(target);
56 probe->SetSourceData(source);
57 probe->Update();
58
59#ifndef TTK_ENABLE_KAMIKAZE
60 if(!probe->GetOutput()) {
61 this->printErr("Data probe failed.");
62 return 0;
63 }
64#endif
65
66 output->ShallowCopy(probe->GetOutput());
67
68 // add original data arrays
69 auto inputPointData = target->GetPointData();
70 auto outputPointData = output->GetPointData();
71
72 const size_t numberOfArrays = inputPointData->GetNumberOfArrays();
73 for(size_t i = 0; i < numberOfArrays; ++i)
74 outputPointData->AddArray(inputPointData->GetAbstractArray(i));
75
76 this->printMsg(
77 "Computing " + std::to_string(target->GetNumberOfPoints()) + " locations",
78 1, t.getElapsedTime());
79
80 return 1;
81}
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
Definition BaseClass.h:47
static vtkInformationIntegerKey * SAME_DATA_TYPE_AS_INPUT_PORT()
TTK VTK-filter that wraps the dataSetInterpolator processing package.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
~ttkDataSetInterpolator() override
int FillInputPortInformation(int port, vtkInformation *info) override
int FillOutputPortInformation(int port, vtkInformation *info) override
void setDebugMsgPrefix(const std::string &prefix)
Definition Debug.h:364
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition Debug.h:149
double getElapsedTime()
Definition Timer.h:15
vtkStandardNewMacro(ttkDataSetInterpolator)
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)