TTK
Loading...
Searching...
No Matches
ttkSurfaceGeometrySmoother.cpp
Go to the documentation of this file.
2
3#include <ttkMacros.h>
4#include <ttkUtils.h>
5
6#include <vtkInformation.h>
7#include <vtkObjectFactory.h>
8#include <vtkPointData.h>
9#include <vtkPointSet.h>
10
12
14 this->SetNumberOfInputPorts(2);
15 this->SetNumberOfOutputPorts(1);
16}
17
19 vtkInformation *info) {
20 if(port == 0) {
21 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPointSet");
22 return 1;
23 } else if(port == 1) {
24 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPointSet");
25 return 1;
26 }
27 return 0;
28}
29
31 int port, vtkInformation *info) {
32 if(port == 0) {
34 return 1;
35 }
36 return 0;
37}
38
40 vtkInformation *ttkNotUsed(request),
41 vtkInformationVector **inputVector,
42 vtkInformationVector *outputVector) {
43
44 auto inputPointSet = vtkPointSet::GetData(inputVector[0]);
45 auto inputMesh = vtkPointSet::GetData(inputVector[1]);
46 auto outputPointSet = vtkPointSet::GetData(outputVector);
47
48 auto triangulationToSmooth = ttkAlgorithm::GetTriangulation(inputPointSet);
49 if(triangulationToSmooth == nullptr) {
50 return 0;
51 }
52 this->preconditionTriangulationToSmooth(triangulationToSmooth);
53
54 auto triangulationSurface = ttkAlgorithm::GetTriangulation(inputMesh);
55 if(triangulationSurface == nullptr) {
56 return 0;
57 }
58 this->preconditionTriangulationSurface(triangulationSurface);
59
60 std::vector<ttk::SimplexId> idSpareStorage{};
61 const auto *vertsId = this->GetIdentifierArrayPtr(
62 ForceIdentifiersField, 0, ttk::VertexScalarFieldName, inputPointSet,
63 idSpareStorage, 0, false);
64 if(vertsId == nullptr) {
65 this->printWrn("No vertex scalar field detected on input");
66 }
67
68 vtkDataArray *inputMaskField = ttkAlgorithm::GetOptionalArray(
69 ForceInputMaskScalarField, 1, ttk::MaskScalarFieldName, inputPointSet);
70
71 // Copy all input points/cells + scalar fields
72 outputPointSet->DeepCopy(inputPointSet);
73
74 // calling the smoothing package
75 auto inputPoints = inputPointSet->GetPoints();
76 auto outputPoints = outputPointSet->GetPoints();
77
78 const auto hasMask{this->UseMaskScalarField && inputMaskField != nullptr};
79
80 if(triangulationSurface->getType() != triangulationToSmooth->getType()) {
81 this->printErr("Triangulations should have the same type");
82 return 0;
83 }
84
85 // here we assume that the two triangulation objects have the same
86 // underlying type
88 triangulationToSmooth->getType(),
89 this->execute(
90 ttkUtils::GetPointer<float>(outputPoints->GetData()),
91 ttkUtils::GetPointer<float>(inputPoints->GetData()),
92 hasMask ? ttkUtils::GetPointer<char>(inputMaskField) : nullptr, vertsId,
93 this->NumberOfIterations,
94 *static_cast<TTK_TT *>(triangulationToSmooth->getData()),
95 *static_cast<TTK_TT *>(triangulationSurface->getData())));
96
97 return 1;
98}
#define ttkTemplateMacro(triangulationType, call)
#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::SimplexId * GetIdentifierArrayPtr(const bool &enforceArrayIndex, const int &arrayIndex, const std::string &arrayName, vtkDataSet *const inputData, std::vector< ttk::SimplexId > &spareStorage, const int inputPort=0, const bool printErr=true)
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 smoothing meshes on surfaces.
int FillOutputPortInformation(int port, vtkInformation *info) override
int FillInputPortInformation(int port, vtkInformation *info) override
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
int printWrn(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition: Debug.h:159
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition: Debug.h:149
void preconditionTriangulationSurface(AbstractTriangulation *const triangulation)
void preconditionTriangulationToSmooth(AbstractTriangulation *const triangulation)
const char VertexScalarFieldName[]
default name for vertex scalar field
Definition: DataTypes.h:35
const char MaskScalarFieldName[]
default name for mask scalar field
Definition: DataTypes.h:32
vtkStandardNewMacro(ttkSurfaceGeometrySmoother)