5#include <vtkDoubleArray.h>
6#include <vtkExecutive.h>
7#include <vtkFloatArray.h>
8#include <vtkIdTypeArray.h>
9#include <vtkImageData.h>
10#include <vtkInformation.h>
11#include <vtkIntArray.h>
12#include <vtkPointData.h>
13#include <vtkSignedCharArray.h>
18 SetNumberOfInputPorts(1);
23 int port, vtkInformation *info) {
25 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),
"vtkImageData");
37 "Wrong ZFP absolute error tolerance for ZFP-only use, aborting.");
42 vtkImageData *vti = vtkImageData::SafeDownCast(input);
44 auto inputScalarField = this->GetInputArrayToProcess(0, input);
45 if(inputScalarField ==
nullptr) {
50 if(triangulation ==
nullptr) {
56 vtkDataSet::SafeDownCast(input), 0, triangulation,
false, 1,
false);
60 switch(inputScalarField->GetDataType()) {
77 this->
printErr(
"Unsupported data type :(");
82 outputScalarField->SetNumberOfTuples(inputScalarField->GetNumberOfTuples());
83 outputScalarField->SetName(inputScalarField->GetName());
87 std::array<double, 2> sfRange{};
88 inputScalarField->GetRange(sfRange.data());
92 inputScalarField->GetDataType(), triangulation->getType(),
97 *
static_cast<TTK_TT *
>(triangulation->getData())));
99 this->
printMsg(
"Compression successful.");
103 if((fp = fopen(FileName,
"wb")) ==
nullptr) {
104 this->
printErr(
"System IO error while opening the file.");
108 int const dt = inputScalarField->GetDataType();
113 vti->GetExtent(), vti->GetSpacing(), vti->GetOrigin(), vp,
116 this->
printMsg(
"Wrote to " + std::string{FileName} +
".");
122 if(this->GetNumberOfInputConnections(0) < 1) {
125 return this->GetExecutive()->GetInputData(0, 0);
130 this->SetInputDataInternal(0, input);
ttk::Triangulation * GetTriangulation(vtkDataSet *dataSet)
vtkDataArray * GetOrderArray(vtkDataSet *const inputData, const int scalarArrayIdx, ttk::Triangulation *triangulation, const bool getGlobalOrder=false, const int orderArrayIdx=0, const bool enforceOrderArrayIdx=false)
VTK-filter that wraps the topologicalCompressionWriter processing package.
void SetInputData(vtkDataObject *input)
ttkTopologicalCompressionWriter()
vtkDataObject * GetInput()
int FillInputPortInformation(int port, vtkInformation *info) override
static void * GetVoidPointer(vtkDataArray *array, vtkIdType start=0)
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
void relToAbsZFPTolerance(const double zfpRelTol, const std::array< double, 2 > &sfRange)
Switch from a relative (% of scalar field range) to an absolute ZFP tolerance.
void setFileName(char *fn)
int WriteToFile(FILE *fp, int compressionType, bool zfpOnly, const char *sqMethod, int dataType, int *dataExtent, double *dataSpacing, double *dataOrigin, double *data, double tolerance, double zfpTolerance, const std::string &dataArrayName)
void preconditionTriangulation(AbstractTriangulation *const triangulation)
int SimplexId
Identifier type for simplices of any dimension.
#define ttkVtkTemplateMacro(dataType, triangulationType, call)
vtkStandardNewMacro(ttkTopologicalCompressionWriter)
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)