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
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
* @class vtkPDataSetWriter
* @brief Manages writing pieces of a data set.
*
* vtkPDataSetWriter will write a piece of a file, and will also create
* a metadata file that lists all of the files in a data set.
*/
#ifndef vtkPDataSetWriter_h
#define vtkPDataSetWriter_h
#include "vtkDataSetWriter.h"
#include "vtkIOParallelModule.h" // For export macro
#include <map> // for keeping track of extents
#include <vector> // for keeping track of extents
VTK_ABI_NAMESPACE_BEGIN
class vtkImageData;
class vtkRectilinearGrid;
class vtkStructuredGrid;
class vtkMultiProcessController;
class VTKIOPARALLEL_EXPORT vtkPDataSetWriter : public vtkDataSetWriter
{
public:
void PrintSelf(ostream& os, vtkIndent indent) override;
vtkTypeMacro(vtkPDataSetWriter, vtkDataSetWriter);
static vtkPDataSetWriter* New();
/**
* Write the pvtk file and corresponding vtk files.
*/
int Write() override;
///@{
/**
* This is how many pieces the whole data set will be divided into.
*/
void SetNumberOfPieces(int num);
vtkGetMacro(NumberOfPieces, int);
///@}
///@{
/**
* Extra ghost cells will be written out to each piece file
* if this value is larger than 0.
*/
vtkSetMacro(GhostLevel, int);
vtkGetMacro(GhostLevel, int);
///@}
///@{
/**
* This is the range of pieces that that this writer is
* responsible for writing. All pieces must be written
* by some process. The process that writes piece 0 also
* writes the pvtk file that lists all the piece file names.
*/
vtkSetMacro(StartPiece, int);
vtkGetMacro(StartPiece, int);
vtkSetMacro(EndPiece, int);
vtkGetMacro(EndPiece, int);
///@}
///@{
/**
* This file pattern uses the file name and piece number
* to construct a file name for the piece file.
*/
vtkSetFilePathMacro(FilePattern);
vtkGetFilePathMacro(FilePattern);
///@}
///@{
/**
* This flag determines whether to use absolute paths for the piece files.
* By default the pieces are put in the main directory, and the piece file
* names in the meta data pvtk file are relative to this directory.
* This should make moving the whole lot to another directory, an easier task.
*/
vtkSetMacro(UseRelativeFileNames, vtkTypeBool);
vtkGetMacro(UseRelativeFileNames, vtkTypeBool);
vtkBooleanMacro(UseRelativeFileNames, vtkTypeBool);
///@}
///@{
/**
* Controller used to communicate data type of blocks.
* By default, the global controller is used. If you want another
* controller to be used, set it with this.
*/
virtual void SetController(vtkMultiProcessController*);
vtkGetObjectMacro(Controller, vtkMultiProcessController);
///@}
protected:
vtkPDataSetWriter();
~vtkPDataSetWriter() override;
ostream* OpenFile();
int WriteUnstructuredMetaData(
vtkDataSet* input, char* root, char* str, size_t strSize, ostream* fptr);
int WriteImageMetaData(vtkImageData* input, char* root, char* str, size_t strSize, ostream* fptr);
int WriteRectilinearGridMetaData(
vtkRectilinearGrid* input, char* root, char* str, size_t strSize, ostream* fptr);
int WriteStructuredGridMetaData(
vtkStructuredGrid* input, char* root, char* str, size_t strSize, ostream* fptr);
int StartPiece;
int EndPiece;
int NumberOfPieces;
int GhostLevel;
vtkTypeBool UseRelativeFileNames;
char* FilePattern;
void DeleteFiles();
typedef std::map<int, std::vector<int>> ExtentsType;
ExtentsType Extents;
vtkMultiProcessController* Controller;
private:
vtkPDataSetWriter(const vtkPDataSetWriter&) = delete;
void operator=(const vtkPDataSetWriter&) = delete;
};
VTK_ABI_NAMESPACE_END
#endif
|