vtkAMRDataSetCache.h 3.48 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*=========================================================================

 Program:   Visualization Toolkit
 Module:    vtkAMRDataSetCache.h

 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
 All rights reserved.
 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

 This software is distributed WITHOUT ANY WARRANTY; without even
 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.  See the above copyright notice for more information.

 =========================================================================*/
15 16 17 18 19 20 21 22 23
/**
 * @class   vtkAMRDataSetCache
 *
 *
 *  A concrete implementation of vtkObject that provides functionality for
 *  caching AMR blocks. The primary intent of this class is to be used by the
 *  AMR reader infrastructure for caching blocks/data in memory to minimize
 *  out-of-core operations.
*/
24

25 26
#ifndef vtkAMRDataSetCache_h
#define vtkAMRDataSetCache_h
27

28
#include "vtkIOAMRModule.h" // For export macro
29
#include "vtkObject.h"
30
#include <map> // For STL map used as the data-structure for the cache.
31 32 33 34

class vtkUniformGrid;
class vtkDataArray;

35
class VTKIOAMR_EXPORT vtkAMRDataSetCache : public vtkObject
36
{
37 38 39
public:
  static vtkAMRDataSetCache* New();
  vtkTypeMacro( vtkAMRDataSetCache, vtkObject );
40
  void PrintSelf(ostream &os, vtkIndent indent ) override;
41

42 43 44
  /**
   * Inserts an AMR block to the cache
   */
45 46
  void InsertAMRBlock(int compositeIdx,vtkUniformGrid *amrGrid);

47 48 49 50
  /**
   * Inserts a point data array to an already cached block
   * NOTE: this->HasAMRBlock( compositeIdx ) == true
   */
51 52 53
  void InsertAMRBlockPointData(
      int compositeIdx, vtkDataArray *dataArray );

54 55 56 57
  /**
   * Inserts a cell data array to an already cached block
   * NOTE: this->HasAMRBlock( compositeIdx ) == true
   */
58 59 60
  void InsertAMRBlockCellData(
      int compositeIdx, vtkDataArray *dataArray );

61 62 63 64 65
  /**
   * Given the name of the cell array and AMR block composite index, this
   * method returns a pointer to the cell data array.
   * NOTE: Null is returned if the cell array and/or block is not cached.
   */
66 67 68
  vtkDataArray* GetAMRBlockCellData(
      int compositeIdx, const char *dataName );

69 70 71
  /**
   * Given the name of the point array and AMR block composite index, this
   * method returns a pointer to the point data array.
luz.paz's avatar
luz.paz committed
72
   * NOTE: Null is returned if the point array and /or block is not cached.
73
   */
74 75 76
  vtkDataArray* GetAMRBlockPointData(
      int compositeIdx, const char *dataName );

77 78 79 80
  /**
   * Given the composite index, this method returns the AMR block.
   * NOTE: Null is returned if the AMR block does not exist in the cache.
   */
81 82
  vtkUniformGrid* GetAMRBlock(int compositeIdx );

83 84 85 86
  /**
   * Checks if the cell data array, associated with the provided name, has
   * been cached for the AMR block with the given composite index.
   */
87 88
  bool HasAMRBlockCellData(int compositeIdx, const char *name);

89 90 91 92
  /**
   * Checks if the point data array, associated with the provided name, has
   * been cached for the AMR block with the given composite index.
   */
93 94
  bool HasAMRBlockPointData(int compositeIdx, const char *name);

95 96 97
  /**
   * Checks if the AMR block associated with the given composite is cached.
   */
98 99 100 101
  bool HasAMRBlock( const int compositeIdx );

protected:
  vtkAMRDataSetCache();
102
  ~vtkAMRDataSetCache() override;
103

104 105
  typedef std::map< int, vtkUniformGrid* > AMRCacheType;
  AMRCacheType Cache;
106

107
private:
108 109
  vtkAMRDataSetCache( const vtkAMRDataSetCache& ) = delete;
  void operator=( const vtkAMRDataSetCache& ) = delete;
110 111
};

112
#endif /* vtkAMRDataSetCache_h */