vtkACosmoReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
3 // SPDX-FileCopyrightText: Copyright (c) 2007, 2009 Los Alamos National Security, LLC
4 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-LANL-USGov
11 #ifndef vtkACosmoReader_h
12 #define vtkACosmoReader_h
13 
14 #include "vtkMultiBlockDataSetAlgorithm.h" // Base class
16 #include "vtkPVVTKExtensionsCosmoToolsModule.h" // For export macro
17 
18 // C/C++ includes
19 #include <set> // For STL set
20 #include <string> // For C++ string
21 #include <vector> // For STL vector
22 
23 // Forward declarations
24 
25 class vtkInformation;
29 
30 class VTKPVVTKEXTENSIONSCOSMOTOOLS_EXPORT vtkACosmoReader : public vtkMultiBlockDataSetAlgorithm
31 {
32 public:
33  static vtkACosmoReader* New();
35  virtual void PrintSelf(ostream& os, vtkIndent indent);
36 
38 
42  void AddFileName(const char*);
43  void RemoveAllFileNames();
45 
46  // Set/Get the box size for the simulation (range along x,y,z)
47  // Negative x,y,z values are subtracted from this for wraparound
48  vtkSetMacro(BoxSize, double);
49  vtkGetMacro(BoxSize, double);
50 
52 
55  vtkSetMacro(ByteSwap, int);
56  vtkGetMacro(ByteSwap, int);
58 
60 
64  vtkSetMacro(TagSize, int);
65  vtkGetMacro(TagSize, int);
67 
69 
72  vtkSetMacro(Level, int);
73  vtkGetMacro(Level, int);
75 
76 protected:
78  ~vtkACosmoReader();
79 
80  // Standard pipeline methods
83 
87  void LoadMetaData();
88 
93  void ExtractInfoFromFileNames();
94 
98  void ReadMetaDataFile(const int levelIdx, std::string file);
99 
104  int GetBlockIndex(const int level, const int idx);
105 
110  void SetupBlockRequest(vtkInformation* outInfo);
111 
115  void ReadBlock(const int blockIdx, vtkMultiBlockDataSet* mbds);
116 
121  int GetBlockStartOffSetInFile(const int level, const int index);
122 
127  void ReadBlockFromFile(
128  std::string file, const int start, const int end, vtkUnstructuredGrid* particles);
129 
130  std::string BaseFileName; // Base path and file name
131  char* FileName; // Name of binary particle file
132  bool MetadataIsLoaded; // Indicates if the meta data has been loaded
133 
134  double BoxSize; // Maximum of x,y,z locations from simulation
135  int ByteSwap; // indicates whether to swap data or not
136  int TagSize; // Size of the tag, 0 = 32-bit or 1 = 64-bit
137  int Level; // level of resolution to load (staring from 1)
138  int TotalNumberOfLevels; // The total number of levels
139 
141 
142  struct block_t; // defined in the implementation
143 
144  std::vector<int> NBlocks; // Number of blocks at level "i"
145  std::vector<block_t> ParticleBlocks; // stores block info for each block
146  std::vector<int> RequestedBlocks; // list of blocks to load
147  std::set<std::string> FileNames;
148 
149 private:
150  vtkACosmoReader(const vtkACosmoReader&) = delete;
151  void operator=(const vtkACosmoReader&) = delete;
152 };
153 
154 #endif
std::vector< block_t > ParticleBlocks
std::set< std::string > FileNames
Adaptively read a binary cosmology data file.
vtkMultiBlockDataSet * MetaData
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
static vtkMultiBlockDataSetAlgorithm * New()
std::vector< int > RequestedBlocks
std::string BaseFileName
std::vector< int > NBlocks
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
void operator=(const vtkObjectBase &)
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)