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   bool FrequencyModes;
00205   double Frequency;
00208   double Phase;
00209 
00210 //ETX
00211 
00212   virtual int RequestInformation(vtkInformation *request,
00213                                  vtkInformationVector **inputVector,
00214                                  vtkInformationVector *outputVector);
00215 
00216   virtual int RequestData(vtkInformation *request,
00217                           vtkInformationVector **inputVector,
00218                           vtkInformationVector *outputVector);
00219 
00221 
00222   static void SelectionModifiedCallback(vtkObject *caller, unsigned long eid,
00223                                         void *clientdata, void *calldata);
00225 
00227 
00232   virtual vtkIdType GetNumTuplesInVariable(int ncFD, int varId,
00233                                            int expectedNumComponents);
00235 
00238   virtual int CheckTetrahedraWinding(int meshFD);
00239 
00241 
00243   virtual int ReadConnectivity(int meshFD, vtkMultiBlockDataSet *surfaceOutput,
00244                                vtkMultiBlockDataSet *volumeOutput);
00246 
00248 
00249   virtual int ReadTetrahedronInteriorArray(int meshFD,
00250                                            vtkIdTypeArray *connectivity);
00251   virtual int ReadTetrahedronExteriorArray(int meshFD,
00252                                            vtkIdTypeArray *connectivity);
00254 
00255 //BTX
00257 
00259   virtual vtkSmartPointer<vtkDataArray> ReadPointDataArray(int ncFD, int varId);
00260 //ETX
00262 
00263 //BTX
00265 
00266   enum {
00267     NumPerTetInt = 5,
00268     NumPerTetExt = 9
00269   };
00270 //ETX
00272 
00273 //BTX
00275 
00276   class VTK_IO_EXPORT MidpointCoordinateMap
00277   {
00278   public:
00279     MidpointCoordinateMap();
00280     ~MidpointCoordinateMap();
00282 
00283     void AddMidpoint(const EdgeEndpoints &edge,
00284                      const MidpointCoordinates &midpoint);
00285     void RemoveMidpoint(const EdgeEndpoints &edge);
00286     void RemoveAllMidpoints();
00287     vtkIdType GetNumberOfMidpoints() const;
00288 
00291     MidpointCoordinates *FindMidpoint(const EdgeEndpoints &edge);
00292 
00293   protected:
00294     class vtkInternal;
00295     vtkInternal *Internal;
00296 
00297   private:
00298     // Too lazy to implement these.
00299     MidpointCoordinateMap(const MidpointCoordinateMap &);
00300     void operator=(const MidpointCoordinateMap &);
00301   };
00302 
00304 
00305   class VTK_IO_EXPORT MidpointIdMap
00306   {
00307   public:
00308     MidpointIdMap();
00309     ~MidpointIdMap();
00311 
00312     void AddMidpoint(const EdgeEndpoints &edge, vtkIdType midpoint);
00313     void RemoveMidpoint(const EdgeEndpoints &edge);
00314     void RemoveAllMidpoints();
00315     vtkIdType GetNumberOfMidpoints() const;
00316 
00319     vtkIdType *FindMidpoint(const EdgeEndpoints &edge);
00320 
00322     void InitTraversal();
00325     bool GetNextMidpoint(EdgeEndpoints &edge, vtkIdType &midpoint);
00326 
00327   protected:
00328     class vtkInternal;
00329     vtkInternal *Internal;
00330 
00331   private:
00332     // Too lazy to implement these.
00333     MidpointIdMap(const MidpointIdMap &);
00334     void operator=(const MidpointIdMap &);
00335   };
00336 //ETX
00337 
00340   virtual int ReadCoordinates(int meshFD, vtkMultiBlockDataSet *output);
00341 
00343 
00346   virtual int ReadMidpointCoordinates(int meshFD, vtkMultiBlockDataSet *output,
00347                                       MidpointCoordinateMap &map);
00349 
00351 
00354   virtual int ReadMidpointData(int meshFD, vtkMultiBlockDataSet *output,
00355                                MidpointIdMap &map);
00357 
00359 
00361   virtual int RestoreMeshCache(vtkMultiBlockDataSet *surfaceOutput,
00362                                vtkMultiBlockDataSet *volumeOutput,
00363                                vtkMultiBlockDataSet *compositeOutput);
00365 
00368   virtual int ReadFieldData(int modeFD, vtkMultiBlockDataSet *output);
00369 
00371 
00373   virtual int InterpolateMidpointData(vtkMultiBlockDataSet *output,
00374                                       MidpointIdMap &map);
00376 
00380   vtkTimeStamp MeshReadTime;
00381 
00384   virtual int MeshUpToDate();
00385 
00386 private:
00387   vtkSLACReader(const vtkSLACReader &);         // Not implemented
00388   void operator=(const vtkSLACReader &);        // Not implemented
00389 };
00390 
00391 #endif //__vtkSLACReader_h