Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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#ifndef __vtkSlicerVolumesLogic_h
21#define __vtkSlicerVolumesLogic_h
22
23// Slicer includes
25
26// MRML includes
27#include "vtkMRML.h"
28#include "vtkMRMLScene.h"
29#include "vtkMRMLStorageNode.h"
31#include "vtkMRMLVolumeNode.h"
32
33// STD includes
34#include <cstdlib>
35#include <list>
36#include <string>
37
38#include "vtkSlicerVolumesModuleLogicExport.h"
39
44class vtkStringArray;
45
47{
49 : Scene(scene)
50 , LabelMap(false)
51 {
52 }
54 {
55 Node = set.Node;
58 Scene = set.Scene;
59 LabelMap = set.LabelMap;
60 }
61 vtkSmartPointer<vtkMRMLVolumeNode> Node;
62 vtkSmartPointer<vtkMRMLVolumeDisplayNode> DisplayNode;
63 vtkSmartPointer<vtkMRMLStorageNode> StorageNode;
64 vtkSmartPointer<vtkMRMLScene> Scene;
65 bool LabelMap; // is this node set for labelmaps?
66};
67
68class VTK_SLICER_VOLUMES_MODULE_LOGIC_EXPORT vtkSlicerVolumesLogic : public vtkSlicerModuleLogic
69{
70public:
73 void PrintSelf(ostream& os, vtkIndent indent) override;
75
77 {
78 std::string id;
79 std::string name;
80 std::string description;
81 std::string icon;
82 double window{ 0.0 };
83 double level{ 0.0 };
84 std::string colorNodeID;
85 bool valid{ false };
86 };
87 std::vector<VolumeDisplayPreset> VolumeDisplayPresets;
88
98
102 typedef ArchetypeVolumeNodeSet (*ArchetypeVolumeNodeSetFactory)(std::string& volumeName, vtkMRMLScene* scene, int options);
103
106 int IsFreeSurferVolume(const char* filename);
107
116
127
136 vtkMRMLVolumeNode* AddArchetypeVolume(const char* filename, const char* volname, int loadingOptions)
137 {
138 return (this->AddArchetypeVolume(filename, volname, loadingOptions, nullptr));
139 }
140 vtkMRMLVolumeNode* AddArchetypeVolume(const char* filename, const char* volname, int loadingOptions, vtkStringArray* fileList);
141 vtkMRMLVolumeNode* AddArchetypeVolume(const char* filename, const char* volname) { return this->AddArchetypeVolume(filename, volname, 0, nullptr); }
142
145 vtkMRMLScalarVolumeNode* AddArchetypeScalarVolume(const char* filename, const char* volname, int loadingOptions, vtkStringArray* fileList);
146
148 int SaveArchetypeVolume(const char* filename, vtkMRMLVolumeNode* volumeNode);
149
153
165
171
179
186
193
195 static void ClearVolumeImageData(vtkMRMLVolumeNode* volumeNode);
196
203
216
221
225
230 static vtkMRMLScalarVolumeNode* CloneVolume(vtkMRMLScene* scene, vtkMRMLVolumeNode* volumeNode, const char* name, bool cloneImageData = true);
232 static vtkMRMLVolumeNode* CloneVolumeGeneric(vtkMRMLScene* scene, vtkMRMLVolumeNode* volumeNode, const char* name, bool cloneImageData = true);
233
237 vtkMRMLVolumeNode* V2Node,
238 vtkMatrix4x4* FSRegistrationMatrix,
239 vtkMatrix4x4* ResultsMatrix);
240
242 void ComputeTkRegVox2RASMatrix(vtkMRMLVolumeNode* VNode, vtkMatrix4x4* M);
243
247
250 void GetVolumeCenteredOrigin(vtkMRMLVolumeNode* volumeNode, double* origin);
251
255
259 vtkGetMacro(CompareVolumeGeometryEpsilon, double);
264
269
272 bool ApplyVolumeDisplayPreset(vtkMRMLVolumeDisplayNode* displayNode, std::string presetId);
273
277
279 std::vector<std::string> GetVolumeDisplayPresetIDs();
280
283 VolumeDisplayPreset GetVolumeDisplayPreset(const std::string& presetId);
284
285protected:
290
293
294 void ProcessMRMLNodesEvents(vtkObject* caller, unsigned long event, void* callData) override;
295
296 void InitializeStorageNode(vtkMRMLStorageNode* storageNode, const char* filename, vtkStringArray* fileList, vtkMRMLScene* mrmlScene = nullptr);
297
298 void SetAndObserveColorToDisplayNode(vtkMRMLDisplayNode* displayNode, int labelmap, const char* filename);
299
300 typedef std::list<ArchetypeVolumeNodeSetFactory> NodeSetFactoryRegistry;
301
304 vtkMRMLVolumeNode* AddArchetypeVolume(const NodeSetFactoryRegistry& volumeRegistry, const char* filename, const char* volname, int loadingOptions, vtkStringArray* fileList);
305
306protected:
308
312
316};
317
318#endif
Abstract class that contains graphical display properties for displayable nodes.
MRML node for representing a label map volume.
MRML node for representing a volume display attributes.
MRML node for representing a volume (image stack).
A set of MRML Nodes that supports serialization and undo/redo.
A superclass for other storage nodes.
MRML node for representing a volume display attributes.
MRML node for representing a volume storage.
MRML node for representing a volume (image stack).
vtkMRMLScalarVolumeNode * CloneVolume(vtkMRMLVolumeNode *volumeNode, const char *name)
void SetCompareVolumeGeometryEpsilon(double epsilon)
void SetAndObserveColorToDisplayNode(vtkMRMLDisplayNode *displayNode, int labelmap, const char *filename)
NodeSetFactoryRegistry VolumeRegistry
std::vector< VolumeDisplayPreset > VolumeDisplayPresets
vtkMRMLLabelMapVolumeNode * CreateAndAddLabelVolume(vtkMRMLScene *scene, vtkMRMLVolumeNode *volumeNode, const char *name)
Create a label map volume to match the given volumeNode and add it to the scene.
std::string CompareVolumeGeometry(vtkMRMLScalarVolumeNode *volumeNode1, vtkMRMLScalarVolumeNode *volumeNode2)
vtkSlicerVolumesLogic(const vtkSlicerVolumesLogic &)
static vtkMRMLScalarVolumeNode * ResampleVolumeToReferenceVolume(vtkMRMLVolumeNode *inputVolumeNode, vtkMRMLVolumeNode *referenceVolumeNode)
bool ApplyVolumeDisplayPreset(vtkMRMLVolumeDisplayNode *displayNode, std::string presetId)
void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData) override
void ComputeTkRegVox2RASMatrix(vtkMRMLVolumeNode *VNode, vtkMatrix4x4 *M)
Convenience method to compute a volume's Vox2RAS-tkreg Matrix.
vtkMRMLLabelMapVolumeNode * FillLabelVolumeFromTemplate(vtkMRMLScene *scene, vtkMRMLLabelMapVolumeNode *labelNode, vtkMRMLVolumeNode *templateNode)
void RegisterArchetypeVolumeNodeSetFactory(ArchetypeVolumeNodeSetFactory factory)
static vtkMRMLScalarVolumeNode * CloneVolumeWithoutImageData(vtkMRMLScene *scene, vtkMRMLVolumeNode *volumeNode, const char *name)
std::string GetAppliedVolumeDisplayPresetId(vtkMRMLVolumeDisplayNode *displayNode)
std::list< ArchetypeVolumeNodeSetFactory > NodeSetFactoryRegistry
static void ClearVolumeImageData(vtkMRMLVolumeNode *volumeNode)
Clear the image data of a volume node to contain all zeros.
vtkMRMLVolumeNode * AddArchetypeVolume(const char *filename, const char *volname)
void operator=(const vtkSlicerVolumesLogic &)
vtkMRMLVolumeNode * AddArchetypeVolume(const char *filename, const char *volname, int loadingOptions, vtkStringArray *fileList)
void GetVolumeCenteredOrigin(vtkMRMLVolumeNode *volumeNode, double *origin)
void TranslateFreeSurferRegistrationMatrixIntoSlicerRASToRASMatrix(vtkMRMLVolumeNode *V1Node, vtkMRMLVolumeNode *V2Node, vtkMatrix4x4 *FSRegistrationMatrix, vtkMatrix4x4 *ResultsMatrix)
void PreRegisterArchetypeVolumeNodeSetFactory(ArchetypeVolumeNodeSetFactory factory)
vtkMRMLLabelMapVolumeNode * CreateLabelVolumeFromVolume(vtkMRMLScene *scene, vtkMRMLLabelMapVolumeNode *outputVolume, vtkMRMLVolumeNode *inputVolume)
static vtkMRMLVolumeNode * CloneVolumeGeneric(vtkMRMLScene *scene, vtkMRMLVolumeNode *volumeNode, const char *name, bool cloneImageData=true)
Create a deep copy of a volumeNode and add it to the scene.
void InitializeDefaultVolumeDisplayPresets()
Read default volume display presets from configuration file.
std::vector< std::string > GetVolumeDisplayPresetIDs()
Method to get a vector to currently defined window level preset IDs.
LoadingOptions
Loading options, bitfield.
~vtkSlicerVolumesLogic() override
vtkSlicerVolumesLogic Self
vtkMRMLScalarVolumeNode * CreateScalarVolumeFromVolume(vtkMRMLScene *scene, vtkMRMLScalarVolumeNode *outputVolume, vtkMRMLVolumeNode *inputVolume)
vtkMRMLLabelMapVolumeNode * CreateLabelVolume(vtkMRMLVolumeNode *volumeNode, const char *name)
vtkMRMLLabelMapVolumeNode * FillLabelVolumeFromTemplate(vtkMRMLLabelMapVolumeNode *labelNode, vtkMRMLVolumeNode *templateNode)
static vtkMRMLScalarVolumeNode * CloneVolume(vtkMRMLScene *scene, vtkMRMLVolumeNode *volumeNode, const char *name, bool cloneImageData=true)
vtkMRMLVolumeNode * AddArchetypeVolume(const NodeSetFactoryRegistry &volumeRegistry, const char *filename, const char *volname, int loadingOptions, vtkStringArray *fileList)
static vtkSlicerVolumesLogic * New()
int IsFreeSurferVolume(const char *filename)
vtkMRMLLabelMapVolumeNode * CreateAndAddLabelVolume(vtkMRMLVolumeNode *volumeNode, const char *name)
vtkMRMLScalarVolumeNode * AddArchetypeScalarVolume(const char *filename, const char *volname, int loadingOptions, vtkStringArray *fileList)
void PrintSelf(ostream &os, vtkIndent indent) override
void CenterVolume(vtkMRMLVolumeNode *volumeNode)
std::string CheckForLabelVolumeValidity(vtkMRMLScalarVolumeNode *volumeNode, vtkMRMLLabelMapVolumeNode *labelNode)
ArchetypeVolumeNodeSet(* ArchetypeVolumeNodeSetFactory)(std::string &volumeName, vtkMRMLScene *scene, int options)
int SaveArchetypeVolume(const char *filename, vtkMRMLVolumeNode *volumeNode)
Write volume's image data to a specified file.
vtkMRMLLabelMapVolumeNode * CreateLabelVolume(vtkMRMLScene *scene, vtkMRMLVolumeNode *volumeNode, const char *name)
void InitializeStorageNode(vtkMRMLStorageNode *storageNode, const char *filename, vtkStringArray *fileList, vtkMRMLScene *mrmlScene=nullptr)
VolumeDisplayPreset GetVolumeDisplayPreset(const std::string &presetId)
vtkMRMLVolumeNode * AddArchetypeVolume(const char *filename, const char *volname, int loadingOptions)
ArchetypeVolumeNodeSet(const ArchetypeVolumeNodeSet &set)
vtkSmartPointer< vtkMRMLVolumeNode > Node
vtkSmartPointer< vtkMRMLVolumeDisplayNode > DisplayNode
ArchetypeVolumeNodeSet(vtkMRMLScene *scene)
vtkSmartPointer< vtkMRMLScene > Scene
vtkSmartPointer< vtkMRMLStorageNode > StorageNode