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
vtkSlicerTransformLogic.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  This file was partly developed by Andras Lasso and Franklin King at
9  PerkLab, Queen's University and was supported through the Applied Cancer
10  Research Unit program of Cancer Care Ontario with funds provided by the
11  Ontario Ministry of Health and Long-Term Care.
12 
13 =========================================================================auto=*/
14 
19 
20 #ifndef __vtkSlicerTransformLogic_h
21 #define __vtkSlicerTransformLogic_h
22 
23 // SlicerLogic includes
24 #include "vtkSlicerBaseLogic.h"
25 #include "vtkSlicerTransformsModuleLogicExport.h"
26 
27 // MRMLLogic includes
28 #include <vtkMRMLAbstractLogic.h>
29 
30 // STD includes
31 #include <vector>
32 
33 // MRML includes
35 class vtkMRMLMarkupsNode;
37 class vtkMRMLScene;
38 class vtkMRMLSliceNode;
42 class vtkMRMLVolumeNode;
43 
44 // VTK includes
45 class vtkImageData;
46 class vtkMatrix4x4;
47 class vtkPoints;
48 class vtkPointSet;
49 class vtkPolyData;
50 class vtkUnstructuredGrid;
51 
52 class VTK_SLICER_TRANSFORMS_MODULE_LOGIC_EXPORT vtkSlicerTransformLogic : public vtkMRMLAbstractLogic
53 {
54  public:
55 
57  static vtkSlicerTransformLogic *New();
59  void PrintSelf(ostream& os, vtkIndent indent) override { Superclass::PrintSelf(os, indent); }
60 
65  static bool hardenTransform(vtkMRMLTransformableNode* node);
66 
69  vtkMRMLTransformNode* AddTransform (const char* filename, vtkMRMLScene *scene);
70 
73  int SaveTransform (const char* filename, vtkMRMLTransformNode *transformNode);
74 
77  static bool GetVisualization2d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode,
78  vtkMRMLSliceNode* sliceNode, vtkMRMLMarkupsNode* glyphPointsNode = nullptr);
79 
82  static bool GetVisualization2d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode,
83  vtkMatrix4x4* sliceToRAS, double* fieldOfViewOrigin, double* fieldOfViewSize, vtkPoints* samplePositions_RAS = nullptr);
84 
89  static bool GetVisualization3d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode,
90  vtkMatrix4x4* roiToRAS, int* roiSize, vtkPoints* samplePositions_RAS = nullptr);
91 
95  static bool GetVisualization3d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode, vtkMRMLNode* regionNode);
96 
99  static const char* GetVisualizationDisplacementMagnitudeScalarName();
100 
106  vtkMRMLVolumeNode* CreateDisplacementVolumeFromTransform(vtkMRMLTransformNode* inputTransformNode, vtkMRMLVolumeNode* referenceVolumeNode = nullptr,
107  bool magnitude = true, vtkMRMLVolumeNode* existingOutputVolumeNode = nullptr);
108 
112  vtkMRMLTransformNode* ConvertToGridTransform(vtkMRMLTransformNode* inputTransformNode, vtkMRMLVolumeNode* referenceVolumeNode = nullptr,
113  vtkMRMLTransformNode* existingOutputTransformNode = nullptr);
114 
121  static bool GetTransformedPointSamplesAsMagnitudeImage(vtkImageData* outputMagnitudeImage, vtkMRMLTransformNode* inputTransformNode,
122  vtkMatrix4x4* ijkToRAS, bool transformToWorld = true);
123 
130  static bool GetTransformedPointSamplesAsVectorImage(vtkImageData* outputVectorImage, vtkMRMLTransformNode* inputTransformNode,
131  vtkMatrix4x4* ijkToRAS, bool transformToWorld = true);
132 
137  static void GetTransformedNodes(
138  vtkMRMLScene* scene, vtkMRMLTransformNode* transformNode,
139  std::vector<vtkMRMLDisplayableNode*>& transformedNodes,
140  bool recursive=true);
141 
146  static void GetNodesRASBounds(
147  const std::vector<vtkMRMLDisplayableNode*>& nodes,
148  double bounds[6]);
149 
154  static void GetNodesBounds(
155  const std::vector<vtkMRMLDisplayableNode*>& nodes,
156  double bounds[6]);
157 
159  {
164  TRANSFORM_THINPLATESPLINE
165  };
172  static TransformKind GetTransformKind(vtkMRMLTransformNode *transformNode);
173 
174 protected:
176  ~vtkSlicerTransformLogic() override;
178  void operator=(const vtkSlicerTransformLogic&);
179 
183  static void GetGlyphVisualization2d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode, vtkMatrix4x4* sliceToRAS,
184  double* fieldOfViewOrigin, double* fieldOfViewSize, vtkPoints* samplePositions_RAS = nullptr);
188  static void GetGlyphVisualization3d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode, vtkMatrix4x4* roiToRAS,
189  int* roiSize, vtkPoints* samplePositions_RAS = nullptr);
190 
193  static void GetGridVisualization2d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode, vtkMatrix4x4* sliceToRAS,
194  double* fieldOfViewOrigin, double* fieldOfViewSize);
197  static void GetGridVisualization3d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode, vtkMatrix4x4* roiToRAS, int* roiSize);
198 
201  static void GetContourVisualization2d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode, vtkMatrix4x4* sliceToRAS,
202  double* fieldOfViewOrigin, double* fieldOfViewSize);
205  static void GetContourVisualization3d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode, vtkMatrix4x4* roiToRAS, int* roiSize);
206 
208  static int GetGridSubdivision(vtkMRMLTransformDisplayNode* displayNode);
209 
211  static void CreateGrid(vtkPolyData* outputGrid_RAS, vtkMRMLTransformDisplayNode* displayNode, int numGridPoints[3], vtkPolyData* outputWarpedGrid_RAS=nullptr);
212 
216  static void GetTransformedPointSamples(vtkPointSet* outputPointSet,
217  vtkMRMLTransformNode* inputTransformNode, vtkPoints* samplePositions_RAS,
218  bool transformToWorld = true);
219 
225  static void GetTransformedPointSamples(vtkPointSet* outputPointSet_RAS, vtkMRMLTransformNode* inputTransformNode,
226  vtkMatrix4x4* gridToRAS, int* gridSize, bool transformToWorld = true);
227 
232  static void GetTransformedPointSamplesOnSlice(vtkPointSet* outputPointSet_RAS, vtkMRMLTransformNode* inputTransformNode,
233  vtkMatrix4x4* sliceToRAS, double* fieldOfViewOrigin, double* fieldOfViewSize, double pointSpacing, int pointGroupSize = 1, int* numGridPoints = nullptr,
234  vtkPoints* samplePositions_RAS = nullptr);
235 
239  static void GetTransformedPointSamplesOnRoi(vtkPointSet* outputPointSet_RAS, vtkMRMLTransformNode* inputTransformNode,
240  vtkMatrix4x4* roiToRAS, int* roiSize, double pointSpacingMm, int pointGroupSize=1, int* numGridPoints=nullptr);
241 
243  static void GetMarkupsAsPoints(vtkMRMLMarkupsNode* markupsNode, vtkPoints* samplePoints_RAS);
244 
245 };
246 
247 #endif
Superclass for MRML logic classes.
MRML node for representing a transformation between this node space and a parent node space...
MRML node for storing a slice through RAS space.
void PrintSelf(ostream &os, vtkIndent indent) override
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
MRML node for representing a volume (image stack).
MRML node for representing a volume (image stack).
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
static vtkMRMLAbstractLogic * New()
MRML node to represent display properties for transforms visualization in the slice and 3D viewers...
MRML node for representing a node with a transform.