TTK
Loading...
Searching...
No Matches
ttkDataSetToTable.cpp
Go to the documentation of this file.
1#include <ttkDataSetToTable.h>
2
3#include <vtkCellData.h>
4#include <vtkDataSet.h>
5#include <vtkInformation.h>
6#include <vtkObjectFactory.h>
7#include <vtkPointData.h>
8#include <vtkTable.h>
9
11
13 this->setDebugMsgPrefix("DataSetToTable");
14
15 this->SetNumberOfInputPorts(1);
16 this->SetNumberOfOutputPorts(1);
17}
18
20
22 vtkInformation *info) {
23 if(port == 0) {
24 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
25 return 1;
26 }
27 return 0;
28}
29
31 vtkInformation *info) {
32 if(port == 0) {
33 info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkTable");
34 return 1;
35 }
36 return 0;
37}
38
39int ttkDataSetToTable::RequestData(vtkInformation *ttkNotUsed(request),
40 vtkInformationVector **inputVector,
41 vtkInformationVector *outputVector) {
42 ttk::Timer t;
43
44 std::string const targetAttributeName = this->DataAssociation == 0 ? "Point"
45 : this->DataAssociation == 1
46 ? "Cell"
47 : "Field";
48
49 this->printMsg("Converting " + targetAttributeName + "Data to Table", 0, 0,
51
52 auto input = vtkDataSet::GetData(inputVector[0]);
53 if(!input)
54 return 0;
55
56 auto targetData = this->DataAssociation == 0 ? input->GetPointData()
57 : this->DataAssociation == 1 ? input->GetCellData()
58 : input->GetFieldData();
59
60#ifndef TTK_ENABLE_KAMIKAZE
61 if(targetData->GetNumberOfArrays() < 1) {
62 this->printWrn("Empty " + targetAttributeName + "Data.");
63 }
64#endif
65
66 auto table = vtkTable::GetData(outputVector);
67 table->GetRowData()->ShallowCopy(targetData);
68
69 this->printMsg("Converting " + targetAttributeName + "Data to Table", 1,
70 t.getElapsedTime());
71
72 return 1;
73}
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
Definition BaseClass.h:47
TTK VTK-filter that creates a vtkTable from a vtkDataSet.
int FillOutputPortInformation(int port, vtkInformation *info) override
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
int FillInputPortInformation(int port, vtkInformation *info) override
~ttkDataSetToTable() override
int printWrn(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition Debug.h:159
void setDebugMsgPrefix(const std::string &prefix)
Definition Debug.h:364
double getElapsedTime()
Definition Timer.h:15
vtkStandardNewMacro(ttkDataSetToTable)
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)