Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VTK
VTK
Commits
9e96c49f
Commit
9e96c49f
authored
Feb 11, 2005
by
Rusty Blue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: Converted XML Readers to new pipline
parent
a9b0503b
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
520 additions
and
522 deletions
+520
-522
Common/Testing/Tcl/otherPrint.tcl
Common/Testing/Tcl/otherPrint.tcl
+12
-12
IO/vtkXMLDataReader.cxx
IO/vtkXMLDataReader.cxx
+30
-67
IO/vtkXMLDataReader.h
IO/vtkXMLDataReader.h
+0
-1
IO/vtkXMLImageDataReader.cxx
IO/vtkXMLImageDataReader.cxx
+48
-25
IO/vtkXMLImageDataReader.h
IO/vtkXMLImageDataReader.h
+2
-1
IO/vtkXMLPDataReader.cxx
IO/vtkXMLPDataReader.cxx
+24
-57
IO/vtkXMLPDataReader.h
IO/vtkXMLPDataReader.h
+1
-2
IO/vtkXMLPImageDataReader.cxx
IO/vtkXMLPImageDataReader.cxx
+39
-24
IO/vtkXMLPImageDataReader.h
IO/vtkXMLPImageDataReader.h
+1
-1
IO/vtkXMLPPolyDataReader.cxx
IO/vtkXMLPPolyDataReader.cxx
+9
-11
IO/vtkXMLPRectilinearGridReader.cxx
IO/vtkXMLPRectilinearGridReader.cxx
+25
-32
IO/vtkXMLPRectilinearGridReader.h
IO/vtkXMLPRectilinearGridReader.h
+0
-1
IO/vtkXMLPStructuredDataReader.cxx
IO/vtkXMLPStructuredDataReader.cxx
+8
-7
IO/vtkXMLPStructuredDataReader.h
IO/vtkXMLPStructuredDataReader.h
+2
-1
IO/vtkXMLPStructuredGridReader.cxx
IO/vtkXMLPStructuredGridReader.cxx
+17
-29
IO/vtkXMLPStructuredGridReader.h
IO/vtkXMLPStructuredGridReader.h
+0
-1
IO/vtkXMLPUnstructuredDataReader.cxx
IO/vtkXMLPUnstructuredDataReader.cxx
+21
-28
IO/vtkXMLPUnstructuredDataReader.h
IO/vtkXMLPUnstructuredDataReader.h
+1
-1
IO/vtkXMLPUnstructuredGridReader.cxx
IO/vtkXMLPUnstructuredGridReader.cxx
+9
-11
IO/vtkXMLPolyDataReader.cxx
IO/vtkXMLPolyDataReader.cxx
+19
-11
IO/vtkXMLPolyDataReader.h
IO/vtkXMLPolyDataReader.h
+2
-0
IO/vtkXMLReader.cxx
IO/vtkXMLReader.cxx
+117
-81
IO/vtkXMLReader.h
IO/vtkXMLReader.h
+30
-15
IO/vtkXMLRectilinearGridReader.cxx
IO/vtkXMLRectilinearGridReader.cxx
+33
-33
IO/vtkXMLRectilinearGridReader.h
IO/vtkXMLRectilinearGridReader.h
+1
-1
IO/vtkXMLStructuredGridReader.cxx
IO/vtkXMLStructuredGridReader.cxx
+27
-29
IO/vtkXMLStructuredGridReader.h
IO/vtkXMLStructuredGridReader.h
+1
-1
IO/vtkXMLUnstructuredDataReader.cxx
IO/vtkXMLUnstructuredDataReader.cxx
+21
-27
IO/vtkXMLUnstructuredDataReader.h
IO/vtkXMLUnstructuredDataReader.h
+1
-1
IO/vtkXMLUnstructuredGridReader.cxx
IO/vtkXMLUnstructuredGridReader.cxx
+17
-11
IO/vtkXMLUnstructuredGridReader.h
IO/vtkXMLUnstructuredGridReader.h
+2
-0
No files found.
Common/Testing/Tcl/otherPrint.tcl
View file @
9e96c49f
...
...
@@ -18,19 +18,19 @@ proc rtOtherTest { fileid } {
#actual test
set all
[
lsort
[
info command vtk*
]]
foreach a $all
{
if
{
$a
==
"vtkIndent"
}
{
continue
}
if
{
$a
==
"vtkOutputPort"
}
{
continue
}
if
{
$a
==
"vtkTimeStamp"
}
{
continue
}
if
{
$a
==
"vtkIndent"
}
{
continue
}
if
{
$a
==
"vtkOutputPort"
}
{
continue
}
if
{
$a
==
"vtkTimeStamp"
}
{
continue
}
if
{
$a
==
"vtkOutputWindow"
}
{
continue
}
catch
{
catch
{
$a b
b Print
if
{[
b IsA $a
]
== 0
}
{
puts stderr
"
$a
failed IsA test!!!"
}
...
...
@@ -38,14 +38,14 @@ proc rtOtherTest { fileid } {
b GetClassName
b Delete
}
catch
{
catch
{
$a b
$a c
set d
[
b SafeDownCast c
]
b Delete
c Delete
}
catch
{
catch
{
b Delete
c Delete
}
...
...
IO/vtkXMLDataReader.cxx
View file @
9e96c49f
...
...
@@ -22,7 +22,7 @@
#include "vtkXMLDataElement.h"
#include "vtkXMLDataParser.h"
vtkCxxRevisionMacro
(
vtkXMLDataReader
,
"1.1
0
"
);
vtkCxxRevisionMacro
(
vtkXMLDataReader
,
"1.1
1
"
);
//----------------------------------------------------------------------------
vtkXMLDataReader
::
vtkXMLDataReader
()
...
...
@@ -140,116 +140,79 @@ void vtkXMLDataReader::DestroyPieces()
this
->
NumberOfPieces
=
0
;
}
//----------------------------------------------------------------------------
void
vtkXMLDataReader
::
SetupOutput
Information
()
void
vtkXMLDataReader
::
SetupOutput
Data
()
{
this
->
Superclass
::
SetupOutputInformation
();
if
(
!
this
->
NumberOfPieces
)
{
return
;
}
this
->
Superclass
::
SetupOutputData
();
int
i
;
// Use the configuration of the first piece since all are the same.
vtkXMLDataElement
*
ePointData
=
this
->
PointDataElements
[
0
];
vtkXMLDataElement
*
eCellData
=
this
->
CellDataElements
[
0
];
vtkPointData
*
pointData
=
this
->
GetOutputAsDataSet
(
0
)
->
GetPointData
();
vtkCellData
*
cellData
=
this
->
GetOutputAsDataSet
(
0
)
->
GetCellData
();
vtkCellData
*
cellData
=
this
->
GetOutputAsDataSet
(
0
)
->
GetCellData
();
// Setup the point and cell data arrays without allocation.
// Get the size of the output arrays.
unsigned
long
pointTuples
=
this
->
GetNumberOfPoints
();
unsigned
long
cellTuples
=
this
->
GetNumberOfCells
();
// Allocate the arrays in the output. We only need the information
// from one piece because all pieces have the same set of arrays.
vtkXMLDataElement
*
ePointData
=
this
->
PointDataElements
[
0
];
vtkXMLDataElement
*
eCellData
=
this
->
CellDataElements
[
0
];
int
i
;
this
->
NumberOfPointArrays
=
0
;
this
->
SetDataArraySelections
(
ePointData
,
this
->
PointDataArraySelection
);
if
(
ePointData
)
if
(
ePointData
)
{
for
(
i
=
0
;
i
<
ePointData
->
GetNumberOfNestedElements
();
++
i
)
for
(
i
=
0
;
i
<
ePointData
->
GetNumberOfNestedElements
();
i
++
)
{
vtkXMLDataElement
*
eNested
=
ePointData
->
GetNestedElement
(
i
);
if
(
this
->
PointDataArrayIsEnabled
(
eNested
))
if
(
this
->
PointDataArrayIsEnabled
(
eNested
))
{
++
this
->
NumberOfPointArrays
;
this
->
NumberOfPointArrays
++
;
vtkDataArray
*
array
=
this
->
CreateDataArray
(
eNested
);
if
(
array
)
if
(
array
)
{
array
->
SetNumberOfTuples
(
pointTuples
);
pointData
->
AddArray
(
array
);
array
->
Delete
();
}
else
{
this
->
Information
Error
=
1
;
this
->
Data
Error
=
1
;
}
}
}
}
this
->
NumberOfCellArrays
=
0
;
this
->
SetDataArraySelections
(
eCellData
,
this
->
CellDataArraySelection
);
if
(
eCellData
)
if
(
eCellData
)
{
for
(
i
=
0
;
i
<
eCellData
->
GetNumberOfNestedElements
();
++
i
)
for
(
i
=
0
;
i
<
eCellData
->
GetNumberOfNestedElements
();
i
++
)
{
vtkXMLDataElement
*
eNested
=
eCellData
->
GetNestedElement
(
i
);
if
(
this
->
CellDataArrayIsEnabled
(
eNested
))
if
(
this
->
CellDataArrayIsEnabled
(
eNested
))
{
++
this
->
NumberOfCellArrays
;
this
->
NumberOfCellArrays
++
;
vtkDataArray
*
array
=
this
->
CreateDataArray
(
eNested
);
if
(
array
)
if
(
array
)
{
array
->
SetNumberOfTuples
(
cellTuples
);
cellData
->
AddArray
(
array
);
array
->
Delete
();
}
else
{
this
->
Information
Error
=
1
;
this
->
Data
Error
=
1
;
}
}
}
}
// Setup attribute indices for the point data and cell data.
this
->
ReadAttributeIndices
(
ePointData
,
pointData
);
this
->
ReadAttributeIndices
(
eCellData
,
cellData
);
}
//----------------------------------------------------------------------------
void
vtkXMLDataReader
::
SetupOutputData
()
{
this
->
Superclass
::
SetupOutputData
();
vtkDataSet
*
output
=
this
->
GetOutputAsDataSet
(
0
);
vtkPointData
*
pointData
=
output
->
GetPointData
();
vtkCellData
*
cellData
=
output
->
GetCellData
();
// Get the size of the output arrays.
unsigned
long
pointTuples
=
this
->
GetNumberOfPoints
();
unsigned
long
cellTuples
=
this
->
GetNumberOfCells
();
// Allocate the arrays in the output. We only need the information
// from one piece because all pieces have the same set of arrays.
vtkXMLDataElement
*
ePointData
=
this
->
PointDataElements
[
0
];
vtkXMLDataElement
*
eCellData
=
this
->
CellDataElements
[
0
];
int
i
;
if
(
ePointData
)
{
int
a
=
0
;
for
(
i
=
0
;
i
<
ePointData
->
GetNumberOfNestedElements
();
++
i
)
{
vtkXMLDataElement
*
eNested
=
ePointData
->
GetNestedElement
(
i
);
if
(
this
->
PointDataArrayIsEnabled
(
eNested
))
{
pointData
->
GetArray
(
a
++
)
->
SetNumberOfTuples
(
pointTuples
);
}
}
}
if
(
eCellData
)
{
int
a
=
0
;
for
(
i
=
0
;
i
<
eCellData
->
GetNumberOfNestedElements
();
++
i
)
{
vtkXMLDataElement
*
eNested
=
eCellData
->
GetNestedElement
(
i
);
if
(
this
->
CellDataArrayIsEnabled
(
eNested
))
{
cellData
->
GetArray
(
a
++
)
->
SetNumberOfTuples
(
cellTuples
);
}
}
}
}
//----------------------------------------------------------------------------
int
vtkXMLDataReader
::
ReadPiece
(
vtkXMLDataElement
*
ePiece
,
int
piece
)
{
...
...
IO/vtkXMLDataReader.h
View file @
9e96c49f
...
...
@@ -48,7 +48,6 @@ protected:
virtual
void
CreateXMLParser
();
virtual
void
DestroyXMLParser
();
int
ReadPrimaryElement
(
vtkXMLDataElement
*
ePrimary
);
void
SetupOutputInformation
();
void
SetupOutputData
();
// Setup the reader for a given number of pieces.
...
...
IO/vtkXMLImageDataReader.cxx
View file @
9e96c49f
...
...
@@ -19,19 +19,21 @@
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkXMLDataElement.h"
#include "vtkInformation.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkCxxRevisionMacro
(
vtkXMLImageDataReader
,
"1.
4
"
);
vtkCxxRevisionMacro
(
vtkXMLImageDataReader
,
"1.
5
"
);
vtkStandardNewMacro
(
vtkXMLImageDataReader
);
//----------------------------------------------------------------------------
vtkXMLImageDataReader
::
vtkXMLImageDataReader
()
{
// Copied from vtkImageDataReader constructor:
this
->
SetOutput
(
vtkImageData
::
New
()
);
vtkImageData
*
output
=
vtkImageData
::
New
();
this
->
SetOutput
(
output
);
// Releasing data for pipeline parallism.
// Filters will know it is empty.
this
->
O
utput
s
[
0
]
->
ReleaseData
();
this
->
O
utput
s
[
0
]
->
Delete
();
o
utput
->
ReleaseData
();
o
utput
->
Delete
();
}
//----------------------------------------------------------------------------
...
...
@@ -48,23 +50,19 @@ void vtkXMLImageDataReader::PrintSelf(ostream& os, vtkIndent indent)
//----------------------------------------------------------------------------
void
vtkXMLImageDataReader
::
SetOutput
(
vtkImageData
*
output
)
{
this
->
Superclass
::
SetNth
Output
(
0
,
output
);
this
->
GetExecutive
()
->
Set
Output
Data
(
0
,
output
);
}
//----------------------------------------------------------------------------
vtkImageData
*
vtkXMLImageDataReader
::
GetOutput
()
{
if
(
this
->
NumberOfOutputs
<
1
)
{
return
0
;
}
return
static_cast
<
vtkImageData
*>
(
this
->
Outputs
[
0
]);
return
this
->
GetOutput
(
0
);
}
//----------------------------------------------------------------------------
vtkImageData
*
vtkXMLImageDataReader
::
GetOutput
(
int
idx
)
{
return
static_cast
<
vtkImageData
*>
(
this
->
Superclass
::
GetOutpu
t
(
idx
));
return
vtkImageData
::
SafeDownCast
(
this
->
GetOutputDataObjec
t
(
idx
)
);
}
...
...
@@ -105,20 +103,45 @@ int vtkXMLImageDataReader::ReadPrimaryElement(vtkXMLDataElement* ePrimary)
}
//----------------------------------------------------------------------------
void
vtkXMLImageDataReader
::
SetupOutputInformation
()
void
vtkXMLImageDataReader
::
SetupOutputInformation
(
vtkInformation
*
outInfo
)
{
this
->
Superclass
::
SetupOutputInformation
();
this
->
Superclass
::
SetupOutputInformation
(
outInfo
);
outInfo
->
Set
(
vtkDataObject
::
ORIGIN
(),
this
->
Origin
,
3
);
outInfo
->
Set
(
vtkDataObject
::
SPACING
(),
this
->
Spacing
,
3
);
// Backward-compatability support for scalar information in output.
vtkImageData
*
output
=
this
->
GetOutput
();
output
->
SetOrigin
(
this
->
Origin
);
output
->
SetSpacing
(
this
->
Spacing
);
vtkDataArray
*
scalars
=
output
->
GetPointData
()
->
GetScalars
();
if
(
scalars
)
if
(
this
->
PointDataElements
[
0
])
{
output
->
SetScalarType
(
scalars
->
GetDataType
());
output
->
SetNumberOfScalarComponents
(
scalars
->
GetNumberOfComponents
());
}
int
components
,
dataType
,
i
;
for
(
i
=
0
;
i
<
this
->
PointDataElements
[
0
]
->
GetNumberOfNestedElements
();
i
++
)
{
vtkXMLDataElement
*
eNested
=
this
->
PointDataElements
[
0
]
->
GetNestedElement
(
i
);
if
(
eNested
->
GetAttribute
(
"Scalars"
)
)
{
if
(
!
eNested
->
GetWordTypeAttribute
(
"type"
,
dataType
))
{
this
->
InformationError
=
1
;
return
;
}
if
(
!
eNested
->
GetScalarAttribute
(
"NumberOfComponents"
,
components
))
{
this
->
InformationError
=
1
;
return
;
}
outInfo
->
Set
(
vtkDataObject
::
SCALAR_TYPE
(),
dataType
);
outInfo
->
Set
(
vtkDataObject
::
SCALAR_NUMBER_OF_COMPONENTS
(),
components
);
break
;
}
}
}
}
//----------------------------------------------------------------------------
int
vtkXMLImageDataReader
::
FillOutputPortInformation
(
int
,
vtkInformation
*
info
)
{
info
->
Set
(
vtkDataObject
::
DATA_TYPE_NAME
(),
"vtkImageData"
);
return
1
;
}
IO/vtkXMLImageDataReader.h
View file @
9e96c49f
...
...
@@ -53,7 +53,8 @@ protected:
const
char
*
GetDataSetName
();
void
SetOutputExtent
(
int
*
extent
);
int
ReadPrimaryElement
(
vtkXMLDataElement
*
ePrimary
);
void
SetupOutputInformation
();
void
SetupOutputInformation
(
vtkInformation
*
outInfo
);
virtual
int
FillOutputPortInformation
(
int
,
vtkInformation
*
);
private:
vtkXMLImageDataReader
(
const
vtkXMLImageDataReader
&
);
// Not implemented.
...
...
IO/vtkXMLPDataReader.cxx
View file @
9e96c49f
...
...
@@ -22,8 +22,9 @@
#include "vtkPointData.h"
#include "vtkXMLDataElement.h"
#include "vtkXMLDataReader.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkCxxRevisionMacro
(
vtkXMLPDataReader
,
"1.1
0
"
);
vtkCxxRevisionMacro
(
vtkXMLPDataReader
,
"1.1
1
"
);
//----------------------------------------------------------------------------
vtkXMLPDataReader
::
vtkXMLPDataReader
()
...
...
@@ -65,23 +66,28 @@ vtkDataSet* vtkXMLPDataReader::GetPieceInputAsDataSet(int piece)
{
vtkXMLDataReader
*
reader
=
this
->
PieceReaders
[
piece
];
if
(
!
reader
)
{
return
0
;
}
if
(
reader
->
GetNumberOfOutputs
()
<
1
)
{
return
0
;
}
return
static_cast
<
vtkDataSet
*>
(
reader
->
Get
Outputs
()[
0
]
);
if
(
reader
->
GetNumberOfOutput
Port
s
()
<
1
)
{
return
0
;
}
return
static_cast
<
vtkDataSet
*>
(
reader
->
Get
Executive
()
->
GetOutputData
(
0
)
);
}
//----------------------------------------------------------------------------
void
vtkXMLPDataReader
::
SetupOutput
Information
()
void
vtkXMLPDataReader
::
SetupOutput
Data
()
{
this
->
Superclass
::
SetupOutputInformation
();
int
i
;
this
->
Superclass
::
SetupOutputData
();
// Setup the output arrays.
vtkXMLDataElement
*
ePointData
=
this
->
PPointDataElement
;
vtkXMLDataElement
*
eCellData
=
this
->
PCellDataElement
;
vtkPointData
*
pointData
=
this
->
GetOutputAsDataSet
(
0
)
->
GetPointData
();
vtkCellData
*
cellData
=
this
->
GetOutputAsDataSet
(
0
)
->
GetCellData
();
vtkCellData
*
cellData
=
this
->
GetOutputAsDataSet
(
0
)
->
GetCellData
();
// Setup the point and cell data arrays without allocation.
// Get the size of the output arrays.
unsigned
long
pointTuples
=
this
->
GetNumberOfPoints
();
unsigned
long
cellTuples
=
this
->
GetNumberOfCells
();
// Allocate data in the arrays.
int
i
;
this
->
SetDataArraySelections
(
ePointData
,
this
->
PointDataArraySelection
);
if
(
ePointData
)
{
...
...
@@ -93,20 +99,22 @@ void vtkXMLPDataReader::SetupOutputInformation()
vtkDataArray
*
array
=
this
->
CreateDataArray
(
eNested
);
if
(
array
)
{
array
->
SetNumberOfTuples
(
pointTuples
);
pointData
->
AddArray
(
array
);
array
->
Delete
();
}
else
{
this
->
Information
Error
=
1
;
this
->
Data
Error
=
1
;
}
}
}
}
this
->
SetDataArraySelections
(
eCellData
,
this
->
CellDataArraySelection
);
if
(
eCellData
)
{
for
(
i
=
0
;
i
<
eCellData
->
GetNumberOfNestedElements
();
++
i
)
for
(
i
=
0
;
i
<
eCellData
->
GetNumberOfNestedElements
();
i
++
)
{
vtkXMLDataElement
*
eNested
=
eCellData
->
GetNestedElement
(
i
);
if
(
this
->
CellDataArrayIsEnabled
(
eNested
))
...
...
@@ -114,73 +122,32 @@ void vtkXMLPDataReader::SetupOutputInformation()
vtkDataArray
*
array
=
this
->
CreateDataArray
(
eNested
);
if
(
array
)
{
array
->
SetNumberOfTuples
(
cellTuples
);
cellData
->
AddArray
(
array
);
array
->
Delete
();
}
else
{
this
->
Information
Error
=
1
;
this
->
Data
Error
=
1
;
}
}
}
}
// Setup attribute indices for the point data and cell data.
this
->
ReadAttributeIndices
(
ePointData
,
pointData
);
this
->
ReadAttributeIndices
(
eCellData
,
cellData
);
}
//----------------------------------------------------------------------------
void
vtkXMLPDataReader
::
SetupOutputData
()
{
this
->
Superclass
::
SetupOutputData
();
vtkDataSet
*
output
=
this
->
GetOutputAsDataSet
(
0
);
vtkXMLDataElement
*
ePointData
=
this
->
PPointDataElement
;
vtkXMLDataElement
*
eCellData
=
this
->
PCellDataElement
;
vtkPointData
*
pointData
=
output
->
GetPointData
();
vtkCellData
*
cellData
=
output
->
GetCellData
();
// Get the size of the output arrays.
unsigned
long
pointTuples
=
this
->
GetNumberOfPoints
();
unsigned
long
cellTuples
=
this
->
GetNumberOfCells
();
// Allocate data in the arrays.
int
i
;
if
(
ePointData
)
{
int
a
=
0
;
for
(
i
=
0
;
i
<
ePointData
->
GetNumberOfNestedElements
();
++
i
)
{
vtkXMLDataElement
*
eNested
=
ePointData
->
GetNestedElement
(
i
);
if
(
this
->
PointDataArrayIsEnabled
(
eNested
))
{
pointData
->
GetArray
(
a
++
)
->
SetNumberOfTuples
(
pointTuples
);
}
}
}
if
(
eCellData
)
{
int
a
=
0
;
for
(
i
=
0
;
i
<
eCellData
->
GetNumberOfNestedElements
();
++
i
)
{
vtkXMLDataElement
*
eNested
=
eCellData
->
GetNestedElement
(
i
);
if
(
this
->
CellDataArrayIsEnabled
(
eNested
))
{
cellData
->
GetArray
(
a
++
)
->
SetNumberOfTuples
(
cellTuples
);
}
}
}
}
//----------------------------------------------------------------------------
void
vtkXMLPDataReader
::
ReadXMLInformation
()
int
vtkXMLPDataReader
::
ReadXMLInformation
()
{
// First setup the filename components.
this
->
SplitFileName
();
// Now proceed with reading the information.
this
->
Superclass
::
ReadXMLInformation
();
return
this
->
Superclass
::
ReadXMLInformation
();
}
//----------------------------------------------------------------------------
...
...
IO/vtkXMLPDataReader.h
View file @
9e96c49f
...
...
@@ -45,11 +45,10 @@ protected:
~
vtkXMLPDataReader
();
// Pipeline execute information driver. Called by vtkXMLReader.
void
ReadXMLInformation
();
int
ReadXMLInformation
();
int
ReadPrimaryElement
(
vtkXMLDataElement
*
ePrimary
);
vtkDataSet
*
GetPieceInputAsDataSet
(
int
piece
);
void
SetupOutputInformation
();
void
SetupOutputData
();
virtual
vtkXMLDataReader
*
CreatePieceReader
()
=
0
;
...
...
IO/vtkXMLPImageDataReader.cxx
View file @
9e96c49f
...
...
@@ -20,19 +20,21 @@
#include "vtkPointData.h"
#include "vtkXMLDataElement.h"
#include "vtkXMLImageDataReader.h"
#include "vtkInformation.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkCxxRevisionMacro
(
vtkXMLPImageDataReader
,
"1.
4
"
);
vtkCxxRevisionMacro
(
vtkXMLPImageDataReader
,
"1.
5
"
);
vtkStandardNewMacro
(
vtkXMLPImageDataReader
);
//----------------------------------------------------------------------------
vtkXMLPImageDataReader
::
vtkXMLPImageDataReader
()
{
// Copied from vtkImageDataReader constructor:
this
->
SetOutput
(
vtkImageData
::
New
()
);
vtkImageData
*
output
=
vtkImageData
::
New
();
this
->
SetOutput
(
output
);
// Releasing data for pipeline parallism.
// Filters will know it is empty.
this
->
O
utput
s
[
0
]
->
ReleaseData
();
this
->
O
utput
s
[
0
]
->
Delete
();
o
utput
->
ReleaseData
();
o
utput
->
Delete
();
}
//----------------------------------------------------------------------------
...
...
@@ -49,23 +51,19 @@ void vtkXMLPImageDataReader::PrintSelf(ostream& os, vtkIndent indent)
//----------------------------------------------------------------------------
void
vtkXMLPImageDataReader
::
SetOutput
(
vtkImageData
*
output
)
{
this
->
Superclass
::
SetNth
Output
(
0
,
output
);
this
->
GetExecutive
()
->
Set
Output
Data
(
0
,
output
);
}
//----------------------------------------------------------------------------
vtkImageData
*
vtkXMLPImageDataReader
::
GetOutput
()
{
if
(
this
->
NumberOfOutputs
<
1
)
{
return
0
;
}
return
static_cast
<
vtkImageData
*>
(
this
->
Outputs
[
0
]);
return
this
->
GetOutput
(
0
);
}
//----------------------------------------------------------------------------
vtkImageData
*
vtkXMLPImageDataReader
::
GetOutput
(
int
idx
)
{
return
static_cast
<
vtkImageData
*>
(
this
->
Superclass
::
GetOutpu
t
(
idx
));
return
vtkImageData
::
SafeDownCast
(
this
->
GetOutputDataObjec
t
(
idx
)
);
}
//----------------------------------------------------------------------------
...
...
@@ -119,21 +117,38 @@ int vtkXMLPImageDataReader::ReadPrimaryElement(vtkXMLDataElement* ePrimary)
}
//----------------------------------------------------------------------------
void
vtkXMLPImageDataReader
::
SetupOutputInformation
()
void
vtkXMLPImageDataReader
::
SetupOutputInformation
(
vtkInformation
*
outInfo
)
{
this
->
Superclass
::
SetupOutputInformation
();
vtkImageData
*
output
=
this
->
GetOutput
();
output
->
SetOrigin
(
this
->
Origin
);
output
->
SetSpacing
(
this
->
Spacing
);
this
->
Superclass
::
SetupOutputInformation
(
outInfo
);
// Backward-compatability support for scalar information in output.
vtkDataArray
*
scalars
=
output
->
GetPointData
()
->
GetScalars
();
if
(
scalars
)
outInfo
->
Set
(
vtkDataObject
::
ORIGIN
(),
this
->
Origin
,
3
);
outInfo
->
Set
(
vtkDataObject
::
SPACING
(),
this
->
Spacing
,
3
);
// Backward-compatability support for scalar information in output.
if
(
this
->
PPointDataElement
)
{
output
->
SetScalarType
(
scalars
->
GetDataType
());
output
->
SetNumberOfScalarComponents
(
scalars
->
GetNumberOfComponents
());
}
int
i
,
components
,
dataType
;
for
(
i
=
0
;
i
<
this
->
PPointDataElement
->
GetNumberOfNestedElements
();
i
++
)
{
vtkXMLDataElement
*
eNested
=
this
->
PPointDataElement
->
GetNestedElement
(
i
);
if
(
eNested
->
GetAttribute
(
"Scalars"
)
)
{
if
(
!
eNested
->
GetWordTypeAttribute
(
"type"
,
dataType
))
{
this
->
InformationError
=
1
;
return
;
}
if
(
!
eNested
->
GetScalarAttribute
(
"NumberOfComponents"
,
components
))
{
this
->
InformationError
=
1
;
return
;
}
outInfo
->
Set
(
vtkDataObject
::
SCALAR_TYPE
(),
dataType
);
outInfo
->
Set
(
vtkDataObject
::
SCALAR_NUMBER_OF_COMPONENTS
(),
components
);
break
;
}
}
}
}
//----------------------------------------------------------------------------
...
...
IO/vtkXMLPImageDataReader.h
View file @
9e96c49f
...
...
@@ -56,7 +56,7 @@ protected:
void
SetOutputExtent
(
int
*
extent
);
void
GetPieceInputExtent
(
int
index
,
int
*
extent
);