5#include <vtkAbstractArray.h>
6#include <vtkCellArray.h>
7#include <vtkFloatArray.h>
8#include <vtkInformation.h>
9#include <vtkInformationVector.h>
10#include <vtkPointData.h>
11#include <vtkPolyData.h>
12#include <vtkSmartPointer.h>
13#include <vtkUnstructuredGrid.h>
22 this->SetNumberOfInputPorts(1);
23 this->SetNumberOfOutputPorts(1);
28 vtkInformation *info) {
30 info->Set(vtkAlgorithm::INPUT_IS_REPEATABLE(), 1);
32 vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),
"vtkUnstructuredGrid");
33 info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),
"vtkPolyData");
40 vtkInformation *info) {
50 vtkInformationVector **inputVector,
51 vtkInformationVector *outputVector) {
54 auto input = vtkDataSet::GetData(inputVector[0]);
55 auto output = vtkDataSet::GetData(outputVector);
58 return !this->
printErr(
"Unable to retrieve input/output data objects.");
61 output->ShallowCopy(input);
63 size_t const nPoints = output->GetNumberOfPoints();
64 size_t const nEdges = output->GetNumberOfCells();
67 auto sequenceArray = this->GetInputArrayToProcess(0, inputVector);
69 return !this->
printErr(
"Unable to retrieve sequence array.");
71 auto sizeArray = this->GetInputArrayToProcess(1, inputVector);
73 return !this->
printErr(
"Unable to retrieve size array.");
75 auto branchArray = this->GetInputArrayToProcess(2, inputVector);
77 return !this->
printErr(
"Unable to retrieve branch array.");
79 auto levelArray = this->GetInputArrayToProcess(3, inputVector);
81 return !this->
printErr(
"Unable to retrieve level array.");
86 outputArray->SetNumberOfComponents(2);
87 outputArray->SetNumberOfValues(nPoints * 2);
89 vtkDataArray *cells{
nullptr};
90 if(
auto outputAsUG = vtkUnstructuredGrid::SafeDownCast(output))
91 cells = outputAsUG->GetCells()->GetConnectivityArray();
92 else if(
auto outputAsPD = vtkPolyData::SafeDownCast(output))
93 cells = outputAsPD->GetLines()->GetConnectivityArray();
96 return !this->
printErr(
"Unable to retrieve connectivity array.");
102 cells->GetDataType(),
103 (status = this->computeLayout<T0, T1, T2>(
105 ttkUtils::GetPointer<float>(outputArray),
107 ttkUtils::GetPointer<T2>(cells), nPoints, nEdges,
110 this->
GetUseSizes() ? ttkUtils::GetPointer<float>(sizeArray) :
nullptr,
111 this->
GetUseBranches() ? ttkUtils::GetPointer<T1>(branchArray) :
nullptr,
112 this->
GetUseLevels() ? ttkUtils::GetPointer<T1>(levelArray) :
nullptr)));
118 output->GetPointData()->AddArray(outputArray);
123template <
class dataType>
125 vtkUnstructuredGrid *treeNodes,
126 vtkUnstructuredGrid *treeArcs,
127 vtkUnstructuredGrid *output) {
128 auto mergeTree = ttk::ftm::makeTree<dataType>(treeNodes, treeArcs);
131 ttk::ftm::computePersistencePairs<dataType>(tree);
133 std::vector<std::vector<int>> treeNodeCorrMesh(1);
136 treeNodeCorrMesh[0][j] = j;
164 vtkInformationVector **inputVector,
165 vtkInformationVector *outputVector) {
167 vtkUnstructuredGrid *treeNodes
168 = vtkUnstructuredGrid::GetData(inputVector[0], 0);
169 vtkUnstructuredGrid *treeArcs
170 = vtkUnstructuredGrid::GetData(inputVector[0], 1);
171 auto output = vtkUnstructuredGrid::GetData(outputVector);
173 return mergeTreePlanarLayoutCallTemplate<float>(treeNodes, treeArcs, output);
177 vtkInformationVector **inputVector,
178 vtkInformationVector *outputVector) {
179 if(not InputIsAMergeTree)
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
static vtkInformationIntegerKey * SAME_DATA_TYPE_AS_INPUT_PORT()
void setMinimumImportantPairs(int minPairs)
void setMaximumImportantPairs(int maxPairs)
void copyPointData(vtkUnstructuredGrid *treeNodes, std::vector< int > &nodeCorrT)
void setTreesNodeCorrMesh(std::vector< std::vector< int > > &nodeCorrMesh)
void setOutputSegmentation(bool b)
void setPlanarLayout(bool b)
void makeTreesOutput(FTMTree_MT *tree1)
void setVtkOutputArc(vtkUnstructuredGrid *vtkArc)
void setVtkOutputNode(vtkUnstructuredGrid *vtkNode)
void setTreesNodes(std::vector< vtkUnstructuredGrid * > &nodes)
TTK VTK-filter that computes a planar graph layout.
int mergeTreePlanarLayoutCallTemplate(vtkUnstructuredGrid *treeNodes, vtkUnstructuredGrid *treeArcs, vtkUnstructuredGrid *output)
int mergeTreePlanarLayoutCall(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
virtual bool GetUseSizes()
virtual bool GetUseLevels()
int planarGraphLayoutCall(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
~ttkPlanarGraphLayout() override
virtual bool GetUseSequences()
int FillInputPortInformation(int port, vtkInformation *info) override
int FillOutputPortInformation(int port, vtkInformation *info) override
virtual std::string GetOutputArrayName()
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
virtual bool GetUseBranches()
virtual int setDebugLevel(const int &debugLevel)
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
void setNonImportantPairsSpacing(double d)
void setNonImportantPairsProximity(double d)
void setBranchSpacing(double d)
void setExcludeImportantPairsLower(std::string &d)
void setImportantPairsSpacing(double d)
void setImportantPairs(double d)
void setExcludeImportantPairsHigher(std::string &d)
void setBranchDecompositionPlanarLayout(bool b)
idNode getNumberOfNodes() const
#define ttkTypeMacroAII(group0, group1, group2, call)
vtkStandardNewMacro(ttkPlanarGraphLayout)