12#include <vtkDataSet.h>
13#include <vtkDataSetAlgorithm.h>
14#include <vtkImageData.h>
15#include <vtkPolyData.h>
16#include <vtkSmartPointer.h>
17#include <vtkUnstructuredGrid.h>
18#include <vtkXMLImageDataReader.h>
19#include <vtkXMLImageDataWriter.h>
20#include <vtkXMLPolyDataReader.h>
21#include <vtkXMLPolyDataWriter.h>
22#include <vtkXMLUnstructuredGridReader.h>
23#include <vtkXMLUnstructuredGridWriter.h>
29#include <ttkProgramBaseModule.h>
36 vtkWrapper_ =
nullptr;
46 if((inputId < 0) || (inputId >= (
int)inputs_.size()))
48 return inputs_[inputId];
52 return inputs_.size();
64 ttkModule_->setDebugLevel(debugLevel_);
65 ttkModule_->setThreadNumber(threadNumber_);
71 int save()
const override;
75 vtkWrapper_ = ttkModule;
76 ttkModule_ = (Debug *)ttkModule;
85 std::vector<vtkSmartPointer<vtkXMLUnstructuredGridReader>>
89 template <
class vtkReaderClass>
90 int load(
const std::string &fileName,
94 int load(
const std::vector<std::string> &inputPaths)
override;
96 template <
class vtkWriterClass>
97 int save(
const int &outputPortId)
const;
100template <
class ttkModule>
117template <
class vtkWriterClass>
123 std::string extension;
125 if((
vtkWrapper_->GetOutput(outputPortId)->GetDataObjectType()
126 == VTK_IMAGE_DATA)) {
132 if((
vtkWrapper_->GetOutput(outputPortId)->GetDataObjectType()
139 if((
vtkWrapper_->GetOutput(outputPortId)->GetDataObjectType()
140 == VTK_UNSTRUCTURED_GRID)) {
146 std::stringstream fileName;
147 fileName <<
outputPath_ <<
"_port#" << outputPortId <<
"." << extension;
151 writer->SetFileName(fileName.str().data());
152 writer->SetInputData(
vtkWrapper_->GetOutput(outputPortId));
153 std::stringstream msg;
154 msg <<
"[ttkProgramBase] Saving output file `" << fileName.str() <<
"'..."
163template <
class vtkReaderClass>
165 const std::string &fileName,
168 readerList.resize(readerList.size() + 1);
171 readerList.back()->SetFileName(fileName.data());
175 std::stringstream msg;
176 msg <<
"[ttkProgramBase] Reading input data..." << std::endl;
183 readerList.back()->Update();
184 inputs_.push_back(readerList.back()->GetOutput());
189 if(!
inputs_.back()->GetNumberOfPoints())
192 if(!
inputs_.back()->GetNumberOfCells())
196 std::stringstream msg;
197 msg <<
"[ttkProgramBase] done! (read "
198 <<
inputs_.back()->GetNumberOfPoints() <<
" vertices, "
199 <<
inputs_.back()->GetNumberOfCells() <<
" cells)" << std::endl;
Base VTK editor class for standalone programs. This class parses the the command line,...
std::vector< vtkSmartPointer< vtkXMLPolyDataReader > > polyDataReaders_
std::vector< vtkSmartPointer< vtkXMLImageDataReader > > imageDataReaders_
int load(const std::string &fileName, std::vector< vtkSmartPointer< vtkReaderClass > > &readerList)
vtkDataSet * getInput(const int &inputId)
~ttkProgramBase() override=default
vtkDataSetAlgorithm * vtkWrapper_
std::vector< vtkSmartPointer< vtkXMLUnstructuredGridReader > > unstructuredGridReaders_
int save() const override
Save the output(s) of the TTK module.
std::vector< vtkDataSet * > inputs_
virtual int setTTKmodule(vtkDataSetAlgorithm *ttkModule)
Base editor class for standalone programs. This class parses the the command line,...
virtual int save() const =0
Save the output(s) of the TTK module.
virtual int execute()=0
Execute your TTK module here.
virtual int load(const std::vector< std::string > &inputPaths)=0
Load a sequence of input data-sets.
vtkSmartPointer< ttkModule > ttkObject_
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)