6#include <vtkDoubleArray.h>
7#include <vtkUnstructuredGrid.h>
12 this->SetNumberOfInputPorts(1);
13 this->SetNumberOfOutputPorts(1);
21 return vtkTable::SafeDownCast(this->GetOutputDataObject(port));
25 vtkInformation *info) {
27 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),
"vtkDataSet");
34 vtkInformation *info) {
36 info->Set(vtkDataObject::DATA_TYPE_NAME(),
"vtkTable");
42static void getVectorWeightCurve(
43 vtkTable *outputCurve,
44 std::vector<ttk::VectorSimplification::PlotPoint> &plotPoints,
46 bool displayCancelTypes) {
48 if(plotPoints.empty()) {
52 vtkNew<vtkDoubleArray> persistenceScalars{};
53 persistenceScalars->SetName(
"Weight Value");
54 persistenceScalars->SetNumberOfTuples(plotPoints.size());
56 vtkNew<ttkSimplexIdTypeArray> numberOfCPScalars{};
57 numberOfCPScalars->SetName(
"Number of Critical Points");
58 numberOfCPScalars->SetNumberOfTuples(plotPoints.size());
60 vtkNew<ttkSimplexIdTypeArray> numberOfSinksScalars{};
61 vtkNew<ttkSimplexIdTypeArray> numberOfSourcesScalars{};
62 if(displayCancelTypes) {
63 numberOfSinksScalars->SetName(
"Number of Sinks");
64 numberOfSinksScalars->SetNumberOfTuples(plotPoints.size());
66 numberOfSourcesScalars->SetName(
"Number of Sources");
67 numberOfSourcesScalars->SetNumberOfTuples(plotPoints.size());
70 vtkNew<ttkSimplexIdTypeArray> numberOfOrbitsAdded{};
71 vtkNew<ttkSimplexIdTypeArray> numberOfOrbitsRemoved{};
73 numberOfOrbitsAdded->SetName(
"Number of Orbits Generated");
74 numberOfOrbitsAdded->SetNumberOfTuples(plotPoints.size());
76 numberOfOrbitsRemoved->SetName(
"Number of Orbits Cancelled");
77 numberOfOrbitsRemoved->SetNumberOfTuples(plotPoints.size());
80 for(
size_t i = 0; i < plotPoints.size(); ++i) {
81 persistenceScalars->SetTuple1(i, plotPoints[i].weight);
82 numberOfCPScalars->SetTuple1(i, plotPoints[i].numCP);
83 if(displayCancelTypes) {
84 numberOfSinksScalars->SetTuple1(i, plotPoints[i].numSinks);
85 numberOfSourcesScalars->SetTuple1(i, plotPoints[i].numSources);
88 numberOfOrbitsAdded->SetTuple1(i, plotPoints[i].orbitsAdded);
89 numberOfOrbitsRemoved->SetTuple1(i, plotPoints[i].orbitsRemoved);
93 vtkNew<vtkTable> vectorWeightCurve{};
94 vectorWeightCurve->AddColumn(persistenceScalars);
95 vectorWeightCurve->AddColumn(numberOfCPScalars);
96 if(displayCancelTypes) {
97 vectorWeightCurve->AddColumn(numberOfSinksScalars);
98 vectorWeightCurve->AddColumn(numberOfSourcesScalars);
101 vectorWeightCurve->AddColumn(numberOfOrbitsAdded);
102 vectorWeightCurve->AddColumn(numberOfOrbitsRemoved);
105 outputCurve->ShallowCopy(vectorWeightCurve);
109 vtkInformationVector **inputVector,
110 vtkInformationVector *outputVector) {
114 auto input = vtkDataSet::GetData(inputVector[0]);
118#ifndef TTK_ENABLE_KAMIKAZE
120 this->
printErr(
"Input pointer is NULL.");
123 if(!input->GetNumberOfPoints()) {
124 this->
printErr(
"Input has no point.");
129 this->
vs_.preconditionTriangulation(triangulation);
131 const auto inputVectors = this->GetInputArrayToProcess(0, input);
133 if(inputVectors ==
nullptr) {
134 this->
printErr(
"Input vector array is NULL");
137 if(this->GetInputArrayAssociation(0, inputVector) != 0) {
138 this->
printErr(
"Input array needs to be a point data array.");
141 if(inputVectors->GetNumberOfComponents() != 3) {
142 this->
printErr(
"Input array needs to be a vector array(3D).");
146 auto *allPairsTable = vtkTable::GetData(outputVector, 0);
152 inputVectors->GetDataType(), triangulation->getType(),
153 (ret = this->vs_.buildField<VTK_TT, TTK_TT>(
155 *
static_cast<TTK_TT *
>(triangulation->getData()))));
157 this->
printErr(
"Could not generate field");
160 this->
printMsg(
"Generated the discrete field");
161 std::vector<ttk::VectorSimplification::PlotPoint> vs_pairs;
165 inputVectors->GetDataType(), triangulation->getType(),
166 (ret = this->vs_.performSimplification<VTK_TT, TTK_TT>(
167 0,
true, vs_pairs, *
static_cast<TTK_TT *
>(triangulation->getData()))));
169 this->
printErr(
"Could not simplify field");
172 this->
printMsg(
"Simplified the discete field");
174 getVectorWeightCurve(
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
ttk::Triangulation * GetTriangulation(vtkDataSet *dataSet)
static void * GetVoidPointer(vtkDataArray *array, vtkIdType start=0)
TTK VTK-filter for the computation of vector field weight curves.
int FillOutputPortInformation(int port, vtkInformation *info) override
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) 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
void UpdateTraceFullOrbits()
#define ttkVtkTemplateMacro(dataType, triangulationType, call)
vtkStandardNewMacro(ttkVectorWeightCurve)
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/| (_) |"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)