3#include <vtkInformation.h>
5#include <vtkDataArray.h>
7#include <vtkObjectFactory.h>
8#include <vtkPointData.h>
9#include <vtkSmartPointer.h>
20 this->SetNumberOfInputPorts(1);
21 this->SetNumberOfOutputPorts(1);
29 int port, vtkInformation *info) {
31 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),
"vtkDataSet");
38 int port, vtkInformation *info) {
48 vtkInformationVector **inputVector,
49 vtkInformationVector *outputVector) {
52 auto inputDataSet = vtkDataSet::GetData(inputVector[0]);
57 if(this->GetInputArrayAssociation(0, inputVector) != 0)
58 return !this->
printErr(
"Input array needs to be a point data array.");
60 auto inputScalars = this->GetInputArrayToProcess(0, inputVector);
62 return !this->
printErr(
"Unable to retrieve input array.");
64 if(inputScalars->GetNumberOfComponents() != 1)
65 return !this->
printErr(
"Input array needs to be a scalar array.");
74 outputScalars->DeepCopy(inputScalars);
77 outputOrder->DeepCopy(inputOrder);
85 double persistenceThreshold = this->PersistenceThreshold;
86 if(!this->ThresholdIsAbsolute) {
88 outputScalars->GetRange(range);
89 persistenceThreshold = (range[1] - range[0]) * persistenceThreshold;
95 outputScalars->GetDataType(), triangulation->getType(),
96 (status = this->removeNonPersistentExtrema<VTK_TT,
ttk::SimplexId, TTK_TT>(
97 ttkUtils::GetPointer<VTK_TT>(outputScalars),
98 ttkUtils::GetPointer<ttk::SimplexId>(outputOrder),
100 static_cast<TTK_TT *
>(triangulation->getData()), persistenceThreshold,
101 this->ComputePerturbation, this->PairType)));
107 auto outputDataSet = vtkDataSet::GetData(outputVector, 0);
108 outputDataSet->ShallowCopy(inputDataSet);
110 auto outputDataSetPD = outputDataSet->GetPointData();
111 outputDataSetPD->AddArray(outputScalars);
112 outputDataSetPD->AddArray(outputOrder);
#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()
vtkDataArray * GetOrderArray(vtkDataSet *const inputData, const int scalarArrayIdx, const int orderArrayIdx=0, const bool enforceOrderArrayIdx=false)
ttk::Triangulation * GetTriangulation(vtkDataSet *dataSet)
TTK VTK-filter that computes a persistence-based simplification of a scalar field.
~ttkTopologicalSimplificationByPersistence() override
ttkTopologicalSimplificationByPersistence()
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
int FillInputPortInformation(int port, vtkInformation *info) override
int FillOutputPortInformation(int port, vtkInformation *info) override
void setDebugMsgPrefix(const std::string &prefix)
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
int preconditionTriangulation(ttk::AbstractTriangulation *triangulation) const
int SimplexId
Identifier type for simplices of any dimension.
#define ttkVtkTemplateMacro(dataType, triangulationType, call)
vtkStandardNewMacro(ttkTopologicalSimplificationByPersistence)