forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvtkSortFileNames.h
147 lines (118 loc) · 4.8 KB
/
vtkSortFileNames.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*=========================================================================
Program: Visualization Toolkit
Module: vtkSortFileNames.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.
=========================================================================*/
// .NAME vtkSortFileNames - Group and sort a set of filenames
// .SECTION Description
// vtkSortFileNames will take a list of filenames (e.g. from
// a file load dialog) and sort them into one or more series. If
// the input list of filenames contains any directories, these can
// be removed before sorting using the SkipDirectories flag. This
// class should be used where information about the series groupings
// can be determined by the filenames, but it might not be successful
// in cases where the information about the series groupings is
// stored in the files themselves (e.g DICOM).
// .SECTION See Also
// vtkImageReader2
#ifndef __vtkSortFileNames_h
#define __vtkSortFileNames_h
#include "vtkObject.h"
class vtkStringArray;
//BTX
// this is a helper class defined in the .cxx file
class vtkStringArrayVector;
//ETX
class VTK_IO_EXPORT vtkSortFileNames : public vtkObject
{
public:
vtkTypeMacro(vtkSortFileNames,vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
static vtkSortFileNames *New();
// Description:
// Sort the file names into groups, according to similarity in
// filename name and path. Files in different directories,
// or with different extensions, or which do not fit into the same
// numbered series will be placed into different groups. This is
// off by default.
vtkSetMacro(Grouping, int);
vtkGetMacro(Grouping, int);
vtkBooleanMacro(Grouping, int);
// Description:
// Sort the files numerically, rather than lexicographically.
// For filenames that contain numbers, this means the order will be
// ["file8.dat", "file9.dat", "file10.dat"]
// instead of the usual alphabetic sorting order
// ["file10.dat" "file8.dat", "file9.dat"].
// NumericSort is off by default.
vtkSetMacro(NumericSort, int);
vtkGetMacro(NumericSort, int);
vtkBooleanMacro(NumericSort, int);
// Description:
// Ignore case when sorting. This flag is honored by both
// the sorting and the grouping. This is off by default.
vtkSetMacro(IgnoreCase, int);
vtkGetMacro(IgnoreCase, int);
vtkBooleanMacro(IgnoreCase, int);
// Description:
// Skip directories. If this flag is set, any input item that
// is a directory rather than a file will not be included in
// the output. This is off by default.
vtkSetMacro(SkipDirectories, int);
vtkGetMacro(SkipDirectories, int);
vtkBooleanMacro(SkipDirectories, int);
// Description:
// Set a list of file names to group and sort.
void SetInputFileNames(vtkStringArray *input);
vtkGetObjectMacro(InputFileNames, vtkStringArray);
// Description:
// Get the full list of sorted filenames.
virtual vtkStringArray *GetFileNames();
// Description:
// Get the number of groups that the names were split into, if
// grouping is on. The filenames are automatically split into
// groups, where the filenames in each group will be identical
// except for their series numbers. If grouping is not on, this
// method will return zero.
virtual int GetNumberOfGroups();
// Description:
// Get the Nth group of file names. This method should only
// be used if grouping is on. If grouping is off, it will always
// return null.
virtual vtkStringArray *GetNthGroup(int i);
// Description:
// Update the output filenames from the input filenames.
// This method is called automatically by GetFileNames()
// and GetNumberOfGroups() if the input names have changed.
virtual void Update();
protected:
vtkSortFileNames();
~vtkSortFileNames();
int NumericSort;
int IgnoreCase;
int Grouping;
int SkipDirectories;
vtkTimeStamp UpdateTime;
vtkStringArray *InputFileNames;
vtkStringArray *FileNames;
vtkStringArrayVector *Groups;
// Description:
// Fill the output.
virtual void Execute();
// Description:
// Sort the input string array, and append the results to the output.
virtual void SortFileNames(vtkStringArray *input, vtkStringArray *output);
// Description:
// Separate a string array into groups and append them to the output.
virtual void GroupFileNames(vtkStringArray *input,
vtkStringArrayVector *output);
private:
vtkSortFileNames(const vtkSortFileNames&); // Not implemented.
void operator=(const vtkSortFileNames&); // Not implemented.
};
#endif