Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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 "vtkMRMLStorageNode.h"
32 #include "vtkMRMLVolumeNode.h"
33 
34 // STD includes
35 #include <cstdlib>
36 #include <list>
37 
38 #include "vtkSlicerVolumesModuleLogicExport.h"
39 
44 class vtkStringArray;
45 
47 {
50  Node = set.Node;
51  DisplayNode = set.DisplayNode;
52  StorageNode = set.StorageNode;
53  Scene = set.Scene;
54  LabelMap = set.LabelMap;
55  }
56  vtkSmartPointer<vtkMRMLVolumeNode> Node;
57  vtkSmartPointer<vtkMRMLVolumeDisplayNode> DisplayNode;
58  vtkSmartPointer<vtkMRMLStorageNode> StorageNode;
59  vtkSmartPointer<vtkMRMLScene> Scene;
60  bool LabelMap; // is this node set for labelmaps?
61 };
62 
63 class VTK_SLICER_VOLUMES_MODULE_LOGIC_EXPORT vtkSlicerVolumesLogic :
65 {
66 public:
67 
68  static vtkSlicerVolumesLogic *New();
70  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
73 
76  LabelMap = 1,
77  CenterImage = 2,
78  SingleFile = 4,
79  AutoWindowLevel = 8,
80  DiscardOrientation = 16
81  };
82 
86  typedef ArchetypeVolumeNodeSet (*ArchetypeVolumeNodeSetFactory)(std::string& volumeName, vtkMRMLScene* scene, int options);
87 
90  int IsFreeSurferVolume(const char* filename);
91 
93  void SetActiveVolumeNode(vtkMRMLVolumeNode *ActiveVolumeNode);
94  vtkMRMLVolumeNode* GetActiveVolumeNode()const;
95 
96 
104  void RegisterArchetypeVolumeNodeSetFactory(ArchetypeVolumeNodeSetFactory factory);
105 
115  void PreRegisterArchetypeVolumeNodeSetFactory(ArchetypeVolumeNodeSetFactory factory);
116 
125  vtkMRMLVolumeNode* AddArchetypeVolume (const char* filename, const char* volname, int loadingOptions)
126  {
127  return (this->AddArchetypeVolume( filename, volname, loadingOptions, nullptr));
128  }
129  vtkMRMLVolumeNode* AddArchetypeVolume (const char* filename, const char* volname, int loadingOptions, vtkStringArray *fileList);
130  vtkMRMLVolumeNode* AddArchetypeVolume (const char *filename, const char* volname)
131  {
132  return this->AddArchetypeVolume( filename, volname, 0, nullptr);
133  }
134 
137  vtkMRMLScalarVolumeNode* AddArchetypeScalarVolume(const char* filename, const char* volname, int loadingOptions, vtkStringArray *fileList);
138 
140  int SaveArchetypeVolume (const char* filename, vtkMRMLVolumeNode *volumeNode);
141 
144  vtkMRMLLabelMapVolumeNode *CreateAndAddLabelVolume(vtkMRMLVolumeNode *volumeNode,
145  const char *name);
146 
148  vtkMRMLLabelMapVolumeNode *CreateAndAddLabelVolume(vtkMRMLScene *scene,
149  vtkMRMLVolumeNode *volumeNode,
150  const char *name);
155  vtkMRMLLabelMapVolumeNode *CreateLabelVolume(vtkMRMLVolumeNode *volumeNode,
156  const char *name);
160  vtkMRMLLabelMapVolumeNode *CreateLabelVolume(vtkMRMLScene *scene,
161  vtkMRMLVolumeNode *volumeNode,
162  const char *name);
163 
168  vtkMRMLLabelMapVolumeNode *FillLabelVolumeFromTemplate(vtkMRMLLabelMapVolumeNode *labelNode,
169  vtkMRMLVolumeNode *templateNode);
170 
177  vtkMRMLLabelMapVolumeNode *FillLabelVolumeFromTemplate(vtkMRMLScene *scene,
178  vtkMRMLLabelMapVolumeNode *labelNode,
179  vtkMRMLVolumeNode *templateNode);
180 
186  vtkMRMLLabelMapVolumeNode *CreateLabelVolumeFromVolume(vtkMRMLScene *scene,
187  vtkMRMLLabelMapVolumeNode *outputVolume,
188  vtkMRMLVolumeNode *inputVolume);
189 
195  vtkMRMLScalarVolumeNode *CreateScalarVolumeFromVolume(vtkMRMLScene *scene,
196  vtkMRMLScalarVolumeNode *outputVolume,
197  vtkMRMLVolumeNode *inputVolume);
198 
200  static void ClearVolumeImageData(vtkMRMLVolumeNode *volumeNode);
201 
207  std::string CheckForLabelVolumeValidity(vtkMRMLScalarVolumeNode *volumeNode,
208  vtkMRMLLabelMapVolumeNode *labelNode);
209 
221  std::string CompareVolumeGeometry(vtkMRMLScalarVolumeNode *volumeNode1,
222  vtkMRMLScalarVolumeNode *volumeNode2);
223 
224 
228  vtkMRMLScalarVolumeNode *CloneVolume(vtkMRMLVolumeNode *volumeNode, const char *name);
229 
232  static vtkMRMLScalarVolumeNode *CloneVolumeWithoutImageData(vtkMRMLScene *scene,
233  vtkMRMLVolumeNode *volumeNode,
234  const char *name);
235 
240  static vtkMRMLScalarVolumeNode *CloneVolume(vtkMRMLScene *scene,
241  vtkMRMLVolumeNode *volumeNode,
242  const char *name,
243  bool cloneImageData=true);
245  static vtkMRMLVolumeNode *CloneVolumeGeneric(vtkMRMLScene *scene,
246  vtkMRMLVolumeNode *volumeNode,
247  const char *name,
248  bool cloneImageData = true);
249 
252  void TranslateFreeSurferRegistrationMatrixIntoSlicerRASToRASMatrix(vtkMRMLVolumeNode *V1Node,
253  vtkMRMLVolumeNode *V2Node,
254  vtkMatrix4x4 *FSRegistrationMatrix,
255  vtkMatrix4x4 *ResultsMatrix);
256 
258  void ComputeTkRegVox2RASMatrix ( vtkMRMLVolumeNode *VNode,
259  vtkMatrix4x4 *M );
260 
263  void CenterVolume(vtkMRMLVolumeNode *volumeNode);
264 
267  void GetVolumeCenteredOrigin(vtkMRMLVolumeNode *volumeNode, double* origin);
268 
271  static vtkMRMLScalarVolumeNode* ResampleVolumeToReferenceVolume(vtkMRMLVolumeNode *inputVolumeNode,
272  vtkMRMLVolumeNode *referenceVolumeNode);
273 
277  vtkGetMacro(CompareVolumeGeometryEpsilon, double);
281  void SetCompareVolumeGeometryEpsilon(double epsilon);
282 
286  vtkGetMacro(CompareVolumeGeometryPrecision, int);
287 
288 protected:
290  ~vtkSlicerVolumesLogic() override;
292  void operator=(const vtkSlicerVolumesLogic&);
293 
294  void ProcessMRMLNodesEvents(vtkObject * caller,
295  unsigned long event,
296  void * callData) override;
297 
298 
299  void InitializeStorageNode(vtkMRMLStorageNode * storageNode,
300  const char * filename,
301  vtkStringArray *fileList,
302  vtkMRMLScene * mrmlScene = nullptr);
303 
304  void SetAndObserveColorToDisplayNode(vtkMRMLDisplayNode* displayNode,
305  int labelmap, const char* filename);
306 
307  typedef std::list<ArchetypeVolumeNodeSetFactory> NodeSetFactoryRegistry;
308 
311  vtkMRMLVolumeNode* AddArchetypeVolume(
312  const NodeSetFactoryRegistry& volumeRegistry,
313  const char* filename, const char* volname, int loadingOptions,
314  vtkStringArray *fileList);
315 
316 protected:
317  vtkSmartPointer<vtkMRMLVolumeNode> ActiveVolumeNode;
318 
320 
324 
328 };
329 
330 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
static vtkSlicerModuleLogic * New()
The Usual vtk class functions.
MRML node for representing a volume storage.
vtkSmartPointer< vtkMRMLStorageNode > StorageNode
vtkSlicerVolumesLogic Self
MRML node for representing a label map volume.
vtkSmartPointer< vtkMRMLVolumeDisplayNode > DisplayNode
vtkSmartPointer< vtkMRMLScene > Scene
virtual void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData)
LoadingOptions
Loading options, bitfield.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:61
A superclass 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