6#include <vtkDoubleArray.h>
7#include <vtkUnstructuredGrid.h>
12 this->SetNumberOfInputPorts(1);
13 this->SetNumberOfOutputPorts(4);
21 return vtkTable::SafeDownCast(this->GetOutputDataObject(port));
25 vtkInformation *info) {
27 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),
"vtkUnstructuredGrid");
34 vtkInformation *info) {
35 if(port == 0 || port == 1 || port == 2 || port == 3) {
36 info->Set(vtkDataObject::DATA_TYPE_NAME(),
"vtkTable");
42static void getPersistenceCurve(vtkTable *outputCurve,
44 const std::string &pairsType) {
50 vtkNew<vtkDoubleArray> persistenceScalars{};
51 const auto persQualifier =
"Persistence (" + pairsType +
")";
52 persistenceScalars->SetName(persQualifier.c_str());
53 persistenceScalars->SetNumberOfTuples(plot.size());
55 vtkNew<ttkSimplexIdTypeArray> numberOfPairsScalars{};
56 const auto nPairsQualifier =
"Number Of Pairs (" + pairsType +
")";
57 numberOfPairsScalars->SetName(nPairsQualifier.c_str());
58 numberOfPairsScalars->SetNumberOfTuples(plot.size());
60 for(
size_t i = 0; i < plot.size(); ++i) {
61 persistenceScalars->SetTuple1(i, plot[i].first);
62 numberOfPairsScalars->SetTuple1(i, plot[i].second);
65 vtkNew<vtkTable> persistenceCurve{};
66 persistenceCurve->AddColumn(persistenceScalars);
67 persistenceCurve->AddColumn(numberOfPairsScalars);
69 outputCurve->ShallowCopy(persistenceCurve);
73 vtkInformationVector **inputVector,
74 vtkInformationVector *outputVector) {
78 auto *input = vtkUnstructuredGrid::GetData(inputVector[0]);
80 auto *minSadTable = vtkTable::GetData(outputVector, 0);
81 auto *sadSadTable = vtkTable::GetData(outputVector, 1);
82 auto *sadMaxTable = vtkTable::GetData(outputVector, 2);
83 auto *allPairsTable = vtkTable::GetData(outputVector, 3);
88 this->
printErr(
"Could not read input Persistence Diagram");
92 std::array<PlotType, 4> plots{};
93 ret = this->
execute(plots, diagram);
95 this->
printErr(
"Could not execute base code");
99 getPersistenceCurve(minSadTable, plots[0],
"minimum-saddle pairs");
100 getPersistenceCurve(sadSadTable, plots[1],
"saddle-saddle pairs");
101 getPersistenceCurve(sadMaxTable, plots[2],
"maximum-saddle pairs");
102 getPersistenceCurve(allPairsTable, plots[3],
"all pairs");
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
TTK VTK-filter for the computation of persistence curves.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
int FillOutputPortInformation(int port, vtkInformation *info) override
int FillInputPortInformation(int port, vtkInformation *info) override
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
int execute(std::array< PlotType, 4 > &plots, const DiagramType &diagram) const
Compute the Persistence Curve from the input Diagram.
std::vector< std::pair< double, SimplexId > > PlotType
std::vector< PersistencePair > DiagramType
Persistence Diagram type as a vector of Persistence pairs.
vtkStandardNewMacro(ttkPersistenceCurve)
int VTUToDiagram(ttk::DiagramType &diagram, vtkUnstructuredGrid *vtu, const ttk::Debug &dbg)
Converts a Persistence Diagram in the VTK Unstructured Grid format (as generated by the ttkPersistenc...
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)