21#ifndef __vtkMRMLMarkupsPlaneNode_h
22#define __vtkMRMLMarkupsPlaneNode_h
30#include "vtkSlicerMarkupsModuleMRMLExport.h"
33#include <vtkMatrix4x4.h>
60 void PrintSelf(ostream& os, vtkIndent indent)
override;
62 const char*
GetIcon()
override {
return ":/Icons/MarkupsPlane.png";}
63 const char*
GetAddIcon()
override {
return ":/Icons/MarkupsPlaneMouseModePlace.png";}
64 const char*
GetPlaceAddIcon()
override {
return ":/Icons/MarkupsPlaneMouseModePlaceAdd.png";}
118 vtkGetMacro(SizeMode,
int);
126 vtkGetMacro(AutoSizeScalingFactor,
double);
127 vtkSetMacro(AutoSizeScalingFactor,
double);
137 virtual
void SetSize(
double x,
double y);
138 virtual
void SetSize(
double size[2]) { this->
SetSize(size[0], size[1]); }
148 void SetSizeWorld(const
double normal[2]);
149 void SetSizeWorld(
double x,
double y);
154 vtkGetVector4Macro(PlaneBounds,
double);
155 virtual
void SetPlaneBounds(
double x0,
double x1,
double y0,
double y1);
156 virtual
void SetPlaneBounds(
double bounds[4]) { this->
SetPlaneBounds(bounds[0], bounds[1], bounds[2], bounds[3]); };
163 void GetNormalWorld(
double normal[3]);
164 double* GetNormalWorld() VTK_SIZEHINT(3);
165 void SetNormal(const
double normal[3]);
166 void SetNormal(
double x,
double y,
double z);
167 void SetNormalWorld(const
double normal[3]);
168 void SetNormalWorld(
double x,
double y,
double z);
173 void GetOrigin(
double origin[3]);
174 double* GetOrigin() VTK_SIZEHINT(3);
175 void GetOriginWorld(
double origin[3]);
176 double* GetOriginWorld() VTK_SIZEHINT(3);
177 void SetOrigin(const
double origin[3]);
178 void SetOrigin(
double x,
double y,
double z);
179 void SetOriginWorld(const
double origin[3]);
180 void SetOriginWorld(
double x,
double y,
double z);
185 void GetCenter(
double origin[3]) { this->GetOrigin(origin); };
186 double*
GetCenter() VTK_SIZEHINT(3) {
return this->GetOrigin(); };
189 void SetCenter(
const double origin[3]) { this->SetOrigin(origin); };
190 void SetCenter(
double x,
double y,
double z) { this->SetOrigin(x, y, z); };
192 void SetCenterWorld(
double x,
double y,
double z) { this->SetOriginWorld(x, y, z); };
201 void GetAxes(
double x[3],
double y[3],
double z[3]);
202 void SetAxes(
const double x[3],
const double y[3],
const double z[3]);
204 void SetAxesWorld(
const double x[3],
const double y[3],
const double z[3]);
251 vtkGetMacro(PlaneType,
int);
258 vtkGetMacro(IsPlaneValid,
bool);
264 vtkMatrix4x4* outputMatrix, vtkAbstractTransform* transform =
nullptr,
bool applyScaling =
true);
266 vtkMatrix4x4* outputMatrix, vtkAbstractTransform* transform =
nullptr,
bool applyScaling =
true);
280 vtkSetMacro(MaximumNumberOfControlPoints,
int);
281 vtkSetMacro(RequiredNumberOfControlPoints,
int);
284 vtkSetMacro(IsPlaneValid,
bool);
290 void CalculateAxesFromPoints(
const double point0[3],
const double point1[3],
const double point2[3],
double x[3],
double y[3],
double z[3]);
318 vtkGetMacro(NormalPointRequired,
bool);
321 bool IsUpdatingControlPointsFromPlane{
false };
322 bool IsUpdatingPlaneFromControlPoints{
false };
324 int SizeMode{ SizeModeAuto };
325 double AutoSizeScalingFactor{ 1.0 };
330 double Size[2] = { 100.0, 100.0 };
331 double PlaneBounds[4] = { -50.0, 50.0, -50.0, 50.0 };
334 double Normal[3] = { 0.0, 0.0, 0.0 };
335 double NormalWorld[3] = { 0.0, 0.0, 0.0 };
336 double Origin[3] = { 0.0, 0.0, 0.0 };
337 double OriginWorld[3] = { 0.0, 0.0, 0.0 };
338 double SizeWorld[2] = { 0.0, 0.0 };
340 int PlaneType{ PlaneTypePointNormal };
341 bool IsPlaneValid{
false };
342 bool NormalPointRequired{
false };
MRML node to represent a plane markup Plane Markups nodes contain three control points....
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.
const char * GetTypeDisplayName() override
void CalculatePlaneBounds(vtkPoints *cornerPoints, double bounds[6])
Calculates the axis-aligned bounds defined by the corners of the plane.
virtual void UpdatePlaneFromPointNormal()
virtual void GetObjectToNodeMatrix(vtkMatrix4x4 *objectToNodeMatrix)
Mapping from XYZ plane coordinates to local coordinates.
vtkSmartPointer< vtkMatrix4x4 > ObjectToBaseMatrix
void SetSizeMode(int sizeMode)
void ApplyTransform(vtkAbstractTransform *transform) override
Apply the passed transformation to the ROI.
vtkMRMLCopyContentMacro(vtkMRMLMarkupsPlaneNode)
virtual void UpdateControlPointsFromPlane()
Calculate the position of control points from the ROI.
double * GetSize() VTK_SIZEHINT(2)
virtual void GetObjectToWorldMatrix(vtkMatrix4x4 *objectToWorldMatrix)
Mapping from XYZ plane coordinates to world coordinates.
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.
vtkMRMLMarkupsPlaneNode()
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])
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.
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
virtual void UpdateControlPointsFromPointNormal()
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 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)
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()
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)
const char * GetDefaultNodeNamePrefix() override
Get markup short name.
void PrintSelf(ostream &os, vtkIndent indent) override
Print out the node information to the output stream.
void SetCenter(double x, double y, double z)
void SetPlaneType(int planeType)
double * GetNormal() VTK_SIZEHINT(3)
void GetBounds(double bounds[6]) override
void GetSizeWorld(double size[2])
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.
Default representation for the plane widget.
Default representation for the plane widget.