VTK
|
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 "vtkIONetCDFModule.h" // For export macro 00041 #include "vtkMultiBlockDataSetAlgorithm.h" 00042 00043 #include "vtkSmartPointer.h" // For internal method. 00044 00045 class vtkDataArraySelection; 00046 class vtkDoubleArray; 00047 class vtkIdTypeArray; 00048 class vtkInformationIntegerKey; 00049 class vtkInformationObjectBaseKey; 00050 00051 class VTKIONETCDF_EXPORT vtkSLACReader : public vtkMultiBlockDataSetAlgorithm 00052 { 00053 public: 00054 vtkTypeMacro(vtkSLACReader, vtkMultiBlockDataSetAlgorithm); 00055 static vtkSLACReader *New(); 00056 virtual void PrintSelf(ostream &os, vtkIndent indent); 00057 00058 vtkGetStringMacro(MeshFileName); 00059 vtkSetStringMacro(MeshFileName); 00060 00062 00066 virtual void AddModeFileName(const char *fname); 00067 virtual void RemoveAllModeFileNames(); 00068 virtual unsigned int GetNumberOfModeFileNames(); 00069 virtual const char *GetModeFileName(unsigned int idx); 00071 00073 00075 vtkGetMacro(ReadInternalVolume, int); 00076 vtkSetMacro(ReadInternalVolume, int); 00077 vtkBooleanMacro(ReadInternalVolume, int); 00079 00081 00083 vtkGetMacro(ReadExternalSurface, int); 00084 vtkSetMacro(ReadExternalSurface, int); 00085 vtkBooleanMacro(ReadExternalSurface, int); 00087 00089 00091 vtkGetMacro(ReadMidpoints, int); 00092 vtkSetMacro(ReadMidpoints, int); 00093 vtkBooleanMacro(ReadMidpoints, int); 00095 00097 00098 virtual int GetNumberOfVariableArrays(); 00099 virtual const char *GetVariableArrayName(int idx); 00100 virtual int GetVariableArrayStatus(const char *name); 00101 virtual void SetVariableArrayStatus(const char *name, int status); 00103 00105 00106 virtual void ResetFrequencyScales(); 00107 virtual void SetFrequencyScale(int index, double scale); 00109 00111 00112 virtual void ResetPhaseShifts(); 00113 virtual void SetPhaseShift(int index, double shift); 00115 00117 00118 virtual vtkDoubleArray* GetFrequencyScales(); 00119 virtual vtkDoubleArray* GetPhaseShifts(); 00121 00123 static int CanReadFile(const char *filename); 00124 00127 static vtkInformationIntegerKey *IS_INTERNAL_VOLUME(); 00128 00131 static vtkInformationIntegerKey *IS_EXTERNAL_SURFACE(); 00132 00134 00138 static vtkInformationObjectBaseKey *POINTS(); 00139 static vtkInformationObjectBaseKey *POINT_DATA(); 00141 00142 //BTX 00144 00147 class VTKIONETCDF_EXPORT EdgeEndpoints 00148 { 00149 public: 00150 EdgeEndpoints() : MinEndPoint(-1), MaxEndPoint(-1) {} 00151 EdgeEndpoints(vtkIdType endpointA, vtkIdType endpointB) { 00152 if (endpointA < endpointB) 00153 { 00154 this->MinEndPoint = endpointA; this->MaxEndPoint = endpointB; 00155 } 00156 else 00157 { 00158 this->MinEndPoint = endpointB; this->MaxEndPoint = endpointA; 00159 } 00160 } 00161 inline vtkIdType GetMinEndPoint() const { return this->MinEndPoint; } 00162 inline vtkIdType GetMaxEndPoint() const { return this->MaxEndPoint; } 00163 inline bool operator==(const EdgeEndpoints &other) const { 00164 return ( (this->GetMinEndPoint() == other.GetMinEndPoint()) 00165 && (this->GetMaxEndPoint() == other.GetMaxEndPoint()) ); 00166 } 00167 protected: 00168 vtkIdType MinEndPoint; 00169 vtkIdType MaxEndPoint; 00170 }; 00172 00174 00175 class VTKIONETCDF_EXPORT MidpointCoordinates 00176 { 00177 public: 00178 MidpointCoordinates() {} 00179 MidpointCoordinates(const double coord[3], vtkIdType id) { 00180 this->Coordinate[0] = coord[0]; 00181 this->Coordinate[1] = coord[1]; 00182 this->Coordinate[2] = coord[2]; 00183 this->ID = id; 00184 } 00185 double Coordinate[3]; 00186 vtkIdType ID; 00187 }; 00189 00190 enum { 00191 SURFACE_OUTPUT = 0, 00192 VOLUME_OUTPUT = 1, 00193 NUM_OUTPUTS = 2 00194 }; 00195 //ETX 00196 00197 protected: 00198 vtkSLACReader(); 00199 ~vtkSLACReader(); 00200 00201 //BTX 00202 class vtkInternal; 00203 vtkInternal *Internal; 00204 00205 // Friend so vtkInternal can access MidpointIdMap 00206 // (so Sun CC compiler doesn't complain). 00207 friend class vtkInternal; 00208 00209 char *MeshFileName; 00210 00211 int ReadInternalVolume; 00212 int ReadExternalSurface; 00213 int ReadMidpoints; 00214 00216 bool ReadModeData; 00217 00219 bool TimeStepModes; 00220 00222 bool FrequencyModes; 00223 00224 //ETX 00225 00226 virtual int RequestInformation(vtkInformation *request, 00227 vtkInformationVector **inputVector, 00228 vtkInformationVector *outputVector); 00229 00230 virtual int RequestData(vtkInformation *request, 00231 vtkInformationVector **inputVector, 00232 vtkInformationVector *outputVector); 00233 00235 00236 static void SelectionModifiedCallback(vtkObject *caller, unsigned long eid, 00237 void *clientdata, void *calldata); 00239 00241 00246 virtual vtkIdType GetNumTuplesInVariable(int ncFD, int varId, 00247 int expectedNumComponents); 00249 00252 virtual int CheckTetrahedraWinding(int meshFD); 00253 00255 00257 virtual int ReadConnectivity(int meshFD, vtkMultiBlockDataSet *surfaceOutput, 00258 vtkMultiBlockDataSet *volumeOutput); 00260 00262 00263 virtual int ReadTetrahedronInteriorArray(int meshFD, 00264 vtkIdTypeArray *connectivity); 00265 virtual int ReadTetrahedronExteriorArray(int meshFD, 00266 vtkIdTypeArray *connectivity); 00268 00269 //BTX 00271 00273 virtual vtkSmartPointer<vtkDataArray> ReadPointDataArray(int ncFD, int varId); 00274 //ETX 00276 00277 //BTX 00279 00280 enum { 00281 NumPerTetInt = 5, 00282 NumPerTetExt = 9 00283 }; 00284 //ETX 00286 00287 //BTX 00289 00290 class VTKIONETCDF_EXPORT MidpointCoordinateMap 00291 { 00292 public: 00293 MidpointCoordinateMap(); 00294 ~MidpointCoordinateMap(); 00296 00297 void AddMidpoint(const EdgeEndpoints &edge, 00298 const MidpointCoordinates &midpoint); 00299 void RemoveMidpoint(const EdgeEndpoints &edge); 00300 void RemoveAllMidpoints(); 00301 vtkIdType GetNumberOfMidpoints() const; 00302 00305 MidpointCoordinates *FindMidpoint(const EdgeEndpoints &edge); 00306 00307 protected: 00308 class vtkInternal; 00309 vtkInternal *Internal; 00310 00311 private: 00312 // Too lazy to implement these. 00313 MidpointCoordinateMap(const MidpointCoordinateMap &); 00314 void operator=(const MidpointCoordinateMap &); 00315 }; 00316 00318 00319 class VTKIONETCDF_EXPORT MidpointIdMap 00320 { 00321 public: 00322 MidpointIdMap(); 00323 ~MidpointIdMap(); 00325 00326 void AddMidpoint(const EdgeEndpoints &edge, vtkIdType midpoint); 00327 void RemoveMidpoint(const EdgeEndpoints &edge); 00328 void RemoveAllMidpoints(); 00329 vtkIdType GetNumberOfMidpoints() const; 00330 00333 vtkIdType *FindMidpoint(const EdgeEndpoints &edge); 00334 00336 void InitTraversal(); 00339 bool GetNextMidpoint(EdgeEndpoints &edge, vtkIdType &midpoint); 00340 00341 protected: 00342 class vtkInternal; 00343 vtkInternal *Internal; 00344 00345 private: 00346 // Too lazy to implement these. 00347 MidpointIdMap(const MidpointIdMap &); 00348 void operator=(const MidpointIdMap &); 00349 }; 00350 //ETX 00351 00354 virtual int ReadCoordinates(int meshFD, vtkMultiBlockDataSet *output); 00355 00357 00360 virtual int ReadMidpointCoordinates(int meshFD, vtkMultiBlockDataSet *output, 00361 MidpointCoordinateMap &map); 00363 00365 00368 virtual int ReadMidpointData(int meshFD, vtkMultiBlockDataSet *output, 00369 MidpointIdMap &map); 00371 00373 00375 virtual int RestoreMeshCache(vtkMultiBlockDataSet *surfaceOutput, 00376 vtkMultiBlockDataSet *volumeOutput, 00377 vtkMultiBlockDataSet *compositeOutput); 00379 00381 00383 virtual int ReadFieldData(const int *modeFDArray, 00384 int numModeFDs, 00385 vtkMultiBlockDataSet *output); 00387 00389 00391 virtual int InterpolateMidpointData(vtkMultiBlockDataSet *output, 00392 MidpointIdMap &map); 00394 00398 vtkTimeStamp MeshReadTime; 00399 00402 virtual int MeshUpToDate(); 00403 00404 private: 00405 vtkSLACReader(const vtkSLACReader &); // Not implemented 00406 void operator=(const vtkSLACReader &); // Not implemented 00407 }; 00408 00409 #endif //__vtkSLACReader_h