Slicer  5.2
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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 
96  static bool GetVisualization3d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode,
97  vtkMRMLNode* regionNode, vtkMRMLMarkupsNode* glyphPointsNode=nullptr);
98 
101  static const char* GetVisualizationDisplacementMagnitudeScalarName();
102 
108  vtkMRMLVolumeNode* CreateDisplacementVolumeFromTransform(vtkMRMLTransformNode* inputTransformNode, vtkMRMLVolumeNode* referenceVolumeNode = nullptr,
109  bool magnitude = true, vtkMRMLVolumeNode* existingOutputVolumeNode = nullptr);
110 
114  vtkMRMLTransformNode* ConvertToGridTransform(vtkMRMLTransformNode* inputTransformNode, vtkMRMLVolumeNode* referenceVolumeNode = nullptr,
115  vtkMRMLTransformNode* existingOutputTransformNode = nullptr);
116 
123  static bool GetTransformedPointSamplesAsMagnitudeImage(vtkImageData* outputMagnitudeImage, vtkMRMLTransformNode* inputTransformNode,
124  vtkMatrix4x4* ijkToRAS, bool transformToWorld = true);
125 
132  static bool GetTransformedPointSamplesAsVectorImage(vtkImageData* outputVectorImage, vtkMRMLTransformNode* inputTransformNode,
133  vtkMatrix4x4* ijkToRAS, bool transformToWorld = true);
134 
139  static void GetTransformedNodes(
140  vtkMRMLScene* scene, vtkMRMLTransformNode* transformNode,
141  std::vector<vtkMRMLDisplayableNode*>& transformedNodes,
142  bool recursive=true);
143 
148  static void GetNodesRASBounds(
149  const std::vector<vtkMRMLDisplayableNode*>& nodes,
150  double bounds[6]);
151 
156  static void GetNodesBounds(
157  const std::vector<vtkMRMLDisplayableNode*>& nodes,
158  double bounds[6]);
159 
161  {
166  TRANSFORM_THINPLATESPLINE
167  };
174  static TransformKind GetTransformKind(vtkMRMLTransformNode *transformNode);
175 
176 protected:
178  ~vtkSlicerTransformLogic() override;
180  void operator=(const vtkSlicerTransformLogic&);
181 
185  static void GetGlyphVisualization2d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode, vtkMatrix4x4* sliceToRAS,
186  double* fieldOfViewOrigin, double* fieldOfViewSize, vtkPoints* samplePositions_RAS = nullptr);
190  static void GetGlyphVisualization3d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode, vtkMatrix4x4* roiToRAS,
191  int* roiSize, vtkPoints* samplePositions_RAS = nullptr);
192 
195  static void GetGridVisualization2d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode, vtkMatrix4x4* sliceToRAS,
196  double* fieldOfViewOrigin, double* fieldOfViewSize);
199  static void GetGridVisualization3d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode, vtkMatrix4x4* roiToRAS, int* roiSize);
200 
203  static void GetContourVisualization2d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode, vtkMatrix4x4* sliceToRAS,
204  double* fieldOfViewOrigin, double* fieldOfViewSize);
207  static void GetContourVisualization3d(vtkPolyData* output_RAS, vtkMRMLTransformDisplayNode* displayNode, vtkMatrix4x4* roiToRAS, int* roiSize);
208 
210  static int GetGridSubdivision(vtkMRMLTransformDisplayNode* displayNode);
211 
213  static void CreateGrid(vtkPolyData* outputGrid_RAS, vtkMRMLTransformDisplayNode* displayNode, int numGridPoints[3], vtkPolyData* outputWarpedGrid_RAS=nullptr);
214 
218  static void GetTransformedPointSamples(vtkPointSet* outputPointSet,
219  vtkMRMLTransformNode* inputTransformNode, vtkPoints* samplePositions_RAS,
220  bool transformToWorld = true);
221 
227  static void GetTransformedPointSamples(vtkPointSet* outputPointSet_RAS, vtkMRMLTransformNode* inputTransformNode,
228  vtkMatrix4x4* gridToRAS, int* gridSize, bool transformToWorld = true);
229 
234  static void GetTransformedPointSamplesOnSlice(vtkPointSet* outputPointSet_RAS, vtkMRMLTransformNode* inputTransformNode,
235  vtkMatrix4x4* sliceToRAS, double* fieldOfViewOrigin, double* fieldOfViewSize, double pointSpacing, int pointGroupSize = 1, int* numGridPoints = nullptr,
236  vtkPoints* samplePositions_RAS = nullptr);
237 
241  static void GetTransformedPointSamplesOnRoi(vtkPointSet* outputPointSet_RAS, vtkMRMLTransformNode* inputTransformNode,
242  vtkMatrix4x4* roiToRAS, int* roiSize, double pointSpacingMm, int pointGroupSize=1, int* numGridPoints=nullptr);
243 
245  static void GetMarkupsAsPoints(vtkMRMLMarkupsNode* markupsNode, vtkPoints* samplePoints_RAS);
246 
247 };
248 
249 #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.