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 targetAttributeName = this->DataAssociation == 0 ? "Point"
45 : this->DataAssociation == 1 ? "Cell"
46 : "Field";
47
48 this->printMsg("Converting " + targetAttributeName + "Data to Table", 0, 0,
50
51 auto input = vtkDataSet::GetData(inputVector[0]);
52 if(!input)
53 return 0;
54
55 auto targetData = this->DataAssociation == 0 ? input->GetPointData()
56 : this->DataAssociation == 1 ? input->GetCellData()
57 : input->GetFieldData();
58
59#ifndef TTK_ENABLE_KAMIKAZE
60 if(targetData->GetNumberOfArrays() < 1) {
61 this->printWrn("Empty " + targetAttributeName + "Data.");
62 }
63#endif
64
65 auto table = vtkTable::GetData(outputVector);
66 table->GetRowData()->ShallowCopy(targetData);
67
68 this->printMsg("Converting " + targetAttributeName + "Data to Table", 1,
69 t.getElapsedTime());
70
71 return 1;
72}
#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
int printMsg(const std::string &msg, const debug::Priority &priority=debug::Priority::INFO, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
Definition: Debug.h:118
double getElapsedTime()
Definition: Timer.h:15
vtkStandardNewMacro(ttkDataSetToTable)