40 vtkInformationVector **inputVector,
41 vtkInformationVector *outputVector) {
44 auto *input = vtkTable::GetData(inputVector[0]);
45 auto *output = vtkTable::GetData(outputVector);
46 output->ShallowCopy(input);
48 if(SelectFieldsWithRegexp) {
51 const auto n = input->GetNumberOfColumns();
52 for(
int i = 0; i < n; ++i) {
53 const auto &name = input->GetColumnName(i);
54 if(std::regex_match(name, std::regex(RegexpString))) {
55 ScalarFields.emplace_back(name);
60 const auto numberOfRows = input->GetNumberOfRows();
61 const auto numberOfColumns = ScalarFields.size();
63 if(numberOfRows <= 0 || numberOfColumns <= 0) {
64 this->
printErr(
"Input matrix has invalid dimensions (rows: "
65 + std::to_string(numberOfRows)
66 +
", columns: " + std::to_string(numberOfColumns) +
")");
70 std::vector<vtkAbstractArray *> arrays{};
71 arrays.reserve(ScalarFields.size());
72 for(
const auto &s : ScalarFields) {
73 arrays.push_back(input->GetColumnByName(s.data()));
76 std::vector<std::vector<double>> inputMatrix(numberOfRows);
77#ifdef TTK_ENABLE_OPENMP
78#pragma omp parallel for num_threads(this->threadNumber_)
80 for(
int i = 0; i < numberOfRows; ++i) {
81 for(
size_t j = 0; j < numberOfColumns; ++j) {
82 inputMatrix[i].emplace_back(arrays[j]->GetVariantValue(i).ToDouble());
86 std::vector<const double *> inputPtrs(inputMatrix.size());
87 for(
size_t i = 0; i < inputMatrix.size(); ++i) {
88 const auto &vec{inputMatrix[i]};
89 inputPtrs[i] = vec.data();
92 std::vector<double *> distanceMatrix(inputMatrix.size());
96 = [](std::string &colName,
const size_t numberCols,
const size_t colIdx) {
97 std::string
const max{std::to_string(numberCols - 1)};
98 std::string
const cur{std::to_string(colIdx)};
99 std::string
const zer(max.size() - cur.size(),
'0');
100 colName.append(zer).append(cur);
104 for(
int i = 0; i < numberOfRows; ++i) {
105 std::string name{
"Distance"};
106 zeroPad(name, distanceMatrix.size(), i);
108 vtkNew<vtkDoubleArray> col{};
109 col->SetNumberOfTuples(numberOfRows);
110 col->SetName(name.c_str());
111 output->AddColumn(col);
113 = ttkUtils::GetPointer<double>(vtkDoubleArray::SafeDownCast(col));
116 this->
execute(distanceMatrix, inputPtrs, inputMatrix[0].size());
118 this->
printMsg(
"Complete (#dimensions: " + std::to_string(numberOfColumns)
119 +
", #points: " + std::to_string(numberOfRows) +
")",
120 1.0, tm.getElapsedTime(), this->threadNumber_);