TTK
Loading...
Searching...
No Matches
ttkIdentifiers.cpp
Go to the documentation of this file.
1#include <ttkIdentifiers.h>
2
3#include <Triangulation.h>
4#include <vtkCellData.h>
5#include <vtkDataSet.h>
6#include <vtkIdTypeArray.h>
7#include <vtkInformation.h>
8#include <vtkPointData.h>
9
10using namespace std;
11using namespace ttk;
12
14
16 this->SetNumberOfInputPorts(1);
17 this->SetNumberOfOutputPorts(1);
18}
19
21
22int ttkIdentifiers::FillInputPortInformation(int port, vtkInformation *info) {
23 if(port == 0) {
24 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
25 return 1;
26 }
27 return 0;
28}
29
30int ttkIdentifiers::FillOutputPortInformation(int port, vtkInformation *info) {
31 if(port == 0) {
33 return 1;
34 }
35 return 0;
36}
37
38int ttkIdentifiers::RequestData(vtkInformation *ttkNotUsed(request),
39 vtkInformationVector **inputVector,
40 vtkInformationVector *outputVector) {
41
42 vtkDataSet *input = vtkDataSet::GetData(inputVector[0]);
43 vtkDataSet *output = vtkDataSet::GetData(outputVector);
44
45 Timer const t;
46
47 int const keepGoing = checkEmptyMPIInput<vtkDataSet>(input);
48 if(keepGoing < 2) {
49 return keepGoing;
50 }
51
52 auto triangulation = ttkAlgorithm::GetTriangulation(input);
53 if(triangulation == nullptr) {
54 this->printErr("Triangulation is NULL");
55 return 0;
56 }
57
58 // The following is reserved to vtkImageData. For UnstructuredGrid and
59 // vtkPolyData, the global identifiers are always stored as vtkDataArrays
60 // automatically during preconditioning
61
62 ttk::SimplexId const numberOfVertices = triangulation->getNumberOfVertices();
63 vtkNew<vtkIdTypeArray> globalPointIds;
64 globalPointIds->SetNumberOfTuples(numberOfVertices);
65 globalPointIds->SetNumberOfComponents(1);
66 globalPointIds->SetName("GlobalPointIds");
67 for(int i = 0; i < numberOfVertices; i++) {
68#ifdef TTK_ENABLE_MPI
69 if(input->GetDataObjectType() == VTK_IMAGE_DATA) {
70 globalPointIds->SetTuple1(i, triangulation->getVertexGlobalId(i));
71 }
72#else
73 globalPointIds->SetTuple1(i, i);
74#endif
75 }
76
77#ifdef TTK_ENABLE_MPI
78 if(input->GetDataObjectType() == VTK_IMAGE_DATA) {
79#endif
80 input->GetPointData()->AddArray(globalPointIds);
81#ifdef TTK_ENABLE_MPI
82 }
83#endif
84
85 output->ShallowCopy(input);
86
88
89 return 1;
90}
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
Definition BaseClass.h:47
static vtkInformationIntegerKey * SAME_DATA_TYPE_AS_INPUT_PORT()
ttk::Triangulation * GetTriangulation(vtkDataSet *dataSet)
TTK VTK-filter that triggers the computation of global identifiers.
int FillInputPortInformation(int port, vtkInformation *info) override
int FillOutputPortInformation(int port, vtkInformation *info) override
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
~ttkIdentifiers() override
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition Debug.h:149
The Topology ToolKit.
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22
vtkStandardNewMacro(ttkIdentifiers)
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)