vtkACosmoReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkACosmoReader.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*=========================================================================
16 
17  Program: VTK/ParaView Los Alamos National Laboratory Modules (PVLANL)
18  Module: vtkACosmoReader.h
19 
20 Copyright (c) 2007, 2009 Los Alamos National Security, LLC
21 
22 All rights reserved.
23 
24 Copyright 2007, 2009. Los Alamos National Security, LLC.
25 This software was produced under U.S. Government contract DE-AC52-06NA25396
26 for Los Alamos National Laboratory (LANL), which is operated by
27 Los Alamos National Security, LLC for the U.S. Department of Energy.
28 The U.S. Government has rights to use, reproduce, and distribute this software.
29 NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY,
30 EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE.
31 If software is modified to produce derivative works, such modified software
32 should be clearly marked, so as not to confuse it with the version available
33 from LANL.
34 
35 Additionally, redistribution and use in source and binary forms, with or
36 without modification, are permitted provided that the following conditions
37 are met:
38 - Redistributions of source code must retain the above copyright notice,
39  this list of conditions and the following disclaimer.
40 - Redistributions in binary form must reproduce the above copyright notice,
41  this list of conditions and the following disclaimer in the documentation
42  and/or other materials provided with the distribution.
43 - Neither the name of Los Alamos National Security, LLC, Los Alamos National
44  Laboratory, LANL, the U.S. Government, nor the names of its contributors
45  may be used to endorse or promote products derived from this software
46  without specific prior written permission.
47 
48 THIS SOFTWARE IS PROVIDED BY LOS ALAMOS NATIONAL SECURITY, LLC AND CONTRIBUTORS
49 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
50 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 ARE DISCLAIMED. IN NO EVENT SHALL LOS ALAMOS NATIONAL SECURITY, LLC OR
52 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
53 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
54 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
55 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
56 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
57 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
58 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 
60 =========================================================================*/
67 #ifndef vtkACosmoReader_h
68 #define vtkACosmoReader_h
69 
70 #include "vtkMultiBlockDataSetAlgorithm.h" // Base class
72 #include "vtkPVVTKExtensionsCosmoToolsModule.h" // For export macro
73 
74 // C/C++ includes
75 #include <set> // For STL set
76 #include <string> // For C++ string
77 #include <vector> // For STL vector
78 
79 // Forward declarations
80 
81 class vtkInformation;
85 
86 class VTKPVVTKEXTENSIONSCOSMOTOOLS_EXPORT vtkACosmoReader : public vtkMultiBlockDataSetAlgorithm
87 {
88 public:
89  static vtkACosmoReader* New();
91  virtual void PrintSelf(ostream& os, vtkIndent indent);
92 
94 
98  void AddFileName(const char*);
99  void RemoveAllFileNames();
101 
102  // Set/Get the box size for the simulation (range along x,y,z)
103  // Negative x,y,z values are subtracted from this for wraparound
104  vtkSetMacro(BoxSize, double);
105  vtkGetMacro(BoxSize, double);
106 
108 
111  vtkSetMacro(ByteSwap, int);
112  vtkGetMacro(ByteSwap, int);
114 
116 
120  vtkSetMacro(TagSize, int);
121  vtkGetMacro(TagSize, int);
123 
125 
128  vtkSetMacro(Level, int);
129  vtkGetMacro(Level, int);
131 
132 protected:
133  vtkACosmoReader();
134  ~vtkACosmoReader();
135 
136  // Standard pipeline methods
139 
143  void LoadMetaData();
144 
149  void ExtractInfoFromFileNames();
150 
154  void ReadMetaDataFile(const int levelIdx, std::string file);
155 
160  int GetBlockIndex(const int level, const int idx);
161 
166  void SetupBlockRequest(vtkInformation* outInfo);
167 
171  void ReadBlock(const int blockIdx, vtkMultiBlockDataSet* mbds);
172 
177  int GetBlockStartOffSetInFile(const int level, const int index);
178 
183  void ReadBlockFromFile(
184  std::string file, const int start, const int end, vtkUnstructuredGrid* particles);
185 
186  std::string BaseFileName; // Base path and file name
187  char* FileName; // Name of binary particle file
188  bool MetadataIsLoaded; // Indicates if the meta data has been loaded
189 
190  double BoxSize; // Maximum of x,y,z locations from simulation
191  int ByteSwap; // indicates whether to swap data or not
192  int TagSize; // Size of the tag, 0 = 32-bit or 1 = 64-bit
193  int Level; // level of resolution to load (staring from 1)
194  int TotalNumberOfLevels; // The total number of levels
195 
197 
198  struct block_t; // defined in the implementation
199 
200  std::vector<int> NBlocks; // Number of blocks at level "i"
201  std::vector<block_t> ParticleBlocks; // stores block info for each block
202  std::vector<int> RequestedBlocks; // list of blocks to load
203  std::set<std::string> FileNames;
204 
205 private:
206  vtkACosmoReader(const vtkACosmoReader&) = delete;
207  void operator=(const vtkACosmoReader&) = delete;
208 };
209 
210 #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 *)