TTK
Loading...
Searching...
No Matches
ttkProgramBase.cpp
Go to the documentation of this file.
1#include <ttkProgramBase.h>
2
3using namespace std;
4using namespace ttk;
5
7
8 if(!vtkWrapper_)
9 return -1;
10
11 for(int i = 0; i < (int)inputs_.size(); i++) {
12 vtkWrapper_->SetInputData(i, inputs_[i]);
13 }
14
15 vtkWrapper_->Update();
16 vtkWrapper_->Modified();
17
18 return 0;
19}
20
21int ttkProgramBase::load(const std::vector<std::string> &inputPaths) {
22
23 int ret = -1;
24
25 for(int i = 0; i < (int)inputPaths.size(); i++) {
26
27 string const extension
28 = inputPaths[i].substr(inputPaths[i].find_last_of('.') + 1);
29
30 if(extension == "vti") {
31 ret = load<vtkXMLImageDataReader>(inputPaths[i], imageDataReaders_);
32 } else if(extension == "vtp") {
33 ret = load<vtkXMLPolyDataReader>(inputPaths[i], polyDataReaders_);
34 } else if(extension == "vtu") {
35 ret = load<vtkXMLUnstructuredGridReader>(
36 inputPaths[i], unstructuredGridReaders_);
37 } else {
38 stringstream msg;
39 msg << "[ttkProgramBase] Unknown input extension `" << extension << "' :("
40 << endl;
41 printErr(msg.str());
42 return -1;
43 }
44
45 if(ret)
46 return ret;
47 }
48
49 return 0;
50}
51
53
54 if(!vtkWrapper_)
55 return -1;
56
57 for(int i = 0; i < vtkWrapper_->GetNumberOfOutputPorts(); i++) {
58
59 if(vtkWrapper_->GetOutput(i)) {
60
61 if((vtkWrapper_->GetOutput(i)->GetDataObjectType() == VTK_IMAGE_DATA)) {
62 // ||(vtkWrapper_->GetOutput(i)->GetDataObjectType() ==
63 // TTK_IMAGE_DATA)){
64 save<vtkXMLImageDataWriter>(i);
65 }
66
67 if((vtkWrapper_->GetOutput(i)->GetDataObjectType() == VTK_POLY_DATA)) {
68 // ||(vtkWrapper_->GetOutput(i)->GetDataObjectType() ==
69 // TTK_POLY_DATA)){
70 save<vtkXMLPolyDataWriter>(i);
71 }
72
73 if((vtkWrapper_->GetOutput(i)->GetDataObjectType()
74 == VTK_UNSTRUCTURED_GRID)) {
75 // ||(vtkWrapper_->GetOutput(i)->GetDataObjectType() ==
76 // TTK_UNSTRUCTURED_GRID)){
77 save<vtkXMLUnstructuredGridWriter>(i);
78 }
79 }
80 }
81
82 return 0;
83}
std::vector< vtkSmartPointer< vtkXMLPolyDataReader > > polyDataReaders_
int execute() override
Set the arguments of your ttk module and execute it here.
std::vector< vtkSmartPointer< vtkXMLImageDataReader > > imageDataReaders_
int load(const std::string &fileName, std::vector< vtkSmartPointer< vtkReaderClass > > &readerList)
vtkDataSetAlgorithm * vtkWrapper_
std::vector< vtkSmartPointer< vtkXMLUnstructuredGridReader > > unstructuredGridReaders_
int save() const override
Save the output(s) of the TTK module.
std::vector< vtkDataSet * > inputs_
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition Debug.h:149
The Topology ToolKit.