Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
vtkSlicerVolumesLogic.h
Go to the documentation of this file.
1 /*=auto=========================================================================
2 
3  Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
4 
5  See COPYRIGHT.txt
6  or http://www.slicer.org/copyright/copyright.txt for details.
7 
8  Program: 3D Slicer
9  Module: $RCSfile: vtkSlicerVolumesLogic.h,v $
10  Date: $Date: 2006/01/08 04:48:05 $
11  Version: $Revision: 1.45 $
12 
13 =========================================================================auto=*/
14 
15 // .NAME vtkSlicerVolumesLogic - slicer logic class for volumes manipulation
16 // .SECTION Description
17 // This class manages the logic associated with reading, saving,
18 // and changing properties of volumes
19 
20 
21 #ifndef __vtkSlicerVolumesLogic_h
22 #define __vtkSlicerVolumesLogic_h
23 
24 // Slicer includes
25 #include "vtkSlicerModuleLogic.h"
26 
27 // MRML includes
28 #include "vtkMRML.h"
29 #include "vtkMRMLScene.h"
30 #include "vtkMRMLVolumeNode.h"
31 
32 // STD includes
33 #include <cstdlib>
34 #include <list>
35 
36 #include "vtkSlicerVolumesModuleLogicExport.h"
37 
42 class vtkStringArray;
43 
45 {
48  Node = set.Node;
49  DisplayNode = set.DisplayNode;
50  StorageNode = set.StorageNode;
51  Scene = set.Scene;
52  LabelMap = set.LabelMap;
53  }
54  vtkSmartPointer<vtkMRMLVolumeNode> Node;
55  vtkSmartPointer<vtkMRMLVolumeDisplayNode> DisplayNode;
56  vtkSmartPointer<vtkMRMLStorageNode> StorageNode;
57  vtkSmartPointer<vtkMRMLScene> Scene;
58  bool LabelMap; // is this node set for labelmaps?
59 };
60 
61 class VTK_SLICER_VOLUMES_MODULE_LOGIC_EXPORT vtkSlicerVolumesLogic :
63 {
64 public:
65 
66  static vtkSlicerVolumesLogic *New();
68  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
69 
71 
74  LabelMap = 1,
75  CenterImage = 2,
76  SingleFile = 4,
77  AutoWindowLevel = 8,
78  DiscardOrientation = 16
79  };
80 
84  typedef ArchetypeVolumeNodeSet (*ArchetypeVolumeNodeSetFactory)(std::string& volumeName, vtkMRMLScene* scene, int options);
85 
86  virtual void SetColorLogic(vtkMRMLColorLogic* colorLogic);
87  vtkMRMLColorLogic* GetColorLogic()const;
88 
91  int IsFreeSurferVolume(const char* filename);
92 
94  void SetActiveVolumeNode(vtkMRMLVolumeNode *ActiveVolumeNode);
95  vtkMRMLVolumeNode* GetActiveVolumeNode()const;
96 
97 
105  void RegisterArchetypeVolumeNodeSetFactory(ArchetypeVolumeNodeSetFactory factory);
106 
116  void PreRegisterArchetypeVolumeNodeSetFactory(ArchetypeVolumeNodeSetFactory factory);
117 
126  vtkMRMLVolumeNode* AddArchetypeVolume (const char* filename, const char* volname, int loadingOptions)
127  {
128  return (this->AddArchetypeVolume( filename, volname, loadingOptions, NULL));
129  }
130  vtkMRMLVolumeNode* AddArchetypeVolume (const char* filename, const char* volname, int loadingOptions, vtkStringArray *fileList);
131  vtkMRMLVolumeNode* AddArchetypeVolume (const char *filename, const char* volname)
132  {
133  return this->AddArchetypeVolume( filename, volname, 0, NULL);
134  }
135 
138  vtkMRMLScalarVolumeNode* AddArchetypeScalarVolume(const char* filename, const char* volname, int loadingOptions, vtkStringArray *fileList);
139 
141  int SaveArchetypeVolume (const char* filename, vtkMRMLVolumeNode *volumeNode);
142 
145  vtkMRMLLabelMapVolumeNode *CreateAndAddLabelVolume(vtkMRMLVolumeNode *volumeNode,
146  const char *name);
147 
149  vtkMRMLLabelMapVolumeNode *CreateAndAddLabelVolume(vtkMRMLScene *scene,
150  vtkMRMLVolumeNode *volumeNode,
151  const char *name);
156  vtkMRMLLabelMapVolumeNode *CreateLabelVolume(vtkMRMLVolumeNode *volumeNode,
157  const char *name);
161  vtkMRMLLabelMapVolumeNode *CreateLabelVolume(vtkMRMLScene *scene,
162  vtkMRMLVolumeNode *volumeNode,
163  const char *name);
164 
169  vtkMRMLLabelMapVolumeNode *FillLabelVolumeFromTemplate(vtkMRMLLabelMapVolumeNode *labelNode,
170  vtkMRMLVolumeNode *templateNode);
171 
178  vtkMRMLLabelMapVolumeNode *FillLabelVolumeFromTemplate(vtkMRMLScene *scene,
179  vtkMRMLLabelMapVolumeNode *labelNode,
180  vtkMRMLVolumeNode *templateNode);
181 
187  vtkMRMLLabelMapVolumeNode *CreateLabelVolumeFromVolume(vtkMRMLScene *scene,
188  vtkMRMLLabelMapVolumeNode *outputVolume,
189  vtkMRMLVolumeNode *inputVolume);
190 
196  vtkMRMLScalarVolumeNode *CreateScalarVolumeFromVolume(vtkMRMLScene *scene,
197  vtkMRMLScalarVolumeNode *outputVolume,
198  vtkMRMLVolumeNode *inputVolume);
199 
201  static void ClearVolumeImageData(vtkMRMLVolumeNode *volumeNode);
202 
208  std::string CheckForLabelVolumeValidity(vtkMRMLScalarVolumeNode *volumeNode,
209  vtkMRMLLabelMapVolumeNode *labelNode);
210 
222  std::string CompareVolumeGeometry(vtkMRMLScalarVolumeNode *volumeNode1,
223  vtkMRMLScalarVolumeNode *volumeNode2);
224 
225 
229  vtkMRMLScalarVolumeNode *CloneVolume(vtkMRMLVolumeNode *volumeNode, const char *name);
230 
233  static vtkMRMLScalarVolumeNode *CloneVolumeWithoutImageData(vtkMRMLScene *scene,
234  vtkMRMLVolumeNode *volumeNode,
235  const char *name);
236 
241  static vtkMRMLScalarVolumeNode *CloneVolume(vtkMRMLScene *scene,
242  vtkMRMLVolumeNode *volumeNode,
243  const char *name,
244  bool cloneImageData=true);
246  static vtkMRMLVolumeNode *CloneVolumeGeneric(vtkMRMLScene *scene,
247  vtkMRMLVolumeNode *volumeNode,
248  const char *name,
249  bool cloneImageData = true);
250 
253  void TranslateFreeSurferRegistrationMatrixIntoSlicerRASToRASMatrix(vtkMRMLVolumeNode *V1Node,
254  vtkMRMLVolumeNode *V2Node,
255  vtkMatrix4x4 *FSRegistrationMatrix,
256  vtkMatrix4x4 *ResultsMatrix);
257 
259  void ComputeTkRegVox2RASMatrix ( vtkMRMLVolumeNode *VNode,
260  vtkMatrix4x4 *M );
261 
264  void CenterVolume(vtkMRMLVolumeNode *volumeNode);
265 
268  void GetVolumeCenteredOrigin(vtkMRMLVolumeNode *volumeNode, double* origin);
269 
272  static vtkMRMLScalarVolumeNode* ResampleVolumeToReferenceVolume(vtkMRMLVolumeNode *inputVolumeNode,
273  vtkMRMLVolumeNode *referenceVolumeNode);
274 
278  vtkGetMacro(CompareVolumeGeometryEpsilon, double);
282  void SetCompareVolumeGeometryEpsilon(double epsilon);
283 
287  vtkGetMacro(CompareVolumeGeometryPrecision, int);
288 
289 protected:
291  virtual ~vtkSlicerVolumesLogic();
293  void operator=(const vtkSlicerVolumesLogic&);
294 
295  virtual void ProcessMRMLNodesEvents(vtkObject * caller,
296  unsigned long event,
297  void * callData) VTK_OVERRIDE;
298 
299 
300  void InitializeStorageNode(vtkMRMLStorageNode * storageNode,
301  const char * filename,
302  vtkStringArray *fileList,
303  vtkMRMLScene * mrmlScene = NULL);
304 
305  void SetAndObserveColorToDisplayNode(vtkMRMLDisplayNode* displayNode,
306  int labelmap, const char* filename);
307 
308  typedef std::list<ArchetypeVolumeNodeSetFactory> NodeSetFactoryRegistry;
309 
312  vtkMRMLVolumeNode* AddArchetypeVolume(
313  const NodeSetFactoryRegistry& volumeRegistry,
314  const char* filename, const char* volname, int loadingOptions,
315  vtkStringArray *fileList);
316 
317 protected:
318  vtkSmartPointer<vtkMRMLVolumeNode> ActiveVolumeNode;
319 
320  vtkSmartPointer<vtkMRMLColorLogic> ColorLogic;
321 
322  NodeSetFactoryRegistry VolumeRegistry;
323 
327 
331 };
332 
333 #endif
vtkSmartPointer< vtkMRMLColorLogic > ColorLogic
MRML node for representing a volume storage.
vtkSmartPointer< vtkMRMLStorageNode > StorageNode
vtkSlicerVolumesLogic Self
MRML node for representing a label map volume.
vtkSmartPointer< vtkMRMLVolumeDisplayNode > DisplayNode
MRML logic class for color manipulation.
vtkSmartPointer< vtkMRMLScene > Scene
LoadingOptions
Loading options, bitfield.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
A supercalss for other storage nodes.
MRML node for representing a volume (image stack).
vtkMRMLVolumeNode * AddArchetypeVolume(const char *filename, const char *volname)
ArchetypeVolumeNodeSet(const ArchetypeVolumeNodeSet &set)
Abstract class that contains graphical display properties for displayable nodes.
MRML node for representing a volume (image stack).
NodeSetFactoryRegistry VolumeRegistry
vtkSmartPointer< vtkMRMLVolumeNode > ActiveVolumeNode
vtkMRMLVolumeNode * AddArchetypeVolume(const char *filename, const char *volname, int loadingOptions)
ArchetypeVolumeNodeSet(vtkMRMLScene *scene)
MRML node for representing a volume display attributes.
std::list< ArchetypeVolumeNodeSetFactory > NodeSetFactoryRegistry
vtkSmartPointer< vtkMRMLVolumeNode > Node