TTK
Loading...
Searching...
No Matches
ttkContourAroundPoint.h
Go to the documentation of this file.
1
19#pragma once
20
21#include <vtkFieldData.h>
22#include <vtkPointData.h>
23#include <vtkSmartPointer.h>
24
26#include <ttkAlgorithm.h>
27#include <ttkContourAroundPointModule.h> // for TTKCONTOURAROUNDPOINT_EXPORT
28
29#include <Triangulation.h> // for tk::Triangulation::Type
30
31class vtkInformation;
32class vtkInformationVector;
33class vtkUnstructuredGrid;
34
35class TTKCONTOURAROUNDPOINT_EXPORT ttkContourAroundPoint
36 : public ttkAlgorithm,
37 protected ttk::ContourAroundPoint {
38
39public:
42
43 // setter+getter macros for each parameter from the XML file
44 vtkSetMacro(ui_extension, double) vtkGetMacro(ui_extension, double);
45 vtkSetMacro(ui_sizeFilter, double) vtkGetMacro(ui_sizeFilter, double);
46 vtkSetMacro(ui_spherical, bool) vtkGetMacro(ui_spherical, bool);
47
48 // for the standalone (maybe unify with the above sometime)
49 void SetRegionExtension(double val) {
50 ui_extension = val;
51 }
52 void SetSizeFilter(double val) {
53 ui_sizeFilter = val;
54 }
55 void SetSpherical(bool val) {
56 ui_spherical = val;
57 }
58
59protected:
61 SetNumberOfInputPorts(3);
62 SetNumberOfOutputPorts(2);
63 }
64
65 ~ttkContourAroundPoint() override = default;
66
67 // Make sure this is consistent with the XML file and the
68 // `SetNumberOfInputPorts` and `SetNumberOfOutputPorts` argument
69 // (used in the constructor). The return value is interpreted as
70 // "PORT_REQUIREMENTS_FILLED" in vtkAlgorithm.cxx
71 int FillInputPortInformation(int port, vtkInformation *info) override;
72 int FillOutputPortInformation(int port, vtkInformation *info) override;
73 int RequestData(vtkInformation *request,
74 vtkInformationVector **iVec,
75 vtkInformationVector *oVec) override;
76
78 bool preprocessFld(vtkDataSet *dataset);
79
81 bool preprocessPts(vtkUnstructuredGrid *nodes, vtkUnstructuredGrid *arcs);
82
84 bool process();
85
87 bool postprocess();
88
89 template <typename T>
90 T *getBuffer(vtkFieldData *data,
91 const std::string &varName,
92 int typeCode,
93 const std::string &typeName) {
94 auto vtkArr = data->GetAbstractArray(varName.c_str());
95 const std::string dataKind
96 = dynamic_cast<vtkPointData *>(data) ? "point" : "cell";
97 if(!vtkArr) {
98 vtkErrorMacro("The " + dataKind + "s must have data named " + varName);
99 return nullptr;
100 }
101 if(vtkArr->GetDataType() != typeCode) {
102 vtkErrorMacro(<< "The " + dataKind + " data " + varName
103 + " must be of type "
104 << typeName << " but it is "
105 << vtkArr->GetDataTypeAsString());
106 return nullptr;
107 }
108 return reinterpret_cast<T *>(vtkArr->GetVoidPointer(0));
109 }
110
111private:
112 // output region size, in percent of the maximum overlap-free size:
113 // 0 --> single point, 100 --> touching neighbor regions
114 double ui_extension;
115 // minimum required output region size,
116 // in centi-percent of the number of input field vertices:
117 // 0 --> all pass, 10000 none pass
118 double ui_sizeFilter;
119 // name of the scalar variable of the input field
120 bool ui_spherical;
121
122 ttk::Triangulation::Type _triangTypeCode; // triangulation->getType()
123 int _scalarTypeCode; // VTK type of the scalars defined on the input field
124 const char *_scalarsName = nullptr;
125
126 // referring to the input points
127 std::vector<float> _coords;
128 std::vector<float> _scalars;
129 std::vector<float> _isovals;
130 std::vector<int> _flags;
131
134
135 std::vector<float> coordsBuf_{};
136 std::vector<ttk::LongSimplexId> cinfosBuf_{};
137 std::vector<float> scalarsBuf_{};
138 std::vector<int> flagsBuf_{};
139};
Baseclass of all VTK filters that wrap ttk modules.
virtual int RequestData(vtkInformation *ttkNotUsed(request), vtkInformationVector **ttkNotUsed(inputVectors), vtkInformationVector *ttkNotUsed(outputVector))
int FillInputPortInformation(int ttkNotUsed(port), vtkInformation *ttkNotUsed(info)) override
int FillOutputPortInformation(int ttkNotUsed(port), vtkInformation *ttkNotUsed(info)) override
TTK VTK-filter that wraps the contourAroundPoint processing package.
T * getBuffer(vtkFieldData *data, const std::string &varName, int typeCode, const std::string &typeName)
static ttkContourAroundPoint * New()
~ttkContourAroundPoint() override=default
void SetRegionExtension(double val)
TTK contourAroundPoint processing package.