forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkXMLPStructuredDataWriter.cxx
143 lines (121 loc) · 5.53 KB
/
vtkXMLPStructuredDataWriter.cxx
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*=========================================================================
Program: Visualization Toolkit
Module: vtkXMLPStructuredDataWriter.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkXMLPStructuredDataWriter.h"
#include "vtkXMLStructuredDataWriter.h"
#include "vtkExecutive.h"
#include "vtkExtentTranslator.h"
#include "vtkErrorCode.h"
#include "vtkDataSet.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkStreamingDemandDrivenPipeline.h"
//----------------------------------------------------------------------------
vtkXMLPStructuredDataWriter::vtkXMLPStructuredDataWriter()
{
}
//----------------------------------------------------------------------------
vtkXMLPStructuredDataWriter::~vtkXMLPStructuredDataWriter()
{
}
//----------------------------------------------------------------------------
void vtkXMLPStructuredDataWriter::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
//----------------------------------------------------------------------------
void vtkXMLPStructuredDataWriter::WritePrimaryElementAttributes(ostream &os, vtkIndent indent)
{
int* wExt = this->GetInputInformation(0, 0)->Get(
vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
this->WriteVectorAttribute("WholeExtent", 6, wExt);
this->Superclass::WritePrimaryElementAttributes(os, indent);
}
//----------------------------------------------------------------------------
void vtkXMLPStructuredDataWriter::WritePPieceAttributes(int index)
{
int extent[6];
vtkInformation* inInfo = this->GetExecutive()->GetInputInformation(0, 0);
vtkExtentTranslator* et = vtkExtentTranslator::SafeDownCast(
inInfo->Get(vtkStreamingDemandDrivenPipeline::EXTENT_TRANSLATOR()));
et->SetNumberOfPieces(this->GetNumberOfPieces());
et->SetWholeExtent(inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
et->SetPiece(index);
et->SetGhostLevel(0);
et->PieceToExtent();
et->GetExtent(extent);
this->WriteVectorAttribute("Extent", 6, extent);
if (this->ErrorCode == vtkErrorCode::OutOfDiskSpaceError)
{
return;
}
this->Superclass::WritePPieceAttributes(index);
}
//----------------------------------------------------------------------------
vtkXMLWriter* vtkXMLPStructuredDataWriter::CreatePieceWriter(int index)
{
int extent[6];
vtkInformation* inInfo = this->GetExecutive()->GetInputInformation(0, 0);
vtkExtentTranslator* et = vtkExtentTranslator::SafeDownCast(
inInfo->Get(vtkStreamingDemandDrivenPipeline::EXTENT_TRANSLATOR()));
et->SetNumberOfPieces(this->GetNumberOfPieces());
et->SetWholeExtent(inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
et->SetPiece(index);
et->SetGhostLevel(0);
et->PieceToExtent();
et->GetExtent(extent);
vtkXMLStructuredDataWriter* pWriter = this->CreateStructuredPieceWriter();
pWriter->SetWriteExtent(extent);
return pWriter;
}
//----------------------------------------------------------------------------
int vtkXMLPStructuredDataWriter::ProcessRequest(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
// generate the data
if(request->Has(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT()))
{
return this->RequestUpdateExtent(request, inputVector, outputVector);
}
return this->Superclass::ProcessRequest(request, inputVector, outputVector);
}
//----------------------------------------------------------------------------
int vtkXMLPStructuredDataWriter::RequestUpdateExtent(
vtkInformation *vtkNotUsed(request),
vtkInformationVector **inputVector,
vtkInformationVector *vtkNotUsed(outputVector))
{
vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
// The code below asks for an extent based on the number of pieces and
// the first piece. This is mainly for the sake of other filters/writers
// that may internally use this reader. Those writers usually delegate
// RequestUpdateExtent() to the internal write and expect it to do the
// right thing. Before this change, vtkXMLPStructuredDataWriter did not
// bother setting the update extent because it is taken care of by the
// vtkXMLStructuredDataWriter during WritePiece() (see vtkXMLPDataWriter).
// This is fine when vtkXMLPStructuredDataWriter's input is connected
// to the actual pipeline but causes problems when it is not, which happens
// in the situation described above. Here I picked the StartPiece as
// the default. This will not effect the behavior when writing multiple
// pieces because that does its own RequestUpdateExtent with the right
// piece information.
int extent[6];
vtkExtentTranslator* et = vtkExtentTranslator::SafeDownCast(
inInfo->Get(vtkStreamingDemandDrivenPipeline::EXTENT_TRANSLATOR()));
et->SetNumberOfPieces(this->GetNumberOfPieces());
et->SetWholeExtent(inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
et->SetPiece(this->StartPiece);
et->SetGhostLevel(0);
et->PieceToExtent();
et->GetExtent(extent);
inInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), extent, 6);
return 1;
}