Slicer 5.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLMarkupsPlaneNode.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 __vtkMRMLMarkupsPlaneNode_h
22#define __vtkMRMLMarkupsPlaneNode_h
23
24// MRML includes
26
27// Markups includes
29#include "vtkMRMLMarkupsNode.h"
30#include "vtkMRMLExport.h"
31
32// VTK includes
33#include <vtkMatrix4x4.h>
34#include <vtkPlane.h>
35
55class VTK_MRML_EXPORT vtkMRMLMarkupsPlaneNode : public vtkMRMLMarkupsNode
56{
57public:
61 void PrintSelf(ostream& os, vtkIndent indent) override;
62
63 const char* GetIcon() override { return ":/Icons/MarkupsPlane.png"; }
64 const char* GetAddIcon() override { return ":/Icons/MarkupsPlaneMouseModePlace.png"; }
65 const char* GetPlaceAddIcon() override { return ":/Icons/MarkupsPlaneMouseModePlaceAdd.png"; }
66
67 //--------------------------------------------------------------------------
68 // MRMLNode methods
69 //--------------------------------------------------------------------------
70
71 enum
72 {
76 };
77
79 enum
80 {
85 };
86
89 const char* GetNodeTagName() override { return "MarkupsPlane"; }
90
92 const char* GetMarkupType() override { return "Plane"; };
93
95 void ReadXMLAttributes(const char** atts) override;
96
98 void WriteXML(ostream& of, int indent) override;
99
103
106 void ApplyTransform(vtkAbstractTransform* transform, bool applyToLockedControlPoints) override;
107
109
113 void SetSizeMode(int sizeMode);
114 vtkGetMacro(SizeMode, int);
115 static const char* GetSizeModeAsString(int sizeMode);
116 static int GetSizeModeFromString(const char* sizeMode);
118
122 vtkGetMacro(AutoSizeScalingFactor, double);
123 vtkSetMacro(AutoSizeScalingFactor, double);
125
127
131 void GetSize(double size[2]);
132 double* GetSize() VTK_SIZEHINT(2);
133 virtual void SetSize(double x, double y);
134 virtual void SetSize(double size[2]) { this->SetSize(size[0], size[1]); }
136
138
142 void GetSizeWorld(double size[2]);
143 double* GetSizeWorld() VTK_SIZEHINT(2);
144 void SetSizeWorld(const double normal[2]);
145 void SetSizeWorld(double x, double y);
147
149
150 vtkGetVector4Macro(PlaneBounds, double);
151 virtual void SetPlaneBounds(double x0, double x1, double y0, double y1);
152 virtual void SetPlaneBounds(double bounds[4]) { this->SetPlaneBounds(bounds[0], bounds[1], bounds[2], bounds[3]); };
154
156
157 void GetNormal(double normal[3]);
158 double* GetNormal() VTK_SIZEHINT(3);
159 void GetNormalWorld(double normal[3]);
160 double* GetNormalWorld() VTK_SIZEHINT(3);
161 void SetNormal(const double normal[3]);
162 void SetNormal(double x, double y, double z);
163 void SetNormalWorld(const double normal[3]);
164 void SetNormalWorld(double x, double y, double z);
166
169
171
172 void GetOrigin(double origin[3]);
173 double* GetOrigin() VTK_SIZEHINT(3);
174 void GetOriginWorld(double origin[3]);
175 double* GetOriginWorld() VTK_SIZEHINT(3);
176 void SetOrigin(const double origin[3]);
177 void SetOrigin(double x, double y, double z);
178 void SetOriginWorld(const double origin[3]);
179 void SetOriginWorld(double x, double y, double z);
181
183
184 void GetCenter(double origin[3]) { this->GetOrigin(origin); };
185 double* GetCenter() VTK_SIZEHINT(3) { return this->GetOrigin(); };
186 void GetCenterWorld(double origin[3]) { this->GetOriginWorld(origin); };
187 double* GetCenterWorld() VTK_SIZEHINT(3) { return this->GetOriginWorld(); };
188 void SetCenter(const double origin[3]) { this->SetOrigin(origin); };
189 void SetCenter(double x, double y, double z) { this->SetOrigin(x, y, z); };
190 void SetCenterWorld(const double origin[3]) { this->SetOriginWorld(origin); };
191 void SetCenterWorld(double x, double y, double z) { this->SetOriginWorld(x, y, z); };
193
195
200 void GetAxes(double x[3], double y[3], double z[3]);
201 void SetAxes(const double x[3], const double y[3], const double z[3]);
202 void GetAxesWorld(double x[3], double y[3], double z[3]);
203 void SetAxesWorld(const double x[3], const double y[3], const double z[3]);
205
207 virtual void GetObjectToNodeMatrix(vtkMatrix4x4* objectToNodeMatrix);
209 virtual void GetObjectToWorldMatrix(vtkMatrix4x4* objectToWorldMatrix);
211 virtual void GetBaseToWorldMatrix(vtkMatrix4x4* baseToWorldMatrix);
213
214 virtual void GetBaseToNodeMatrix(vtkMatrix4x4* matrix);
215 virtual vtkMatrix4x4* GetBaseToNodeMatrix();
217
220 virtual vtkMatrix4x4* GetObjectToBaseMatrix();
221
229 double GetClosestPointOnPlaneWorld(const double posWorld[3], double closestPosWorld[3], bool infinitePlane = true);
230
233
236
238
240 void GetRASBounds(double bounds[6]) override;
241 void GetBounds(double bounds[6]) override;
243
245
250 vtkGetMacro(PlaneType, int);
251 void SetPlaneType(int planeType);
252 static const char* GetPlaneTypeAsString(int planeType);
253 static int GetPlaneTypeFromString(const char* planeType);
255
257 vtkGetMacro(IsPlaneValid, bool);
258
260
262 static void GenerateOrthogonalMatrix(vtkMatrix4x4* inputMatrix, vtkMatrix4x4* outputMatrix, vtkAbstractTransform* transform = nullptr, bool applyScaling = true);
263 static void GenerateOrthogonalMatrix(double xAxis[3],
264 double yAxis[3],
265 double zAxis[3],
266 double origin[3],
267 vtkMatrix4x4* outputMatrix,
268 vtkAbstractTransform* transform = nullptr,
269 bool applyScaling = true);
271
273 void ProcessMRMLEvents(vtkObject* caller, unsigned long event, void* callData) override;
274
276
277 void GetPlaneCornerPoints(vtkPoints* points_Node);
278 void GetPlaneCornerPointsWorld(vtkPoints* points_World);
280
281protected:
284
285 // Set plane validity flag. True if the plane is fully defined.
286 vtkSetMacro(IsPlaneValid, bool);
287
290
292 void CalculateAxesFromPoints(const double point0[3], const double point1[3], const double point2[3], double x[3], double y[3], double z[3]);
293
295 void CalculatePlaneBounds(vtkPoints* cornerPoints, double bounds[6]);
296
298 void CalculatePlaneCornerPoints(vtkPoints* points, double xAxis[3], double yAxis[3], double center[3], double size[2]);
299
305 virtual void UpdatePlaneSize();
306
312 bool GetClosestFitPlaneFromControlPoints(vtkMatrix4x4* closestFitPlane);
313
318
319 virtual void SetNormalPointRequired(bool);
320 vtkGetMacro(NormalPointRequired, bool);
321
323 vtkImplicitFunction* GetImplicitFunctionWorld() override;
324
325protected:
328
331
332 vtkSmartPointer<vtkMatrix4x4> ObjectToBaseMatrix;
333 vtkSmartPointer<vtkMatrix4x4> BaseToNodeMatrix;
334
335 double Size[2] = { 100.0, 100.0 };
336 double PlaneBounds[4] = { -50.0, 50.0, -50.0, 50.0 };
337
338 // Arrays used to return pointers from GetNormal/GetOrigin functions.
339 double Normal[3] = { 0.0, 0.0, 0.0 };
340 double NormalWorld[3] = { 0.0, 0.0, 0.0 };
341 double Origin[3] = { 0.0, 0.0, 0.0 };
342 double OriginWorld[3] = { 0.0, 0.0, 0.0 };
343 double SizeWorld[2] = { 0.0, 0.0 };
344
346 bool IsPlaneValid{ false };
347 bool NormalPointRequired{ false };
348
351
352 friend class vtkSlicerPlaneWidget; // To directly access plane update functions
353 friend class vtkSlicerPlaneRepresentation3D; // To directly access plane update functions
354 friend class vtkSlicerPlaneRepresentation2D; // To directly access plane update functions
355
356 vtkSmartPointer<vtkPlane> ImplicitPlaneWorld;
357};
358
359#endif
void ApplyTransform(vtkAbstractTransform *transform) override
void operator=(const vtkMRMLMarkupsPlaneNode &)
virtual void UpdateControlPointsFromPlaneFit()
static vtkMRMLMarkupsPlaneNode * New()
virtual void UpdateControlPointsFrom3Points()
void SetAxes(const double x[3], const double y[3], const double z[3])
vtkSmartPointer< vtkMatrix4x4 > BaseToNodeMatrix
void UpdateInteractionHandleToWorldMatrix() override
Calculates the handle to world matrix based on the current control points.
virtual void GetBaseToWorldMatrix(vtkMatrix4x4 *baseToWorldMatrix)
Mapping from Base plane coordinates to world coordinates.
void CalculatePlaneBounds(vtkPoints *cornerPoints, double bounds[6])
Calculates the axis-aligned bounds defined by the corners of the plane.
void FlipNormal()
Flip the normal vector direction by 180deg rotation around Y axis at the plane center.
virtual void UpdatePlaneFromPointNormal()
virtual void GetObjectToNodeMatrix(vtkMatrix4x4 *objectToNodeMatrix)
Mapping from XYZ plane coordinates to local coordinates.
vtkSmartPointer< vtkMatrix4x4 > ObjectToBaseMatrix
void SetSizeMode(int sizeMode)
void SetOriginWorld(const double origin[3])
vtkMRMLCopyContentMacro(vtkMRMLMarkupsPlaneNode)
virtual void UpdateControlPointsFromPlane()
Calculate the position of control points from the ROI.
void SetNormalWorld(const double normal[3])
double * GetSize() VTK_SIZEHINT(2)
virtual void GetObjectToWorldMatrix(vtkMatrix4x4 *objectToWorldMatrix)
Mapping from XYZ plane coordinates to world coordinates.
virtual void SetSize(double x, double y)
void SetOrigin(const double origin[3])
static const char * GetSizeModeAsString(int sizeMode)
const char * GetPlaceAddIcon() override
void GetNormal(double normal[3])
Get/Set the normal vector for the plane in object or world coordinate system.
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
bool GetClosestFitPlaneFromControlPoints(vtkMatrix4x4 *closestFitPlane)
void GetAxesWorld(double x[3], double y[3], double z[3])
void ApplyTransform(vtkAbstractTransform *transform, bool applyToLockedControlPoints) override
double * GetCenterWorld() VTK_SIZEHINT(3)
virtual void SetNormalPointRequired(bool)
~vtkMRMLMarkupsPlaneNode() override
void SetAxesWorld(const double x[3], const double y[3], const double z[3])
void CalculatePlaneCornerPoints(vtkPoints *points, double xAxis[3], double yAxis[3], double center[3], double size[2])
Calculates the axis-aligned bounds defined by the corners of the plane.
virtual void SetSize(double size[2])
static int GetSizeModeFromString(const char *sizeMode)
virtual void GetBaseToNodeMatrix(vtkMatrix4x4 *matrix)
Mapping from Base plane coordinates to local coordinates.
virtual void SetPlaneBounds(double x0, double x1, double y0, double y1)
void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) override
Re-implemented to react to changes in internal matrices or control points.
void GetRASBounds(double bounds[6]) override
void GetCenter(double origin[3])
Get/Set geometric center of the plane. Currently, it is always the same as the origin of the plane.
virtual void UpdateControlPointsFromPointNormal()
void GetOrigin(double origin[3])
Get/Set the origin of the plane in object or world coordinate system.
void GetAxes(double x[3], double y[3], double z[3])
void SetCenterWorld(double x, double y, double z)
void OnTransformNodeReferenceChanged(vtkMRMLTransformNode *transformNode) override
Reimplemented to recalculate InteractionHandleToWorld matrix when parent transform is changed.
void SetCenterWorld(const double origin[3])
void GetPlaneCornerPointsWorld(vtkPoints *points_World)
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file.
void SetSizeWorld(const double normal[2])
void CreateDefaultDisplayNodes() override
Create default display node or nullptr if does not have one.
double GetClosestPointOnPlaneWorld(const double posWorld[3], double closestPosWorld[3], bool infinitePlane=true)
static void GenerateOrthogonalMatrix(vtkMatrix4x4 *inputMatrix, vtkMatrix4x4 *outputMatrix, vtkAbstractTransform *transform=nullptr, bool applyScaling=true)
void SetNormal(const double normal[3])
vtkMRMLNode * CreateNodeInstance() override
MRMLNode methods.
virtual void UpdatePlaneSize()
double * GetCenter() VTK_SIZEHINT(3)
virtual void UpdatePlaneFromPlaneFit()
static const char * GetPlaneTypeAsString(int planeType)
virtual void UpdatePlaneFromControlPoints()
Updates the plane based on plane type and control point position.
vtkMRMLMarkupsPlaneNode(const vtkMRMLMarkupsPlaneNode &)
const char * GetMarkupType() override
Get markup type internal name.
virtual vtkMatrix4x4 * GetObjectToBaseMatrix()
virtual void SetPlaneBounds(double bounds[4])
double * GetSizeWorld() VTK_SIZEHINT(2)
void SetCenter(const double origin[3])
const char * GetAddIcon() override
virtual void UpdatePlaneFrom3Points()
vtkImplicitFunction * GetImplicitFunctionWorld() override
static void GenerateOrthogonalMatrix(double xAxis[3], double yAxis[3], double zAxis[3], double origin[3], vtkMatrix4x4 *outputMatrix, vtkAbstractTransform *transform=nullptr, bool applyScaling=true)
const char * GetIcon() override
void GetCenterWorld(double origin[3])
vtkMRMLStorageNode * CreateDefaultStorageNode() override
Create default storage node or nullptr if does not have one.
static int GetPlaneTypeFromString(const char *planeType)
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
void GetNormalWorld(double normal[3])
void PrintSelf(ostream &os, vtkIndent indent) override
Print out the node information to the output stream.
void SetCenter(double x, double y, double z)
vtkSmartPointer< vtkPlane > ImplicitPlaneWorld
void SetPlaneType(int planeType)
double * GetNormal() VTK_SIZEHINT(3)
void GetBounds(double bounds[6]) override
void GetSizeWorld(double size[2])
void GetOriginWorld(double origin[3])
void GetSize(double size[2])
void GetPlaneCornerPoints(vtkPoints *points_Node)
Retrieves the list of points that define the corners of the plane.
virtual vtkMatrix4x4 * GetBaseToNodeMatrix()
void CalculateAxesFromPoints(const double point0[3], const double point1[3], const double point2[3], double x[3], double y[3], double z[3])
Calculates the x y and z axis of the plane from the 3 input points.
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.