IO/vtkXMLReader.h Source File

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# IO/vtkXMLReader.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkXMLReader.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00037 #ifndef __vtkXMLReader_h
    00038 #define __vtkXMLReader_h
    00039
    00040 #include "vtkSource.h"
    00041
    00042 class vtkCallbackCommand;
    00043 class vtkDataArray;
    00044 class vtkDataArraySelection;
    00045 class vtkDataSet;
    00046 class vtkDataSetAttributes;
    00047 class vtkXMLDataElement;
    00048 class vtkXMLDataParser;
    00049
    00050 class VTK_IO_EXPORT vtkXMLReader : public vtkSource
    00051 {
    00052 public:
    00053   vtkTypeRevisionMacro(vtkXMLReader,vtkSource);
    00054   void PrintSelf(ostream& os, vtkIndent indent);
    00055
    00057
    00058   vtkSetStringMacro(FileName);
    00059   vtkGetStringMacro(FileName);
    00061
    00063   virtual int CanReadFile(const char* name);
    00064
    00066   vtkDataSet* GetOutputAsDataSet();
    00067
    00069
    00071   vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
    00072   vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
    00074
    00076
    00077   int GetNumberOfPointArrays();
    00078   int GetNumberOfCellArrays();
    00080
    00082
    00084   const char* GetPointArrayName(int index);
    00085   const char* GetCellArrayName(int index);
    00087
    00089
    00091   int GetPointArrayStatus(const char* name);
    00092   int GetCellArrayStatus(const char* name);
    00093   void SetPointArrayStatus(const char* name, int status);
    00094   void SetCellArrayStatus(const char* name, int status);
    00096
    00097 protected:
    00098   vtkXMLReader();
    00099   ~vtkXMLReader();
    00100
    00101   // Standard pipeline exectution methods.
    00102   void ExecuteInformation();
    00103   void ExecuteData(vtkDataObject* output);
    00104
    00105   // Pipeline execution methods to be defined by subclass.  Called by
    00106   // corresponding Execute methods after appropriate setup has been
    00107   // done.
    00108   virtual void ReadXMLInformation();
    00109   virtual void ReadXMLData();
    00110
    00111   // Get the name of the data set being read.
    00112   virtual const char* GetDataSetName()=0;
    00113
    00114   // Test if the reader can read a file with the given version number.
    00115   virtual int CanReadFileVersion(int major, int minor);
    00116
    00117   // Setup the output with no data available.  Used in error cases.
    00118   virtual void SetupEmptyOutput()=0;
    00119
    00120   // Setup the output's information and data without allocation.
    00121   virtual void SetupOutputInformation();
    00122
    00123   // Setup the output's information and data with allocation.
    00124   virtual void SetupOutputData();
    00125
    00126   // Read the primary element from the file.  This is the element
    00127   // whose name is the value returned by GetDataSetName().
    00128   virtual int ReadPrimaryElement(vtkXMLDataElement* ePrimary);
    00129
    00130   // Read the top-level element from the file.  This is always the
    00131   // VTKFile element.
    00132   int ReadVTKFile(vtkXMLDataElement* eVTKFile);
    00133
    00134   // Create a vtkDataArray from its cooresponding XML representation.
    00135   // Does not allocate.
    00136   vtkDataArray* CreateDataArray(vtkXMLDataElement* da);
    00137
    00138   // Internal utility methods.
    00139   int OpenVTKFile();
    00140   void CloseVTKFile();
    00141   void CreateXMLParser();
    00142   void DestroyXMLParser();
    00143   void SetupCompressor(const char* type);
    00144   int CanReadFileVersionString(const char* version);
    00145
    00146   // Utility methods for subclasses.
    00147   int IntersectExtents(int* extent1, int* extent2, int* result);
    00148   int Min(int a, int b);
    00149   int Max(int a, int b);
    00150   void ComputeDimensions(int* extent, int* dimensions, int isPoint);
    00151   void ComputeIncrements(int* extent, int* increments, int isPoint);
    00152   unsigned int GetStartTuple(int* extent, int* increments,
    00153                              int i, int j, int k);
    00154   void ReadAttributeIndices(vtkXMLDataElement* eDSA,
    00155                             vtkDataSetAttributes* dsa);
    00156   char** CreateStringArray(int numStrings);
    00157   void DestroyStringArray(int numStrings, char** strings);
    00158
    00159   // Setup the data array selections for the input's set of arrays.
    00160   void SetDataArraySelections(vtkXMLDataElement* eDSA,
    00161                               vtkDataArraySelection* sel);
    00162
    00163   // Check whether the given array element is an enabled array.
    00164   int PointDataArrayIsEnabled(vtkXMLDataElement* ePDA);
    00165   int CellDataArrayIsEnabled(vtkXMLDataElement* eCDA);
    00166
    00167   // Callback registered with the SelectionObserver.
    00168   static void SelectionModifiedCallback(vtkObject* caller, unsigned long eid,
    00169                                         void* clientdata, void* calldata);
    00170
    00171   // The vtkXMLDataParser instance used to hide XML reading details.
    00172   vtkXMLDataParser* XMLParser;
    00173
    00174   // The input file's name.
    00175   char* FileName;
    00176
    00177   // The file stream used to read the input file.
    00178   ifstream* FileStream;
    00179
    00180   // The array selections.
    00181   vtkDataArraySelection* PointDataArraySelection;
    00182   vtkDataArraySelection* CellDataArraySelection;
    00183
    00184   // The observer to modify this object when the array selections are
    00185   // modified.
    00186   vtkCallbackCommand* SelectionObserver;
    00187
    00188   // Whether there was an error reading the file in ExecuteInformation.
    00189   int InformationError;
    00190
    00191   // Whether there was an error reading the file in ExecuteData.
    00192   int DataError;
    00193
    00194 private:
    00195   vtkXMLReader(const vtkXMLReader&);  // Not implemented.
    00196   void operator=(const vtkXMLReader&);  // Not implemented.
    00197 };
    00198
    00199 #endif