43 vtkInformationVector **inputVector,
44 vtkInformationVector *outputVector) {
48 vtkInformation *info = inputVector[0]->GetInformationObject(0);
49 vtkDataObject *input = info->Get(vtkDataObject::DATA_OBJECT());
50 vtkUnstructuredGrid *outputPersistenceDiagram
51 = vtkUnstructuredGrid::GetData(outputVector);
57 int numberOfPoints = 0;
60 if(vtkTable *table = vtkTable::SafeDownCast(input)) {
61 if(SelectFieldsWithRegexp) {
64 const auto n = table->GetNumberOfColumns();
65 for(
int i = 0; i < n; ++i) {
66 const auto &name = table->GetColumnName(i);
67 if(std::regex_match(name, std::regex(RegexpString))) {
68 ScalarFields.emplace_back(name);
73 if(table->GetNumberOfRows() <= 0 || ScalarFields.size() <= 1) {
74 this->
printErr(
"Input matrix has invalid dimensions (rows: "
75 + std::to_string(table->GetNumberOfRows()) +
", columns: "
76 + std::to_string(ScalarFields.size()) +
")");
80 std::vector<vtkAbstractArray *> arrays;
81 arrays.reserve(ScalarFields.size());
82 for(
const auto &s : ScalarFields)
83 arrays.push_back(table->GetColumnByName(s.data()));
85 numberOfPoints = table->GetNumberOfRows();
86 dimension = ScalarFields.size();
88 points.resize(numberOfPoints);
89 for(
int i = 0; i < numberOfPoints; ++i) {
90 for(
int j = 0; j < dimension; ++j)
91 points[i].push_back(arrays[j]->GetVariantValue(i).ToDouble());
95 else if(vtkPointSet *pointset = vtkPointSet::SafeDownCast(input)) {
96 numberOfPoints = pointset->GetNumberOfPoints();
98 points.resize(numberOfPoints, std::vector<double>(3));
99 for(
int i = 0; i < numberOfPoints; ++i)
100 pointset->GetPoint(i, points[i].data());
103 this->
printMsg(
"Computing Delaunay-Rips persistence diagram", 1.0,
105 this->
printMsg(
"#dimensions: " + std::to_string(dimension)
106 +
", #points: " + std::to_string(numberOfPoints),
110 if(this->
execute(points, diagram) != 0)
118 outputPersistenceDiagram->GetFieldData()->ShallowCopy(input->GetFieldData());
int DiagramToVTU(vtkUnstructuredGrid *vtu, const ttk::DiagramType &diagram, vtkDataArray *const inputScalars, const ttk::Debug &dbg, const int dim, const bool embedInDomain)
Converts a Persistence Diagram in the ttk::DiagramType format to the VTK Unstructured Grid format (as...
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/| (_) |"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)