VTK
|
00001 /*========================================================================= 00002 00003 Program: ParaView 00004 Module: $RCSfile: vtkXMLCompositeDataWriter.h,v $ 00005 00006 Copyright (c) Kitware, Inc. 00007 All rights reserved. 00008 See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00025 #ifndef __vtkXMLCompositeDataWriter_h 00026 #define __vtkXMLCompositeDataWriter_h 00027 00028 #include "vtkXMLWriter.h" 00029 #include "vtkStdString.h" // needed for vtkStdString. 00030 00031 class vtkCallbackCommand; 00032 class vtkCompositeDataSet; 00033 class vtkXMLDataElement; 00034 class vtkXMLCompositeDataWriterInternals; 00035 00036 class VTK_IO_EXPORT vtkXMLCompositeDataWriter : public vtkXMLWriter 00037 { 00038 public: 00039 vtkTypeRevisionMacro(vtkXMLCompositeDataWriter,vtkXMLWriter); 00040 void PrintSelf(ostream& os, vtkIndent indent); 00041 00043 virtual const char* GetDefaultFileExtension(); 00044 00046 00048 vtkGetMacro(Piece, int); 00049 vtkSetMacro(Piece, int); 00051 00053 00054 vtkGetMacro(NumberOfPieces, int); 00055 vtkSetMacro(NumberOfPieces, int); 00057 00059 00060 vtkGetMacro(GhostLevel, int); 00061 vtkSetMacro(GhostLevel, int); 00063 00065 00066 vtkGetMacro(WriteMetaFile, int); 00067 virtual void SetWriteMetaFile(int flag); 00069 00070 // See the vtkAlgorithm for a desciption of what these do 00071 int ProcessRequest(vtkInformation*, 00072 vtkInformationVector**, 00073 vtkInformationVector*); 00074 00075 protected: 00076 vtkXMLCompositeDataWriter(); 00077 ~vtkXMLCompositeDataWriter(); 00078 00079 // Methods to define the file's major and minor version numbers. 00080 // Major version incremented since v0.1 composite data readers cannot read 00081 // the files written by this new reader. 00082 virtual int GetDataSetMajorVersion() { return 1; } 00083 virtual int GetDataSetMinorVersion() { return 0; } 00084 00085 // Create a filename for the given index. 00086 vtkStdString CreatePieceFileName(int index); 00087 00088 // see algorithm for more info 00089 virtual int FillInputPortInformation(int port, vtkInformation* info); 00090 00091 int RequestData( 00092 vtkInformation* , vtkInformationVector** , vtkInformationVector*); 00093 int RequestUpdateExtent( 00094 vtkInformation* , vtkInformationVector** , vtkInformationVector*); 00095 00096 virtual int WriteData(); 00097 virtual const char* GetDataSetName(); 00098 00099 // Create a default executive. 00100 virtual vtkExecutive* CreateDefaultExecutive(); 00101 00102 vtkInformation* InputInformation; 00103 00105 virtual void FillDataTypes(vtkCompositeDataSet*); 00106 00107 unsigned int GetNumberOfDataTypes(); 00108 int* GetDataTypesPointer(); 00109 00110 // Methods to create the set of writers matching the set of inputs. 00111 void CreateWriters(vtkCompositeDataSet*); 00112 vtkXMLWriter* GetWriter(int index); 00113 00114 // Methods to help construct internal file names. 00115 void SplitFileName(); 00116 const char* GetFilePrefix(); 00117 const char* GetFilePath(); 00118 00122 int WriteMetaFileIfRequested(); 00123 00124 // Make a directory. 00125 void MakeDirectory(const char* name); 00126 00127 // Remove a directory. 00128 void RemoveADirectory(const char* name); 00129 00130 // Internal implementation details. 00131 vtkXMLCompositeDataWriterInternals* Internal; 00132 00133 // The piece number to write. 00134 int Piece; 00135 00136 // The number of pieces into which the inputs are split. 00137 int NumberOfPieces; 00138 00139 // The number of ghost levels to write for unstructured data. 00140 int GhostLevel; 00141 00142 // Whether to write the collection file on this node. 00143 int WriteMetaFile; 00144 int WriteMetaFileInitialized; 00145 00146 // Callback registered with the ProgressObserver. 00147 static void ProgressCallbackFunction(vtkObject*, unsigned long, void*, 00148 void*); 00149 // Progress callback from internal writer. 00150 virtual void ProgressCallback(vtkAlgorithm* w); 00151 00152 // The observer to report progress from the internal writer. 00153 vtkCallbackCommand* ProgressObserver; 00154 00155 // Garbage collection support. 00156 virtual void ReportReferences(vtkGarbageCollector*); 00157 00158 // Internal method called recursively to create the xml tree for the children 00159 // of compositeData. 00160 virtual int WriteComposite(vtkCompositeDataSet* compositeData, 00161 vtkXMLDataElement* element, int &writerIdx)=0; 00162 00163 // Internal method to write non vtkCompositeDataSet subclass. 00164 virtual int WriteNonCompositeData(vtkDataObject* dObj, 00165 vtkXMLDataElement* element, int& writerIdx); 00166 private: 00167 vtkXMLCompositeDataWriter(const vtkXMLCompositeDataWriter&); // Not implemented. 00168 void operator=(const vtkXMLCompositeDataWriter&); // Not implemented. 00169 }; 00170 00171 #endif