VTK
dox/IO/XML/vtkXMLUnstructuredDataWriter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkXMLUnstructuredDataWriter.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm 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 =========================================================================*/
00022 #ifndef __vtkXMLUnstructuredDataWriter_h
00023 #define __vtkXMLUnstructuredDataWriter_h
00024 
00025 #include "vtkIOXMLModule.h" // For export macro
00026 #include "vtkXMLWriter.h"
00027 
00028 class vtkPointSet;
00029 class vtkCellArray;
00030 class vtkDataArray;
00031 class vtkIdTypeArray;
00032 class vtkUnstructuredGrid;
00033 
00034 class VTKIOXML_EXPORT vtkXMLUnstructuredDataWriter : public vtkXMLWriter
00035 {
00036 public:
00037   vtkTypeMacro(vtkXMLUnstructuredDataWriter,vtkXMLWriter);
00038   void PrintSelf(ostream& os, vtkIndent indent);
00039 
00041 
00043   vtkSetMacro(NumberOfPieces, int);
00044   vtkGetMacro(NumberOfPieces, int);
00046 
00048 
00050   vtkSetMacro(WritePiece, int);
00051   vtkGetMacro(WritePiece, int);
00053 
00055 
00056   vtkSetMacro(GhostLevel, int);
00057   vtkGetMacro(GhostLevel, int);
00059 
00060   // See the vtkAlgorithm for a desciption of what these do
00061   int ProcessRequest(vtkInformation*,
00062                      vtkInformationVector**,
00063                      vtkInformationVector*);
00064 
00065 protected:
00066   vtkXMLUnstructuredDataWriter();
00067   ~vtkXMLUnstructuredDataWriter();
00068 
00069   vtkPointSet* GetInputAsPointSet();
00070   virtual const char* GetDataSetName()=0;
00071   virtual void SetInputUpdateExtent(int piece, int numPieces,
00072                                     int ghostLevel);
00073 
00074   virtual int WriteHeader();
00075   virtual int WriteAPiece();
00076   virtual int WriteFooter();
00077 
00078   virtual void AllocatePositionArrays();
00079   virtual void DeletePositionArrays();
00080 
00081   virtual int WriteInlineMode(vtkIndent indent);
00082   virtual void WriteInlinePieceAttributes();
00083   virtual void WriteInlinePiece(vtkIndent indent);
00084 
00085   virtual void WriteAppendedPieceAttributes(int index);
00086   virtual void WriteAppendedPiece(int index, vtkIndent indent);
00087   virtual void WriteAppendedPieceData(int index);
00088 
00089   void WriteCellsInline(const char* name, vtkCellArray* cells,
00090                         vtkDataArray* types, vtkIndent indent);
00091 
00092   // New API with face infomration for polyhedron cell support.
00093   void WriteCellsInline(const char* name, vtkCellArray* cells,
00094                         vtkDataArray* types, vtkIdTypeArray* faces,
00095                         vtkIdTypeArray* faceOffsets, vtkIndent indent);
00096 
00097   void WriteCellsAppended(const char* name, vtkDataArray* types,
00098                           vtkIndent indent, OffsetsManagerGroup *cellsManager);
00099 
00100   void WriteCellsAppendedData(vtkCellArray* cells, vtkDataArray* types,
00101                               int timestep, OffsetsManagerGroup *cellsManager);
00102 
00103   // New API with face infomration for polyhedron cell support.
00104   void WriteCellsAppendedData(vtkCellArray* cells, vtkDataArray* types,
00105                               vtkIdTypeArray* faces,vtkIdTypeArray* faceOffsets,
00106                               int timestep, OffsetsManagerGroup *cellsManager);
00107 
00108   void ConvertCells(vtkCellArray* cells);
00109 
00110   // For polyhedron support, conversion results are stored in Faces and FaceOffsets
00111   void ConvertFaces(vtkIdTypeArray* faces, vtkIdTypeArray* faceOffsets);
00112 
00113   // Get the number of points/cells.  Valid after Update has been
00114   // invoked on the input.
00115   virtual vtkIdType GetNumberOfInputPoints();
00116   virtual vtkIdType GetNumberOfInputCells()=0;
00117   void CalculateDataFractions(float* fractions);
00118   void CalculateCellFractions(float* fractions, vtkIdType typesSize);
00119 
00120   // Number of pieces used for streaming.
00121   int NumberOfPieces;
00122 
00123   // Which piece to write, if not all.
00124   int WritePiece;
00125 
00126   // The ghost level on each piece.
00127   int GhostLevel;
00128 
00129   // Positions of attributes for each piece.
00130   vtkTypeInt64* NumberOfPointsPositions;
00131 
00132   // For TimeStep support
00133   OffsetsManagerGroup *PointsOM;
00134   OffsetsManagerArray *PointDataOM;
00135   OffsetsManagerArray *CellDataOM;
00136 
00137   // Hold the new cell representation arrays while writing a piece.
00138   vtkIdTypeArray* CellPoints;
00139   vtkIdTypeArray* CellOffsets;
00140 
00141   int CurrentPiece;
00142 
00143   // Hold the face arrays for polyhedron cells.
00144   vtkIdTypeArray* Faces;
00145   vtkIdTypeArray* FaceOffsets;
00146 
00147 private:
00148   vtkXMLUnstructuredDataWriter(const vtkXMLUnstructuredDataWriter&);  // Not implemented.
00149   void operator=(const vtkXMLUnstructuredDataWriter&);  // Not implemented.
00150 };
00151 
00152 #endif