vtkPNrrdReader.h 4.39 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// -*- c++ -*-
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkPNrrdReader.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.

=========================================================================*/
/*----------------------------------------------------------------------------
 Copyright (c) Sandia Corporation
 See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
----------------------------------------------------------------------------*/

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
/**
 * @class   vtkPNrrdReader
 * @brief   Read nrrd files efficiently from parallel file systems (and reasonably well elsewhere).
 *
 *
 *
 * vtkPNrrdReader is a subclass of vtkNrrdReader that will read Nrrd format
 * header information of the image before reading the data.  This means that the
 * reader will automatically set information like file dimensions.
 *
 *
 * @bug
 * There are several limitations on what type of nrrd files we can read.  This
 * reader only supports nrrd files in raw format.  Other encodings like ascii
 * and hex will result in errors.  When reading in detached headers, this only
 * supports reading one file that is detached.
 *
*/
39

40 41
#ifndef vtkPNrrdReader_h
#define vtkPNrrdReader_h
42

43 44
#include "vtkIOMPIImageModule.h" // For export macro
#include "vtkNrrdReader.h"
45 46

class vtkCharArray;
47 48
class vtkMultiProcessController;
class vtkMPIOpaqueFileHandle;
49

50
class VTKIOMPIIMAGE_EXPORT vtkPNrrdReader : public vtkNrrdReader
51 52
{
public:
53
  vtkTypeMacro(vtkPNrrdReader, vtkNrrdReader);
54
  static vtkPNrrdReader *New();
55
  virtual void PrintSelf(ostream &os, vtkIndent indent) override;
56

57 58 59 60 61
  //@{
  /**
   * Get/set the multi process controller to use for coordinated reads.  By
   * default, set to the global controller.
   */
62 63
  vtkGetObjectMacro(Controller, vtkMultiProcessController);
  virtual void SetController(vtkMultiProcessController *);
64
  //@}
65 66 67 68 69

protected:
  vtkPNrrdReader();
  ~vtkPNrrdReader();

70 71
  virtual int ReadHeader() override;
  virtual int ReadHeader(vtkCharArray *headerBuffer) override;
72

73 74 75
  /**
   * Returns the size, in bytes of the scalar data type (GetDataScalarType).
   */
76 77
  int GetDataScalarTypeSize();

78 79 80 81 82
  /**
   * Break up the controller based on the files each process reads.  Each group
   * comprises the processes that read the same files in the same order.
   * this->GroupedController is set to the group for the current process.
   */
83 84
  virtual void PartitionController(const int extent[6]);

85 86 87 88
  /**
   * Get the header size of the given open file.  This should be used in liu of
   * the GetHeaderSize methods of the superclass.
   */
89 90
  virtual unsigned long GetHeaderSize(vtkMPIOpaqueFileHandle &file);

91 92 93 94 95 96
  /**
   * Set up a "view" on the open file that will allow you to read the 2D or 3D
   * subarray from the file in one read.  Once you call this method, the file
   * will look as if it contains only the data the local process needs to read
   * in.
   */
97 98
  virtual void SetupFileView(vtkMPIOpaqueFileHandle &file, const int extent[6]);

99 100 101 102 103 104
  /**
   * Given a slice of the data, open the appropriate file, read the data into
   * given buffer, and close the file.  For three dimensional data, always
   * use "slice" 0.  Make sure the GroupedController is properly created before
   * calling this using the PartitionController method.
   */
105 106
  virtual void ReadSlice(int slice, const int extent[6], void *buffer);

107 108 109 110
  /**
   * Transform the data from the order read from a file to the order to place
   * in the output data (as defined by the transform).
   */
111 112
  virtual void TransformData(vtkImageData *data);

113 114 115 116 117
  //@{
  /**
   * A group of processes that are reading the same file (as determined by
   * PartitionController.
   */
118 119
  void SetGroupedController(vtkMultiProcessController *);
  vtkMultiProcessController *GroupedController;
120
  //@}
121 122

  virtual void ExecuteDataWithInformation(vtkDataObject *data,
123
                                          vtkInformation *outInfo) override;
124 125

  vtkMultiProcessController *Controller;
126 127

private:
128 129
  vtkPNrrdReader(const vtkPNrrdReader &) = delete;
  void operator=(const vtkPNrrdReader &) = delete;
130 131
};

132
#endif //vtkPNrrdReader_h