TTK
Loading...
Searching...
No Matches
ttkGeometrySmoother.cpp
Go to the documentation of this file.
2
3#include <ttkUtils.h>
4#include <vtkInformation.h>
5
6#include <vtkPointData.h>
7#include <vtkPointSet.h>
8#include <vtkUnsignedCharArray.h>
9
11
13 this->setDebugMsgPrefix("GeometrySmoother");
14
15 this->SetNumberOfInputPorts(1);
16 this->SetNumberOfOutputPorts(1);
17}
18
20
22 vtkInformation *info) {
23 if(port == 0) {
24 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPointSet");
25 return 1;
26 }
27 return 0;
28}
29
31 vtkInformation *info) {
32 if(port == 0) {
34 return 1;
35 }
36 return 0;
37}
38
39int ttkGeometrySmoother::RequestData(vtkInformation *ttkNotUsed(request),
40 vtkInformationVector **inputVector,
41 vtkInformationVector *outputVector) {
42
43 auto inputPointSet = vtkPointSet::GetData(inputVector[0]);
44 auto outputPointSet = vtkPointSet::GetData(outputVector);
45
46 auto triangulation = ttkAlgorithm::GetTriangulation(inputPointSet);
47
48 int keepGoing = checkEmptyMPIInput<ttk::Triangulation>(triangulation);
49 if(keepGoing < 2) {
50 return keepGoing;
51 }
52 this->preconditionTriangulation(triangulation);
53
54 vtkDataArray *inputMaskField = ttkAlgorithm::GetOptionalArray(
55 ForceInputMaskScalarField, 1, ttk::MaskScalarFieldName, inputPointSet);
56
57 // This filter copies the input into a new data-set (smoothed)
58 // let's use shallow copies, in order to only duplicate point positions
59 // (before and after). the rest is not changed, pointers are sufficient.
60 outputPointSet->DeepCopy(inputPointSet);
61
62 // calling the smoothing package
63 auto inputPoints = inputPointSet->GetPoints();
64 auto outputPoints = outputPointSet->GetPoints();
65
66 this->setDimensionNumber(3);
69
70 const auto hasMask{this->UseMaskScalarField && inputMaskField != nullptr};
71 this->setMaskDataPointer(hasMask ? ttkUtils::GetPointer<char>(inputMaskField)
72 : nullptr);
73
74 switch(outputPoints->GetDataType()) {
75 vtkTemplateMacro(
76 this->smooth<VTK_TT>(triangulation->getData(), this->NumberOfIterations));
77 }
78
79 return 1;
80}
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
Definition: BaseClass.h:47
static vtkInformationIntegerKey * SAME_DATA_TYPE_AS_INPUT_PORT()
ttk::Triangulation * GetTriangulation(vtkDataSet *dataSet)
vtkDataArray * GetOptionalArray(const bool &enforceArrayIndex, const int &arrayIndex, const std::string &arrayName, vtkDataSet *const inputData, const int &inputPort=0)
TTK VTK-filter for geometry smoothing.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
int FillInputPortInformation(int port, vtkInformation *info) override
int FillOutputPortInformation(int port, vtkInformation *info) override
~ttkGeometrySmoother() override
static void * GetVoidPointer(vtkDataArray *array, vtkIdType start=0)
Definition: ttkUtils.cpp:225
void setDebugMsgPrefix(const std::string &prefix)
Definition: Debug.h:364
void setMaskDataPointer(const char *const mask)
int preconditionTriangulation(AbstractTriangulation *triangulation)
void setDimensionNumber(const int &dimensionNumber)
void setOutputDataPointer(void *data)
void setInputDataPointer(void *data)
const char MaskScalarFieldName[]
default name for mask scalar field
Definition: DataTypes.h:32
vtkStandardNewMacro(ttkGeometrySmoother)