TTK
Loading...
Searching...
No Matches
ttkFiber.cpp
Go to the documentation of this file.
1#include <ttkFiber.h>
2
3#include <vtkContourFilter.h>
4#include <vtkInformation.h>
5
7
9 this->setDebugMsgPrefix("Fiber");
10
11 this->SetNumberOfInputPorts(1);
12 this->SetNumberOfOutputPorts(1);
13}
14
15ttkFiber::~ttkFiber() = default;
16
17int ttkFiber::FillInputPortInformation(int port, vtkInformation *info) {
18 if(port == 0) {
19 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
20 return 1;
21 }
22
23 return 0;
24}
25
26int ttkFiber::FillOutputPortInformation(int port, vtkInformation *info) {
27 if(port == 0) {
28 info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkPolyData");
29 return 1;
30 }
31
32 return 0;
33}
34
35int ttkFiber::RequestData(vtkInformation *ttkNotUsed(request),
36 vtkInformationVector **inputVector,
37 vtkInformationVector *outputVector) {
38 ttk::Timer t;
39
40 this->printMsg("Computing Fiber", 0, 0, ttk::debug::LineMode::REPLACE);
41
42 auto input = vtkDataSet::GetData(inputVector[0]);
43 auto output = vtkPolyData::GetData(outputVector);
44
45 auto uArray = this->GetInputArrayToProcess(0, inputVector);
46 if(!uArray) {
47 this->printErr("Unable to retrieve input array U.");
48 return 0;
49 }
50 std::string const uArrayName(uArray->GetName());
51
52 auto vArray = this->GetInputArrayToProcess(1, inputVector);
53 if(!vArray) {
54 this->printErr("Unable to retrieve input array V.");
55 return 0;
56 }
57 std::string const vArrayName(vArray->GetName());
58
59 this->printMsg("Computing Fiber (" + uArrayName + ": "
60 + std::to_string(UValue) + ", " + vArrayName + ": "
61 + std::to_string(VValue) + ")",
63
65 isoSurface->SetInputData(input);
66 isoSurface->SetComputeScalars(true);
67 isoSurface->SetInputArrayToProcess(
68 0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, uArray->GetName());
69 isoSurface->SetGenerateTriangles(true);
70 isoSurface->SetNumberOfContours(1);
71 isoSurface->SetValue(0, UValue);
72 isoSurface->Update();
73
75 isoLine->SetInputData(isoSurface->GetOutput());
76 isoLine->SetComputeScalars(true);
77 isoLine->SetInputArrayToProcess(
78 0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, vArray->GetName());
79 isoLine->SetNumberOfContours(1);
80 isoLine->SetValue(0, VValue);
81 isoLine->Update();
82
83 output->ShallowCopy(isoLine->GetOutput());
84
85 this->printMsg("Computing Fiber (" + uArrayName + ": "
86 + std::to_string(UValue) + ", " + vArrayName + ": "
87 + std::to_string(VValue) + ")",
88 1, t.getElapsedTime());
89
90 return 1;
91}
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
Definition BaseClass.h:47
TTK VTK-filter for fiber computation on bivariate volumetric data.
Definition ttkFiber.h:34
int FillInputPortInformation(int port, vtkInformation *info) override
Definition ttkFiber.cpp:17
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Definition ttkFiber.cpp:35
~ttkFiber() override
int FillOutputPortInformation(int port, vtkInformation *info) override
Definition ttkFiber.cpp:26
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(ttkFiber)
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)