Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
VTK
VTK
Commits
b2b7f98a
Commit
b2b7f98a
authored
Nov 05, 2001
by
Charles Law
Browse files
Get first regression tests working with parallel reader and writer.
parent
5b5295a2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Parallel/vtkPDataSetReader.cxx
View file @
b2b7f98a
...
...
@@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkPDataSetReader.h"
#include "vtkDataSetReader.h"
#include "vtkStructuredPointsReader.h"
#include "vtkStructuredGridReader.h"
#include "vtkAppendPolyData.h"
#include "vtkAppendFilter.h"
#include "vtkPolyData.h"
...
...
@@ -633,8 +634,11 @@ void vtkPDataSetReader::Execute()
case
VTK_IMAGE_DATA
:
this
->
ImageDataExecute
();
break
;
case
VTK_STRUCTURED_GRID
:
this
->
StructuredGridExecute
();
break
;
default:
vtkErrorMacro
(
"We do not handle vtk
StructuredGrid
yet."
);
vtkErrorMacro
(
"We do not handle vtk
Rectilinear
yet."
);
return
;
}
}
...
...
@@ -841,6 +845,173 @@ void vtkPDataSetReader::ImageDataExecute()
}
//----------------------------------------------------------------------------
// Structured data is trickier. Which files to load?
void
vtkPDataSetReader
::
StructuredGridExecute
()
{
vtkStructuredGrid
*
output
;
vtkStructuredGrid
*
tmp
;
vtkStructuredGrid
**
pieces
;
int
count
=
0
;
vtkStructuredGridReader
*
reader
;
vtkPoints
*
newPts
;
int
uExt
[
6
];
int
ext
[
6
];
int
*
pieceMask
;
int
i
;
int
pIncY
,
pIncZ
,
cIncY
,
cIncZ
;
int
ix
,
iy
,
iz
;
float
*
pt
;
vtkIdType
inId
,
outId
;
vtkIdType
numPts
,
numCells
;
// Use out internal method to get the output because GetOutput calls
// UpdateInformation.
output
=
vtkStructuredGrid
::
SafeDownCast
(
this
->
CheckOutput
());
if
(
output
==
NULL
)
{
vtkErrorMacro
(
"Could not create output."
);
return
;
}
// Allocate the data object.
output
->
SetExtent
(
uExt
);
// Get the pieces that will be read.
pieceMask
=
new
int
[
this
->
NumberOfPieces
];
for
(
i
=
0
;
i
<
this
->
NumberOfPieces
;
++
i
)
{
pieceMask
[
i
]
=
0
;
}
output
->
GetUpdateExtent
(
uExt
);
this
->
CoverExtent
(
uExt
,
pieceMask
);
// Now read the pieces.
pieces
=
new
vtkStructuredGrid
*
[
this
->
NumberOfPieces
];
reader
=
vtkStructuredGridReader
::
New
();
for
(
i
=
0
;
i
<
this
->
NumberOfPieces
;
++
i
)
{
if
(
pieceMask
[
i
])
{
tmp
=
vtkStructuredGrid
::
New
();
reader
->
SetOutput
(
tmp
);
reader
->
SetFileName
(
this
->
PieceFileNames
[
i
]);
reader
->
Update
();
if
(
tmp
->
GetNumberOfCells
()
>
0
)
{
pieces
[
count
]
=
tmp
;
// Sanity check: extent is correct. Ignore electric slide.
tmp
->
GetExtent
(
ext
);
if
(
ext
[
1
]
-
ext
[
0
]
!=
this
->
PieceExtents
[
i
][
1
]
-
this
->
PieceExtents
[
i
][
0
]
||
ext
[
3
]
-
ext
[
2
]
!=
this
->
PieceExtents
[
i
][
3
]
-
this
->
PieceExtents
[
i
][
2
]
||
ext
[
5
]
-
ext
[
4
]
!=
this
->
PieceExtents
[
i
][
5
]
-
this
->
PieceExtents
[
i
][
4
])
{
vtkErrorMacro
(
"Unexpected extent in VTK file: "
<<
this
->
PieceFileNames
[
i
]);
}
else
{
// Reverse the electric slide.
tmp
->
SetExtent
(
this
->
PieceExtents
[
i
]);
}
++
count
;
}
else
{
tmp
->
Delete
();
}
}
}
// Anything could happen with files.
if
(
count
<=
0
)
{
delete
[]
pieces
;
delete
[]
pieceMask
;
reader
->
Delete
();
}
// Allocate the points.
cIncY
=
uExt
[
1
]
-
uExt
[
0
];
pIncY
=
cIncY
+
1
;
cIncZ
=
cIncY
*
(
uExt
[
3
]
-
uExt
[
2
]);
pIncZ
=
pIncY
*
(
uExt
[
3
]
-
uExt
[
2
]
+
1
);
numPts
=
pIncZ
*
(
uExt
[
5
]
-
uExt
[
4
]
+
1
);
numCells
=
cIncY
*
(
uExt
[
5
]
-
uExt
[
4
]);
output
->
SetExtent
(
uExt
);
newPts
=
vtkPoints
::
New
();
newPts
->
SetNumberOfPoints
(
numPts
);
// Copy allocate gymnastics.
vtkDataSetAttributes
::
FieldList
ptList
(
count
);
vtkDataSetAttributes
::
FieldList
cellList
(
count
);
ptList
.
InitializeFieldList
(
pieces
[
0
]
->
GetPointData
());
cellList
.
InitializeFieldList
(
pieces
[
0
]
->
GetCellData
());
for
(
i
=
1
;
i
<
count
;
++
i
)
{
ptList
.
IntersectFieldList
(
pieces
[
i
]
->
GetPointData
());
cellList
.
IntersectFieldList
(
pieces
[
i
]
->
GetCellData
());
}
output
->
GetPointData
()
->
CopyAllocate
(
ptList
,
numPts
);
output
->
GetCellData
()
->
CopyAllocate
(
cellList
,
numCells
);
// Now append the pieces.
for
(
i
=
0
;
i
<
count
;
++
i
)
{
pieces
[
i
]
->
GetExtent
(
ext
);
// Copy point data first.
inId
=
0
;
for
(
iz
=
ext
[
4
];
iz
<=
ext
[
5
];
++
iz
)
{
for
(
iy
=
ext
[
2
];
iy
<=
ext
[
3
];
++
iy
)
{
for
(
ix
=
ext
[
0
];
ix
<=
ext
[
1
];
++
ix
)
{
// For clipping. I know it is bad to have this condition
// in the inner most loop, but we had to read the data ...
if
(
iz
<=
uExt
[
5
]
&&
iz
>=
uExt
[
4
]
&&
iy
<=
uExt
[
3
]
&&
iy
>=
uExt
[
2
]
&&
ix
<=
uExt
[
1
]
&&
ix
>=
uExt
[
0
])
{
outId
=
(
ix
-
uExt
[
0
])
+
pIncY
*
(
iy
-
uExt
[
2
])
+
pIncZ
*
(
iz
-
uExt
[
4
]);
pt
=
pieces
[
i
]
->
GetPoint
(
inId
);
newPts
->
SetPoint
(
outId
,
pt
);
output
->
GetPointData
()
->
CopyData
(
ptList
,
pieces
[
i
]
->
GetPointData
(),
i
,
inId
,
outId
);
}
++
inId
;
}
}
}
// Copy cell data now.
inId
=
0
;
for
(
iz
=
ext
[
4
];
iz
<
ext
[
5
];
++
iz
)
{
for
(
iy
=
ext
[
2
];
iy
<
ext
[
3
];
++
iy
)
{
for
(
ix
=
ext
[
0
];
ix
<
ext
[
1
];
++
ix
)
{
outId
=
(
ix
-
uExt
[
0
])
+
cIncY
*
(
iy
-
uExt
[
2
])
+
cIncZ
*
(
iz
-
uExt
[
4
]);
output
->
GetCellData
()
->
CopyData
(
cellList
,
pieces
[
i
]
->
GetCellData
(),
i
,
inId
,
outId
);
++
inId
;
}
}
}
}
output
->
SetPoints
(
newPts
);
newPts
->
Delete
();
for
(
i
=
0
;
i
<
count
;
++
i
)
{
pieces
[
i
]
->
Delete
();
pieces
[
i
]
=
NULL
;
}
delete
[]
pieces
;
delete
[]
pieceMask
;
reader
->
Delete
();
}
//----------------------------------------------------------------------------
void
vtkPDataSetReader
::
CoverExtent
(
int
ext
[
6
],
int
*
pieceMask
)
{
...
...
Parallel/vtkPDataSetReader.h
View file @
b2b7f98a
...
...
@@ -95,6 +95,7 @@ protected:
void
PolyDataExecute
();
void
UnstructuredGridExecute
();
void
ImageDataExecute
();
void
StructuredGridExecute
();
void
CoverExtent
(
int
ext
[
6
],
int
*
pieceMask
);
...
...
Parallel/vtkPDataSetWriter.cxx
View file @
b2b7f98a
...
...
@@ -80,6 +80,22 @@ vtkPDataSetWriter::~vtkPDataSetWriter()
}
//----------------------------------------------------------------------------
void
vtkPDataSetWriter
::
SetNumberOfPieces
(
int
num
)
{
if
(
num
==
this
->
NumberOfPieces
)
{
return
;
}
this
->
Modified
();
this
->
NumberOfPieces
=
num
;
// Default behavior is for the single process to stream the pieces.
this
->
StartPiece
=
0
;
this
->
EndPiece
=
num
-
1
;
}
//----------------------------------------------------------------------------
void
vtkPDataSetWriter
::
Write
()
{
...
...
@@ -87,7 +103,6 @@ void vtkPDataSetWriter::Write()
int
length
;
char
*
fileRoot
;
char
*
fileName
;
char
*
savedFileName
;
ostream
*
fptr
;
vtkDataSet
*
input
=
this
->
GetInput
();
...
...
@@ -179,16 +194,29 @@ void vtkPDataSetWriter::Write()
}
// Now write the pieces assigned to this writer.
savedFileName
=
this
->
FileName
;
vtkDataSetWriter
*
writer
=
vtkDataSetWriter
::
New
();
writer
->
SetFileTypeToBinary
();
vtkDataObject
*
copy
;
for
(
i
=
this
->
StartPiece
;
i
<=
this
->
EndPiece
;
++
i
)
{
sprintf
(
fileName
,
this
->
FilePattern
,
fileRoot
,
i
);
writer
->
SetFileName
(
fileName
);
input
->
SetUpdateExtent
(
i
,
this
->
NumberOfPieces
,
this
->
GhostLevel
);
this
->
FileName
=
fileName
;
this
->
vtkDataSetWriter
::
Write
();
input
->
Update
();
copy
=
input
->
MakeObject
();
copy
->
ShallowCopy
(
input
);
// I am putting this in here because shallow copy does not copy the
// UpdateExtentInitializedFlag, and I do not want to touch ShallowCopy
// in ParaViews release.
copy
->
SetUpdateExtent
(
input
->
GetUpdateExtent
());
copy
->
SetRequestExactExtent
(
1
);
writer
->
SetInput
(
vtkDataSet
::
SafeDownCast
(
copy
));
writer
->
Write
();
copy
->
Delete
();
copy
=
NULL
;
}
this
->
FileName
=
savedFileName
;
savedFileName
=
NULL
;
writer
->
Delete
()
;
writer
=
NULL
;
delete
[]
fileName
;
delete
[]
fileRoot
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment