5#include <vtkCellData.h>
6#include <vtkDataArray.h>
7#include <vtkDataObject.h>
9#include <vtkDoubleArray.h>
10#include <vtkFloatArray.h>
11#include <vtkIdTypeArray.h>
12#include <vtkInformation.h>
14#include <vtkPointData.h>
15#include <vtkPolyData.h>
16#include <vtkSignedCharArray.h>
17#include <vtkUnsignedCharArray.h>
18#include <vtkUnsignedLongLongArray.h>
21 template <
typename vtkArrayType,
typename vectorType>
22 void setArray(vtkArrayType &vtkArray, vectorType &vector) {
31 this->SetNumberOfInputPorts(1);
32 this->SetNumberOfOutputPorts(1);
36 vtkInformation *info) {
38 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),
"vtkDataSet");
45 vtkInformation *info) {
47 info->Set(vtkDataObject::DATA_TYPE_NAME(),
"vtkPolyData");
53template <
typename scalarType,
typename triangulationType>
55 vtkPolyData *
const outputSeparators,
56 const triangulationType &triangulation) {
58 const auto scalars = ttkUtils::GetPointer<scalarType>(inputScalars);
59 const int dim = triangulation.getDimensionality();
66 = this->execute<scalarType, triangulationType>(scalars, triangulation);
69 return !this->
printErr(
"MarchingTetrahedra.execute() error");
71 vtkNew<vtkFloatArray> pointsCoords{};
72 pointsCoords->SetNumberOfComponents(3);
75 vtkNew<ttkSimplexIdTypeArray> offsets{}, connectivity{};
76 offsets->SetNumberOfComponents(1);
78 connectivity->SetNumberOfComponents(1);
81 vtkNew<vtkUnsignedLongLongArray> hashArr{};
82 hashArr->SetNumberOfComponents(1);
83 hashArr->SetName(
"Hash");
86 if(dim == 2 || dim == 3) {
87#ifdef TTK_ENABLE_OPENMP
88#pragma omp parallel for num_threads(this->threadNumber_)
91 offsets->SetTuple1(i, dim * i);
95 vtkNew<vtkPoints> points{};
96 points->SetData(pointsCoords);
97 outputSeparators->SetPoints(points);
99 vtkNew<vtkCellArray> cells{};
100#ifndef TTK_ENABLE_64BIT_IDS
101 cells->Use32BitStorage();
103 cells->SetData(offsets, connectivity);
105 outputSeparators->SetPolys(cells);
107 outputSeparators->SetLines(cells);
110 auto cellData = outputSeparators->GetCellData();
111 cellData->AddArray(hashArr);
117 vtkInformationVector **inputVector,
118 vtkInformationVector *outputVector) {
120 const auto input = vtkDataSet::GetData(inputVector[0]);
121 auto outputSeparators = vtkPolyData::GetData(outputVector, 0);
124 return !this->
printErr(
"Input pointer is NULL.");
126 if(input->GetNumberOfPoints() == 0)
127 return !this->
printErr(
"Input has no point.");
129 if(!outputSeparators)
130 return !this->
printErr(
"Output pointers are NULL.");
134 if(triangulation ==
nullptr)
135 return !this->
printErr(
"Triangulation is null");
137 const auto inputScalars = this->GetInputArrayToProcess(0, inputVector);
139 if(inputScalars ==
nullptr)
140 return !this->
printErr(
"wrong scalars.");
142 this->
printMsg(
"Launching computation on field `"
143 + std::string(inputScalars->GetName()) +
"'...");
145 const SimplexId numberOfVertices = triangulation->getNumberOfVertices();
147 if(!numberOfVertices)
148 return !this->
printErr(
"Input has no vertices.");
153 (status = dispatch<VTK_TT, TTK_TT>(
154 inputScalars, outputSeparators,
155 *
static_cast<TTK_TT *
>(triangulation->getData()))));
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
ttk::Triangulation * GetTriangulation(vtkDataSet *dataSet)
TTK VTK-filter that wraps the ttk::MarchingTetrahedra module.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
int FillOutputPortInformation(int port, vtkInformation *info) override
int FillInputPortInformation(int port, vtkInformation *info) override
int dispatch(vtkDataArray *const inputScalars, vtkPolyData *const outputSeparators, const triangulationType &triangulation)
static void SetVoidArray(vtkDataArray *array, void *data, vtkIdType size, int save)
void setDebugMsgPrefix(const std::string &prefix)
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
SimplexId output_numberOfCells_
std::vector< float > output_points_
std::vector< unsigned long long > output_cells_labels_
std::vector< SimplexId > output_cells_connectivity_
#define ttkVtkTemplateMacro(dataType, triangulationType, call)
vtkStandardNewMacro(ttkMarchingTetrahedra)
void setArray(vtkArrayType &vtkArray, vectorType &vector)
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)