TTK
Loading...
Searching...
No Matches
TrackingFromFields.h
Go to the documentation of this file.
1
10
11#pragma once
12
13// base code includes
14#include <BottleneckDistance.h>
15#include <PersistenceDiagram.h>
16#include <Triangulation.h>
17
18namespace ttk {
19
20 class TrackingFromFields : virtual public Debug {
21
22 public:
24 this->setDebugMsgPrefix("TrackingFromFields");
25 }
26
29 // template <class dataType>
30 // int execute();
31
32 template <typename dataType,
33 typename triangulationType = ttk::AbstractTriangulation>
35 int fieldNumber,
36 std::vector<ttk::DiagramType> &persistenceDiagrams,
37 const triangulationType *triangulation);
38
44 inline int setInputDataPointer(int idx, void *data) {
45 if(idx < numberOfInputs_)
46 inputData_[idx] = data;
47 else
48 return -1;
49 return 0;
50 }
51
55 inline int setNumberOfInputs(int numberOfInputs) {
56 numberOfInputs_ = numberOfInputs;
57 return 0;
58 }
59
60 inline void
65
66 inline void setInputScalars(std::vector<void *> &is) {
67 inputData_ = is;
68 }
69
78 inline void setInputOffsets(std::vector<SimplexId *> &io) {
79 inputOffsets_ = io;
80 }
81
82 protected:
84 std::vector<void *> inputData_{};
85 std::vector<SimplexId *> inputOffsets_{};
86 };
87} // namespace ttk
88
89template <typename dataType, typename triangulationType>
91 int fieldNumber,
92 std::vector<ttk::DiagramType> &persistenceDiagrams,
93 const triangulationType *triangulation) {
94
95#ifdef TTK_ENABLE_OPENMP
96#pragma omp parallel for num_threads(threadNumber_)
97#endif // TTK_ENABLE_OPENMP
98 for(int i = 0; i < fieldNumber; ++i) {
99 ttk::PersistenceDiagram persistenceDiagram;
100 persistenceDiagram.setThreadNumber(1);
101 persistenceDiagram.execute(persistenceDiagrams[i],
102 (dataType *)(inputData_[i]), 0, inputOffsets_[i],
103 triangulation);
104
105 // Augment diagram.
106 for(auto &pair : persistenceDiagrams[i]) {
107 triangulation->getVertexPoint(pair.birth.id, pair.birth.coords[0],
108 pair.birth.coords[1], pair.birth.coords[2]);
109 triangulation->getVertexPoint(pair.death.id, pair.death.coords[0],
110 pair.death.coords[1], pair.death.coords[2]);
111 pair.birth.sfValue = static_cast<double *>(inputData_[i])[pair.birth.id];
112 pair.death.sfValue = static_cast<double *>(inputData_[i])[pair.death.id];
113 }
114 }
115
116 return 0;
117}
AbstractTriangulation is an interface class that defines an interface for efficient traversal methods...
virtual int setThreadNumber(const int threadNumber)
Definition BaseClass.h:80
Minimalist debugging class.
Definition Debug.h:88
void setDebugMsgPrefix(const std::string &prefix)
Definition Debug.h:364
TTK processing package for the computation of persistence diagrams.
void preconditionTriangulation(AbstractTriangulation *triangulation)
int execute(std::vector< PersistencePair > &CTDiagram, const scalarType *inputScalars, const size_t scalarsMTime, const SimplexId *inputOffsets, const triangulationType *triangulation, const std::vector< bool > *updateMask=nullptr)
void setInputOffsets(std::vector< SimplexId * > &io)
std::vector< SimplexId * > inputOffsets_
int setNumberOfInputs(int numberOfInputs)
void preconditionTriangulation(AbstractTriangulation *triangulation)
int setInputDataPointer(int idx, void *data)
void setInputScalars(std::vector< void * > &is)
int performDiagramComputation(int fieldNumber, std::vector< ttk::DiagramType > &persistenceDiagrams, const triangulationType *triangulation)
std::vector< void * > inputData_
The Topology ToolKit.