3#include <vtkInformation.h>
5#include <vtkDoubleArray.h>
6#include <vtkFloatArray.h>
7#include <vtkIdTypeArray.h>
8#include <vtkIntArray.h>
10#include <vtkPointData.h>
11#include <vtkPolyData.h>
12#include <vtkSignedCharArray.h>
24 this->SetNumberOfInputPorts(1);
25 this->SetNumberOfOutputPorts(1);
31 int port, vtkInformation *info) {
33 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),
"vtkDataSet");
41 int port, vtkInformation *info) {
43 info->Set(vtkDataObject::DATA_TYPE_NAME(),
"vtkPolyData");
52 vtkInformationVector **inputVector,
53 vtkInformationVector *outputVector) {
55 vtkDataSet *input = vtkDataSet::GetData(inputVector[0]);
56 vtkPolyData *output = vtkPolyData::GetData(outputVector, 0);
60 int keepGoing = checkEmptyMPIInput<Triangulation>(triangulation);
73 vtkDataArray *inputScalarField = this->GetInputArrayToProcess(0, inputVector);
77 vtkDataArray *offsetField
78 = this->
GetOrderArray(input, 0, 1, ForceInputOffsetScalarField);
84#ifdef TTK_ENABLE_MPI_TIME
90 printMsg({{
" Scalar Array", inputScalarField->GetName()},
91 {
" Offset Array", offsetField ? offsetField->GetName() :
"None"}});
96 (status = this->execute(
98 (TTK_TT *)triangulation->
getData())));
103#ifdef TTK_ENABLE_MPI_TIME
107 +
" MPI processes lasted :" + std::to_string(elapsedTime));
112 vtkNew<vtkSignedCharArray> vertexTypes{};
113 vertexTypes->SetNumberOfComponents(1);
114 vertexTypes->SetNumberOfTuples(criticalPoints_.size());
115 vertexTypes->SetName(
"CriticalType");
117 vtkNew<vtkPoints> pointSet{};
118 pointSet->SetNumberOfPoints(criticalPoints_.size());
120#ifdef TTK_ENABLE_OPENMP
121#pragma omp parallel for num_threads(this->threadNumber_)
123 for(
size_t i = 0; i < criticalPoints_.size(); i++) {
124 std::array<double, 3> p{};
125 input->GetPoint(criticalPoints_[i].first, p.data());
126 pointSet->SetPoint(i, p.data());
127 vertexTypes->SetTuple1(i, (
float)criticalPoints_[i].second);
131 output->GetPointData()->AddArray(vertexTypes);
134 vtkNew<vtkSignedCharArray> vertexBoundary{};
135 vertexBoundary->SetNumberOfComponents(1);
136 vertexBoundary->SetNumberOfTuples(criticalPoints_.size());
137 vertexBoundary->SetName(
"IsOnBoundary");
139#ifdef TTK_ENABLE_OPENMP
140#pragma omp parallel for num_threads(threadNumber_)
142 for(
size_t i = 0; i < criticalPoints_.size(); i++) {
143 vertexBoundary->SetTuple1(
145 criticalPoints_[i].first));
148 output->GetPointData()->AddArray(vertexBoundary);
150 output->GetPointData()->RemoveArray(
"IsOnBoundary");
154 vtkNew<ttkSimplexIdTypeArray> vertexIds{};
155 vertexIds->SetNumberOfComponents(1);
156 vertexIds->SetNumberOfTuples(criticalPoints_.size());
158 for(
size_t i = 0; i < criticalPoints_.size(); i++) {
160 if(hasInitializedMPI()) {
161 vertexIds->SetTuple1(
162 i, triangulation->getVertexGlobalId(criticalPoints_[i].first));
166 vertexIds->SetTuple1(i, criticalPoints_[i].first);
170 output->GetPointData()->AddArray(vertexIds);
176 for(
SimplexId i = 0; i < input->GetPointData()->GetNumberOfArrays(); i++) {
178 vtkDataArray *scalarField = input->GetPointData()->GetArray(i);
181 scalarArray->SetNumberOfComponents(scalarField->GetNumberOfComponents());
182 scalarArray->SetNumberOfTuples(criticalPoints_.size());
183 scalarArray->SetName(scalarField->GetName());
184 std::vector<double> value(scalarField->GetNumberOfComponents());
185 for(
size_t j = 0; j < criticalPoints_.size(); j++) {
186 scalarField->GetTuple(criticalPoints_[j].first, value.data());
187 scalarArray->SetTuple(j, value.data());
189 output->GetPointData()->AddArray(scalarArray);
192 for(
SimplexId i = 0; i < input->GetPointData()->GetNumberOfArrays(); i++) {
193 output->GetPointData()->RemoveArray(
194 input->GetPointData()->GetArray(i)->GetName());
#define ttkTemplateMacro(triangulationType, call)
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
vtkDataArray * GetOrderArray(vtkDataSet *const inputData, const int scalarArrayIdx, const int orderArrayIdx=0, const bool enforceOrderArrayIdx=false)
ttk::Triangulation * GetTriangulation(vtkDataSet *dataSet)
TTK VTK-filter for the computation of critical points in PL scalar fields defined on PL manifolds.
ttkScalarFieldCriticalPoints()
int FillOutputPortInformation(int port, vtkInformation *info) override
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
~ttkScalarFieldCriticalPoints() override
int FillInputPortInformation(int port, vtkInformation *info) override
static void * GetVoidPointer(vtkDataArray *array, vtkIdType start=0)
static int CellVertexFromPoints(vtkDataSet *const dataSet, vtkPoints *const points)
int printMsg(const std::string &msg, const debug::Priority &priority=debug::Priority::INFO, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
void preconditionTriangulation(AbstractTriangulation *triangulation)
void setOutput(std::vector< std::pair< SimplexId, char > > *criticalPoints)
Triangulation is a class that provides time and memory efficient traversal methods on triangulations ...
AbstractTriangulation * getData()
bool isVertexOnBoundary(const SimplexId &vertexId) const override
Triangulation::Type getType() const
int preconditionBoundaryVertices() override
COMMON_EXPORTS int MPIsize_
COMMON_EXPORTS int MPIrank_
const char VertexScalarFieldName[]
default name for vertex scalar field
int SimplexId
Identifier type for simplices of any dimension.
vtkStandardNewMacro(ttkScalarFieldCriticalPoints)