VTK
dox/IO/vtkSLACReader.h
Go to the documentation of this file.
00001 // -*- c++ -*-
00002 /*=========================================================================
00003 
00004   Program:   Visualization Toolkit
00005   Module:    vtkSLACReader.h
00006 
00007   Copyright (c) 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 =========================================================================*/
00016 
00017 /*-------------------------------------------------------------------------
00018   Copyright 2008 Sandia Corporation.
00019   Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00020   the U.S. Government retains certain rights in this software.
00021 -------------------------------------------------------------------------*/
00022 
00037 #ifndef __vtkSLACReader_h
00038 #define __vtkSLACReader_h
00039 
00040 #include "vtkMultiBlockDataSetAlgorithm.h"
00041 
00042 #include "vtkSmartPointer.h"      // For internal method.
00043 
00044 class vtkDataArraySelection;
00045 class vtkIdTypeArray;
00046 class vtkInformationIntegerKey;
00047 class vtkInformationObjectBaseKey;
00048 
00049 class VTK_IO_EXPORT vtkSLACReader : public vtkMultiBlockDataSetAlgorithm
00050 {
00051 public:
00052   vtkTypeMacro(vtkSLACReader, vtkMultiBlockDataSetAlgorithm);
00053   static vtkSLACReader *New();
00054   virtual void PrintSelf(ostream &os, vtkIndent indent);
00055 
00056   vtkGetStringMacro(MeshFileName);
00057   vtkSetStringMacro(MeshFileName);
00058 
00060 
00064   virtual void AddModeFileName(const char *fname);
00065   virtual void RemoveAllModeFileNames();
00066   virtual unsigned int GetNumberOfModeFileNames();
00067   virtual const char *GetModeFileName(unsigned int idx);
00069 
00071 
00073   vtkGetMacro(ReadInternalVolume, int);
00074   vtkSetMacro(ReadInternalVolume, int);
00075   vtkBooleanMacro(ReadInternalVolume, int);
00077 
00079 
00081   vtkGetMacro(ReadExternalSurface, int);
00082   vtkSetMacro(ReadExternalSurface, int);
00083   vtkBooleanMacro(ReadExternalSurface, int);
00085 
00087 
00089   vtkGetMacro(ReadMidpoints, int);
00090   vtkSetMacro(ReadMidpoints, int);
00091   vtkBooleanMacro(ReadMidpoints, int);
00093 
00095 
00096   virtual int GetNumberOfVariableArrays();
00097   virtual const char *GetVariableArrayName(int idx);
00098   virtual int GetVariableArrayStatus(const char *name);
00099   virtual void SetVariableArrayStatus(const char *name, int status);
00101 
00103   static int CanReadFile(const char *filename);
00104 
00107   static vtkInformationIntegerKey *IS_INTERNAL_VOLUME();
00108 
00111   static vtkInformationIntegerKey *IS_EXTERNAL_SURFACE();
00112 
00114 
00118   static vtkInformationObjectBaseKey *POINTS();
00119   static vtkInformationObjectBaseKey *POINT_DATA();
00121 
00122 //BTX
00124 
00127   class VTK_IO_EXPORT EdgeEndpoints
00128   {
00129   public:
00130     EdgeEndpoints() : MinEndPoint(-1), MaxEndPoint(-1) {}
00131     EdgeEndpoints(vtkIdType endpointA, vtkIdType endpointB) {
00132       if (endpointA < endpointB)
00133         {
00134         this->MinEndPoint = endpointA;  this->MaxEndPoint = endpointB;
00135         }
00136       else
00137         {
00138         this->MinEndPoint = endpointB;  this->MaxEndPoint = endpointA;
00139         }
00140     }
00141     inline vtkIdType GetMinEndPoint() const { return this->MinEndPoint; }
00142     inline vtkIdType GetMaxEndPoint() const { return this->MaxEndPoint; }
00143     inline bool operator==(const EdgeEndpoints &other) const {
00144       return (   (this->GetMinEndPoint() == other.GetMinEndPoint())
00145               && (this->GetMaxEndPoint() == other.GetMaxEndPoint()) );
00146     }
00147   protected:
00148     vtkIdType MinEndPoint;
00149     vtkIdType MaxEndPoint;
00150   };
00152 
00154 
00155   class VTK_IO_EXPORT MidpointCoordinates
00156   {
00157   public:
00158     MidpointCoordinates() {}
00159     MidpointCoordinates(const double coord[3], vtkIdType id) {
00160       this->Coordinate[0] = coord[0];
00161       this->Coordinate[1] = coord[1];
00162       this->Coordinate[2] = coord[2];
00163       this->ID = id;
00164     }
00165     double Coordinate[3];
00166     vtkIdType ID;
00167   };
00169 
00170   enum {
00171     SURFACE_OUTPUT = 0,
00172     VOLUME_OUTPUT = 1,
00173     NUM_OUTPUTS = 2
00174   };
00175 //ETX
00176 
00177 protected:
00178   vtkSLACReader();
00179   ~vtkSLACReader();
00180 
00181 //BTX
00182   class vtkInternal;
00183   vtkInternal *Internal;
00184 
00185   // Friend so vtkInternal can access MidpointIdMap 
00186   // (so Sun CC compiler doesn't complain).
00187   friend class vtkInternal;
00188 
00189   char *MeshFileName;
00190 
00191   int ReadInternalVolume;
00192   int ReadExternalSurface;
00193   int ReadMidpoints;
00194 
00196   bool ReadModeData;
00197 
00199   bool TimeStepModes;
00200 
00202 
00203   bool FrequencyModes;
00204   // Description:
00205   // The rate at which the fields repeat.
00206   // Only valid when FrequencyModes is true.
00207   double Frequency;
00208   // Description:
00209   // The phase of the current time step.  Set at the begining of RequestData.
00210   double Phase;
00212 
00213 //ETX
00214 
00215   virtual int RequestInformation(vtkInformation *request,
00216                                  vtkInformationVector **inputVector,
00217                                  vtkInformationVector *outputVector);
00218 
00219   virtual int RequestData(vtkInformation *request,
00220                           vtkInformationVector **inputVector,
00221                           vtkInformationVector *outputVector);
00222 
00224 
00225   static void SelectionModifiedCallback(vtkObject *caller, unsigned long eid,
00226                                         void *clientdata, void *calldata);
00228 
00230 
00235   virtual vtkIdType GetNumTuplesInVariable(int ncFD, int varId,
00236                                            int expectedNumComponents);
00238 
00241   virtual int CheckTetrahedraWinding(int meshFD);
00242 
00244 
00246   virtual int ReadConnectivity(int meshFD, vtkMultiBlockDataSet *surfaceOutput,
00247                                vtkMultiBlockDataSet *volumeOutput);
00249 
00251 
00252   virtual int ReadTetrahedronInteriorArray(int meshFD,
00253                                            vtkIdTypeArray *connectivity);
00254   virtual int ReadTetrahedronExteriorArray(int meshFD,
00255                                            vtkIdTypeArray *connectivity);
00257 
00258 //BTX
00260 
00262   virtual vtkSmartPointer<vtkDataArray> ReadPointDataArray(int ncFD, int varId);
00263 //ETX
00265 
00266 //BTX
00268 
00269   enum {
00270     NumPerTetInt = 5,
00271     NumPerTetExt = 9
00272   };
00273 //ETX
00275 
00276 //BTX
00278 
00279   class VTK_IO_EXPORT MidpointCoordinateMap
00280   {
00281   public:
00282     MidpointCoordinateMap();
00283     ~MidpointCoordinateMap();
00285 
00286     void AddMidpoint(const EdgeEndpoints &edge,
00287                      const MidpointCoordinates &midpoint);
00288     void RemoveMidpoint(const EdgeEndpoints &edge);
00289     void RemoveAllMidpoints();
00290     vtkIdType GetNumberOfMidpoints() const;
00291 
00294     MidpointCoordinates *FindMidpoint(const EdgeEndpoints &edge);
00295 
00296   protected:
00297     class vtkInternal;
00298     vtkInternal *Internal;
00299 
00300   private:
00301     // Too lazy to implement these.
00302     MidpointCoordinateMap(const MidpointCoordinateMap &);
00303     void operator=(const MidpointCoordinateMap &);
00304   };
00305 
00307 
00308   class VTK_IO_EXPORT MidpointIdMap
00309   {
00310   public:
00311     MidpointIdMap();
00312     ~MidpointIdMap();
00314 
00315     void AddMidpoint(const EdgeEndpoints &edge, vtkIdType midpoint);
00316     void RemoveMidpoint(const EdgeEndpoints &edge);
00317     void RemoveAllMidpoints();
00318     vtkIdType GetNumberOfMidpoints() const;
00319 
00322     vtkIdType *FindMidpoint(const EdgeEndpoints &edge);
00323 
00325 
00326     void InitTraversal();
00327     // Description:
00328     // Get the next midpoint in the iteration.  Return 0 if the end is reached.
00329     bool GetNextMidpoint(EdgeEndpoints &edge, vtkIdType &midpoint);
00331 
00332   protected:
00333     class vtkInternal;
00334     vtkInternal *Internal;
00335 
00336   private:
00337     // Too lazy to implement these.
00338     MidpointIdMap(const MidpointIdMap &);
00339     void operator=(const MidpointIdMap &);
00340   };
00341 //ETX
00342 
00345   virtual int ReadCoordinates(int meshFD, vtkMultiBlockDataSet *output);
00346 
00348 
00351   virtual int ReadMidpointCoordinates(int meshFD, vtkMultiBlockDataSet *output,
00352                                       MidpointCoordinateMap &map);
00354 
00356 
00359   virtual int ReadMidpointData(int meshFD, vtkMultiBlockDataSet *output,
00360                                MidpointIdMap &map);
00362 
00364 
00366   virtual int RestoreMeshCache(vtkMultiBlockDataSet *surfaceOutput,
00367                                vtkMultiBlockDataSet *volumeOutput,
00368                                vtkMultiBlockDataSet *compositeOutput);
00370 
00373   virtual int ReadFieldData(int modeFD, vtkMultiBlockDataSet *output);
00374 
00376 
00378   virtual int InterpolateMidpointData(vtkMultiBlockDataSet *output,
00379                                       MidpointIdMap &map);
00381 
00385   vtkTimeStamp MeshReadTime;
00386 
00389   virtual int MeshUpToDate();
00390 
00391 private:
00392   vtkSLACReader(const vtkSLACReader &);         // Not implemented
00393   void operator=(const vtkSLACReader &);        // Not implemented
00394 };
00395 
00396 #endif //__vtkSLACReader_h