1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-FileCopyrightText: Copyright (c) Kitware, Inc.
// SPDX-License-Identifier: BSD-3-Clause
#include "vtkXMLPartitionedDataSetReader.h"
#include "vtkCompositeDataPipeline.h"
#include "vtkCompositeDataSet.h"
#include "vtkDataSet.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkPartitionedDataSet.h"
#include "vtkSmartPointer.h"
#include "vtkXMLDataElement.h"
VTK_ABI_NAMESPACE_BEGIN
vtkStandardNewMacro(vtkXMLPartitionedDataSetReader);
//------------------------------------------------------------------------------
vtkXMLPartitionedDataSetReader::vtkXMLPartitionedDataSetReader() = default;
//------------------------------------------------------------------------------
vtkXMLPartitionedDataSetReader::~vtkXMLPartitionedDataSetReader() = default;
//------------------------------------------------------------------------------
void vtkXMLPartitionedDataSetReader::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
//------------------------------------------------------------------------------
int vtkXMLPartitionedDataSetReader::FillOutputPortInformation(
int vtkNotUsed(port), vtkInformation* info)
{
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkPartitionedDataSet");
return 1;
}
//------------------------------------------------------------------------------
const char* vtkXMLPartitionedDataSetReader::GetDataSetName()
{
return "vtkPartitionedDataSet";
}
//------------------------------------------------------------------------------
void vtkXMLPartitionedDataSetReader::ReadComposite(vtkXMLDataElement* element,
vtkCompositeDataSet* composite, const char* filePath, unsigned int& dataSetIndex)
{
vtkPartitionedDataSet* pds = vtkPartitionedDataSet::SafeDownCast(composite);
if (!pds)
{
vtkErrorMacro("Unsupported composite dataset.");
return;
}
const unsigned int numberOfParitions =
vtkXMLCompositeDataReader::CountNestedElements(element, "Dataset");
unsigned int maxElems = element->GetNumberOfNestedElements();
for (unsigned int cc = 0; cc < maxElems; ++cc)
{
vtkXMLDataElement* childXML = element->GetNestedElement(cc);
if (!childXML || !childXML->GetName())
{
continue;
}
int index = pds->GetNumberOfPartitions();
// child is a leaf node, read and insert.
const char* tagName = childXML->GetName();
if (strcmp(tagName, "DataSet") == 0)
{
vtkSmartPointer<vtkDataObject> childDS;
if (this->ShouldReadDataSet(dataSetIndex, index, numberOfParitions))
{
// Read
childDS.TakeReference(this->ReadDataObject(childXML, filePath));
}
pds->SetPartition(index, childDS);
dataSetIndex++;
}
else
{
vtkErrorMacro("Syntax error in file.");
return;
}
}
}
VTK_ABI_NAMESPACE_END
|