vtk-dicom  0.8.14
vtkDICOMFileSorter.h
1 /*=========================================================================
2 
3  Program: DICOM for VTK
4 
5  Copyright (c) 2012-2022 David Gobbi
6  All rights reserved.
7  See Copyright.txt or http://dgobbi.github.io/bsd3.txt for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 #ifndef vtkDICOMFileSorter_h
15 #define vtkDICOMFileSorter_h
16 
17 #include "vtkObject.h"
18 #include "vtkDICOMModule.h" // For export macro
19 #include "vtkDICOMConfig.h" // For configuration details
20 
21 // Declare VTK classes within VTK's optional namespace
22 #if defined(VTK_ABI_NAMESPACE_BEGIN)
23 VTK_ABI_NAMESPACE_BEGIN
24 #endif
25 
26 class vtkStringArray;
27 class vtkIntArray;
28 
29 #if defined(VTK_ABI_NAMESPACE_BEGIN)
30 VTK_ABI_NAMESPACE_END
31 #endif
32 
33 class vtkDICOMMetaData;
34 
36 
43 class VTKDICOM_EXPORT vtkDICOMFileSorter : public vtkObject
44 {
45 public:
47  void PrintSelf(ostream& os, vtkIndent indent) VTK_DICOM_OVERRIDE;
48  static vtkDICOMFileSorter *New();
49 
51 
57  void SetInputFileName(const char *name);
58  const char *GetInputFileName() { return this->InputFileName; }
60 
62 
68  void SetInputFileNames(vtkStringArray *input);
69  vtkStringArray *GetInputFileNames() { return this->InputFileNames; }
71 
73 
77  virtual void Update();
79 
81  int GetNumberOfSeries();
83 
86 
88  int GetFirstSeriesForStudy(int study);
89 
91  int GetLastSeriesForStudy(int study);
93 
95  vtkStringArray *GetOutputFileNames() { return this->OutputFileNames; }
97 
99  vtkStringArray *GetFileNamesForSeries(int i);
101 
103  unsigned long GetErrorCode() { return this->ErrorCode; }
105 
107  const char *GetInternalFileName() { return this->InternalFileName; }
109 
111 
116  vtkSetMacro(RequirePixelData, int);
117  vtkBooleanMacro(RequirePixelData, int);
118  int GetRequirePixelData() { return this->RequirePixelData; }
120 
121 protected:
123  ~vtkDICOMFileSorter() VTK_DICOM_OVERRIDE;
124 
125  const char *InputFileName;
126  vtkStringArray *InputFileNames;
127  vtkStringArray *OutputFileNames;
128  int RequirePixelData;
129 
130  vtkTimeStamp UpdateTime;
131  unsigned long ErrorCode;
132  char *InternalFileName;
133 
135  virtual void Execute();
136 
138  virtual void SortFiles(vtkStringArray *input);
139 
141 
147  void AddSeriesFileNames(int study, vtkStringArray *files);
148 
150  // Convert parser errors into sorter errors.
151  void RelayError(vtkObject *o, unsigned long e, void *data);
152 
154  // Set the name of the file currently being operated on.
155  void SetInternalFileName(const char *fname);
156 
158  void SetErrorCode(unsigned long e) { this->ErrorCode = e; }
159 
160 private:
161 #ifdef VTK_DICOM_DELETE
162  vtkDICOMFileSorter(const vtkDICOMFileSorter&) VTK_DICOM_DELETE;
163  void operator=(const vtkDICOMFileSorter&) VTK_DICOM_DELETE;
164 #else
165  vtkDICOMFileSorter(const vtkDICOMFileSorter&) = delete;
166  void operator=(const vtkDICOMFileSorter&) = delete;
167 #endif
168 
169  class StringArrayVector;
170  struct FileInfo;
171  class FileInfoVectorList;
172 
173  StringArrayVector *Series;
174  vtkIntArray *Studies;
175 
177  static bool CompareInstance(const FileInfo &fi1, const FileInfo &fi2);
178 };
179 
180 #endif
Sort DICOM files and group them by study and series.
Definition: vtkDICOMFileSorter.h:44
int GetLastSeriesForStudy(int study)
Get the last series (inclusive) for a particular study.
void PrintSelf(ostream &os, vtkIndent indent) VTK_DICOM_OVERRIDE
vtkStringArray * GetFileNamesForSeries(int i)
Get the file names for a specific series.
int GetFirstSeriesForStudy(int study)
Get the first series for a particular study.
void SetInputFileNames(vtkStringArray *input)
Set a list of file names to group and sort.
int GetNumberOfStudies()
Get the number of studies that were found.
void SetInputFileName(const char *name)
Set one file from the desired series.
const char * GetInternalFileName()
Get the filename associated with the error code.
Definition: vtkDICOMFileSorter.h:107
virtual void Update()
Update the information about the files.
A container class for DICOM metadata.
Definition: vtkDICOMMetaData.h:44
abstract base class for most VTK objects
Definition: vtkObject.h:54
static vtkObject * New()