Slicer  5.0
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 "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;
72 
74  {
75  std::string id;
76  std::string name;
77  std::string description;
78  std::string icon;
79  double window{0.0};
80  double level{0.0};
81  std::string colorNodeID;
82  bool valid{false};
83  };
84  std::vector<VolumeDisplayPreset> VolumeDisplayPresets;
85 
88  LabelMap = 1,
89  CenterImage = 2,
90  SingleFile = 4,
91  AutoWindowLevel = 8,
92  DiscardOrientation = 16
93  };
94 
98  typedef ArchetypeVolumeNodeSet (*ArchetypeVolumeNodeSetFactory)(std::string& volumeName, vtkMRMLScene* scene, int options);
99 
102  int IsFreeSurferVolume(const char* filename);
103 
111  void RegisterArchetypeVolumeNodeSetFactory(ArchetypeVolumeNodeSetFactory factory);
112 
122  void PreRegisterArchetypeVolumeNodeSetFactory(ArchetypeVolumeNodeSetFactory factory);
123 
132  vtkMRMLVolumeNode* AddArchetypeVolume (const char* filename, const char* volname, int loadingOptions)
133  {
134  return (this->AddArchetypeVolume( filename, volname, loadingOptions, nullptr));
135  }
136  vtkMRMLVolumeNode* AddArchetypeVolume (const char* filename, const char* volname, int loadingOptions, vtkStringArray *fileList);
137  vtkMRMLVolumeNode* AddArchetypeVolume (const char *filename, const char* volname)
138  {
139  return this->AddArchetypeVolume( filename, volname, 0, nullptr);
140  }
141 
144  vtkMRMLScalarVolumeNode* AddArchetypeScalarVolume(const char* filename, const char* volname, int loadingOptions, vtkStringArray *fileList);
145 
147  int SaveArchetypeVolume (const char* filename, vtkMRMLVolumeNode *volumeNode);
148 
151  vtkMRMLLabelMapVolumeNode *CreateAndAddLabelVolume(vtkMRMLVolumeNode *volumeNode,
152  const char *name);
153 
155  vtkMRMLLabelMapVolumeNode *CreateAndAddLabelVolume(vtkMRMLScene *scene,
156  vtkMRMLVolumeNode *volumeNode,
157  const char *name);
162  vtkMRMLLabelMapVolumeNode *CreateLabelVolume(vtkMRMLVolumeNode *volumeNode,
163  const char *name);
167  vtkMRMLLabelMapVolumeNode *CreateLabelVolume(vtkMRMLScene *scene,
168  vtkMRMLVolumeNode *volumeNode,
169  const char *name);
170 
175  vtkMRMLLabelMapVolumeNode *FillLabelVolumeFromTemplate(vtkMRMLLabelMapVolumeNode *labelNode,
176  vtkMRMLVolumeNode *templateNode);
177 
184  vtkMRMLLabelMapVolumeNode *FillLabelVolumeFromTemplate(vtkMRMLScene *scene,
185  vtkMRMLLabelMapVolumeNode *labelNode,
186  vtkMRMLVolumeNode *templateNode);
187 
193  vtkMRMLLabelMapVolumeNode *CreateLabelVolumeFromVolume(vtkMRMLScene *scene,
194  vtkMRMLLabelMapVolumeNode *outputVolume,
195  vtkMRMLVolumeNode *inputVolume);
196 
202  vtkMRMLScalarVolumeNode *CreateScalarVolumeFromVolume(vtkMRMLScene *scene,
203  vtkMRMLScalarVolumeNode *outputVolume,
204  vtkMRMLVolumeNode *inputVolume);
205 
207  static void ClearVolumeImageData(vtkMRMLVolumeNode *volumeNode);
208 
214  std::string CheckForLabelVolumeValidity(vtkMRMLScalarVolumeNode *volumeNode,
215  vtkMRMLLabelMapVolumeNode *labelNode);
216 
228  std::string CompareVolumeGeometry(vtkMRMLScalarVolumeNode *volumeNode1,
229  vtkMRMLScalarVolumeNode *volumeNode2);
230 
231 
235  vtkMRMLScalarVolumeNode *CloneVolume(vtkMRMLVolumeNode *volumeNode, const char *name);
236 
239  static vtkMRMLScalarVolumeNode *CloneVolumeWithoutImageData(vtkMRMLScene *scene,
240  vtkMRMLVolumeNode *volumeNode,
241  const char *name);
242 
247  static vtkMRMLScalarVolumeNode *CloneVolume(vtkMRMLScene *scene,
248  vtkMRMLVolumeNode *volumeNode,
249  const char *name,
250  bool cloneImageData=true);
252  static vtkMRMLVolumeNode *CloneVolumeGeneric(vtkMRMLScene *scene,
253  vtkMRMLVolumeNode *volumeNode,
254  const char *name,
255  bool cloneImageData = true);
256 
259  void TranslateFreeSurferRegistrationMatrixIntoSlicerRASToRASMatrix(vtkMRMLVolumeNode *V1Node,
260  vtkMRMLVolumeNode *V2Node,
261  vtkMatrix4x4 *FSRegistrationMatrix,
262  vtkMatrix4x4 *ResultsMatrix);
263 
265  void ComputeTkRegVox2RASMatrix ( vtkMRMLVolumeNode *VNode,
266  vtkMatrix4x4 *M );
267 
270  void CenterVolume(vtkMRMLVolumeNode *volumeNode);
271 
274  void GetVolumeCenteredOrigin(vtkMRMLVolumeNode *volumeNode, double* origin);
275 
278  static vtkMRMLScalarVolumeNode* ResampleVolumeToReferenceVolume(vtkMRMLVolumeNode *inputVolumeNode,
279  vtkMRMLVolumeNode *referenceVolumeNode);
280 
284  vtkGetMacro(CompareVolumeGeometryEpsilon, double);
288  void SetCompareVolumeGeometryEpsilon(double epsilon);
289 
293  vtkGetMacro(CompareVolumeGeometryPrecision, int);
294 
297  bool ApplyVolumeDisplayPreset(vtkMRMLVolumeDisplayNode* displayNode, std::string presetId);
298 
301  std::string GetAppliedVolumeDisplayPresetId(vtkMRMLVolumeDisplayNode* displayNode);
302 
304  std::vector<std::string> GetVolumeDisplayPresetIDs();
305 
308  VolumeDisplayPreset GetVolumeDisplayPreset(const std::string& presetId);
309 
310 protected:
312  ~vtkSlicerVolumesLogic() override;
314  void operator=(const vtkSlicerVolumesLogic&);
315 
317  void InitializeDefaultVolumeDisplayPresets();
318 
319  void ProcessMRMLNodesEvents(vtkObject * caller,
320  unsigned long event,
321  void * callData) override;
322 
323 
324  void InitializeStorageNode(vtkMRMLStorageNode * storageNode,
325  const char * filename,
326  vtkStringArray *fileList,
327  vtkMRMLScene * mrmlScene = nullptr);
328 
329  void SetAndObserveColorToDisplayNode(vtkMRMLDisplayNode* displayNode,
330  int labelmap, const char* filename);
331 
332  typedef std::list<ArchetypeVolumeNodeSetFactory> NodeSetFactoryRegistry;
333 
336  vtkMRMLVolumeNode* AddArchetypeVolume(
337  const NodeSetFactoryRegistry& volumeRegistry,
338  const char* filename, const char* volname, int loadingOptions,
339  vtkStringArray *fileList);
340 
341 protected:
342 
344 
348 
352 };
353 
354 #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 volume display attributes.
MRML node for representing a label map volume.
std::vector< VolumeDisplayPreset > VolumeDisplayPresets
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:57
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
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