vtkXMLCompositeDataWriter.h 6.5 KB
Newer Older
1 2 3
/*=========================================================================

  Program:   ParaView
4
  Module:    vtkXMLCompositeDataWriter.h
5 6 7 8 9 10 11 12 13 14

  Copyright (c) Kitware, Inc.
  All rights reserved.
  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html 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.

=========================================================================*/
15
// .NAME vtkXMLCompositeDataWriter - Writer for multi-group datasets
16
// .SECTION Description
17
// vtkXMLCompositeDataWriter writes (serially) the VTK XML multi-group,
Berk Geveci's avatar
Berk Geveci committed
18 19
// multi-block hierarchical and hierarchical box files. XML multi-group
// data files are meta-files that point to a list of serial VTK XML files.
20
// .SECTION See Also
21
// vtkXMLPCompositeDataWriter
22

23 24
#ifndef vtkXMLCompositeDataWriter_h
#define vtkXMLCompositeDataWriter_h
25

26
#include "vtkIOXMLModule.h" // For export macro
27
#include "vtkXMLWriter.h"
28
#include "vtkStdString.h" // needed for vtkStdString.
29 30

class vtkCallbackCommand;
31 32 33
class vtkCompositeDataSet;
class vtkXMLDataElement;
class vtkXMLCompositeDataWriterInternals;
34

35
class VTKIOXML_EXPORT vtkXMLCompositeDataWriter : public vtkXMLWriter
36 37
{
public:
38
  vtkTypeMacro(vtkXMLCompositeDataWriter,vtkXMLWriter);
39 40
  void PrintSelf(ostream& os, vtkIndent indent);

41 42 43
  // Description:
  // Get the default file extension for files written by this writer.
  virtual const char* GetDefaultFileExtension();
44

45 46
  // Description:
  // Get/Set the number of pieces into which the inputs are split.
47

48 49 50 51
  // Description:
  // Get/Set the number of ghost levels to be written.
  vtkGetMacro(GhostLevel, int);
  vtkSetMacro(GhostLevel, int);
52

53
  // Description:
54
  // Get/Set whether this instance will write the meta-file.
55 56 57
  vtkGetMacro(WriteMetaFile, int);
  virtual void SetWriteMetaFile(int flag);

58
  // Description:
59 60 61 62 63 64
  // See the vtkAlgorithm for a desciption of what these do
  int ProcessRequest(vtkInformation*,
                     vtkInformationVector**,
                     vtkInformationVector*);

protected:
65 66 67
  vtkXMLCompositeDataWriter();
  ~vtkXMLCompositeDataWriter();

68
  // Description:
69
  // Methods to define the file's major and minor version numbers.
70
  // Major version incremented since v0.1 composite data readers cannot read
71 72 73
  // the files written by this new reader.
  virtual int GetDataSetMajorVersion() { return 1; }
  virtual int GetDataSetMinorVersion() { return 0; }
74

75
  // Description:
76
  // Create a filename for the given index.
77
  vtkStdString CreatePieceFileName(int Piece);
78

79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
  // see algorithm for more info
  virtual int FillInputPortInformation(int port, vtkInformation* info);

  int RequestData(
    vtkInformation*  , vtkInformationVector** , vtkInformationVector*);
  int RequestUpdateExtent(
    vtkInformation*  , vtkInformationVector** , vtkInformationVector*);

  virtual int WriteData();
  virtual const char* GetDataSetName();

  // Create a default executive.
  virtual vtkExecutive* CreateDefaultExecutive();

  vtkInformation* InputInformation;

95 96
  // Description:
  // Determine the data types for each of the leaf nodes.
97 98
  virtual void FillDataTypes(vtkCompositeDataSet*);

99 100
  // Description:
  // Returns the number of leaf nodes (also includes empty leaf nodes).
101
  unsigned int GetNumberOfDataTypes();
102 103 104

  // Description:
  // Returns the array pointer to the array of leaf nodes.
105 106 107
  int* GetDataTypesPointer();

  // Methods to create the set of writers matching the set of inputs.
108
  void CreateWriters(vtkCompositeDataSet*);
109
  vtkXMLWriter* GetWriter(int index);
110

111 112 113 114 115
  // Methods to help construct internal file names.
  void SplitFileName();
  const char* GetFilePrefix();
  const char* GetFilePath();

116 117 118 119 120
  // Description:
  // Returns the default extension to use for the given dataset type.
  // Returns NULL if an extension cannot be determined.
  const char* GetDefaultFileExtensionForDataSet(int dataset_type);

121
  // Description:
122
  // Write the collection file if it is requested.
123
  // This is overridden in parallel writers to communicate the hierarchy to the
124
  // root which then write the meta file.
125
  int WriteMetaFileIfRequested();
126

127 128
  // Make a directory.
  void MakeDirectory(const char* name);
129

130 131
  // Remove a directory.
  void RemoveADirectory(const char* name);
132

133
  // Internal implementation details.
134 135
  vtkXMLCompositeDataWriterInternals* Internal;

136 137
  // The number of ghost levels to write for unstructured data.
  int GhostLevel;
138

139 140
  // Description:
  // Whether to write the collection file on this node. This could
141
  // potentially be set to 0 (i.e. do not write) for optimization
142
  // if the file structured does not change but the data does.
143
  int WriteMetaFile;
144

145 146 147 148 149
  // Callback registered with the ProgressObserver.
  static void ProgressCallbackFunction(vtkObject*, unsigned long, void*,
                                       void*);
  // Progress callback from internal writer.
  virtual void ProgressCallback(vtkAlgorithm* w);
150

151
  // The observer to report progress from the internal writer.
152 153
  vtkCallbackCommand* ProgressObserver;

154
  // Description:
155 156
  // Internal method called recursively to create the xml tree for
  // the children of compositeData as well as write the actual data
157 158 159 160 161
  // set files.  element will only have added nested information.
  // writerIdx is the global piece index used to create unique
  // filenames for each file written.
  // This function returns 0 if no files were written from
  // compositeData.
162
  virtual int WriteComposite(vtkCompositeDataSet* compositeData,
163 164
    vtkXMLDataElement* element, int &writerIdx)=0;

165 166 167 168 169 170 171
  // Description:
  // Internal method to write a non vtkCompositeDataSet subclass as
  // well as add in the file name to the metadata file.
  // Element is the containing XML metadata element that may
  // have data overwritten and added to (the index XML attribute
  // should not be touched though).  writerIdx is the piece index
  // that gets incremented for the globally numbered piece.
172 173
  // This function returns 0 if no file was written (not necessarily an error).
  // this->ErrorCode is set on error.
174
  virtual int WriteNonCompositeData(
175
    vtkDataObject* dObj, vtkXMLDataElement* element,
176 177 178 179 180 181 182
    int& writerIdx, const char* FileName);

  // Description:
  // Utility function to remove any already written files
  // in case writer failed.
  virtual void RemoveWrittenFiles(const char* SubDirectory);

183
private:
184 185
  vtkXMLCompositeDataWriter(const vtkXMLCompositeDataWriter&);  // Not implemented.
  void operator=(const vtkXMLCompositeDataWriter&);  // Not implemented.
186 187 188
};

#endif