VTK
vtkSLACReader.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 /*=========================================================================
3 
4  Program: Visualization Toolkit
5  Module: vtkSLACReader.h
6 
7  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
8  All rights reserved.
9  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
10 
11  This software is distributed WITHOUT ANY WARRANTY; without even
12  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the above copyright notice for more information.
14 
15 =========================================================================*/
16 
17 /*-------------------------------------------------------------------------
18  Copyright 2008 Sandia Corporation.
19  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
20  the U.S. Government retains certain rights in this software.
21 -------------------------------------------------------------------------*/
22 
38 #ifndef vtkSLACReader_h
39 #define vtkSLACReader_h
40 
41 #include "vtkIONetCDFModule.h" // For export macro
43 
44 #include "vtkSmartPointer.h" // For internal method.
45 
47 class vtkDoubleArray;
48 class vtkIdTypeArray;
51 
52 class VTKIONETCDF_EXPORT vtkSLACReader : public vtkMultiBlockDataSetAlgorithm
53 {
54 public:
56  static vtkSLACReader *New();
57  void PrintSelf(ostream &os, vtkIndent indent) override;
58 
59  vtkGetStringMacro(MeshFileName);
60  vtkSetStringMacro(MeshFileName);
61 
63 
68  virtual void AddModeFileName(const char *fname);
69  virtual void RemoveAllModeFileNames();
70  virtual unsigned int GetNumberOfModeFileNames();
71  virtual const char *GetModeFileName(unsigned int idx);
73 
75 
78  vtkGetMacro(ReadInternalVolume, vtkTypeBool);
79  vtkSetMacro(ReadInternalVolume, vtkTypeBool);
80  vtkBooleanMacro(ReadInternalVolume, vtkTypeBool);
82 
84 
87  vtkGetMacro(ReadExternalSurface, vtkTypeBool);
88  vtkSetMacro(ReadExternalSurface, vtkTypeBool);
89  vtkBooleanMacro(ReadExternalSurface, vtkTypeBool);
91 
93 
97  vtkGetMacro(ReadMidpoints, vtkTypeBool);
98  vtkSetMacro(ReadMidpoints, vtkTypeBool);
99  vtkBooleanMacro(ReadMidpoints, vtkTypeBool);
101 
103 
107  virtual const char *GetVariableArrayName(int idx);
108  virtual int GetVariableArrayStatus(const char *name);
109  virtual void SetVariableArrayStatus(const char *name, int status);
111 
113 
116  virtual void ResetFrequencyScales();
117  virtual void SetFrequencyScale(int index, double scale);
119 
121 
124  virtual void ResetPhaseShifts();
125  virtual void SetPhaseShift(int index, double shift);
127 
129 
135 
139  static int CanReadFile(const char *filename);
140 
146 
152 
154 
163 
165 
169  class VTKIONETCDF_EXPORT EdgeEndpoints
170  {
171  public:
172  EdgeEndpoints() : MinEndPoint(-1), MaxEndPoint(-1) {}
173  EdgeEndpoints(vtkIdType endpointA, vtkIdType endpointB) {
174  if (endpointA < endpointB)
175  {
176  this->MinEndPoint = endpointA; this->MaxEndPoint = endpointB;
177  }
178  else
179  {
180  this->MinEndPoint = endpointB; this->MaxEndPoint = endpointA;
181  }
182  }
183  inline vtkIdType GetMinEndPoint() const { return this->MinEndPoint; }
184  inline vtkIdType GetMaxEndPoint() const { return this->MaxEndPoint; }
185  inline bool operator==(const EdgeEndpoints &other) const {
186  return ( (this->GetMinEndPoint() == other.GetMinEndPoint())
187  && (this->GetMaxEndPoint() == other.GetMaxEndPoint()) );
188  }
189  protected:
192  };
194 
196 
199  class VTKIONETCDF_EXPORT MidpointCoordinates
200  {
201  public:
203  MidpointCoordinates(const double coord[3], vtkIdType id) {
204  this->Coordinate[0] = coord[0];
205  this->Coordinate[1] = coord[1];
206  this->Coordinate[2] = coord[2];
207  this->ID = id;
208  }
209  double Coordinate[3];
211  };
213 
214  enum {
215  SURFACE_OUTPUT = 0,
216  VOLUME_OUTPUT = 1,
217  NUM_OUTPUTS = 2
218  };
219 
220 protected:
222  ~vtkSLACReader() override;
223 
224  class vtkInternal;
225  vtkInternal *Internal;
226 
227  // Friend so vtkInternal can access MidpointIdMap
228  // (so Sun CC compiler doesn't complain).
229  friend class vtkInternal;
230 
232 
236 
241 
246 
251 
253  vtkInformationVector **inputVector,
254  vtkInformationVector *outputVector) override;
255 
257  vtkInformationVector **inputVector,
258  vtkInformationVector *outputVector) override;
259 
263  static void SelectionModifiedCallback(vtkObject *caller, unsigned long eid,
264  void *clientdata, void *calldata);
265 
273  virtual vtkIdType GetNumTuplesInVariable(int ncFD, int varId,
274  int expectedNumComponents);
275 
280  virtual int CheckTetrahedraWinding(int meshFD);
281 
286  virtual int ReadConnectivity(int meshFD, vtkMultiBlockDataSet *surfaceOutput,
287  vtkMultiBlockDataSet *volumeOutput);
288 
290 
293  virtual int ReadTetrahedronInteriorArray(int meshFD,
294  vtkIdTypeArray *connectivity);
295  virtual int ReadTetrahedronExteriorArray(int meshFD,
296  vtkIdTypeArray *connectivity);
298 
302  virtual vtkSmartPointer<vtkDataArray> ReadPointDataArray(int ncFD, int varId);
303 
307  enum {
308  NumPerTetInt = 5,
309  NumPerTetExt = 9
310  };
311 
313 
316  class VTKIONETCDF_EXPORT MidpointCoordinateMap
317  {
318  public:
322 
323  void AddMidpoint(const EdgeEndpoints &edge,
324  const MidpointCoordinates &midpoint);
325  void RemoveMidpoint(const EdgeEndpoints &edge);
328 
334 
335  protected:
336  class vtkInternal;
337  vtkInternal *Internal;
338 
339  private:
340  // Too lazy to implement these.
342  void operator=(const MidpointCoordinateMap &);
343  };
344 
346 
349  class VTKIONETCDF_EXPORT MidpointIdMap
350  {
351  public:
355 
356  void AddMidpoint(const EdgeEndpoints &edge, vtkIdType midpoint);
357  void RemoveMidpoint(const EdgeEndpoints &edge);
360 
365 
373  bool GetNextMidpoint(EdgeEndpoints &edge, vtkIdType &midpoint);
374 
375  protected:
376  class vtkInternal;
377  vtkInternal *Internal;
378 
379  private:
380  // Too lazy to implement these.
381  MidpointIdMap(const MidpointIdMap &);
382  void operator=(const MidpointIdMap &);
383  };
384 
389  virtual int ReadCoordinates(int meshFD, vtkMultiBlockDataSet *output);
390 
396  virtual int ReadMidpointCoordinates(int meshFD, vtkMultiBlockDataSet *output,
397  MidpointCoordinateMap &map);
398 
404  virtual int ReadMidpointData(int meshFD, vtkMultiBlockDataSet *output,
405  MidpointIdMap &map);
406 
411  virtual int RestoreMeshCache(vtkMultiBlockDataSet *surfaceOutput,
412  vtkMultiBlockDataSet *volumeOutput,
413  vtkMultiBlockDataSet *compositeOutput);
414 
419  virtual int ReadFieldData(const int *modeFDArray,
420  int numModeFDs,
421  vtkMultiBlockDataSet *output);
422 
428  MidpointIdMap &map);
429 
436 
441  virtual int MeshUpToDate();
442 
443 private:
444  vtkSLACReader(const vtkSLACReader &) = delete;
445  void operator=(const vtkSLACReader &) = delete;
446 };
447 
448 #endif //vtkSLACReader_h
vtkSLACReader::MidpointCoordinateMap
Manages a map from edges to midpoint coordinates.
Definition: vtkSLACReader.h:317
vtkSLACReader::MidpointIdMap
Manages a map from edges to the point id of the midpoint.
Definition: vtkSLACReader.h:350
vtkSLACReader::ReadFieldData
virtual int ReadFieldData(const int *modeFDArray, int numModeFDs, vtkMultiBlockDataSet *output)
Read in the field data from the mode file.
vtkSLACReader::MidpointCoordinates::MidpointCoordinates
MidpointCoordinates()
Definition: vtkSLACReader.h:202
vtkSLACReader::EdgeEndpoints
Simple class used internally to define an edge based on the endpoints.
Definition: vtkSLACReader.h:170
vtkSLACReader::EdgeEndpoints::MinEndPoint
vtkIdType MinEndPoint
Definition: vtkSLACReader.h:190
vtkX3D::scale
@ scale
Definition: vtkX3D.h:229
vtkSLACReader::MidpointIdMap::RemoveMidpoint
void RemoveMidpoint(const EdgeEndpoints &edge)
vtkSLACReader::New
static vtkSLACReader * New()
vtkSLACReader::MidpointCoordinateMap::RemoveAllMidpoints
void RemoveAllMidpoints()
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkSLACReader::SelectionModifiedCallback
static void SelectionModifiedCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
Callback registered with the VariableArraySelection.
vtkSLACReader::ReadMidpointCoordinates
virtual int ReadMidpointCoordinates(int meshFD, vtkMultiBlockDataSet *output, MidpointCoordinateMap &map)
Reads in the midpoint coordinate data from the mesh file and returns a map from edges to midpoints.
vtkSLACReader::GetPhaseShifts
virtual vtkDoubleArray * GetPhaseShifts()
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:42
vtkSLACReader::MidpointCoordinateMap::FindMidpoint
MidpointCoordinates * FindMidpoint(const EdgeEndpoints &edge)
Finds the coordinates for the given edge or returns nullptr if it does not exist.
vtkSLACReader::FrequencyModes
bool FrequencyModes
True if mode files describe vibrating fields.
Definition: vtkSLACReader.h:250
vtkSLACReader::MeshUpToDate
virtual int MeshUpToDate()
Returns 1 if the mesh is up to date, 0 if the mesh needs to be read from disk.
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:36
vtkSLACReader::ReadInternalVolume
vtkTypeBool ReadInternalVolume
Definition: vtkSLACReader.h:233
vtkSLACReader::MeshFileName
char * MeshFileName
Definition: vtkSLACReader.h:231
vtkSLACReader::MidpointIdMap::RemoveAllMidpoints
void RemoveAllMidpoints()
vtkSLACReader::ResetPhaseShifts
virtual void ResetPhaseShifts()
Sets the phase offset for each mode.
vtkSLACReader::SetFrequencyScale
virtual void SetFrequencyScale(int index, double scale)
vtkSLACReader::RemoveAllModeFileNames
virtual void RemoveAllModeFileNames()
vtkSmartPointer< vtkDataArray >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkSLACReader::EdgeEndpoints::MaxEndPoint
vtkIdType MaxEndPoint
Definition: vtkSLACReader.h:191
vtkSLACReader
Definition: vtkSLACReader.h:53
vtkSLACReader::TimeStepModes
bool TimeStepModes
True if "mode" files are a sequence of time steps.
Definition: vtkSLACReader.h:245
vtkSLACReader::MidpointIdMap::FindMidpoint
vtkIdType * FindMidpoint(const EdgeEndpoints &edge)
Finds the id for the given edge or returns nullptr if it does not exist.
vtkSLACReader::RequestInformation
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
vtkMultiBlockDataSet
Composite dataset that organizes datasets into blocks.
Definition: vtkMultiBlockDataSet.h:52
vtkSLACReader::MidpointIdMap::InitTraversal
void InitTraversal()
Initialize iteration.
vtkSLACReader::GetVariableArrayStatus
virtual int GetVariableArrayStatus(const char *name)
vtkSLACReader::MidpointCoordinateMap::GetNumberOfMidpoints
vtkIdType GetNumberOfMidpoints() const
vtkSLACReader::MidpointCoordinateMap::MidpointCoordinateMap
MidpointCoordinateMap()
vtkSLACReader::GetNumberOfVariableArrays
virtual int GetNumberOfVariableArrays()
Variable array selection.
vtkDataArraySelection
Store on/off settings for data arrays for a vtkSource.
Definition: vtkDataArraySelection.h:38
vtkSLACReader::IS_EXTERNAL_SURFACE
static vtkInformationIntegerKey * IS_EXTERNAL_SURFACE()
This key is attached to the metadata information of all data sets in the output that are part of the ...
vtkSLACReader::EdgeEndpoints::operator==
bool operator==(const EdgeEndpoints &other) const
Definition: vtkSLACReader.h:185
vtkSLACReader::CheckTetrahedraWinding
virtual int CheckTetrahedraWinding(int meshFD)
Checks the winding of the tetrahedra in the mesh file.
vtkSLACReader::MidpointIdMap::AddMidpoint
void AddMidpoint(const EdgeEndpoints &edge, vtkIdType midpoint)
vtkSLACReader::RestoreMeshCache
virtual int RestoreMeshCache(vtkMultiBlockDataSet *surfaceOutput, vtkMultiBlockDataSet *volumeOutput, vtkMultiBlockDataSet *compositeOutput)
Instead of reading data from the mesh file, restore the data from the previous mesh file read.
vtkSLACReader::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSLACReader::MidpointCoordinates::ID
vtkIdType ID
Definition: vtkSLACReader.h:210
vtkSLACReader::SetVariableArrayStatus
virtual void SetVariableArrayStatus(const char *name, int status)
vtkSLACReader::MidpointIdMap::GetNumberOfMidpoints
vtkIdType GetNumberOfMidpoints() const
vtkSLACReader::ReadMidpointData
virtual int ReadMidpointData(int meshFD, vtkMultiBlockDataSet *output, MidpointIdMap &map)
Read in the midpoint data from the mesh file.
vtkInformationObjectBaseKey
Key for vtkObjectBase values.
Definition: vtkInformationObjectBaseKey.h:37
vtkSLACReader::ReadModeData
bool ReadModeData
True if reading from a proper mode file.
Definition: vtkSLACReader.h:240
vtkInformationIntegerKey
Key for integer values in vtkInformation.
Definition: vtkInformationIntegerKey.h:35
vtkSLACReader::ReadPointDataArray
virtual vtkSmartPointer< vtkDataArray > ReadPointDataArray(int ncFD, int varId)
Reads point data arrays.
vtkSLACReader::InterpolateMidpointData
virtual int InterpolateMidpointData(vtkMultiBlockDataSet *output, MidpointIdMap &map)
Takes the data read on the fields and interpolates data for the midpoints.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkSLACReader::MidpointCoordinateMap::AddMidpoint
void AddMidpoint(const EdgeEndpoints &edge, const MidpointCoordinates &midpoint)
vtkSLACReader::CanReadFile
static int CanReadFile(const char *filename)
Returns true if the given file can be read by this reader.
vtkSLACReader::EdgeEndpoints::EdgeEndpoints
EdgeEndpoints()
Definition: vtkSLACReader.h:172
vtkSLACReader::GetFrequencyScales
virtual vtkDoubleArray * GetFrequencyScales()
NOTE: This is not thread-safe.
vtkSLACReader::GetNumberOfModeFileNames
virtual unsigned int GetNumberOfModeFileNames()
vtkSmartPointer.h
vtkSLACReader::ReadMidpoints
vtkTypeBool ReadMidpoints
Definition: vtkSLACReader.h:235
vtkSLACReader::GetModeFileName
virtual const char * GetModeFileName(unsigned int idx)
vtkMultiBlockDataSetAlgorithm.h
vtkSLACReader::EdgeEndpoints::GetMinEndPoint
vtkIdType GetMinEndPoint() const
Definition: vtkSLACReader.h:183
vtkX3D::name
@ name
Definition: vtkX3D.h:219
vtkSLACReader::GetNumTuplesInVariable
virtual vtkIdType GetNumTuplesInVariable(int ncFD, int varId, int expectedNumComponents)
Convenience function that checks the dimensions of a 2D netCDF array that is supposed to be a set of ...
vtkSLACReader::AddModeFileName
virtual void AddModeFileName(const char *fname)
There may be one mode file (usually for actual modes) or multiple mode files (which usually actually ...
vtkSLACReader::MeshReadTime
vtkTimeStamp MeshReadTime
A time stamp for the last time the mesh file was read.
Definition: vtkSLACReader.h:435
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:87
vtkSLACReader::vtkSLACReader
vtkSLACReader()
vtkSLACReader::ReadTetrahedronInteriorArray
virtual int ReadTetrahedronInteriorArray(int meshFD, vtkIdTypeArray *connectivity)
Reads tetrahedron connectivity arrays.
vtkSLACReader::ReadTetrahedronExteriorArray
virtual int ReadTetrahedronExteriorArray(int meshFD, vtkIdTypeArray *connectivity)
vtkSLACReader::IS_INTERNAL_VOLUME
static vtkInformationIntegerKey * IS_INTERNAL_VOLUME()
This key is attached to the metadata information of all data sets in the output that are part of the ...
vtkSLACReader::MidpointIdMap::GetNextMidpoint
bool GetNextMidpoint(EdgeEndpoints &edge, vtkIdType &midpoint)
Get the next midpoint in the iteration.
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:42
vtkSLACReader::POINTS
static vtkInformationObjectBaseKey * POINTS()
All the data sets stored in the multiblock output share the same point data.
vtkSLACReader::MidpointIdMap::Internal
vtkInternal * Internal
Definition: vtkSLACReader.h:376
vtkSLACReader::EdgeEndpoints::GetMaxEndPoint
vtkIdType GetMaxEndPoint() const
Definition: vtkSLACReader.h:184
vtkSLACReader::GetVariableArrayName
virtual const char * GetVariableArrayName(int idx)
vtkSLACReader::MidpointCoordinates
Simple class used internally for holding midpoint information.
Definition: vtkSLACReader.h:200
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:42
vtkSLACReader::SetPhaseShift
virtual void SetPhaseShift(int index, double shift)
vtkSLACReader::POINT_DATA
static vtkInformationObjectBaseKey * POINT_DATA()
vtkSLACReader::ResetFrequencyScales
virtual void ResetFrequencyScales()
Sets the scale factor for each mode.
vtkSLACReader::MidpointCoordinates::MidpointCoordinates
MidpointCoordinates(const double coord[3], vtkIdType id)
Definition: vtkSLACReader.h:203
vtkSLACReader::EdgeEndpoints::EdgeEndpoints
EdgeEndpoints(vtkIdType endpointA, vtkIdType endpointB)
Definition: vtkSLACReader.h:173
vtkSLACReader::Internal
vtkInternal * Internal
Definition: vtkSLACReader.h:224
vtkSLACReader::~vtkSLACReader
~vtkSLACReader() override
vtkSLACReader::MidpointCoordinateMap::RemoveMidpoint
void RemoveMidpoint(const EdgeEndpoints &edge)
vtkX3D::index
@ index
Definition: vtkX3D.h:246
vtkSLACReader::MidpointCoordinateMap::Internal
vtkInternal * Internal
Definition: vtkSLACReader.h:336
vtkSLACReader::MidpointIdMap::MidpointIdMap
MidpointIdMap()
vtkSLACReader::ReadExternalSurface
vtkTypeBool ReadExternalSurface
Definition: vtkSLACReader.h:234
vtkSLACReader::ReadConnectivity
virtual int ReadConnectivity(int meshFD, vtkMultiBlockDataSet *surfaceOutput, vtkMultiBlockDataSet *volumeOutput)
Read the connectivity information from the mesh file.
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkSLACReader::MidpointIdMap::~MidpointIdMap
~MidpointIdMap()
vtkSLACReader::RequestData
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
vtkX3D::Coordinate
@ Coordinate
Definition: vtkX3D.h:44
vtkSLACReader::ReadCoordinates
virtual int ReadCoordinates(int meshFD, vtkMultiBlockDataSet *output)
Read in the point coordinate data from the mesh file.
vtkSLACReader::MidpointCoordinateMap::~MidpointCoordinateMap
~MidpointCoordinateMap()
vtkMultiBlockDataSetAlgorithm
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
Definition: vtkMultiBlockDataSetAlgorithm.h:36