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
00261   virtual vtkSmartPointer<vtkDataArray> ReadPointDataArray(int ncFD, int varId);
00262 //ETX
00263 
00264 //BTX
00266 
00267   enum {
00268     NumPerTetInt = 5,
00269     NumPerTetExt = 9
00270   };
00272 //ETX
00273 
00274 //BTX
00276 
00277   class VTK_IO_EXPORT MidpointCoordinateMap
00278   {
00279   public:
00280     MidpointCoordinateMap();
00281     ~MidpointCoordinateMap();
00283 
00284     void AddMidpoint(const EdgeEndpoints &edge,
00285                      const MidpointCoordinates &midpoint);
00286     void RemoveMidpoint(const EdgeEndpoints &edge);
00287     void RemoveAllMidpoints();
00288     vtkIdType GetNumberOfMidpoints() const;
00289 
00292     MidpointCoordinates *FindMidpoint(const EdgeEndpoints &edge);
00293 
00294   protected:
00295     class vtkInternal;
00296     vtkInternal *Internal;
00297 
00298   private:
00299     // Too lazy to implement these.
00300     MidpointCoordinateMap(const MidpointCoordinateMap &);
00301     void operator=(const MidpointCoordinateMap &);
00302   };
00303 
00305 
00306   class VTK_IO_EXPORT MidpointIdMap
00307   {
00308   public:
00309     MidpointIdMap();
00310     ~MidpointIdMap();
00312 
00313     void AddMidpoint(const EdgeEndpoints &edge, vtkIdType midpoint);
00314     void RemoveMidpoint(const EdgeEndpoints &edge);
00315     void RemoveAllMidpoints();
00316     vtkIdType GetNumberOfMidpoints() const;
00317 
00320     vtkIdType *FindMidpoint(const EdgeEndpoints &edge);
00321 
00323 
00324     void InitTraversal();
00325     // Description:
00326     // Get the next midpoint in the iteration.  Return 0 if the end is reached.
00327     bool GetNextMidpoint(EdgeEndpoints &edge, vtkIdType &midpoint);
00329 
00330   protected:
00331     class vtkInternal;
00332     vtkInternal *Internal;
00333 
00334   private:
00335     // Too lazy to implement these.
00336     MidpointIdMap(const MidpointIdMap &);
00337     void operator=(const MidpointIdMap &);
00338   };
00339 //ETX
00340 
00343   virtual int ReadCoordinates(int meshFD, vtkMultiBlockDataSet *output);
00344 
00346 
00349   virtual int ReadMidpointCoordinates(int meshFD, vtkMultiBlockDataSet *output,
00350                                       MidpointCoordinateMap &map);
00352 
00354 
00357   virtual int ReadMidpointData(int meshFD, vtkMultiBlockDataSet *output,
00358                                MidpointIdMap &map);
00360 
00362 
00364   virtual int RestoreMeshCache(vtkMultiBlockDataSet *surfaceOutput,
00365                                vtkMultiBlockDataSet *volumeOutput,
00366                                vtkMultiBlockDataSet *compositeOutput);
00368 
00371   virtual int ReadFieldData(int modeFD, vtkMultiBlockDataSet *output);
00372 
00374 
00376   virtual int InterpolateMidpointData(vtkMultiBlockDataSet *output,
00377                                       MidpointIdMap &map);
00379 
00383   vtkTimeStamp MeshReadTime;
00384 
00387   virtual int MeshUpToDate();
00388 
00389 private:
00390   vtkSLACReader(const vtkSLACReader &);         // Not implemented
00391   void operator=(const vtkSLACReader &);        // Not implemented
00392 };
00393 
00394 #endif //__vtkSLACReader_h