SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
svkImageReader2.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2009-2014 The Regents of the University of California.
3  * All Rights Reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * • Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * • Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * • None of the names of any campus of the University of California, the name
13  * "The Regents of the University of California," or the names of any of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
26  * OF SUCH DAMAGE.
27  */
28 
29 
30 
31 /*
32  * $URL$
33  * $Rev$
34  * $Author$
35  * $Date$
36  *
37  * Authors:
38  * Jason C. Crane, Ph.D.
39  * Beck Olson
40  */
41 
42 
43 #ifndef SVK_IMAGE_READER_2_H
44 #define SVK_IMAGE_READER_2_H
45 
46 
47 #include <vtkImageReader2.h>
48 #include <vtkImageData.h>
49 
50 #include <svkImageData.h>
51 #include <svkUtils.h>
52 
53 
54 namespace svk {
55 
56 
60 class svkImageReader2 : public vtkImageReader2
61 {
62 
63  public:
64 
65  vtkTypeMacro( svkImageReader2, vtkImageReader2);
66 
67  typedef enum {
68  UNDEFINED = -1,
88  DDF,
89  IDF,
91  } ReaderType;
92 
93 
94  // Methods:
96  svkImageData* GetOutput(int);
97  svkDcmHeader* GetDcmHeader( const char* fileName );
98  static string StripWhite(string in);
99  static string RemoveDelimFromDate(string* slashDate, char delimChar = '/');
100  static string GetFileRoot(const char* fname);
101  static string GetFileExtension(const char* fname);
102  static string GetFilePath(const char* fname);
103  static string GetFileNameWithoutPath(const char* fname);
104  void OnlyReadOneInputFile();
105  void OnlyGlobFiles();
106  void GlobFileNames();
107  static long GetFileSize(ifstream* fs);
108  void OnlyReadHeader(bool onlyReadHeader);
110 
111 
112  protected:
113 
114  svkImageReader2();
116 
117  // Methods:
118  virtual int FillOutputPortInformation(int port, vtkInformation* info);
120  void SetupOutputInformation();
121  void SetupOutputExtent();
122  void SetupOutputScalarData();
123 
124  virtual void ReadLine(ifstream* hdr, istringstream* iss);
125  void ReadLineIgnore(
126  ifstream* hdr,
127  istringstream* iss,
128  char delim
129  );
130  string ReadLineSubstr(
131  ifstream* hdr,
132  istringstream* iss,
133  int start,
134  int stop
135  );
136  string ReadLineValue(
137  ifstream* hdr,
138  istringstream* iss,
139  char delim
140  );
141  int ReadLineKeyValue(
142  ifstream* hdr,
143  istringstream* iss,
144  char delim,
145  string* key,
146  string* value
147  );
148 
149 
150  virtual void SetProvenance();
151 
152 
153  // Members:
154  vtkDataArray* dataArray;
158  virtual string GetFileSeriesDescription( string fileName );
159  void SetReadLength(int length);
160 
161 
162  private:
163 
164  virtual void InitDcmHeader() = 0;
165  int readLength;
166 
167 
168 };
169 
170 
171 } //svk
172 
173 
174 #endif //SVK_IMAGE_READER_2_H
175 
virtual svkImageReader2::ReaderType GetReaderType()=0
Definition: svkImageReader2.h:72
Definition: svkImageReader2.h:86
Definition: svkImageReader2.h:77
Definition: svkImageReader2.h:70
void SetupOutputInformation()
Definition: svkImageReader2.cc:265
void SetupOutputScalarData()
Definition: svkImageReader2.cc:355
Definition: svkDcmHeader.h:66
svkImageData * GetOutput()
Definition: svkImageReader2.cc:416
vtkTypeMacro(svkImageReader2, vtkImageReader2)
Definition: svkImageReader2.h:75
Definition: svkImageReader2.h:60
Definition: svkImageReader2.h:73
Definition: svkImageReader2.h:71
static long GetFileSize(ifstream *fs)
Definition: svkImageReader2.cc:218
static string RemoveDelimFromDate(string *slashDate, char delimChar= '/')
Definition: svkImageReader2.cc:439
Definition: svkImageReader2.h:76
~svkImageReader2()
Definition: svkImageReader2.cc:88
Definition: svkImageReader2.h:78
ReaderType
Definition: svkImageReader2.h:67
Definition: svkImageReader2.h:83
virtual svkDcmHeader::DcmPixelDataFormat GetFileType()=0
static string GetFilePath(const char *fname)
Definition: svkImageReader2.cc:182
static string GetFileExtension(const char *fname)
Definition: svkImageReader2.cc:158
bool onlyReadHeader
Definition: svkImageReader2.h:157
bool readOneInputFile
Definition: svkImageReader2.h:155
DcmPixelDataFormat
Definition: svkDcmHeader.h:92
Definition: svkImageReader2.h:68
Definition: svkImageReader2.h:88
void OnlyReadOneInputFile()
Definition: svkImageReader2.cc:110
Definition: svkImageReader2.h:84
Definition: svkImageReader2.h:85
int ReadLineKeyValue(ifstream *hdr, istringstream *iss, char delim, string *key, string *value)
Definition: svkImageReader2.cc:530
Definition: svkImageReader2.h:79
Definition: svkImageReader2.h:80
Definition: svkImageReader2.h:87
static string StripWhite(string in)
Definition: svkImageReader2.cc:234
void ReadLineIgnore(ifstream *hdr, istringstream *iss, char delim)
Definition: svkImageReader2.cc:497
Definition: svkImageReader2.h:69
string ReadLineSubstr(ifstream *hdr, istringstream *iss, int start, int stop)
Definition: svkImageReader2.cc:507
Definition: svkImageReader2.h:74
Definition: svkImageReader2.h:89
virtual void SetProvenance()
Definition: svkImageReader2.cc:618
Definition: svkImageReader2.h:81
void SetReadLength(int length)
Definition: svkImageReader2.cc:475
static string GetFileNameWithoutPath(const char *fname)
Definition: svkImageReader2.cc:200
vtkDataArray * dataArray
Definition: svkImageReader2.h:154
void OnlyGlobFiles()
Definition: svkImageReader2.cc:119
string ReadLineValue(ifstream *hdr, istringstream *iss, char delim)
Definition: svkImageReader2.cc:570
Definition: svkImageReader2.h:90
void GlobFileNames()
Definition: svkImageReader2.cc:641
bool onlyGlobFiles
Definition: svkImageReader2.h:156
void OnlyReadHeader(bool onlyReadHeader)
Definition: svkImageReader2.cc:628
svkImageReader2()
Definition: svkImageReader2.cc:64
virtual void ReadLine(ifstream *hdr, istringstream *iss)
Definition: svkImageReader2.cc:483
Definition: svkImageReader2.h:82
svkDcmHeader * GetDcmHeader(const char *fileName)
Definition: svkImageReader2.cc:608
Definition: svkImageData.h:107
void SetupOutputExtent()
Definition: svkImageReader2.cc:323
virtual int FillOutputPortInformation(int port, vtkInformation *info)
Definition: svkImageReader2.cc:406
virtual string GetFileSeriesDescription(string fileName)
Definition: svkImageReader2.cc:752
static string GetFileRoot(const char *fname)
Definition: svkImageReader2.cc:128