SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
svkImageData.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_DATA_H
44 #define SVK_IMAGE_DATA_H
45 
46 #include <vtkObjectFactory.h>
47 #include <vtkImageData.h>
48 #include <vtkCell.h>
49 #include <vtkVertex.h>
50 #include <vtkLine.h>
51 #include <vtkPixel.h>
52 #include <vtkVoxel.h>
53 #include <vtkGenericCell.h>
54 #include <vtkMath.h>
55 #include <vtkPoints.h>
56 #include <vtkPointData.h>
57 #include <vtkCellData.h>
58 #include <vtkUnsignedCharArray.h>
59 #include <vtkUnsignedShortArray.h>
60 #include <vtkShortArray.h>
61 #include <vtkFloatArray.h>
62 #include <vtkDataSetAttributes.h>
63 #include <vtkXMLDataElement.h>
64 #include <vtkIndent.h>
65 
66 #include <svkFastCellData.h>
67 #include <svkDcmtkAdapter.h>
68 #include <svkDcmHeader.h>
69 #include <svkProvenance.h>
70 
71 #include <assert.h>
72 #include <set>
73 
74 
75 namespace svk {
76 
77 
78 using namespace std;
79 using namespace svk;
80 
81 
82 
107 class svkImageData: public vtkImageData
108 {
109 
110  public:
111 
112  vtkTypeMacro( svkImageData, vtkImageData );
113  virtual void PrintSelf( ostream &os, vtkIndent indent );
114 
115 
117  REAL = 0,
119  MAGNITUDE
120  };
121 
122  typedef enum {
123  ROW = 0,
126  LR,
127  PA,
128  SI
129  } DataBasis;
130 
131 
132  // Copy and Cast Methods
133  virtual void DeepCopy( vtkDataObject* src );
134  virtual void DeepCopy(
135  vtkDataObject* src,
137  );
138  virtual void ShallowCopy( vtkDataObject* src );
139  virtual void ShallowCopy(
140  vtkDataObject* src,
142  );
143  virtual void ZeroCopy(
144  vtkImageData* src,
146  );
147  virtual void CopyAndFillComponents(
148  vtkImageData* src, double fillValue,
150  );
151  virtual void CastDataFormat( svkDcmHeader::DcmPixelDataFormat castToFormat );
152  virtual void CopyAndCastFrom( vtkImageData* inData, int extent[6] );
153  virtual void CopyAndCastFrom(
154  vtkImageData* inData, int x0, int x1, int y0, int y1, int z0, int z1
155  );
156  virtual void CopyStructure( vtkDataSet* ds );
157  virtual void CopyDcos( vtkDataObject* src );
158  virtual void CopyVtkImage( vtkImageData* sourceImage, double dcos[][3] );
159 
160  // Dcos sensitive methods:
161  virtual double * GetPoint (vtkIdType ptId);
162 
163  // Inline for performance:
164  virtual void GetPoint (vtkIdType id, double x[3])
165  {
166  const double *p = this->GetPoint(id);
167  x[0] = p[0]; x[1] = p[1]; x[2] = p[2];
168  }
169 
170  virtual vtkCell * GetCell (vtkIdType cellId);
171  virtual void GetCell (vtkIdType cellId, vtkGenericCell *cell);
172  virtual void GetCellBounds (vtkIdType cellId, double bounds[6]);
173  virtual vtkIdType FindPoint (double x, double y, double z);
174  virtual vtkIdType FindPoint (double x[3]);
175  virtual vtkIdType FindCell (
176  double x[3],
177  vtkCell *cell,
178  vtkIdType cellId,
179  double tol2,
180  int &subId,
181  double pcoords[3],
182  double *weights
183  );
184  virtual vtkIdType FindCell (
185  double x[3],
186  vtkCell *cell,
187  vtkGenericCell *gencell,
188  vtkIdType cellId,
189  double tol2,
190  int &subId,
191  double pcoords[3],
192  double *weights
193  );
194  virtual vtkCell * FindAndGetCell (
195  double x[3],
196  vtkCell *cell,
197  vtkIdType cellId,
198  double tol2,
199  int &subId,
200  double pcoords[3],
201  double *weights
202  );
203  virtual int GetCellType (vtkIdType cellId);
204  virtual void GetCellPoints (vtkIdType cellId, vtkIdList *ptIds);
205  virtual void GetPointCells (vtkIdType ptId, vtkIdList *cellIds);
206  virtual void ComputeBounds ();
207  virtual int ComputeStructuredCoordinates (double x[3], int ijk[3], double pcoords[3]);
208  virtual void GetVoxelGradient (int i, int j, int k, vtkDataArray *s, vtkDataArray *g);
209  virtual void GetPointGradient (int i, int j, int k, vtkDataArray *s, double g[3]);
210  virtual void SetAxisUpdateExtent (int axis, int min, int max);
211  virtual void GetAxisUpdateExtent (int axis, int &min, int &max);
212 
213  virtual void SetDcos( double x[3][3]);
214  virtual void GetDcos( double x[3][3]);
215 
216  void SetDcmHeader(svkDcmHeader* dcmHeader);
218  void SetProvenance(svkProvenance* provenance);
219  svkProvenance* GetProvenance();
220  int GetIDFromIndex(int indexX, int indexY, int indexZ);
221  virtual void GetNumberOfVoxels(int numVoxels[3]) = 0;
222  void GetIndexFromID(int voxelID, int* indexX, int* indexY, int* indexZ);
223  void GetIndexFromID(int voxelID, int* index);
224  void GetIndexFromPosition(double posLPS[3], int* index);
225  void GetIndexFromPosition(double posLPS[3], double* index);
226  virtual void GetPositionFromIndex(int* index, double* posLPS);
227  virtual void GetSliceOrigin(
228  int slice,
229  double* sliceOrigin,
231  );
232  virtual void GetSliceCenter(
233  int slice,
234  double* sliceCenter,
236  );
237  virtual void GetSliceNormal(
238  double* normal,
240  );
241  virtual int GetClosestSlice(
242  double * posLPS,
244  double tolerance = -1
245  );
246  virtual int GetNumberOfSlices(
248  );
249  virtual int GetFirstSlice( svkDcmHeader::Orientation sliceOrientation = svkDcmHeader::UNKNOWN_ORIENTATION );
250  virtual int GetLastSlice( svkDcmHeader::Orientation sliceOrientation = svkDcmHeader::UNKNOWN_ORIENTATION );
251  virtual void GetDataBasis( double basisVector[3], DataBasis basis );
252  virtual int GetOrientationIndex( svkDcmHeader::Orientation orientation );
253  virtual void GetImageCenter( double* center );
254  void GetDataRange( double range[2], int component );
255  void SetDataRange( double range[2], int component );
256 
257  void SetSourceData( svkImageData* source );
258  svkImageData* GetSourceData();
259 
260  void SyncVTKImageDataToDcmHeader();
261 
262  static void RemoveArrays( svkImageData* data );
263 
264  vtkSetStringMacro(SourceFileName);
265  vtkGetStringMacro(SourceFileName);
266 
267 
268  protected:
269 
270  svkImageData();
271  ~svkImageData();
272 
273  // Members:
278 
280  double range[3][2];
281  bool WasModified();
282  virtual void UpdateSvkParams();
283  virtual void UpdateRange( int component );
284  int FindMatchingSlice(
285  double* posLPS,
286  svkDcmHeader::Orientation sliceOrientation,
287  double* origin,
288  double* spacing,
289  double tolerance = -1
290  );
291 
292 
293  private:
294  // dcos = Directional Cosine Matrix
295  double dcos[3][3];
296  unsigned long lastUpdateTime;
297 
298  void CastDataArrays( int vtkDataArrayType, vtkDataSetAttributes* fieldData );
299 
300  void CopyMetaData( vtkDataObject* src, svkDcmHeader::DcmPixelDataFormat castToFormat);
301 };
302 
303 
304 } //svk
305 
306 #endif //SVK_IMAGE_DATA_H
Definition: svkDcmHeader.h:66
RangeComponent
Definition: svkImageData.h:116
Definition: svkImageData.h:124
virtual void GetPoint(vtkIdType id, double x[3])
Definition: svkImageData.h:164
DcmPixelDataFormat
Definition: svkDcmHeader.h:92
Orientation
Definition: svkDcmHeader.h:101
svkDcmHeader * dcmHeader
Definition: svkImageData.h:274
Definition: svkImageData.h:118
data GetDcmHeader() -> RemoveDimensionIndex(svkDcmHeader::EPSI_ACQ_INDEX)
Definition: svkProvenance.h:62
svkImageData * source
Definition: svkImageData.h:277
Definition: svkImageData.h:125
Definition: svkDcmHeader.h:93
Definition: svkImageData.h:126
Definition: svkImageData.h:127
Definition: svkImageData.h:107
svkProvenance * provenance
Definition: svkImageData.h:275
char * SourceFileName
Definition: svkImageData.h:276
Definition: svkDcmHeader.h:102