3#include <vtkAbstractArray.h>
4#include <vtkCellArray.h>
5#include <vtkCellData.h>
6#include <vtkDataSetTriangleFilter.h>
8#include <vtkFloatArray.h>
9#include <vtkIdTypeArray.h>
11#include <vtkInformation.h>
12#include <vtkInformationVector.h>
13#include <vtkPointData.h>
14#include <vtkUnstructuredGrid.h>
16#include <vtkArrayDispatch.h>
17#include <vtkDataArrayAccessor.h>
25 this->SetNumberOfInputPorts(1);
26 this->SetNumberOfOutputPorts(1);
33 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),
"vtkUnstructuredGrid");
41 info->Set(vtkDataObject::DATA_TYPE_NAME(),
"vtkUnstructuredGrid");
48 vtkInformationVector **inputVector,
49 vtkInformationVector *outputVector) {
55 auto input = vtkUnstructuredGrid::GetData(inputVector[0]);
56 if(input ==
nullptr) {
60 size_t nInputPoints = input->GetNumberOfPoints();
61 size_t nInputCells = input->GetNumberOfCells();
63 auto inputPointSizes = this->GetInputArrayToProcess(0, inputVector);
64 if(!inputPointSizes) {
65 this->
printErr(
"Unable to retrieve point size array.");
74 auto inputPoints = input->GetPoints();
77 outputPoints->SetDataType(inputPoints->GetDataType());
81 outputPoints->SetNumberOfPoints(nOutputPoints);
84 auto inputConnectivityArray = input->GetCells()->GetConnectivityArray();
92 inputConnectivityArray->NewInstance());
93 outputConnectivityArray->SetNumberOfValues(outputTopologySize);
96 inputConnectivityArray->NewInstance());
97 outputOffsetArray->SetNumberOfValues(nOutputCells + 1);
106 inputPoints->GetDataType(), inputPointSizes->GetDataType(),
107 outputConnectivityArray->GetDataType(),
108 (status = this->execute<T2, T0, T1>(
110 ttkUtils::GetPointer<T0>(outputPoints->GetData()),
111 ttkUtils::GetPointer<T2>(outputConnectivityArray),
112 ttkUtils::GetPointer<T2>(outputOffsetArray),
115 ttkUtils::GetPointer<T0>(inputPoints->GetData()),
116 ttkUtils::GetPointer<T2>(input->GetCells()->GetConnectivityArray()),
117 nInputPoints, nInputCells, ttkUtils::GetPointer<T1>(inputPointSizes),
118 this->GetSizeScale(), this->GetSizeAxis())));
121 inputPoints->GetDataType(), inputPointSizes->GetDataType(),
122 outputConnectivityArray->GetDataType(),
123 (status = this->execute2<T2, T0, T1>(
125 ttkUtils::GetPointer<T0>(outputPoints->GetData()),
126 ttkUtils::GetPointer<T2>(outputConnectivityArray),
127 ttkUtils::GetPointer<T2>(outputOffsetArray),
130 ttkUtils::GetPointer<T0>(inputPoints->GetData()),
131 ttkUtils::GetPointer<T2>(input->GetCells()->GetConnectivityArray()),
132 nInputPoints, nInputCells, this->GetSubdivisions(),
133 ttkUtils::GetPointer<T1>(inputPointSizes), this->GetSizeScale(),
134 this->GetSizeAxis())));
144 auto meshedGraph = vtkUnstructuredGrid::GetData(outputVector);
146 meshedGraph->SetPoints(outputPoints);
149 outputCellArray->SetData(outputOffsetArray, outputConnectivityArray);
150 meshedGraph->SetCells(
156 auto iPointData = input->GetPointData();
157 auto oPointData = meshedGraph->GetPointData();
159 for(
int i = 0; i < iPointData->GetNumberOfArrays(); i++) {
160 auto iArray = iPointData->GetArray(i);
161 if(iArray->GetNumberOfComponents() > 1)
165 vtkDataArray::CreateDataArray(iArray->GetDataType()));
166 oArray->SetName(iArray->GetName());
167 oArray->SetNumberOfTuples(nOutputPoints);
168 oArray->SetNumberOfComponents(1);
169 oPointData->AddArray(oArray);
172 iArray->GetDataType(), inputConnectivityArray->GetDataType(),
173 (status = this->mapInputPointDataToOutputPointData<T0, T1>(
174 ttkUtils::GetPointer<T0>(oArray),
176 nInputPoints, nInputCells,
177 ttkUtils::GetPointer<T1>(inputConnectivityArray),
178 ttkUtils::GetPointer<T0>(iArray), this->GetUseQuadraticCells(),
179 this->GetSubdivisions())));
188 auto iCellData = input->GetCellData();
189 auto oCellData = meshedGraph->GetCellData();
191 for(
int i = 0; i < iCellData->GetNumberOfArrays(); i++) {
192 auto iArray = iCellData->GetArray(i);
193 if(iArray->GetNumberOfComponents() > 1)
197 vtkDataArray::CreateDataArray(iArray->GetDataType()));
198 oArray->SetName(iArray->GetName());
199 oArray->SetNumberOfTuples(nOutputCells);
200 oArray->SetNumberOfComponents(1);
201 oCellData->AddArray(oArray);
204 iArray->GetDataType(),
205 (status = this->mapInputCellDataToOutputCellData<T0>(
206 ttkUtils::GetPointer<T0>(oArray), nInputCells,
207 ttkUtils::GetPointer<T0>(iArray), this->GetUseQuadraticCells())));
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
TTK VTK-filter that generates a mesh for a graph.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
virtual bool GetUseQuadraticCells()
int FillInputPortInformation(int port, vtkInformation *info) override
int FillOutputPortInformation(int port, vtkInformation *info) override
virtual int GetSubdivisions()
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
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
size_t computeOutputConnectivityArraySize(const size_t &nInputCells, const bool &useQuadraticCells, const size_t &nSubdivisions=0) const
size_t computeNumberOfOutputPoints(const size_t &nInputPoints, const size_t &nInputCells, const bool &useQuadraticCells, const size_t &nSubdivisions=0) const
size_t computeNumberOfOutputCells(const size_t &nInputCells, const bool &useQuadraticCells) const
#define ttkTypeMacroRRI(group0, group1, group2, call)
#define ttkTypeMacroA(group, call)
#define ttkTypeMacroAI(group0, group1, call)
vtkStandardNewMacro(ttkMeshGraph)