Skip to content
Snippets Groups Projects
Commit 666f5895 authored by Louis Gombert's avatar Louis Gombert :speech_balloon:
Browse files

JSONDataSetWriter: support array selection

parent b65eba29
No related branches found
No related tags found
1 merge request!11713JSONExporter: select arrays to be written for a collection of named actors
......@@ -39,6 +39,8 @@ vtkJSONDataSetWriter::vtkJSONDataSetWriter()
{
this->Archiver = vtkArchiver::New();
this->ValidStringCount = 1;
this->GetPointArraySelection()->SetUnknownArraySetting(1);
this->GetCellArraySelection()->SetUnknownArraySetting(1);
}
//------------------------------------------------------------------------------
......@@ -94,6 +96,23 @@ std::string vtkJSONDataSetWriter::WriteDataSetAttributes(
continue;
}
if (std::string(className) == "pointData")
{
if (!this->GetPointArraySelection()->ArrayIsEnabled(field->GetName()))
{
vtkDebugMacro("Skipping writing point array " << field->GetName());
continue;
}
}
else if (std::string(className) == "cellData")
{
if (!this->GetCellArraySelection()->ArrayIsEnabled(field->GetName()))
{
vtkDebugMacro("Skipping cell array " << field->GetName());
continue;
}
}
if (nbArrayWritten)
{
jsonSnippet << ",\n";
......
......@@ -32,6 +32,9 @@
#include <string> // std::string used as parameters in a few methods
#include "vtkDataArraySelection.h" // Instantiated
#include "vtkNew.h" // Used for DataArray selection
VTK_ABI_NAMESPACE_BEGIN
class vtkDataSet;
class vtkDataArray;
......@@ -118,6 +121,16 @@ public:
vtkGetObjectMacro(Archiver, vtkArchiver);
///@}
/**
* Specify which point arrays should be written.
*/
vtkGetObjectMacro(PointArraySelection, vtkDataArraySelection);
/**
* Specify which cell arrays should be written.
*/
vtkGetObjectMacro(CellArraySelection, vtkDataArraySelection);
void Write(vtkDataSet*);
bool IsDataSetValid() { return this->ValidDataSet; }
......@@ -139,6 +152,9 @@ protected:
private:
vtkJSONDataSetWriter(const vtkJSONDataSetWriter&) = delete;
void operator=(const vtkJSONDataSetWriter&) = delete;
vtkNew<vtkDataArraySelection> PointArraySelection;
vtkNew<vtkDataArraySelection> CellArraySelection;
};
VTK_ABI_NAMESPACE_END
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment