Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLMarkupsROINode.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
4 Queen's University, Kingston, ON, Canada. All Rights Reserved.
5
6 See COPYRIGHT.txt
7 or http://www.slicer.org/copyright/copyright.txt for details.
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14
15 This file was originally developed by Kyle Sunderland, PerkLab, Queen's University
16 and was supported through CANARIE's Research Software Program, Cancer
17 Care Ontario, OpenAnatomy, and Brigham and Women's Hospital through NIH grant R01MH112748.
18
19==============================================================================*/
20
21#ifndef __vtkMRMLMarkupsROINode_h
22#define __vtkMRMLMarkupsROINode_h
23
24// MRML includes
26#include "vtkMRMLModelNode.h"
27
28// Markups includes
29#include "vtkMRMLExport.h"
31#include "vtkMRMLMarkupsNode.h"
32
33// VTK includes
34#include <vtkImplicitBoolean.h>
35#include <vtkImplicitFunction.h>
36#include <vtkMatrix4x4.h>
37#include <vtkSmartPointer.h>
38#include <vtkStringArray.h>
39#include <vtkTransform.h>
40
41// std includes
42#include <vector>
43
44class vtkPlanes;
45
56class VTK_MRML_EXPORT vtkMRMLMarkupsROINode : public vtkMRMLMarkupsNode
57{
58public:
62 void PrintSelf(ostream& os, vtkIndent indent) override;
63
64 const char* GetIcon() override { return ":/Icons/MarkupsROI.png"; }
65 const char* GetAddIcon() override { return ":/Icons/MarkupsROIMouseModePlace.png"; }
66 const char* GetPlaceAddIcon() override { return ":/Icons/MarkupsROIMouseModePlaceAdd.png"; }
67
68 //--------------------------------------------------------------------------
69 // MRMLNode methods
70 //--------------------------------------------------------------------------
71
73
75 const char* GetNodeTagName() override { return "MarkupsROI"; }
76
78 const char* GetMarkupType() override { return "ROI"; };
79
83
86 void ApplyTransform(vtkAbstractTransform* transform, bool applyToLockedControlPoints) override;
87
89
90 vtkGetVector3Macro(Size, double);
91 void SetSize(const double size[3]);
92 void SetSize(double x, double y, double z);
93 void GetSizeWorld(double size_World[3]);
94 void SetSizeWorld(const double size_World[3]);
95 void SetSizeWorld(double x_World, double y_World, double z_World);
97
99
100 void GetCenter(double center[3]);
101 void GetCenterWorld(double center[3]);
102 vtkVector3d GetCenter();
103 vtkVector3d GetCenterWorld();
104 void SetCenterWorld(const double center[3]);
105 void SetCenterWorld(double x, double y, double z);
106 void SetCenter(const double center[3]);
107 void SetCenter(double x, double y, double z);
109
111
113 void GetXAxisWorld(double axis_World[3]);
114 void GetYAxisWorld(double axis_World[3]);
115 void GetZAxisWorld(double axis_World[3]);
116 void GetAxisWorld(int axisIndex, double axis_World[3]);
117 void GetXAxis(double axis_Node[3]);
118 void GetYAxis(double axis_Node[3]);
119 void GetZAxis(double axis_Node[3]);
120 void GetAxis(int axisIndex, double axis_Node[3]);
122
124
125 vtkMatrix4x4* GetObjectToNodeMatrix() { return this->ObjectToNodeMatrix; };
126 void SetAndObserveObjectToNodeMatrix(vtkMatrix4x4* objectToNodeMatrix);
128
131 vtkMatrix4x4* GetObjectToWorldMatrix() { return this->ObjectToWorldMatrix; };
132
134
136 vtkGetMacro(ROIType, int);
137 void SetROIType(int roiType);
138 static const char* GetROITypeAsString(int roiType);
139 static int GetROITypeFromString(const char* roiType);
141
143
148
150
155
156 // ROI type enum defines the calculation method that should be used to convert to and from control points.
157 enum
158 {
162 };
163
166
167 void ProcessMRMLEvents(vtkObject* caller, unsigned long event, void* callData) override;
168
171
174
177
179
185 void GetRASBounds(double bounds[6]) override;
186 void GetBounds(double bounds[6]) override;
188
191 void GetObjectBounds(double bounds[6]);
192
194
198 void GetPlanes(vtkPlanes* planes) { this->GetPlanes(planes, this->GetInsideOut()); }
199 void GetPlanesWorld(vtkPlanes* planes) { this->GetPlanesWorld(planes, this->GetInsideOut()); }
201
203
207 void GetPlanes(vtkPlanes* planes, bool insideOut);
208 void GetPlanesWorld(vtkPlanes* planes, bool insideOut);
210
212
213 bool IsPointInROI(double point_Node[3]);
214 bool IsPointInROIWorld(double point_World[3]);
216
218
222 void SetInsideOut(bool insideOut);
223 vtkGetMacro(InsideOut, bool);
224 vtkBooleanMacro(InsideOut, bool);
226
228 vtkGetObjectMacro(ImplicitFunction, vtkImplicitFunction);
230 vtkImplicitFunction* GetImplicitFunctionWorld() override { return this->ImplicitFunctionWorld; }
231
234 VTK_NEWINSTANCE vtkPolyData* CreateROIBoxPolyDataWorld();
235
239
241
250 int SetXYZ(double center[3]);
251 int SetXYZ(double x, double y, double z);
252 bool GetXYZ(double center[3]);
254
256
263 void SetRadiusXYZ(double radiusXYZ[3]);
264 void SetRadiusXYZ(double x, double y, double z);
265 void GetRadiusXYZ(double radiusXYZ[3]);
267
270 void GetTransformedPlanes(vtkPlanes* planes, bool insideOut = false);
271
273
275 static void GenerateOrthogonalMatrix(vtkMatrix4x4* inputMatrix, vtkMatrix4x4* outputMatrix, vtkAbstractTransform* transform = nullptr, bool applyScaling = true);
276 static void GenerateOrthogonalMatrix(double xAxis[3],
277 double yAxis[3],
278 double zAxis[3],
279 double origin[3],
280 vtkMatrix4x4* outputMatrix,
281 vtkAbstractTransform* transform = nullptr,
282 bool applyScaling = true);
284
289 void WriteCLI(std::vector<std::string>& commandLine, std::string prefix, int coordinateSystem = vtkMRMLStorageNode::CoordinateSystemRAS, int multipleFlag = 1) override;
290
291protected:
293
294 double Size[3]{ 0.0, 0.0, 0.0 };
295
299 bool InsideOut{ false };
301
302 vtkSmartPointer<vtkMatrix4x4> ObjectToNodeMatrix{ nullptr };
303 vtkSmartPointer<vtkMatrix4x4> ObjectToWorldMatrix{ nullptr };
304
305 vtkSmartPointer<vtkImplicitFunction> ImplicitFunction{ nullptr };
306 vtkSmartPointer<vtkImplicitFunction> ImplicitFunctionWorld{ nullptr };
307
309 void GenerateBoxBounds(double bounds[6], double xAxis[3], double yAxis[3], double zAxis[3], double center[3], double size[3]);
310
313
316
321};
322
323#endif
void ApplyTransform(vtkAbstractTransform *transform) override
void GetXAxisWorld(double axis_World[3])
int SetXYZ(double center[3])
void GetRASBounds(double bounds[6]) override
void SetSize(const double size[3])
vtkSmartPointer< vtkImplicitFunction > ImplicitFunction
int SetXYZ(double x, double y, double z)
void GetObjectBounds(double bounds[6])
void SetCenter(double x, double y, double z)
void UpdateObjectToWorldMatrix()
Calculates the transform from the Object (ROI) to World coordinates.
void GetBounds(double bounds[6]) override
void PrintSelf(ostream &os, vtkIndent indent) override
Print out the node information to the output stream.
void GetPlanesWorld(vtkPlanes *planes, bool insideOut)
void WriteCLI(std::vector< std::string > &commandLine, std::string prefix, int coordinateSystem=vtkMRMLStorageNode::CoordinateSystemRAS, int multipleFlag=1) override
bool IsPointInROI(double point_Node[3])
Returns true if the specified point is within the ROI.
vtkVector3d GetCenterWorld()
void ApplyTransform(vtkAbstractTransform *transform, bool applyToLockedControlPoints) override
void OnTransformNodeReferenceChanged(vtkMRMLTransformNode *transformNode) override
Reimplemented to recalculate InteractionHandleToWorld matrix when parent transform is changed.
vtkMatrix4x4 * GetObjectToWorldMatrix()
void GetAxisWorld(int axisIndex, double axis_World[3])
const char * GetIcon() override
void SetSizeWorld(const double size_World[3])
vtkMRMLNode * CreateNodeInstance() override
MRMLNode methods.
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
const char * GetAddIcon() override
void GetCenter(double center[3])
Center of the ROI.
static int GetROITypeFromString(const char *roiType)
virtual void UpdateROIFromControlPoints()
Calculate the ROI dimensions from the control points.
void SetRadiusXYZ(double x, double y, double z)
vtkImplicitFunction * GetImplicitFunctionWorld() override
Get the implicit function that represents the ROI in world coordinates.
void GetAxis(int axisIndex, double axis_Node[3])
static void GenerateOrthogonalMatrix(vtkMatrix4x4 *inputMatrix, vtkMatrix4x4 *outputMatrix, vtkAbstractTransform *transform=nullptr, bool applyScaling=true)
bool GetObjectToNodeMatrixRotated()
void SetRadiusXYZ(double radiusXYZ[3])
vtkSmartPointer< vtkImplicitFunction > ImplicitFunctionWorld
void GetZAxisWorld(double axis_World[3])
static const char * GetROITypeAsString(int roiType)
void SetROIType(int roiType)
void GetTransformedPlanes(vtkPlanes *planes, bool insideOut=false)
void GetYAxisWorld(double axis_World[3])
~vtkMRMLMarkupsROINode() override
virtual void UpdateBoundingBoxROIFromControlPoints()
void GetPlanesWorld(vtkPlanes *planes)
void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) override
Alternative method to propagate events generated in Display nodes.
VTK_NEWINSTANCE vtkPolyData * CreateROIBoxPolyDataWorld()
void SetCenterWorld(double x, double y, double z)
vtkSmartPointer< vtkMatrix4x4 > ObjectToNodeMatrix
void SetCenterWorld(const double center[3])
static vtkMRMLMarkupsROINode * New()
virtual void UpdateControlPointsFromBoundingBoxROI()
void GetSizeWorld(double size_World[3])
void operator=(const vtkMRMLMarkupsROINode &)
vtkMatrix4x4 * GetObjectToNodeMatrix()
4x4 matrix defining the object center and axis directions within the node coordinate system.
void GetCenterWorld(double center[3])
const char * GetMarkupType() override
Get markup type internal name.
vtkSmartPointer< vtkMatrix4x4 > ObjectToWorldMatrix
virtual void UpdateBoxROIFromControlPoints()
vtkMRMLStorageNode * CreateDefaultStorageNode() override
Create default storage node or nullptr if does not have one.
virtual void UpdateControlPointsFromBoxROI()
const char * GetPlaceAddIcon() override
@ ROITypeBoundingBox
ROI forms a bounding box around the control points.
@ ROITypeBox
Requires two Control points that are removed after they have been placed.
bool IsPointInROIWorld(double point_World[3])
vtkMRMLCopyContentMacro(vtkMRMLMarkupsROINode)
void SetSizeWorld(double x_World, double y_World, double z_World)
void GetYAxis(double axis_Node[3])
bool GetXYZ(double center[3])
void GenerateBoxBounds(double bounds[6], double xAxis[3], double yAxis[3], double zAxis[3], double center[3], double size[3])
Fills the specified vtkPoints with the points for all of the box ROI corners.
virtual bool GetInsideOut()
void SetAndObserveObjectToNodeMatrix(vtkMatrix4x4 *objectToNodeMatrix)
void CreateDefaultDisplayNodes() override
Create default display node or nullptr if does not have one.
vtkVector3d GetCenter()
virtual void UpdateControlPointsFromROI()
Calculate the position of control points from the ROI.
void GetRadiusXYZ(double radiusXYZ[3])
static void GenerateOrthogonalMatrix(double xAxis[3], double yAxis[3], double zAxis[3], double origin[3], vtkMatrix4x4 *outputMatrix, vtkAbstractTransform *transform=nullptr, bool applyScaling=true)
void SetCenter(const double center[3])
void UpdateImplicitFunction()
Updates the parameters of the internal implicit functions.
void GetXAxis(double axis_Node[3])
void SetSize(double x, double y, double z)
void GetPlanes(vtkPlanes *planes, bool insideOut)
void GetPlanes(vtkPlanes *planes)
void GetZAxis(double axis_Node[3])
void UpdateInteractionHandleToWorldMatrix() override
Update the InteractionHandleToWorldMatrix based on the ObjectToNode and NodeToWorld transforms.
vtkMRMLMarkupsROINode(const vtkMRMLMarkupsROINode &)
void SetInsideOut(bool insideOut)
Abstract Superclass for all specific types of MRML nodes.
A superclass for other storage nodes.
MRML node for representing a transformation between this node space and a parent node space.