3#include <vtkPointData.h>
4#include <vtkPointSet.h>
5#include <vtkUnstructuredGrid.h>
7#include <vtkInformation.h>
8#include <vtkInformationVector.h>
21 this->SetNumberOfInputPorts(1);
22 this->SetNumberOfOutputPorts(1);
26 vtkInformation *info) {
28 info->Set(vtkDataObject::DATA_TYPE_NAME(),
"vtkPointSet");
35 vtkInformation *info) {
37 info->Set(vtkDataObject::DATA_TYPE_NAME(),
"vtkUnstructuredGrid");
43template <
typename VTK_TT>
45 std::vector<std::pair<vtkIdType, double>> &storage,
46 const VTK_TT *
const values,
47 const size_t nvalues) {
49 for(
size_t i = 0; i < nvalues; ++i) {
50 storage.emplace_back(i,
static_cast<double>(values[i]));
55 vtkInformationVector **inputVector,
56 vtkInformationVector *outputVector) {
57 const auto input = vtkPointSet::GetData(inputVector[0]);
58 auto output = vtkUnstructuredGrid::GetData(outputVector);
60 if(input ==
nullptr || output ==
nullptr) {
61 this->
printErr(
"Null input data, aborting");
66 const auto oa = this->GetInputArrayToProcess(0, inputVector);
69 this->
printErr(
"Cannot find the required data array");
73 const auto nvalues = oa->GetNumberOfTuples();
76 std::vector<std::pair<vtkIdType, double>> orderedValues{};
78 switch(oa->GetDataType()) {
86 = [](
const std::pair<vtkIdType, double> &a,
87 const std::pair<vtkIdType, double> &b) {
return a.second < b.second; };
91 this->
threadNumber_, orderedValues.begin(), orderedValues.end(), cmp);
94 output->ShallowCopy(input);
97 vtkNew<vtkCellArray> cells{};
99 for(
size_t i = 1; i < orderedValues.size(); ++i) {
100 std::array<vtkIdType, 2> linePoints{
101 orderedValues[i - 1].first, orderedValues[i].first};
102 cells->InsertNextCell(2, linePoints.data());
106 std::array<vtkIdType, 2> linePoints{
107 orderedValues.back().first, orderedValues.front().first};
108 cells->InsertNextCell(2, linePoints.data());
111 output->SetCells(VTK_LINE, cells);
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
#define TTK_PSORT(NTHREADS,...)
Parallel sort macro.
TTK VTK-filter that reads a Cinema Spec D Database.
int FillInputPortInformation(int port, vtkInformation *info) override
void dispatch(std::vector< std::pair< vtkIdType, double > > &storage, const VTK_TT *const values, const size_t nvalues)
int FillOutputPortInformation(int port, vtkInformation *info) override
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
static void * GetVoidPointer(vtkDataArray *array, vtkIdType start=0)
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
vtkStandardNewMacro(ttkPointSetToCurve)