TTK
Loading...
Searching...
No Matches
FTRCommon.h
Go to the documentation of this file.
1
2//
7
8#pragma once
9
10#include "FTRDataTypes.h"
11
12#include <Debug.h>
13
14#include <iostream>
15#include <numeric>
16#include <vector>
17
18namespace ttk {
19 namespace ftr {
20 // Compute parameters (global)
21 struct Params {
22 bool singleSweep = false;
23 bool segm = true;
24 bool normalize = true;
25 bool advStats = true;
26 int samplingLvl = 0;
27
28 int threadNumber = 1;
29 int debugLevel = 1;
30
31 void printSelf() {
32 Debug dbg{};
33 dbg.setDebugMsgPrefix("FTRGraph");
34 dbg.setDebugLevel(debugLevel);
35 dbg.printMsg(std::vector<std::vector<std::string>>{
36 {"#Threads", std::to_string(threadNumber)},
37 {"Debug level", std::to_string(debugLevel)},
38 {"Segmentation", std::to_string(segm)},
39 {"Sampling level", std::to_string(samplingLvl)},
40 });
41 }
42 };
43
47 class Allocable : virtual public Debug {
48 protected:
50 idVertex nbElmt_ = nullVertex;
51
52 public:
53 void setNumberOfElmt(const idVertex nbVerts) {
54 nbElmt_ = nbVerts;
55 }
56
57 template <typename type>
58 void fillVector(std::vector<type> &vect, const type &elmt) {
59 const std::size_t nbIt = vect.size();
60#ifdef TTK_ENABLE_OPENMP
61#pragma omp parallel for schedule(dynamic)
62#endif
63 for(std::size_t i = 0; i < nbIt; i++) {
64 vect[i] = elmt;
65 }
66 }
67
68 virtual void alloc() = 0;
69
70 virtual void init() = 0;
71 };
72
73 } // namespace ftr
74} // namespace ttk
Minimalist debugging class.
Definition Debug.h:88
void setDebugMsgPrefix(const std::string &prefix)
Definition Debug.h:364
void setNumberOfElmt(const idVertex nbVerts)
Definition FTRCommon.h:53
virtual void alloc()=0
void fillVector(std::vector< type > &vect, const type &elmt)
Definition FTRCommon.h:58
virtual void init()=0
idVertex nbElmt_
Allocation may depends on the number of vertices.
Definition FTRCommon.h:50
SimplexId idVertex
Vertex index in scalars_.
The Topology ToolKit.